summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/Math.scala
diff options
context:
space:
mode:
authorAditya Naik2024-05-03 10:59:45 -0700
committerAditya Naik2024-05-03 10:59:45 -0700
commit878d488a7c8e0d6973de58b3164022c6a102e449 (patch)
treecd081bbcbe3f797f80b10c2d8153da0069750e51 /src/main/scala/chisel3/util/Math.scala
parent8200c0cdf1d471453946d5ae24bc99757b2ef02d (diff)
Get cleanup to compile
Diffstat (limited to 'src/main/scala/chisel3/util/Math.scala')
-rw-r--r--src/main/scala/chisel3/util/Math.scala11
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.