diff options
| -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 + } } |
