diff options
Diffstat (limited to 'src/test/scala/chiselTests/UIntOps.scala')
| -rw-r--r-- | src/test/scala/chiselTests/UIntOps.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/scala/chiselTests/UIntOps.scala b/src/test/scala/chiselTests/UIntOps.scala index 149ec3c4..d583c0bb 100644 --- a/src/test/scala/chiselTests/UIntOps.scala +++ b/src/test/scala/chiselTests/UIntOps.scala @@ -96,6 +96,21 @@ class NegativeShift(t: => Bits) extends Module { Reg(t) >> -1 } +class UIntLitExtractTester extends BasicTester { + assert("b101010".U(2) === false.B) + assert("b101010".U(3) === true.B) + assert("b101010".U(100) === false.B) + assert("b101010".U(3, 0) === "b1010".U) + assert("b101010".U(9, 0) === "b0000101010".U) + + assert("b101010".U(6.W)(2) === false.B) + assert("b101010".U(6.W)(3) === true.B) + assert("b101010".U(6.W)(100) === false.B) + assert("b101010".U(6.W)(3, 0) === "b1010".U) + assert("b101010".U(6.W)(9, 0) === "b0000101010".U) + stop() +} + class UIntOpsSpec extends ChiselPropSpec with Matchers { // Disable shrinking on error. implicit val noShrinkListVal = Shrink[List[Int]](_ => Stream.empty) @@ -120,5 +135,9 @@ class UIntOpsSpec extends ChiselPropSpec with Matchers { property("Negative shift amounts are invalid") { a [ChiselException] should be thrownBy { elaborate(new NegativeShift(UInt())) } } + + property("Bit extraction on literals should work for all non-negative indices") { + assertTesterPasses(new UIntLitExtractTester) + } } |
