shaiko
Advanced Member level 5
Hello,
I use this VHDL log function for vector length sizing.
The problem is that is rounds down results.
For example:
log2 of 50,000,000 is 25.575
However the output of my function rounds it down to 25.
I want, to round it up to 26 instead. How should I modify it ?
I use this VHDL log function for vector length sizing.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 function log2_unsigned ( x : natural ) return natural is variable temp : natural := x ; variable n : natural := 0 ; begin while temp > 1 loop temp := temp / 2 ; n := n + 1 ; end loop ; return n ; end function log2_unsigned ;
The problem is that is rounds down results.
For example:
log2 of 50,000,000 is 25.575
However the output of my function rounds it down to 25.
I want, to round it up to 26 instead. How should I modify it ?
Last edited by a moderator: