summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Waterman2015-07-23 17:21:36 -0700
committerAndrew Waterman2015-07-24 15:10:59 -0700
commit94893bad972ded686a2c68dd334aa40b92e3b85d (patch)
treed15ec79354e9adb61fe4c3f319c685143c4d49af /src
parent523abfdf49a3af747b2243a46415dc7a817154e4 (diff)
Factor out common code from object Bits
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/Core.scala16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/main/scala/Core.scala b/src/main/scala/Core.scala
index e1b2375b..8236c154 100644
--- a/src/main/scala/Core.scala
+++ b/src/main/scala/Core.scala
@@ -720,16 +720,6 @@ abstract class Bits(dirArg: Direction, width: Int) extends Element(dirArg, width
def toBool(): Bool = this(0)
}
-import UInt._
-
-object Bits {
- def apply(dir: Direction = OUTPUT, width: Int = -1) = new UInt(dir, width)
- def apply(value: BigInt, width: Int): UInt = uintLit(value, width)
- def apply(value: BigInt): UInt = apply(value, -1)
- def apply(n: String, width: Int): UInt = UInt(n, width)
- def apply(n: String): UInt = apply(n, -1)
-}
-
abstract trait Num[T <: Data] {
// def << (b: T): T;
// def >> (b: T): T;
@@ -808,7 +798,7 @@ class UInt(dir: Direction, width: Int) extends Bits(dir, width) with Num[UInt] {
def asUInt(): UInt = this
}
-object UInt {
+trait UIntFactory {
def apply(dir: Direction = OUTPUT, width: Int = -1) =
new UInt(dir, width)
def uintLit(value: BigInt, width: Int) = {
@@ -829,6 +819,10 @@ object UInt {
def apply(n: String): UInt = apply(n, -1)
}
+// Bits constructors are identical to UInt constructors.
+object Bits extends UIntFactory
+object UInt extends UIntFactory
+
class SInt(dir: Direction, width: Int) extends Bits(dir, width) with Num[SInt] {
override def cloneTypeWidth(w: Int): this.type =
new SInt(dir, w).asInstanceOf[this.type]