diff options
| author | Jim Lawson | 2016-06-03 12:38:28 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-06-03 12:38:28 -0700 |
| commit | 9dd286b8613beba58e053ed00d15877d3a4b02c9 (patch) | |
| tree | 6ae9268d8e7e6532e5b8a0f3ad51d6c345623376 /src/main/scala/Chisel/package.scala | |
| parent | 70271cd8c3811cb518e81d1d5eb3ed20cb1e2063 (diff) | |
| parent | fd53af8642237998e23456a3fd1648ac84607db0 (diff) | |
Merge branch 'master' into front_end_dependency
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 + } } |
