I have a module which has an integer parameter. This parameter controls a generate loop. When the parameter value is 0, then it cannot be used but must be replaced by 1. I tried to use a function, but the function can only initialize a variable, which cannot be used for the control of the generate loop. This is my example code which gave this error message
Unable to bind parameter `number'
for the code line with the generate instruction:
module test
#(parameter
g_latency = 8
)
;
function integer get_number;
begin
if (g_latency==0) begin
get_number = 1;
end else begin
get_number = g_latency;
end
end
endfunction
genvar i;
integer number;
initial begin
number = get_number;
end
generate for (i=0; i<=number-1; i=i+1)
begin: step_g
// comment
end
endgenerate
endmodule
So, how can I calculate a generate control value from a module parameter?