summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/scala/chisel3/util/BitPat.scala7
-rw-r--r--src/main/scala/chisel3/util/Conditional.scala4
2 files changed, 5 insertions, 6 deletions
diff --git a/src/main/scala/chisel3/util/BitPat.scala b/src/main/scala/chisel3/util/BitPat.scala
index 8d6565fb..3a3a7061 100644
--- a/src/main/scala/chisel3/util/BitPat.scala
+++ b/src/main/scala/chisel3/util/BitPat.scala
@@ -74,9 +74,8 @@ object BitPat {
* @note the UInt must be a literal
*/
def apply(x: UInt): BitPat = {
- require(x.isLit)
val len = if (x.isWidthKnown) x.getWidth else 0
- apply("b" + x.litValue.toString(2).reverse.padTo(len, "0").reverse.mkString)
+ apply("b" + x.litToBigInt.toString(2).reverse.padTo(len, "0").reverse.mkString)
}
}
@@ -93,7 +92,7 @@ sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) {
def getWidth: Int = width
def === (that: UInt): Bool = macro SourceInfoTransform.thatArg
def =/= (that: UInt): Bool = macro SourceInfoTransform.thatArg
-
+
def do_=== (that: UInt) // scalastyle:ignore method.name
(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
value.asUInt === (that & mask.asUInt)
@@ -102,7 +101,7 @@ sealed class BitPat(val value: BigInt, val mask: BigInt, width: Int) {
(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): Bool = {
!(this === that)
}
-
+
def != (that: UInt): Bool = macro SourceInfoTransform.thatArg
@chiselRuntimeDeprecated
@deprecated("Use '=/=', which avoids potential precedence problems", "chisel3")
diff --git a/src/main/scala/chisel3/util/Conditional.scala b/src/main/scala/chisel3/util/Conditional.scala
index 860ffde3..f558b7ba 100644
--- a/src/main/scala/chisel3/util/Conditional.scala
+++ b/src/main/scala/chisel3/util/Conditional.scala
@@ -28,8 +28,8 @@ class SwitchContext[T <: Bits](cond: T, whenContext: Option[WhenContext], lits:
def is(v: Iterable[T])(block: => Unit): SwitchContext[T] = {
if (!v.isEmpty) {
val newLits = v.map { w =>
- require(w.isLit, "is conditions must be literals!")
- val value = w.litValue
+ require(w.litToBigIntOption != None, "is condition must be literal")
+ val value = w.litToBigInt
require(!lits.contains(value), "all is conditions must be mutually exclusive!")
value
}