summaryrefslogtreecommitdiff
path: root/src/main/scala/Chisel/Enum.scala
diff options
context:
space:
mode:
authorAndrew Waterman2015-08-05 01:28:58 -0700
committerAndrew Waterman2015-08-05 01:28:58 -0700
commit1f2383fb61ca7c4e4def0c7c4ee1a19e58c36288 (patch)
treec43ae73dba5d971828e37ddb5ab8f5fa2947e7fb /src/main/scala/Chisel/Enum.scala
parent4dc84e2f57be972287d77caca3121b21d0c79b56 (diff)
Use Width object, not Int
Please, no more -1
Diffstat (limited to 'src/main/scala/Chisel/Enum.scala')
-rw-r--r--src/main/scala/Chisel/Enum.scala10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/main/scala/Chisel/Enum.scala b/src/main/scala/Chisel/Enum.scala
index ae87dc00..6f7994f0 100644
--- a/src/main/scala/Chisel/Enum.scala
+++ b/src/main/scala/Chisel/Enum.scala
@@ -32,16 +32,12 @@ package Chisel
import Literal._
object Enum {
- private def makeLit[T <: Bits](nodeType: T, i: Int, n: Int) =
- nodeType.cloneType.makeLit(i, BigInt(1 max (n-1)).bitLength)
-
/** create n enum values of given type */
- def apply[T <: Bits](nodeType: T, n: Int): List[T] = Range(0, n).map(x => makeLit(nodeType, x, n)).toList
+ def apply[T <: Bits](nodeType: T, n: Int): List[T] = Range(0, n).map(x => nodeType.makeLit(x)).toList
/** create enum values of given type and names */
- def apply[T <: Bits](nodeType: T, l: Symbol *): Map[Symbol, T] = (l.toList zip (Range(0, l.length).map(x => makeLit(nodeType, x, l.length)))).toMap
+ def apply[T <: Bits](nodeType: T, l: Symbol *): Map[Symbol, T] = (l.toList zip (Range(0, l.length).map(x => nodeType.makeLit(x)))).toMap
/** create enum values of given type and names */
- def apply[T <: Bits](nodeType: T, l: List[Symbol]): Map[Symbol, T] = (l zip (Range(0, l.length).map(x => makeLit(nodeType, x, l.length)))).toMap
-
+ def apply[T <: Bits](nodeType: T, l: List[Symbol]): Map[Symbol, T] = (l zip (Range(0, l.length).map(x => nodeType.makeLit(x)))).toMap
}