I'm trying to pass a random value using $urandom into a parameter for a top-level module in my testbench. But, I get the error:
Illegal non-local reference to constant function [10.3.5(IEEE)].
when running with the code below:
generate
for (genvar chip=0; chip<NUM_CHIPS; chip++) begin: gen_yodawg
YODAWG #(
.TEL_VSUM_OFFSET_ERROR('{(($urandom/(1 << 31))-1)*0.025, (($urandom/(1 << 31))-1)*0.025, (($urandom/(1 << 31))-1)*0.025, (($urandom/(1 << 31))-1)*0.025}),
.TEL_VSUM_GAIN_ERROR('{(($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05}),
.TEL_VOUT_OFFSET_ERROR('{(($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05}),
.TEL_VOUT_GAIN_ERROR('{(($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05, (($urandom/(1 << 31))-1)*0.05}),
.TEL_VIN_OFFSET_ERROR((($urandom/(1 << 31))-1)*0.05),
.TEL_VIN_GAIN_ERROR((($urandom/(1 << 31))-1)*0.05),
.TEL_TEMP_OFFSET_ERROR((($urandom/(1 << 31))-1)*0.05),
.TEL_TEMP_GAIN_ERROR((($urandom/(1 << 31))-1)*0.05)
) yodawg (
// ports
);
end
endgenerate
I'm assuming that the $urandom isn't being done at compile time, so this doesn't work. Is there any way to get $urandom to generate its value at compile time and then pass that into the parameter?
I tried generating all the parameter values in an initial block, or generating const values, but it doesn't seem like I can pass any variable into a parameter, even if it's a const.