diff options
| author | Jim Lawson | 2016-12-14 16:53:52 -0800 |
|---|---|---|
| committer | Jim Lawson | 2016-12-14 16:53:52 -0800 |
| commit | 0f13cace653fa45e907f59a060b6acd93c7bce2a (patch) | |
| tree | 2d54e3b30b77f553eedd28d20343468a644c317c /src/test | |
| parent | 1ea7b6d686a276537f3feb5a40cbe8453ba10ac8 (diff) | |
Add support for top-level use of MiddleFirrtlCompiler.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/scala/firrtlTests/CompilerTests.scala | 39 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/DriverSpec.scala | 1 | ||||
| -rw-r--r-- | src/test/scala/firrtlTests/MultiThreadingSpec.scala | 1 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/CompilerTests.scala b/src/test/scala/firrtlTests/CompilerTests.scala index 2a5311f8..8ec7665c 100644 --- a/src/test/scala/firrtlTests/CompilerTests.scala +++ b/src/test/scala/firrtlTests/CompilerTests.scala @@ -14,6 +14,7 @@ import firrtl.{ CircuitState, Compiler, HighFirrtlCompiler, + MiddleFirrtlCompiler, LowFirrtlCompiler, Parser, VerilogCompiler @@ -61,6 +62,44 @@ class HighFirrtlCompilerSpec extends CompilerSpec with Matchers { } /** + * An example test for testing the MiddleFirrtlCompiler. + * + * Given an input Firrtl circuit (expressed as a string), + * the compiler is executed. The output of the compiler is + * a lowered (to MidForm) version of the input circuit. The output is + * string compared to the correct lowered circuit. + */ +class MiddleFirrtlCompilerSpec extends CompilerSpec with Matchers { + val compiler = new MiddleFirrtlCompiler() + val input = + """ +circuit Top : + module Top : + input reset : UInt<1> + input a : UInt<1>[2] + wire b : UInt + b <= a[0] + when reset : + b <= UInt(0) +""" + // Verify that Vecs are retained, but widths are inferred and whens are expanded. + val check = Seq( + "circuit Top :", + " module Top :", + " input reset : UInt<1>", + " input a : UInt<1>[2]", + " wire b : UInt<1>", + " node _GEN_0 = mux(reset, UInt<1>(\"h0\"), a[0])", + " b <= _GEN_0\n\n" + ).reduce(_ + "\n" + _) + "A circuit" should "match exactly to its MidForm state" in { + val parsedOutput = parse(getOutput) + val checkedOutput = parse(check) + (parse(getOutput)) should be (parse(check)) + } +} + +/** * An example test for testing the LoweringCompiler. * * Given an input Firrtl circuit (expressed as a string), diff --git a/src/test/scala/firrtlTests/DriverSpec.scala b/src/test/scala/firrtlTests/DriverSpec.scala index cdabc28c..3b0dee0a 100644 --- a/src/test/scala/firrtlTests/DriverSpec.scala +++ b/src/test/scala/firrtlTests/DriverSpec.scala @@ -155,6 +155,7 @@ class DriverSpec extends FreeSpec with Matchers with BackendCompilationUtilities Seq( "low" -> "./Dummy.lo.fir", "high" -> "./Dummy.hi.fir", + "middle" -> "./Dummy.mid.fir", "verilog" -> "./Dummy.v" ).foreach { case (compilerName, expectedOutputFileName) => val manager = new ExecutionOptionsManager("test") with HasFirrtlOptions { diff --git a/src/test/scala/firrtlTests/MultiThreadingSpec.scala b/src/test/scala/firrtlTests/MultiThreadingSpec.scala index 169aa6b2..1698c462 100644 --- a/src/test/scala/firrtlTests/MultiThreadingSpec.scala +++ b/src/test/scala/firrtlTests/MultiThreadingSpec.scala @@ -21,6 +21,7 @@ class MultiThreadingSpec extends FirrtlPropSpec { // The parameters we're testing with val compilers = Seq( new firrtl.HighFirrtlCompiler, + new firrtl.MiddleFirrtlCompiler, new firrtl.LowFirrtlCompiler, new firrtl.VerilogCompiler) val inputFilePath = s"/integration/GCDTester.fir" // arbitrary |
