i have a module parameter that is an array of a predefined struct. I set the default size of this array as 1 element. The idea is to override it with the appropriate size at the time of instantiation.
The way i show below doesn't override the size. It only overides the first value. I can see why it would do this as the size field is not parameterized. Is there a better way than to pass a parameter for the size?
Thank you for the help.
module reg_slave
#(parameter
reg_pkg::defval_pair [0:0] REG_DEFVAL = '0 //param decl with size=1
)();
endmodule : reg_slave
module top();
localparam reg_pkg::defval_pair [1:0] REG_DEFVAL = '{
{3,'h32},
{0,'h1}
}; //param of same type and size = 2
reg_slave #(
.REG_DEFVAL(REG_DEFVAL) //trying to override the size.
)
reg_slave_inst ();
endmodule : top
package reg_pkg;
typedef struct packed { int ADDR; bit [31:0] VAL;} defval_pair;
endpackage : reg_pkg
Using type parameter. However, you still need an extra parameter to pass into the instance. The advantage is that you can change a parameter's type.