summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/Chisel/BitPat.scala
diff options
context:
space:
mode:
authorducky2016-05-05 13:22:04 -0700
committerducky2016-05-20 16:02:49 -0700
commite92f2f69477a6ce86fc148a1a95db5797f2e3051 (patch)
tree2f1511e3395299fd4f1e98c3f75886e06c0cd096 /chiselFrontend/src/main/scala/Chisel/BitPat.scala
parent84de04606bc972bd6a83f67913a0e30c4c46ee5e (diff)
Implementation of 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
}