[英]How do I define a module with a parameter in Verilog?
I want to define an add
module which has a parameter, but my declaration of the new instance doesn't go well. 我想定义一个带有参数的
add
模块,但是我对新实例的声明并不顺利。
I want to define an instance of this module: 我想定义这个模块的一个实例:
module add #(parameter wd=1) (input wire [wd-1:0] a,b, output wire [wd-1:0] o);
assign o = a + b;
endmodule
I tried this line, but I get an error: 我试过这一行,但是我收到一个错误:
add len_plus_1 #(8)(.a(len),.b(8'h1),.o(lenPlus1));
The instance name must come after the parameter specifier: 实例名称必须位于参数说明符之后:
add #(8) len_plus_1 (.a(len),.b(8'h1),.o(lenPlus1));
This syntax is specified in the IEEE Standard (1800-2009, for example). 该语法在IEEE标准(例如1800-2009)中规定。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.