diff options
| author | Ducky | 2016-05-23 14:09:26 -0700 |
|---|---|---|
| committer | Andrew Waterman | 2016-05-31 19:05:25 -0700 |
| commit | 2e2e3da0c07cd1dc873c064510f68123cae69059 (patch) | |
| tree | d56c9d9e7092a07280ef7942b81f7041e83dcd05 | |
| parent | 3b10267257de7662abbbc235d9bfd8a8b89f69f5 (diff) | |
Move BitPat out of core/frontend, add implicit conversion
| -rw-r--r-- | chiselFrontend/src/main/scala/Chisel/Bits.scala | 8 | ||||
| -rw-r--r-- | src/main/scala/Chisel/BitPat.scala (renamed from chiselFrontend/src/main/scala/Chisel/BitPat.scala) | 0 | ||||
| -rw-r--r-- | src/main/scala/Chisel/package.scala | 14 |
3 files changed, 14 insertions, 8 deletions
diff --git a/chiselFrontend/src/main/scala/Chisel/Bits.scala b/chiselFrontend/src/main/scala/Chisel/Bits.scala index 2783c160..bc8cc8e2 100644 --- a/chiselFrontend/src/main/scala/Chisel/Bits.scala +++ b/chiselFrontend/src/main/scala/Chisel/Bits.scala @@ -464,14 +464,6 @@ sealed class UInt private[Chisel] (dir: Direction, width: Width, lit: Option[ULi Mux(dat, this | bit, ~(~this | bit)) } - 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 === this - def do_!= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that != this - def do_=/= (that: BitPat)(implicit sourceInfo: SourceInfo): Bool = that =/= this - /** Returns this UInt as a [[SInt]] with an additional zero in the MSB. */ // TODO: this eventually will be renamed as toSInt, once the existing toSInt diff --git a/chiselFrontend/src/main/scala/Chisel/BitPat.scala b/src/main/scala/Chisel/BitPat.scala index cf412542..cf412542 100644 --- a/chiselFrontend/src/main/scala/Chisel/BitPat.scala +++ b/src/main/scala/Chisel/BitPat.scala diff --git a/src/main/scala/Chisel/package.scala b/src/main/scala/Chisel/package.scala index 61fb6904..f05e8b5d 100644 --- a/src/main/scala/Chisel/package.scala +++ b/src/main/scala/Chisel/package.scala @@ -1,5 +1,9 @@ package object Chisel { + 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()) @@ -14,4 +18,14 @@ package object Chisel { implicit class fromBooleanToLiteral(val x: Boolean) extends AnyVal { def B: Bool = Bool(x) } + + implicit class fromUIntToBitPatComparable(val x: UInt) extends AnyVal { + 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 + } } |
