I have a package that contains a bunch of localparams. Instead of defining them like this:
localparam FIFO_DEPTH = 8;
I wanted to make the localparams all overwritable by setting defines in the command-line. So instead inside the package I define them like this:
package mypkg;
`my_localparm ( FIFO_DEPTH, DEFINED_FIFO_DEPTH, 8);
…
endpackage;
And my_localparm is:
define my_localparam(param_name, defined_value, default_value)
ifdef defined_value \ localparam param_name =
defined_value
else \ localparam param_name = default_value \
endif
Everything in the above code is synthesizable. This way, on the simulation command-line, I can specify -d DEFINED_FIFO_DEPTH=16, and it runs a simulation with the localparam being overridden with 16. All of this is fine.
But is there a way to automatically print out in my simulation logfile all of these parameters, so I can confirm which ones were in fact overridden?
Since SV packages do not actually contain variables and cannot contain procedural code such as initial statements, I’m not sure how to automatically print them out. In my regular RTL I can add an initial statement and just manually print out each of the localparams that I’ve defined in the package, but if I have ~100 localparams, I prefer to have a way to automatically print them out without manually specifying each one again.