Open tymcauley opened 9 months ago
I realize this might be a bit easier to reproduce by just using the .fir
output. Here's the FIRRTL from Chisel 5.1.0:
FIRRTL version 2.0.0
circuit Foo :
module Foo :
input clock : Clock
input reset : UInt<1>
input addr : UInt<4>[2]
input inData : UInt<8>[2]
output out : UInt<8>[2]
input wen : UInt<1>[2]
smem mem : UInt<8> [16]
infer mport rwPort = mem[addr[0]], clock
out[0] is invalid
when wen[0] :
rwPort <= inData[0]
else :
out[0] <= rwPort
smem mem_1 : UInt<8> [16]
infer mport rwPort_1 = mem_1[addr[1]], clock
out[1] is invalid
when wen[1] :
rwPort_1 <= inData[1]
else :
out[1] <= rwPort_1
You can reproduce using:
firtool --repl-seq-mem --repl-seq-mem-file=foo.conf Foo.fir
Okay, after investigating a bit:
--repl-seq-mem --repl-seq-mem-file=...
options, the memory modules will be deduped. In particular, lower-seq-to-sv
will merge the two seq.firmem
operations.--repl-seq-mem --repl-seq-mem-file=...
options, the firrtl-lower-memory
pass will convert the two firrtl.mem
operations into two separate, identical firrtl.module
s (mem
and mem_1
), but this is after the dedup pass has already run, so these two module definitions don't get deduped.Might want to re-open this issue after #6719 got reverted in https://github.com/llvm/circt/commit/bea85107e8e42261e9c2e3ed24dd398e7f33b915, waiting on #6830 to be completed before re-marking this as complete.
Context
Platform: macOS 14.1.1 Architecture: arm64 circt version: Firtool 1.58.0 release, also f124fb041
Description
When generating a design from Chisel with arrays of SRAM instances, I notice that the SRAM instances are placed inside of modules that aren't deduped. Here's a small Chisel design to reproduce the issue with an array of SRAMs, each with a single read-write port:
If you run that through a Chisel 3.6.0 flow, using the SFC...
Then you get this:
Notice that there's only one
mem
module definition, which wraps aroundmem_ext
.If you run this through firtool (change that
useFirtool
flag fromfalse
totrue
), you get this:While there's only one
mem_ext
definition, the wrapper modulesmem
/mem_1
aren't deduplicated.