Why function call to clogb2
is not being executed in the following code. I don't get any compilation errors but still parameter adder_width
is not updated with the value from clogb2
. In fact, that function doesn't return any value.
See http://www.edaplayground.com/x/Pxc.
module ram_model ();
parameter ram_depth = 8;
localparam adder_width = clogb2(ram_depth);
initial begin
$dumpfile("dump.vcd");
$dumpvars(1);
$monitor("%d",adder_width);
end
function integer clogb2;
input depth;
integer i,result;
begin
for (i = 0; 2**(i) < depth; i = i + 1)
result = i + 1;
clogb2 = result;
end
endfunction
endmodule