diff options
| author | Jack Koenig | 2018-07-31 13:32:15 -0700 |
|---|---|---|
| committer | GitHub | 2018-07-31 13:32:15 -0700 |
| commit | fea4f3a80d2ed5d4735ef33558bebbab290290fb (patch) | |
| tree | 4d3f7fa475f208a14a955c55e25fd0229ce4334f /src/test/scala/chiselTests/UIntOps.scala | |
| parent | 566d181837715605ec1681e71856ff1fca1e4e3e (diff) | |
Revert removal of bit extraction const prop for literals (#857)
See https://github.com/freechipsproject/chisel3/issues/867 for future API discussion
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) + } } |
