Forum Discussion
Altera_Forum
Honored Contributor
17 years agoHi,
Everytime I see code with parameters, some manual action has to be done for setting the bit-width of a register (counter). There is a nice trick with a 'constant-function' to prevednt this action : change this : parameter N = CLogB2(dur);
and add : //ceil of the log base 2
function integer CLogB2;
input Depth;
integer i;
begin
i = Depth;
for(CLogB2 = 0; i > 0; CLogB2 = CLogB2 + 1)
i = i >> 1;
end
endfunction