I've written a simple function which does log2 computation of any integer number and then "ceils" it to the next integer:
function log2ceil(intVal: integer) return natural is
variable i : natural;
variable bitCount : natural;
begin
i := (intVal - 1);
bitCount := 0;
while (i > 0) loop
bitCount := bitCount + 1;
i:=shiftRightInt(i,1);
end loop;
return bitCount;
end log2ceil;
function shiftRightInt(ValueToShift: integer; NrToShift:natural) return integer is
begin
return to_integer(shift_right(to_unsigned(ValueToShift, 32), NrToShift));
end shiftRightInt;
Works, fine. The problem is with the simulation. Every time I try to simulate it with a simple function call in a test bench:
stim: process
begin
wait for 10 ns;
log2ceil(3);
wait;
end process;
it gives me following error:
ERROR: [VRFC 10-1472] type error near log2ceil ; expected type void
Why does it expect type Void? And how can I avoid getting this error?
log2ceilas well or just use another test function.