summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/Chisel/BitPat.scala
diff options
context:
space:
mode:
authorRichard Lin2016-05-20 16:34:03 -0700
committerRichard Lin2016-05-20 16:34:03 -0700
commitd742d70a05b5fa997517ea7b5eb2d15b23e7a431 (patch)
tree3c2453014c78e889fd1502085661ed604c5f0b34 /chiselFrontend/src/main/scala/Chisel/BitPat.scala
parentd7697eb14a0195cc3726bf45fdf38c631b6f6507 (diff)
parente92f2f69477a6ce86fc148a1a95db5797f2e3051 (diff)
Merge pull request #186 from ucb-bar/sloc_impl
Source locators
Diffstat (limited to 'chiselFrontend/src/main/scala/Chisel/BitPat.scala')
-rw-r--r--chiselFrontend/src/main/scala/Chisel/BitPat.scala14
1 files changed, 11 insertions, 3 deletions
diff --git a/chiselFrontend/src/main/scala/Chisel/BitPat.scala b/chiselFrontend/src/main/scala/Chisel/BitPat.scala
index a1bf1985..cf412542 100644
--- a/chiselFrontend/src/main/scala/Chisel/BitPat.scala
+++ b/chiselFrontend/src/main/scala/Chisel/BitPat.scala
@@ -2,6 +2,10 @@
package Chisel
+import scala.language.experimental.macros
+
+import Chisel.internal.sourceinfo.{SourceInfo, SourceInfoTransform}
+
object BitPat {
/** Parses a bit pattern string into (bits, mask, width).
*
@@ -74,7 +78,11 @@ object BitPat {
*/
sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) {
def getWidth: Int = width
- def === (other: UInt): Bool = UInt(value) === (other & UInt(mask))
- def =/= (other: UInt): Bool = !(this === other)
- def != (other: UInt): Bool = this =/= other
+ def === (that: UInt): Bool = macro SourceInfoTransform.thatArg
+ def =/= (that: UInt): Bool = macro SourceInfoTransform.thatArg
+ def != (that: UInt): Bool = macro SourceInfoTransform.thatArg
+
+ def do_=== (that: UInt)(implicit sourceInfo: SourceInfo): Bool = UInt(value) === (that & UInt(mask))
+ def do_=/= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = !(this === that)
+ def do_!= (that: UInt)(implicit sourceInfo: SourceInfo): Bool = this =/= that
}