diff options
Diffstat (limited to 'src/main/scala/chisel3/util/Math.scala')
| -rw-r--r-- | src/main/scala/chisel3/util/Math.scala | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/scala/chisel3/util/Math.scala b/src/main/scala/chisel3/util/Math.scala index 6eab9241..1fc45650 100644 --- a/src/main/scala/chisel3/util/Math.scala +++ b/src/main/scala/chisel3/util/Math.scala @@ -23,11 +23,10 @@ import chisel3.internal * }}} */ object log2Up { - // Do not deprecate until zero-width wires fully work: - // https://github.com/freechipsproject/chisel3/issues/847 - //@chiselRuntimeDeprecated - //@deprecated("Use log2Ceil instead", "chisel3") - def apply(in: BigInt): Int = Chisel.log2Up(in) + def apply(in: BigInt): Int = { + require(in >= 0) + 1.max((in - 1).bitLength) + } } /** Compute the log2 of a Scala integer, rounded up. @@ -66,7 +65,7 @@ object log2Down { // https://github.com/freechipsproject/chisel3/issues/847 //@chiselRuntimeDeprecated //@deprecated("Use log2Floor instead", "chisel3") - def apply(in: BigInt): Int = Chisel.log2Down(in) + def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1) } /** Compute the log2 of a Scala integer, rounded down. |
