diff options
| author | Albert Magyar | 2020-03-06 11:16:49 -0800 |
|---|---|---|
| committer | GitHub | 2020-03-06 11:16:49 -0800 |
| commit | 140a29a851a9e5b0b1cd486cc5ba53c3ff763f27 (patch) | |
| tree | 73c21dbb30dcc073987ce9ee3e578435452a5a66 /src/test | |
| parent | 668a80d1262a24bb4588426f83d9deb72afde23b (diff) | |
Check sign of primop constants where appropriate (#1421)
* Avoid IndexOutOfBoundsException when Bits has too few consts
* Check for negative consts in all relevant primops
* Use BigInt for all checks on primop constants
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/CheckSpec.scala | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/test/scala/firrtlTests/CheckSpec.scala b/src/test/scala/firrtlTests/CheckSpec.scala index 96275003..9a384d21 100644 --- a/src/test/scala/firrtlTests/CheckSpec.scala +++ b/src/test/scala/firrtlTests/CheckSpec.scala @@ -267,7 +267,7 @@ class CheckSpec extends FlatSpec with Matchers { } } - for (op <- List("shl", "shr")) { + for (op <- List("shl", "shr", "pad", "head", "tail", "incp", "decp")) { s"$op by negative amount" should "result in an error" in { val amount = -1 val input = @@ -283,16 +283,19 @@ class CheckSpec extends FlatSpec with Matchers { } } - "LSB larger than MSB in bits" should "throw an exception" in { - val input = - """|circuit bar : - | module bar : - | input in : UInt<8> - | output foo : UInt - | foo <= bits(in, 3, 4) - | """.stripMargin - val exception = intercept[PassException] { - checkHighInput(input) + // Check negative bits constant, too + for (args <- List((3, 4), (0, -1))) { + val opExp = s"bits(in, ${args._1}, ${args._2})" + s"Illegal bit extract ${opExp}" should "throw an exception" in { + val input = + s"""|circuit bar : + | module bar : + | input in : UInt<8> + | output foo : UInt + | foo <= ${opExp}""".stripMargin + val exception = intercept[PassException] { + checkHighInput(input) + } } } |
