From 8bdc969f95571fa22b39612d3e3acc69268cf2f0 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 30 Jan 2018 12:49:44 -0800 Subject: Fix bug incorrectly propagating constants on submodule inputs Two instances of the same module could collide in counting the number of instances of each Module. This could lead to constants being propagated on inputs when it is incorrect to do so. Fixes #734 --- src/test/scala/firrtlTests/ConstantPropagationTests.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 06e24b97..2aad4f21 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -67,9 +67,9 @@ s"""circuit Top : out <= in module Child : output out : UInt<1> - inst b of Bottom - b.in <= UInt(1) - out <= b.out + inst b0 of Bottom + b0.in <= UInt(1) + out <= b0.out module Top : input x : UInt<1> output z : UInt<1> @@ -91,8 +91,8 @@ s"""circuit Top : out <= UInt(1) module Child : output out : UInt<1> - inst b of Bottom - b.in <= UInt(1) + inst b0 of Bottom + b0.in <= UInt(1) out <= UInt(1) module Top : input x : UInt<1> -- cgit v1.2.3 From c9d3e257bff74235a75ff5530051e419b9ce8005 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Tue, 30 Jan 2018 12:53:56 -0800 Subject: Make Constant Propagation respect dontTouch on registers --- src/test/scala/firrtlTests/ConstantPropagationTests.scala | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 2aad4f21..e143f853 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -712,6 +712,21 @@ class ConstantPropagationIntegrationSpec extends LowTransformSpec { execute(input, check, Seq(dontTouch("Top.z"))) } + "ConstProp" should "NOT optimize across dontTouch on registers" in { + val input = + """circuit Top : + | module Top : + | input clk : Clock + | input reset : UInt<1> + | output y : UInt<1> + | reg z : UInt<1>, clk + | y <= z + | z <= mux(reset, UInt<1>("h0"), z)""".stripMargin + val check = input + execute(input, check, Seq(dontTouch("Top.z"))) + } + + it should "NOT optimize across dontTouch on wires" in { val input = """circuit Top : -- cgit v1.2.3