Reputation: 567
Should a localparam
of a struct
type still require an initializer if it has default initial values?
Eg
typedef struct {
int a = 1;
} my_struct;
localparam my_struct m;
Upvotes: 2
Views: 776
Reputation: 17
This trick is supported in ModelSim (Intel) and synthesizable in Efinix. But using a function to partially override parameter values would be a bit awkward.
//define:
typedef struct {
bit PARAM1 = 1;
bit PARAM2 = 0;
}some_localparameter_t;
function automatic some_localparameter_t SOME_LOCALPARAMETER_INIT();
automatic some_localparameter_t P;
return P;
endfunction
//example to use inside module declaration:
localparam some_localparameter_t SOME_LOCALPARAMETER = SOME_LOCALPARAMETER_INIT();
Upvotes: 0
Reputation: 42738
SystemVerilog syntax/semantics requires a declaration assignment for any localparam
declaration, or a parameter
declaration outside the module header (i.e. inside the module body).
Upvotes: 0
Reputation: 62236
Your code generates a syntax error on 3 major Verilog simulators. From IEEE Std 1800-2017, section 6.20.1 Parameter declaration syntax:
It shall be legal to omit the constant_param_expression from a param_assignment or the data_type from a type_assignment only within a parameter_port_list.
Upvotes: 0