From fea4f3a80d2ed5d4735ef33558bebbab290290fb Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 31 Jul 2018 13:32:15 -0700 Subject: Revert removal of bit extraction const prop for literals (#857) See https://github.com/freechipsproject/chisel3/issues/867 for future API discussion--- src/test/scala/chiselTests/UIntOps.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/test/scala/chiselTests/UIntOps.scala') 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) + } } -- cgit v1.2.3