Can anyone tel me how to calculate the log value of a parameter in a design file?
I am coming across such a situation where I have a generate for a loop like this:
parameter N=8;
genvar i,m;
generate
for(m=1;m<N;m=m*2)
begin :m_loop
// I have an instance here
// "in" is an input of N bits, "out" is an output N bits
Inst u(in(i+log2(m)),in(i+1+log2(m)),out(i+log2(m)));
end
endgenerate
Is there a way to do log2(m), where m varies as powers of 2 (2^0,2^1,2^2, till N)? If not,
I was thinking of introducing a new variable, m1, say, which is 0,1,2,... (i.e log2(m)).
In such a case m1 should vary with simultaneously every m, ie, when m=1,m1=0; m=2,m1=1;
m=4,m1=2; m=8,m1=3 and so on.