summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/package.scala
diff options
context:
space:
mode:
authorJim Lawson2016-07-06 09:31:47 -0700
committerJim Lawson2016-07-18 15:49:45 -0700
commit12810b5efe6a8f872fbc1c63cdfb835ca354624f (patch)
tree1fe4d0666e28f15880bbaf164592bd2bba1eff7c /src/main/scala/chisel3/package.scala
parentc5f9ea3133ef363ff8944e17d94fea79767b6bed (diff)
Update Chisel -> chisel3 references.
Diffstat (limited to 'src/main/scala/chisel3/package.scala')
-rw-r--r--src/main/scala/chisel3/package.scala82
1 files changed, 79 insertions, 3 deletions
diff --git a/src/main/scala/chisel3/package.scala b/src/main/scala/chisel3/package.scala
index f05e8b5d..35bbd1c4 100644
--- a/src/main/scala/chisel3/package.scala
+++ b/src/main/scala/chisel3/package.scala
@@ -1,12 +1,88 @@
-package object Chisel {
+package object chisel3 {
import scala.language.experimental.macros
-
+
import internal.firrtl.Width
import internal.sourceinfo.{SourceInfo, SourceInfoTransform}
implicit class fromBigIntToLiteral(val x: BigInt) extends AnyVal {
def U: UInt = UInt(x, Width())
def S: SInt = SInt(x, Width())
+
+ import util.BitPat
+
+
+ type Direction = chisel3.core.Direction
+ type Data = chisel3.core.Data
+ val Wire = chisel3.core.Wire
+ val Clock = chisel3.core.Clock
+ type Clock = chisel3.core.Clock
+
+ type Aggregate = chisel3.core.Aggregate
+ val Vec = chisel3.core.Vec
+ type Vec[T <: Data] = chisel3.core.Vec[T]
+ type VecLike[T <: Data] = chisel3.core.VecLike[T]
+ type Bundle = chisel3.core.Bundle
+
+ val assert = chisel3.core.assert
+
+ type Element = chisel3.core.Element
+ type Bits = chisel3.core.Bits
+ val Bits = chisel3.core.Bits
+ type Num[T <: Data] = chisel3.core.Num[T]
+ type UInt = chisel3.core.UInt
+ val UInt = chisel3.core.UInt
+ type SInt = chisel3.core.SInt
+ val SInt = chisel3.core.SInt
+ type Bool = chisel3.core.Bool
+ val Bool = chisel3.core.Bool
+ val Mux = chisel3.core.Mux
+
+ type BlackBox = chisel3.core.BlackBox
+
+ val Mem = chisel3.core.Mem
+ type MemBase[T <: Data] = chisel3.core.MemBase[T]
+ type Mem[T <: Data] = chisel3.core.Mem[T]
+ val SeqMem = chisel3.core.SeqMem
+ type SeqMem[T <: Data] = chisel3.core.SeqMem[T]
+
+ val Module = chisel3.core.Module
+ type Module = chisel3.core.Module
+
+ val printf = chisel3.core.printf
+
+ val Reg = chisel3.core.Reg
+
+ val when = chisel3.core.when
+ type WhenContext = chisel3.core.WhenContext
+
+ /**
+ * These implicit classes allow one to convert scala.Int|scala.BigInt to
+ * Chisel.UInt|Chisel.SInt by calling .asUInt|.asSInt on them, respectively.
+ * The versions .asUInt(width)|.asSInt(width) are also available to explicitly
+ * mark a width for the new literal.
+ *
+ * Also provides .asBool to scala.Boolean and .asUInt to String
+ *
+ * Note that, for stylistic reasons, one hould avoid extracting immediately
+ * after this call using apply, ie. 0.asUInt(1)(0) due to potential for
+ * confusion (the 1 is a bit length and the 0 is a bit extraction position).
+ * Prefer storing the result and then extracting from it.
+ */
+ implicit class addLiteraltoScalaInt(val target: Int) extends AnyVal {
+ def asUInt() = UInt.Lit(target)
+ def asSInt() = SInt.Lit(target)
+ def asUInt(width: Int) = UInt.Lit(target, width)
+ def asSInt(width: Int) = SInt.Lit(target, width)
+
+ // These were recently added to chisel2/3 but are not to be used internally
+ @deprecated("asUInt should be used over U", "gchisel")
+ def U() = UInt.Lit(target)
+ @deprecated("asSInt should be used over S", "gchisel")
+ def S() = SInt.Lit(target)
+ @deprecated("asUInt should be used over U", "gchisel")
+ def U(width: Int) = UInt.Lit(target, width)
+ @deprecated("asSInt should be used over S", "gchisel")
+ def S(width: Int) = SInt.Lit(target, width)
}
implicit class fromIntToLiteral(val x: Int) extends AnyVal {
def U: UInt = UInt(BigInt(x), Width())
@@ -23,7 +99,7 @@ package object Chisel {
final def === (that: BitPat): Bool = macro SourceInfoTransform.thatArg
final def != (that: BitPat): Bool = macro SourceInfoTransform.thatArg
final def =/= (that: BitPat): Bool = macro SourceInfoTransform.thatArg
-
+
def do_=== (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that === x
def do_!= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that != x
def do_=/= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that =/= x