aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Waterman2019-03-26 12:00:03 -0700
committerAndrew Waterman2019-03-26 12:31:08 -0700
commit24f81e828b70e2745c2fbd06a4694a9f054851e8 (patch)
treefde107953d72f30ddd329ae10d895cc5a37ed60b /src
parenta076a8ec18bdda6f8a964bea7f91d32cb17f0b89 (diff)
Add test for DCE of printf and stop
Diffstat (limited to 'src')
-rw-r--r--src/test/scala/firrtlTests/DCETests.scala17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/DCETests.scala b/src/test/scala/firrtlTests/DCETests.scala
index a6def402..620cc5f3 100644
--- a/src/test/scala/firrtlTests/DCETests.scala
+++ b/src/test/scala/firrtlTests/DCETests.scala
@@ -449,6 +449,23 @@ class DCETests extends FirrtlFlatSpec {
// Check for register update
verilog should include regex ("""(?m)if \(a\) begin\n\s*r <= x;\s*end""")
}
+
+ "Emitted Verilog" should "not contain dead print or stop statements" in {
+ val input = parse(
+ """circuit test :
+ | module test :
+ | input clock : Clock
+ | when UInt<1>(0) :
+ | printf(clock, UInt<1>(1), "o hai")
+ | stop(clock, UInt<1>(1), 1)""".stripMargin
+ )
+
+ val state = CircuitState(input, ChirrtlForm)
+ val result = (new VerilogCompiler).compileAndEmit(state, List.empty)
+ val verilog = result.getEmittedCircuit.value
+ verilog shouldNot include regex ("""fwrite""")
+ verilog shouldNot include regex ("""fatal""")
+ }
}
class DCECommandLineSpec extends FirrtlFlatSpec {