I have a doubt in the generate, my code is:
parameter m=1;
generate
for(i=0; i<m; i=i+1) :loopstart
begin
statements;
end
endgenerate
Inside this loop, m should be 2^0, 2^1, 2^2, and so on. Since exponentiation is not supported, I thought of initializing m and then multiplying it by 2 on each iteration.
I have a few questions:
Is it possible to use m << 1 inside the generate in some way (since this is the same as
multiplying by 2)? If I do that, it results in an error.
I referred to Samir Palnitkar's book, which says that always statement works inside a generate, so I tried:
always @(m)
m <= m*2; // (or m << 1)
This doesn't work. I realize it can't be done because m is a parameter and not a variable.
If what I think is right, it can't be done with genvar either, since a genvar can't be initialized.
Is there an alternative?