Keywords: Verilog, parameter, passing, local
XST will not propagate a defparam to modify a parameter if the defparam spans multiple level of hierarchy and modifies multiple instantiations, as shown in the following example:
module top (...);
:
defparam u1.sub_inst.P1 = 1;
defparam u2.sub_inst.P1 = 2;
my_mod u1 (<port_mapping>);
my_mod u2 (<port_mapping>);
:
endmodule
//------------------------------
module my_mod (...);
SUB_MOD sub_inst (<port_mapping>);
endmodule
//------------------------------
module SUB_MOD (...);
parameter P1 = 0;
:
:
endmodule
//------------------------------
You can work around this issue by creating parameters on every level of hierarchy in order to modify the wanted parameter, as shown in the following example:
module top (...);
:
my_mod #(.mymod_param(1)) u1 (<port_mapping>);
my_mod #(.mymod_param(2)) u2 (<port_mapping>);
:
endmodule
//------------------------------
module my_mod (...);
parameter mymod_param = 0;
SUB_MOD #(.P1(mymod_param)) sub_inst (<port_mapping>);
endmodule
//------------------------------
module SUB_MOD (...);
parameter P1 = 0;
:
:
endmodule
//------------------------------