Package prim_util_pkg
Functions
- _clog2(integer value)
- Parameters:
value (integer)
- vbits(integer value)
Math function
Number of bits needed to address |value| items.
0 for value == 0 vbits = 1 for value == 1 ceil(log2(value)) for value > 1
The primary use case for this function is the definition of registers/arrays which are wide enough to contain |value| items.
This function identical to $clog2() for all input values except the value 1; it could be considered an "enhanced" $clog2() function.
Example 1
Example 2
Note
If you want to store the number "value" inside a register, you need
a register with size vbits(value + 1), since you also need to store the number 0.
Example 3
- Parameters:
value (integer)
×
Math function
$clog2 as specified in Verilog-2005
Do not use this function if $clog2() is available.
clog2 = 0 for value == 0 ceil(log2(value)) for value >= 1
This implementation is a synthesizable variant of the $clog2 function as specified in the Verilog-2005 standard (IEEE 1364-2005).
To quote the standard