diff options
| author | Schuyler Eldridge | 2021-03-26 13:50:21 -0400 |
|---|---|---|
| committer | GitHub | 2021-03-26 17:50:21 +0000 |
| commit | 67ce97a10564cfa07829af8cfce562009d60bafb (patch) | |
| tree | 4ce6abe40d8e576dbf6c290f79264100e560439a /src/main | |
| parent | 5614a5b534ef5901d2862a07fa79e6eb65893123 (diff) | |
Fix bug in zero-width memory removal (#2153)
* Fix bug in zero-width memory removal
Correctly remove all extraneous connections to all types of memory
ports (read, write, readwrite) for zero-width memories. Previously,
only read ports were correctly handled.
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
* fixup! Fix bug in zero-width memory removal
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/passes/ZeroWidth.scala | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/main/scala/firrtl/passes/ZeroWidth.scala b/src/main/scala/firrtl/passes/ZeroWidth.scala index e918ff63..003ab3c9 100644 --- a/src/main/scala/firrtl/passes/ZeroWidth.scala +++ b/src/main/scala/firrtl/passes/ZeroWidth.scala @@ -25,19 +25,12 @@ object ZeroWidth extends Transform with DependencyAPIMigration { case _ => false } - private def makeEmptyMemBundle(name: String): Field = - Field( - name, - Flip, - BundleType( - Seq( - Field("addr", Default, UIntType(IntWidth(0))), - Field("en", Default, UIntType(IntWidth(0))), - Field("clk", Default, UIntType(IntWidth(0))), - Field("data", Flip, UIntType(IntWidth(0))) - ) - ) - ) + private def makeZero(tpe: ir.Type): ir.Type = tpe match { + case ClockType => UIntType(IntWidth(0)) + case a: UIntType => a.copy(IntWidth(0)) + case a: SIntType => a.copy(IntWidth(0)) + case a: AggregateType => a.map(makeZero) + } private def onEmptyMemStmt(s: Statement): Statement = s match { case d @ DefMemory(info, name, tpe, _, _, _, rs, ws, rws, _) => @@ -46,11 +39,9 @@ object ZeroWidth extends Transform with DependencyAPIMigration { DefWire( info, name, - BundleType( - rs.map(r => makeEmptyMemBundle(r)) ++ - ws.map(w => makeEmptyMemBundle(w)) ++ - rws.map(rw => makeEmptyMemBundle(rw)) - ) + MemPortUtils + .memType(d) + .map(makeZero) ) case Some(_) => d } |
