diff options
| author | Donggyu Kim | 2016-05-06 12:45:04 -0700 |
|---|---|---|
| committer | Andrew Waterman | 2016-05-09 11:10:07 -0700 |
| commit | afa6f2740f4243de8345af0a899ac4a9c4a48d6c (patch) | |
| tree | 3f0e775a0403ac7c3ab34ee804c207c37a7468f2 /src | |
| parent | b13b5a019a24d8b6eb1557d6f971169e723c1e15 (diff) | |
fix width inference in enum
Diffstat (limited to 'src')
| -rw-r--r-- | src/main/scala/Chisel/util/Enum.scala | 3 |
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 |
