summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Chisel/util/Enum.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/util/Enum.scala b/src/main/scala/Chisel/util/Enum.scala
index 3e2b038f..20057197 100644
--- a/src/main/scala/Chisel/util/Enum.scala
+++ b/src/main/scala/Chisel/util/Enum.scala
@@ -7,7 +7,8 @@ package Chisel
object Enum {
/** Returns a sequence of Bits subtypes with values from 0 until n. Helper method. */
- private def createValues[T <: Bits](nodeType: T, n: Int): Seq[T] = (0 until n).map(x => nodeType.fromInt(x))
+ private def createValues[T <: Bits](nodeType: T, n: Int): Seq[T] =
+ (0 until n).map(x => nodeType.fromInt(x, log2Up(n)))
/** create n enum values of given type */
def apply[T <: Bits](nodeType: T, n: Int): List[T] = createValues(nodeType, n).toList