From 334c9bbe5061a3bcb72df971ec555de7df0ba36c Mon Sep 17 00:00:00 2001 From: Schuyler Eldridge Date: Fri, 25 Jan 2019 14:04:16 -0500 Subject: Add "mverilog" Compiler Option, Compiler Fixes This adds "mverilog" to the "--compiler" command line option. This will run the MinimumVerilogCompiler. This additionally fixes the MinimumVerilogCompiler such that DeadCodeElimination will not be run (it's not supposed to be). This is done by adding a MinimumVerilogEmitter, subclassing VerilogVerilog, that strips the DeadCodeElimination step from its parent. Additionally, BlackBoxSourceHelper is removed from the MinimumVerilogCompiler since this will be run by the VerilogEmitter already. Signed-off-by: Schuyler Eldridge --- src/test/scala/firrtlTests/CompilerTests.scala | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/CompilerTests.scala b/src/test/scala/firrtlTests/CompilerTests.scala index 348ed300..ff7d2cb8 100644 --- a/src/test/scala/firrtlTests/CompilerTests.scala +++ b/src/test/scala/firrtlTests/CompilerTests.scala @@ -13,6 +13,7 @@ import firrtl.{ Compiler, HighFirrtlCompiler, MiddleFirrtlCompiler, + MinimumVerilogCompiler, LowFirrtlCompiler, Parser, VerilogCompiler @@ -153,3 +154,31 @@ class VerilogCompilerSpec extends CompilerSpec with Matchers { getOutput should be (check) } } + +class MinimumVerilogCompilerSpec extends CompilerSpec with Matchers { + val input = """|circuit Top: + | module Top: + | output b: UInt<1>[2] + | node c = UInt<1>("h0") + | node d = UInt<1>("h0") + | b[0] <= UInt<1>("h0") + | b[1] <= c + |""".stripMargin + val check = """|module Top( + | output b_0, + | output b_1 + |); + | wire c; + | wire d; + | assign c = 1'h0; + | assign d = 1'h0; + | assign b_0 = 1'h0; + | assign b_1 = c; + |endmodule + |""".stripMargin + def compiler = new MinimumVerilogCompiler() + + "A circuit's minimum Verilog output" should "not have constants propagated or dead code eliminated" in { + getOutput should be (check) + } +} -- cgit v1.2.3