From f5a42ce22193a038008a1c4f80618e38f72b40f1 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Sun, 13 Jan 2019 21:05:17 -0800 Subject: Keep constant propagating expressions until done optimizing --- .../scala/firrtlTests/ConstantPropagationTests.scala | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/test/scala/firrtlTests') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 603ddc25..a6df1a3b 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -734,6 +734,24 @@ class ConstantPropagationSingleModule extends ConstantPropagationSpec { """.stripMargin (parse(exec(input))) should be(parse(check)) } + + // Optimizing this mux gives: z <= pad(UInt<2>(0), 4) + // Thus this checks that we then optimize that pad + "ConstProp" should "optimize nested Expressions" in { + val input = + """circuit Top : + | module Top : + | output z : UInt<4> + | z <= mux(UInt(1), UInt<2>(0), UInt<4>(0)) + """.stripMargin + val check = + """circuit Top : + | module Top : + | output z : UInt<4> + | z <= UInt<4>("h0") + """.stripMargin + (parse(exec(input))) should be(parse(check)) + } } // More sophisticated tests of the full compiler -- cgit v1.2.3