Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces AUTO_MEMORIES, an experimental feature for the asap7 platform that automatically detects memory modules in RTL pre-synthesis and generates abstract .lib and .lef macro views for them. The feedback focuses on improving the robustness and correctness of the newly added Python scripts. Specifically, the reviewer recommends stripping comments in detect.py to prevent parsing errors, handling parameterized bus widths safely instead of silently corrupting the memory model, wrapping file operations in gen_memories.py with exception handling, and extending schema validation in schema.py to ensure address and data pins are present before emitting views.
Detect memory-shaped modules (firtool R*/W*/RW*_ port convention) in the RTL before synthesis, inventory them in results/memories.json, and generate .lib/.lef macro views for the ones idiomatic as SRAM macros. Synthesis blackboxes the converted modules so the liberty view wins over their behavioral bodies; floorplan through final read the generated views. ADDITIONAL_MEMORIES merges user-supplied .memories files onto the detected set, e.g. to force-convert a memory the idiomatic gate rejects. Together with RTL-MP macro placement this gives macro-based physical design results on an existing design without a memory compiler or hand-maintained fakeram files. asap7 only; the emitters are split into general structure and asap7 parameters as a first pass at separating PDK concerns. Banking and yosys/OpenROAD-SYN-based memory detection are documented as future work. The new designs/asap7/tinyRocket design demonstrates the flow end to end with no platform memory-mapping file and no checked-in fakerams; its tag_array forces conversion via a .memories override because the generic RTL has no behavioral fallback for it. Tested with `bazelisk test //flow:memories_tests` (detector, schema, idiomatic gate, and .lib/.lef emitter unit tests) and `make DESIGN_CONFIG=designs/asap7/tinyRocket/config.mk floorplan`. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
bazel-orfs runs each flow stage in a sandbox where only declared outputs survive, so the generated memories.json and memories/ views must be declared as canonicalize outputs and propagated to every downstream stage. Carried here as a patch so the bazel-orfs side can be reviewed together with the feature; to be upstreamed to bazel-orfs once this lands. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
|
I'm not excited to have a third version of fakeram. Why can't the existing fakeram be used here? |
Which fakeram? I don't see anything googling that has been changed in 3 years. This implementation actually makes the RAMs that are used in the design or it will tell you that it can't. fakeram, near as I can tell gives the use som fixed RAMs that don't necessarily match the behavioral model and hence the .lib file is meaningless without some extra logic added around it. Also, this path strongly implies how supporting memory banks can be done, thus, as a separate concern and PR something that fills the rold of barstools type tools can be done. |
|
@maliberty Is there a fakeram that is actively in use and developed? I only found some tiny python scripts printing out some .lib and .lef files without any tests or behavioral model (.v files) and I failed to make it to the behavioral use-case I had. |
|
https://github.com/The-OpenROAD-Project/FakeRAM2.0 had a commit 4 days ago. It doesn't do behavioral models but that is a reason to enhance it not to build a competing solution that overlaps the functionality it does have. |
|
@maliberty Thanks! I only got FakeRAM, not FakeRAM2.0 in my search results. I'll ask AI how this PR relates to FakeRAM2.0 in terms of intent and if there's any overlap. |
|
https://github.com/The-OpenROAD-Project/FakeRAM2.0 is a fork, which repository should I target? |
|
Nobody is working on the upstream so you should target our fork. |
|
Superseded by new PR leveraging FakeRAM2.0 via Bazel. |
|
Superseded by #4389. |
AUTO_MEMORIES: generated memory macros from RTL (experimental)
AUTO_MEMORIES=1detects memory-shaped modules in the design's RTLbefore synthesis, inventories them in
results/.../memories.json, andgenerates
.lib/.lefmacro views for the ones idiomatic as SRAMmacros. Synthesis blackboxes the converted modules so the liberty view
wins over their behavioral bodies; floorplan through final read the
generated views. Together with RTL-MP macro placement this gives
macro-based physical design results on an existing design without a
memory compiler or hand-maintained fakeram files.
ADDITIONAL_MEMORIESlists user-supplied.memoriesfiles (same JSONschema as memories.json) merged onto the detected set — e.g. to
force-convert a memory the idiomatic gate rejects.
Documentation:
docs/user/AutoMemories.md.How it works
flow/scripts/memories/gen_memories.pyover
VERILOG_FILES. Detection is a fast Python scan for moduleswhose entire port list follows the firtool (CIRCT) memory port
convention (
R0_addr,W0_en,RW0_wdata, subword-splitRW0_wdata_3/W0_mask_2), i.e. module-boundary memories.macro-vs-flops; rejected memories stay behavioral RTL and are
reported with a reason.
.libmirrors the OpenROAD abstract-writer shape(
bus()groups with per-bit pins — required for yosys buselaboration — per-port clocks with clock-tree-path arcs, setup/hold,
internal_powerunder apower_lut_template). Both a regular and anideal-clock
_pre_layoutvariant are emitted. The.leffollows theasap7 fakeram conventions (M4 pin pads, interleaved M4 PG straps the
platform PDN macro grid connects to, full-footprint OBS). Timing/area
come from parametric models anchored to published 7 nm SP-SRAM IP.
memories/*.lib|*.lef,blackboxes.txt) — a file-based handoff thatalso lets build systems (e.g. bazel-orfs) declare the artifacts as
ordinary stage outputs and transitive dependencies of later stages.
liberty.py,lef.py,parameterized by
PdkParams) and asap7 constants (pdk_asap7.py) asa first pass at separating PDK concerns. asap7 only for now; any
other platform errors out.
Demo design
flow/designs/asap7/tinyRocket— the generic tinyRocket RTL with noplatform memory-mapping file and no checked-in fakerams (contrast
with
flow/designs/nangate45/tinyRocket). Itstag_array(4 entries)is rejected by the gate but has no behavioral fallback in this RTL, so
the design forces its conversion via
tag_array.memories—demonstrating
ADDITIONAL_MEMORIES. Example only; not enrolled in CI.bazel-orfs consumption
bazel-orfs runs each stage in a sandbox where only declared outputs
survive, so it needs to declare
memories.json+ thememories/directory (a directory artifact — file names only known at run time)
as canonicalize outputs and stage them into every downstream stage.
That change is carried in this PR as
flow/scripts/memories/bazel-orfs-auto-memories.patchso both sidesreview together; it will be upstreamed to bazel-orfs once this lands.
Deliberately out of scope (documented)
could be wired up as the detector (and would catch those), but
OpenROAD SYN has no memory inference pass — perhaps it could grow
into such a detector. Punted here with the fast, simple Python
scanner; see the note at the top of
detect.py.PdkParamsseam exists; the calibration work doesnot).
Testing
Fast unit tests, orthogonal to the classic full-flow tests — the value
here is correct detection and handing synthesis/later stages the right
files, not QoR:
(detector fixtures incl. subword-split style, schema round-trip/merge,
idiomatic gate, structural .lib/.lef assertions, the flow contract, and
the area model; also runnable directly with python3.)
End-to-end sanity, run locally:
synthesis blackboxes the four memory wrappers, the OpenROAD stages read
the four generated lib/lef, RTL-MP places the three reachable macros,
and the PDN macro grid connects to the generated straps.
Support posture
Experimental. Intended for flows built on top of ORFS (e.g. bazel-orfs
based in-house flows) that need early results on designs whose memories
exist only as behavioral RTL. If it works for you, great; if it needs
fixing, the report is itself a welcome signal that someone is using it.