My module has a configurable width input of signals sensor_line[WIDTH-1:0] where WIDTH is parameter.
For each sensor_line I have a recorder module instantiated with a generate block in a for loop.
I need to pass a decimal number parameter to this recorder which is different for each sensor_line.
I need to create some decimal array parameter to give to my module in the top, which it’s width will be aligned with the WIDTH parameter. I don’t mind if I need to match the given array size myself as long as I can do it from the top when instantiating my module.
Looking for a solution, I found only for passing an array of bits (binary value).
For example, to pass 5 bits for each sensor_line, a code like this can be used:
module my_module #(
parameter WIDTH = 4, // number of input lines
parameter [4:0] CYCELS [WIDTH-1:0] = '{ WIDTH{5'b0}}
)
(
Input clk;
input [WIDTH-1:0] sensor_line;
…
);
logic [WIDTH-1:0] sensor_line_out;
…
genvar i;
generate
for (i=0; i< WIDTH; i=i+1) begin : sensor_sync
recorder #(
. CYCELS(CYCELS [(i+1)*5:i*5])
)
recorder_instance(
.in(sensor_line[i]),
.out(sensor_line_out[i]),
.clk(clk),
…
);
end
endgenerate
…
endmodule
How can I pass decimal values to the recorder module, not bits like in the example, like passing integer array in C and then point to the array at index [i] and at the end instance my module like this:
my_module #(
.WIDTH(4), // number of input lines
.CYCELS([2,3,5,4])
) my_module_1 (
...
)
my_module #(
.WIDTH(3), // number of input lines
.CYCELS([3,2,2])
) my_module_2 (
...
)