This is an environment that is not UVM based but I have a testbench and multiple tests. The tests and testbench are all the top-level but will optimize one test and the testbench for a single run and reoptimize with another test for the next run and so on. This allows a single testbench and compilation of all the sources once and optimize and simulate on a test basis. I have the following piece of code that had issues with the simulator which is a bug because I don’t see anything wrong from an LRM point of view. Also, since defparam is getting deprecated in future I was wondering what’s the best way to achieve this behavior?. I would prefer not to use defines and override it from command line because I will be dealing with a lot of parameters.
Here’s the code that has a problem with simulation:
module test_tb();
parameter int NUM_LAYERS = 3;
parameter int NUM_NS_PER_LAYER[NUM_LAYERS] = '{8,8,8};
initial
begin
#100;
$display ("NUM_LAYERS is %d and NUM_NS_PER_LAYER is %p", NUM_LAYERS, NUM_NS_PER_LAYER);
$display ("NUM_LAYERS is %d ", NUM_LAYERS);
end
endmodule
module test();
localparam int NS = 1;
localparam int NSP[NS] = '{4};
defparam test_tb.NUM_LAYERS = 1;
// The following 2 lines fail with simulators but some simulators will accept it if I uncomment the next line and comment out the line after it.
//defparam test_tb.NUM_NS_PER_LAYER = NSP;
defparam test_tb.NUM_NS_PER_LAYER = '{4};
endmodule
defparam is an elegant way to do this but is there something that can be done with class and override the parameters but make it available within the testbech.
Thanks