diff options
| author | ducky | 2018-05-09 17:07:13 -0700 |
|---|---|---|
| committer | Richard Lin | 2018-07-04 18:39:28 -0500 |
| commit | 7834f0ada9f8bcfc28c1d6124f63acdcaa2d4755 (patch) | |
| tree | f086a643a249a04e4929bf12c9d508cf3fea2087 /src/main/scala/chisel3 | |
| parent | b74034446223db6731c7e4f2eb362b3349efc8be (diff) | |
work on new style literal accessors
Diffstat (limited to 'src/main/scala/chisel3')
| -rw-r--r-- | src/main/scala/chisel3/util/BitPat.scala | 7 | ||||
| -rw-r--r-- | src/main/scala/chisel3/util/Conditional.scala | 4 |
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 } |
