aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJack Koenig2018-04-10 21:24:49 -0700
committerGitHub2018-04-10 21:24:49 -0700
commit0c93a121c109c3e167d80173dbfe8c2e355b30ef (patch)
tree1da105cf6ff46a8badb0ec23b27bbd5fedc6b8b4 /src/main
parent1d4914c396881c66aceb47d5cdd8740ad9a5be26 (diff)
Fix bug in Constant Propagation for registers propped to zero (#787)
It wasn't properly padding the width of the constant zero. Also add a test that shows the buggy behavior.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/scala/firrtl/transforms/ConstantPropagation.scala3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
index 2def130c..c417357b 100644
--- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala
+++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala
@@ -379,7 +379,8 @@ class ConstantPropagation extends Transform {
case Mux(_, tval: Literal, fval: WRef, _) if weq(lref, fval) =>
nodeMap(lname) = constPropExpression(nodeMap, instMap, constSubOutputs)(pad(tval, ltpe))
case WRef(`lname`, _,_,_) => // If a register is connected to itself, propagate zero
- nodeMap(lname) = passes.RemoveValidIf.getGroundZero(ltpe)
+ val zero = passes.RemoveValidIf.getGroundZero(ltpe)
+ nodeMap(lname) = constPropExpression(nodeMap, instMap, constSubOutputs)(pad(zero, ltpe))
case _ =>
}
// Mark instance inputs connected to a constant