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 /src/main/scala/Chisel/package.scala | |
| parent | 3b10267257de7662abbbc235d9bfd8a8b89f69f5 (diff) | |
Move BitPat out of core/frontend, add implicit conversion
Diffstat (limited to 'src/main/scala/Chisel/package.scala')
| -rw-r--r-- | src/main/scala/Chisel/package.scala | 14 |
1 files changed, 14 insertions, 0 deletions
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 + } } |
