log2Ceil
chisel3.util.log2Ceil
object log2Ceil
Compute the log2 of a Scala integer, rounded up. Useful for getting the number of bits needed to represent some number of states (in - 1). To get the number of bits needed to represent some number n, use log2Ceil(n + 1).
Note: can return zero, and should not be used in cases where it may generate unsupported zero-width wires.
Attributes
- Example
-
log2Ceil(1) // returns 0 log2Ceil(2) // returns 1 log2Ceil(3) // returns 2 log2Ceil(4) // returns 2 - Source
- Math.scala
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
log2Ceil.type
Members list
In this article