0

I have a parameterised module whose SEED value has to change depending on the WIDTH parameter, where the seed values have to be hard-coded.

module Module;

parameter WIDTH = 8;

integer seeds [31:0] = {'hC, 'h1E, 'h39, 'h7E, /* ... */};
localparam SEED = seeds[WIDTH];

endmodule

This doesn't work, It's clear I'm trying to use the unpacked array in the wrong context.

Unable to bind parameter seeds[WIDTH] in module Module

How else can I implement this?

Inigo Selwood
  • 822
  • 9
  • 20

1 Answers1

0

After adjusting the post to compile with the truncated 4-element array, Questa shows:

** Error: testbench.sv(): Parameter value must be constant.    

Parameters and localparams can't accept variable values.
Integer is a variable type, it can change at run time.
Parameters must be known an compile time.

This compiles without warnings:

module Module;

parameter WIDTH = 1;

parameter integer seeds[4]  = {4'hC, 8'h1E, 8'h39, 8'h7E};

localparam SEED = seeds[WIDTH];

initial  
  $display("SEED = %0h",SEED);

endmodule    

Questa Produces:

# vsim -voptargs=+acc=npr
# run -all
# SEED = 1e

This has an array of 4 hex values, and uses index 1 (WIDTH==1) as an argument to seeds.

Mikef
  • 1,572
  • 2
  • 10
  • 21
  • I used the ellipsis comment to indicate that I'd truncated the full list of 32 values, that's common notation as far as I'm aware – Inigo Selwood Nov 04 '22 at 16:03