diff options
| author | azidar | 2016-08-04 15:15:00 -0700 |
|---|---|---|
| committer | azidar | 2016-08-04 15:16:37 -0700 |
| commit | 6aea3924fb48cbb4c1be217630c60be39b243ff1 (patch) | |
| tree | c9fc072f10598953f54405a3336e3079e394bfbb /src/test | |
| parent | 9b310a04c9c355c8a6f11da2e2f704fbce8f89bb (diff) | |
Addd check: bits, tail, head arg width
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/UnitTests.scala | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/UnitTests.scala b/src/test/scala/firrtlTests/UnitTests.scala index bc8db897..2d1bbdc1 100644 --- a/src/test/scala/firrtlTests/UnitTests.scala +++ b/src/test/scala/firrtlTests/UnitTests.scala @@ -232,4 +232,61 @@ class UnitTests extends FirrtlFlatSpec { ) executeTest(input, check, passes) } + + "Oversized bit select" should "throw an exception" in { + val passes = Seq( + ToWorkingIR, + ResolveKinds, + InferTypes, + ResolveGenders, + InferWidths, + CheckWidths) + val input = + """circuit Unit : + | module Unit : + | node x = bits(UInt(1), 100, 0)""".stripMargin + intercept[CheckWidths.BitsWidthException] { + passes.foldLeft(Parser.parse(input.split("\n").toIterator)) { + (c: Circuit, p: Pass) => p.run(c) + } + } + } + + "Oversized head select" should "throw an exception" in { + val passes = Seq( + ToWorkingIR, + ResolveKinds, + InferTypes, + ResolveGenders, + InferWidths, + CheckWidths) + val input = + """circuit Unit : + | module Unit : + | node x = head(UInt(1), 100)""".stripMargin + intercept[CheckWidths.HeadWidthException] { + passes.foldLeft(Parser.parse(input.split("\n").toIterator)) { + (c: Circuit, p: Pass) => p.run(c) + } + } + } + + "Oversized tail select" should "throw an exception" in { + val passes = Seq( + ToWorkingIR, + ResolveKinds, + InferTypes, + ResolveGenders, + InferWidths, + CheckWidths) + val input = + """circuit Unit : + | module Unit : + | node x = tail(UInt(1), 100)""".stripMargin + intercept[CheckWidths.TailWidthException] { + passes.foldLeft(Parser.parse(input.split("\n").toIterator)) { + (c: Circuit, p: Pass) => p.run(c) + } + } + } } |
