summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Waterman2017-02-24 00:34:04 -0800
committerJack Koenig2017-03-08 11:27:04 -0600
commit09e95c484e145e2a1b2f0a1aacf549c7354a1eca (patch)
tree8154279b25708c4faa91444db88a70763b966cd6 /src
parent5f846792824cdb467691d929d64de117bb3cffcb (diff)
Move log2Up and log2Down to compatibility wrapper
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/compatibility.scala18
-rw-r--r--src/main/scala/chisel3/util/Math.scala11
2 files changed, 19 insertions, 10 deletions
diff --git a/src/main/scala/chisel3/compatibility.scala b/src/main/scala/chisel3/compatibility.scala
index e58650ea..aee02dfe 100644
--- a/src/main/scala/chisel3/compatibility.scala
+++ b/src/main/scala/chisel3/compatibility.scala
@@ -215,13 +215,25 @@ package object Chisel { // scalastyle:ignore package.object.name
val TesterDriver = chisel3.testers.TesterDriver
}
-
- val log2Up = chisel3.util.log2Up
val log2Ceil = chisel3.util.log2Ceil
- val log2Down = chisel3.util.log2Down
val log2Floor = chisel3.util.log2Floor
val isPow2 = chisel3.util.isPow2
+ /** Compute the log2 rounded up with min value of 1 */
+ object log2Up {
+ def apply(in: BigInt): Int = {
+ require(in >= 0)
+ 1 max (in-1).bitLength
+ }
+ def apply(in: Int): Int = apply(BigInt(in))
+ }
+
+ /** Compute the log2 rounded down with min value of 1 */
+ object log2Down {
+ def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1)
+ def apply(in: Int): Int = apply(BigInt(in))
+ }
+
val BitPat = chisel3.util.BitPat
type BitPat = chisel3.util.BitPat
diff --git a/src/main/scala/chisel3/util/Math.scala b/src/main/scala/chisel3/util/Math.scala
index 73665f0f..cf75e756 100644
--- a/src/main/scala/chisel3/util/Math.scala
+++ b/src/main/scala/chisel3/util/Math.scala
@@ -8,12 +8,9 @@ package chisel3.util
import chisel3._
/** Compute the log2 rounded up with min value of 1 */
+@deprecated("Use log2Ceil instead", "chisel3")
object log2Up {
- def apply(in: BigInt): Int = {
- require(in >= 0)
- 1 max (in-1).bitLength
- }
- def apply(in: Int): Int = apply(BigInt(in))
+ def apply(in: BigInt): Int = Chisel.log2Up(in)
}
/** Compute the log2 rounded up */
@@ -26,9 +23,9 @@ object log2Ceil {
}
/** Compute the log2 rounded down with min value of 1 */
+@deprecated("Use log2Floor instead", "chisel3")
object log2Down {
- def apply(in: BigInt): Int = log2Up(in) - (if (isPow2(in)) 0 else 1)
- def apply(in: Int): Int = apply(BigInt(in))
+ def apply(in: BigInt): Int = Chisel.log2Down(in)
}
/** Compute the log2 rounded down */