如何在 Verilog 中定义带有参数的模块? [英] How do I define a module with a parameter in Verilog?
本文介绍了如何在 Verilog 中定义带有参数的模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想定义一个带有参数的 add
模块,但我对新实例的声明并不顺利.
I want to define an add
module which has a parameter, but my declaration of the new instance doesn't go well.
我想定义这个模块的一个实例:
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));
此语法在 IEEE 标准(例如 1800-2009)中指定.
This syntax is specified in the IEEE Standard (1800-2009, for example).
这篇关于如何在 Verilog 中定义带有参数的模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文