[FIRRTL] Can not canonicalize away memories without more care
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 524
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 46
Description
I have some doubts about the validity of the canonicalizer in https://github.com/llvm/circt/pull/7868
This doesn't seem safe to do when we are running with `repl-seq-mems`, which should mock out the memory with an extmodule. Instead it is lowered to a register and no memory shows up in the metadata.
`./bin/firtool --disable-all-randomization --repl-seq-mem --repl-seq-mem-file=mems.txt ./mem.fir`
```firrtl
FIRRTL version 4.1.0
circuit Foo:
public module Foo:
input clk : Clock
input r : UInt<1>
output rdata : UInt<8>
input wdata : UInt<8>
input addr : UInt<0>
input en : UInt<1>
input mode : UInt<1>
mem mem:
data-type => UInt<8>
depth => 1
readwriter => rw
read-latency => 1
write-latency => 1
read-under-write => undefined
connect mem.rw.clk, clk
connect mem.rw.en, en
connect mem.rw.addr, addr
connect mem.rw.wmode, mode
connect mem.rw.wmask, UInt<8>(-1)
connect mem.rw.wdata, wdata
connect rdata, mem.rw.rdata
```
gives:
```
// ----- 8< ----- FILE "metadata/seq_mems.json" ----- 8< -----
[]
// ----- 8< ----- FILE "mems.txt" ----- 8< -----
```
We should also make sure that this is working correctly for cmems, especially that it is giving identical results when we are using MemToRegOfVec, FullAsynchronousResetTransform, PrefixModules, etc.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the provided bin/firtool command with mem.fir and inspecting the generated metadata/seq_mems.json output. Trace the canonicalizer behavior with repl-seq-mems, then compare cmems results when using MemToRegOfVec, FullAsynchronousResetTransform, and PrefixModules. Done means memories are not incorrectly lowered and the relevant metadata remains correct and consistent across those transforms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100