From afa6f2740f4243de8345af0a899ac4a9c4a48d6c Mon Sep 17 00:00:00 2001 From: Donggyu Kim Date: Fri, 6 May 2016 12:45:04 -0700 Subject: fix width inference in enum --- src/main/scala/Chisel/util/Enum.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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 -- cgit v1.2.3