From 98a23c0c1fe018c0899d26da5bfd18fb1e0bcab5 Mon Sep 17 00:00:00 2001 From: Albert Magyar Date: Thu, 6 Feb 2020 16:29:58 -0800 Subject: Better register const prop through speculative de-optimization * Fixes #1240 * Add failing reg const prop test case from #1240 --- .../firrtlTests/ConstantPropagationTests.scala | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index af186cda..99b8c2f0 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -1148,6 +1148,29 @@ class ConstantPropagationIntegrationSpec extends LowTransformSpec { execute(input, check, Seq.empty) } + "Const prop of registers" should "do limited speculative expansion of optimized muxes to absorb bigger cones" in { + val input = + """circuit Top : + | module Top : + | input clock : Clock + | input reset : UInt<1> + | input en : UInt<1> + | output out : UInt<1> + | reg r : UInt<1>, clock + | when en : + | r <= UInt<1>(1) + | out <= r""".stripMargin + val check = + """circuit Top : + | module Top : + | input clock : Clock + | input reset : UInt<1> + | input en : UInt<1> + | output out : UInt<1> + | out <= UInt<1>("h1")""".stripMargin + execute(input, check, Seq.empty) + } + "A register with constant reset and all connection to either itself or the same constant" should "be replaced with that constant" in { val input = """circuit Top : -- cgit v1.2.3 From ec365cece903de078c8c673348574a7b3b2ab7d4 Mon Sep 17 00:00:00 2001 From: Albert Magyar Date: Fri, 7 Feb 2020 00:27:07 -0800 Subject: Add extra 'de-optimization' opportunity for register const prop test --- src/test/scala/firrtlTests/ConstantPropagationTests.scala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index 99b8c2f0..ef52507f 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -1153,18 +1153,20 @@ class ConstantPropagationIntegrationSpec extends LowTransformSpec { """circuit Top : | module Top : | input clock : Clock - | input reset : UInt<1> | input en : UInt<1> | output out : UInt<1> - | reg r : UInt<1>, clock + | reg r1 : UInt<1>, clock + | reg r2 : UInt<1>, clock + | when en : + | r1 <= UInt<1>(1) + | r2 <= UInt<1>(0) | when en : - | r <= UInt<1>(1) - | out <= r""".stripMargin + | r2 <= r2 + | out <= xor(r1, r2)""".stripMargin val check = """circuit Top : | module Top : | input clock : Clock - | input reset : UInt<1> | input en : UInt<1> | output out : UInt<1> | out <= UInt<1>("h1")""".stripMargin -- cgit v1.2.3