aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorJack Koenig2018-03-28 10:48:54 -0700
committerGitHub2018-03-28 10:48:54 -0700
commitfd8feb55cfa55e2c270d11c1a6ae60ba1950be59 (patch)
tree82d90510de252da6e3b7587b735fa80744f4b8ef /src/test
parentcf0d971beda33a1802c384bd8d5eebb150d9d578 (diff)
Replace unconnected registers with 0 in Constant Propagation (#776)
Moved from RemoveValidIf Also Make RemoveValidIf.getGroundZero public and support Fixed
Diffstat (limited to 'src/test')
-rw-r--r--src/test/scala/firrtlTests/ConstantPropagationTests.scala40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/test/scala/firrtlTests/ConstantPropagationTests.scala b/src/test/scala/firrtlTests/ConstantPropagationTests.scala
index 079b4823..ca7daa17 100644
--- a/src/test/scala/firrtlTests/ConstantPropagationTests.scala
+++ b/src/test/scala/firrtlTests/ConstantPropagationTests.scala
@@ -971,4 +971,44 @@ class ConstantPropagationIntegrationSpec extends LowTransformSpec {
| z <= mux(c, a, b)""".stripMargin
execute(input, check, Seq.empty)
}
+
+ "Registers connected only to themselves" should "be replaced with zero" in {
+ val input =
+ """circuit Top :
+ | module Top :
+ | input clock : Clock
+ | output a : UInt<8>
+ | reg ra : UInt<8>, clock
+ | ra <= ra
+ | a <= ra
+ |""".stripMargin
+ val check =
+ """circuit Top :
+ | module Top :
+ | input clock : Clock
+ | output a : UInt<8>
+ | a <= UInt<8>(0)
+ |""".stripMargin
+ execute(input, check, Seq.empty)
+ }
+
+ "Registers connected only to themselves from constant propagation" should "be replaced with zero" in {
+ val input =
+ """circuit Top :
+ | module Top :
+ | input clock : Clock
+ | output a : UInt<8>
+ | reg ra : UInt<8>, clock
+ | ra <= or(ra, UInt(0))
+ | a <= ra
+ |""".stripMargin
+ val check =
+ """circuit Top :
+ | module Top :
+ | input clock : Clock
+ | output a : UInt<8>
+ | a <= UInt<8>(0)
+ |""".stripMargin
+ execute(input, check, Seq.empty)
+ }
}