summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/Chisel/util/Math.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/util/Math.scala b/src/main/scala/Chisel/util/Math.scala
index 270301f0..5f8212d8 100644
--- a/src/main/scala/Chisel/util/Math.scala
+++ b/src/main/scala/Chisel/util/Math.scala
@@ -7,7 +7,10 @@ package Chisel
/** Compute the log2 rounded up with min value of 1 */
object log2Up {
- def apply(in: BigInt): Int = 1 max (in-1).bitLength
+ def apply(in: BigInt): Int = {
+ require(in >= 0)
+ 1 max (in-1).bitLength
+ }
def apply(in: Int): Int = apply(BigInt(in))
}