verilog - 如何在 Verilog 中定义带有参数的模块?

标签 verilog system-verilog

我想定义一个带有参数的 add 模块,但我对新实例的声明不太顺利。

我想定义此模块的一个实例:

module add #(parameter wd=1) (input wire [wd-1:0] a,b, output wire [wd-1:0] o);

   assign o = a + b;

endmodule

我尝试了这一行,但收到​​错误:

 add len_plus_1 #(8)(.a(len),.b(8'h1),.o(lenPlus1));

最佳答案

实例名称必须位于参数说明符之后:

add #(8) len_plus_1 (.a(len),.b(8'h1),.o(lenPlus1));

此语法在 IEEE 标准(例如 1800-2009)中指定。

关于verilog - 如何在 Verilog 中定义带有参数的模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8668143/

相关文章:

module - 如何在两个verilog模块之间传递数组结构

constraints - SystemVerilog 中一组变量的循环随机化

verilog - Verilog 中的 Casex 和 Casez

system-verilog - 自动变量有什么好处?

interface - 系统Verilog : Passing interfaces to functions/tasks (for synthesis!)

verilog - 编写一个简单的函数来计算向量中的个数

verilog - 是否可以在verilog中将输入端口作为数组?

system-verilog - systemverilog 从函数返回动态数组

system-verilog - 如何在垃圾回收时执行 SystemVerilog 代码?

case - System Verilog - case with or