From a0aeafa3d591f9bcc14eca6d8a41eb2155f1b5b0 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Wed, 28 Jun 2017 18:49:32 -0700 Subject: Make Constant Propagation respect dontTouch Constant Propagation will not optimize across components marked dontTouch --- .../firrtlTests/ConstantPropagationTests.scala | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/test') diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala index c94adbf6..f818f9c0 100644 --- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala +++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala @@ -373,3 +373,46 @@ class ConstantPropagationSpec extends FirrtlFlatSpec { (parse(exec(input))) should be (parse(check)) } } + +// More sophisticated tests of the full compiler +class ConstantPropagationIntegrationSpec extends LowTransformSpec { + def transform = new LowFirrtlOptimization + + "ConstProp" should "should not optimize across dontTouch on nodes" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output y : UInt<1> + | node z = x + | y <= z""".stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output y : UInt<1> + | node z = x + | y <= z""".stripMargin + execute(input, check, Seq(dontTouch("Top.z"))) + } + + it should "should not optimize across dontTouch on wires" in { + val input = + """circuit Top : + | module Top : + | input x : UInt<1> + | output y : UInt<1> + | wire z : UInt<1> + | y <= z + | z <= x""".stripMargin + val check = + """circuit Top : + | module Top : + | input x : UInt<1> + | output y : UInt<1> + | wire z : UInt<1> + | y <= z + | z <= x""".stripMargin + execute(input, check, Seq(dontTouch("Top.z"))) + } +} -- cgit v1.2.3