diff options
| author | Jack Koenig | 2018-03-27 10:58:45 -0700 |
|---|---|---|
| committer | GitHub | 2018-03-27 10:58:45 -0700 |
| commit | 65454f5ff1a370d66202a073e18cdcd40180f051 (patch) | |
| tree | 0d24d5e3152af1cea51a4de3fc8bd1036ec964df /src/main | |
| parent | ae623fd24794bddc3ad8ab0849787fdf033af7b7 (diff) | |
Const prop improvement (#772)
Improve constant propagation of connections to references
[skip formal checks]
LEC fails on this PR because this PR actually changes the circuit. The
change is that it constant propagates some additional registers. This is
really just extending #621 to work on more registers that it was
supposed to be propagating anyway.
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/transforms/ConstantPropagation.scala | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/transforms/ConstantPropagation.scala b/src/main/scala/firrtl/transforms/ConstantPropagation.scala index 57b88890..8217a9bd 100644 --- a/src/main/scala/firrtl/transforms/ConstantPropagation.scala +++ b/src/main/scala/firrtl/transforms/ConstantPropagation.scala @@ -358,6 +358,7 @@ class ConstantPropagation extends Transform { def constPropStmt(s: Statement): Statement = { val stmtx = s map constPropStmt map constPropExpression(nodeMap, instMap, constSubOutputs) + // Record things that should be propagated stmtx match { case x: DefNode if !dontTouches.contains(x.name) => propagateRef(x.name, x.value) case Connect(_, WRef(wname, wtpe, WireKind, _), expr: Literal) if !dontTouches.contains(wname) => @@ -387,7 +388,13 @@ class ConstantPropagation extends Transform { portsMap(port) = paddedLit +: portsMap.getOrElse(port, List.empty) case _ => } - stmtx + // Actually transform some statements + stmtx match { + // Propagate connections to references + case Connect(info, lhs, rref @ WRef(rname, _, NodeKind, _)) if !dontTouches.contains(rname) => + Connect(info, lhs, nodeMap(rname)) + case other => other + } } val modx = m.copy(body = backPropStmt(constPropStmt(m.body))) |
