Aman551
1
I want to do something like this…how can I do this
module dummy #(
parameter ARR_SZ,
parameter bit[`INT_B-1:0] VAR_A[ARR_SZ ? ARR_SZ : 1],
parameter bit[` INT_B-1:0] VAR_B[ARR_SZ ? ARR_SZ : 1]
) (
.
.
.
);
localparam WIDTH = **`max value from VAR_A`**;
endmodule
You can’t use the max
reduction method in a constant function, so you will have create your own function. It is very simple
localparam WIDTH = max(VAR_A);
function bit[`INT_B-1:0] max(bit[`INT_B-1:0] arg[ARR_SZ ? ARR_SZ : 1]);
max = 0;
foreach(arg[i]) if (arg[i]>max) max = arg[i];
endfunction
If you have many different parameterized array shapes in the same module you can wrap the function as a static method in a parameterized class.