类似与VHDL中得generic()portmap(); verilog中各个模块之间也可以进行了参数得传递,通过修改顶层模块的参数,底层的模块参数被修改。
方法1: defparam定义法
方法2: #方法
例如
底层模块,设置参数初始值
- module parameter_tst(clk,a,b,c);
- parameter parameter1 = 10,
- parameter2 = 0 ;
- input clk;
- input [2:0]a;
- input [2:0]b;
- output reg [4:0]c;
- always@(posedge clk)
- c = a + parameter1 + b + parameter2;
- endmodule
顶层模块,修改参数
- module parameter_top(clk,a,b,c);
- input clk;
- input [2:0]a;
- input [2:0]b;
- output reg [5:0]c;
- wire [4:0]c1;
- wire [4:0]c2;