defparam 的用法
时间:10-02
整理:3721RD
点击:
下面的源码中使用了 defparam,对于defparam的含义给出了解释。
`timescale 1 ps / 1 ps
// synopsys translate_on
module sintab (
address,
clock,
data,
wren,
q);
input [9:0] address;
input clock;
input [13:0] data;
input wren;
output [13:0] q;
wire [13:0] sub_wire0;
wire [13:0] q = sub_wire0[13:0];
altsyncram altsyncram_component (
.wren_a (wren),
.clock0 (clock),
.address_a (address),
.data_a (data),
.q_a (sub_wire0),
.aclr0 (1'b0),
.aclr1 (1'b0),
.q_b (),
.clocken1 (1'b1),
.clocken0 (1'b1),
.data_b (1'b1),
.rden_b (1'b1),
.address_b (1'b1),
.wren_b (1'b0),
.byteena_b (1'b1),
.addressstall_a (1'b0),
.byteena_a (1'b1),
.addressstall_b (1'b0),
.clock1 (1'b1));
defparam
altsyncram_component.clock_enable_input_a = "BYPASS",
altsyncram_component.clock_enable_output_a = "BYPASS",
altsyncram_component.init_file = "sintab.mif",
altsyncram_component.intended_device_family = "Cyclone II",
altsyncram_component.lpm_hint = "ENABLE_RUNTIME_MOD=NO",
altsyncram_component.lpm_type = "altsyncram",
altsyncram_component.numwords_a = 1024,
altsyncram_component.operation_mode = "SINGLE_PORT",
altsyncram_component.outdata_aclr_a = "NONE",
altsyncram_component.outdata_reg_a = "CLOCK0",
altsyncram_component.power_up_uninitialized = "FALSE",
altsyncram_component.widthad_a = 10,
altsyncram_component.width_a = 14,
altsyncram_component.width_byteena_a = 1;
endmodule
在设计中,可以用关键字defparam在任意模块调用中改变参数值。模块调用的层级名称可以用在改写语句中。
例如上面的模块altsyncram中,一定会有
clock_enable_input_a = “BYPASS”;
。
width_byteena_a = 1;
那么在调用altsyncram的模块,即altsyncram的父模块中,可以使用
defparam altsyncram_component.clock_enable_input_a = "BYPASS";
来改写其中的参数。
这个和在例化时将参数传递进去的效果是一样的。如下
altsyncram #( .clock_enable_input_a("BYPASS"),
......
.width_byteena_a (1)
)
altsyncram_component (
);
`timescale 1 ps / 1 ps
// synopsys translate_on
module sintab (
address,
clock,
data,
wren,
q);
input [9:0] address;
input clock;
input [13:0] data;
input wren;
output [13:0] q;
wire [13:0] sub_wire0;
wire [13:0] q = sub_wire0[13:0];
altsyncram altsyncram_component (
.wren_a (wren),
.clock0 (clock),
.address_a (address),
.data_a (data),
.q_a (sub_wire0),
.aclr0 (1'b0),
.aclr1 (1'b0),
.q_b (),
.clocken1 (1'b1),
.clocken0 (1'b1),
.data_b (1'b1),
.rden_b (1'b1),
.address_b (1'b1),
.wren_b (1'b0),
.byteena_b (1'b1),
.addressstall_a (1'b0),
.byteena_a (1'b1),
.addressstall_b (1'b0),
.clock1 (1'b1));
defparam
altsyncram_component.clock_enable_input_a = "BYPASS",
altsyncram_component.clock_enable_output_a = "BYPASS",
altsyncram_component.init_file = "sintab.mif",
altsyncram_component.intended_device_family = "Cyclone II",
altsyncram_component.lpm_hint = "ENABLE_RUNTIME_MOD=NO",
altsyncram_component.lpm_type = "altsyncram",
altsyncram_component.numwords_a = 1024,
altsyncram_component.operation_mode = "SINGLE_PORT",
altsyncram_component.outdata_aclr_a = "NONE",
altsyncram_component.outdata_reg_a = "CLOCK0",
altsyncram_component.power_up_uninitialized = "FALSE",
altsyncram_component.widthad_a = 10,
altsyncram_component.width_a = 14,
altsyncram_component.width_byteena_a = 1;
endmodule
在设计中,可以用关键字defparam在任意模块调用中改变参数值。模块调用的层级名称可以用在改写语句中。
例如上面的模块altsyncram中,一定会有
clock_enable_input_a = “BYPASS”;
。
width_byteena_a = 1;
那么在调用altsyncram的模块,即altsyncram的父模块中,可以使用
defparam altsyncram_component.clock_enable_input_a = "BYPASS";
来改写其中的参数。
这个和在例化时将参数传递进去的效果是一样的。如下
altsyncram #( .clock_enable_input_a("BYPASS"),
......
.width_byteena_a (1)
)
altsyncram_component (
);