Repository navigation
Conversation
blackboxes.txt had two writers. FakeRAM's asap7 backend wrote a line per macro it built, then gen_memories.py appended a line per register file RAM. FakeRAM also ran before the listed register files were taken out of the inventory, so a module both idiomatic and listed in AUTO_MEMORIES_REGFILES got FakeRAM views it does not use, and blackboxes.txt still named the module with FakeRAM's area, beside its RAM when it was placed as a macro. gen_memories.py now resolves the listed register files before FakeRAM runs: their records replace the module's in memories.json, so FakeRAM, which builds a view for every idiomatic record, never sees them, and memories.json has one record per module from the start. Once every view exists it writes blackboxes.txt whole, one `<module> <area>` line per macro with the area its .lib states, and stops on a macro named twice. FakeRAM's backend writes only the views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
With one writer, blackboxes.txt cannot hold a malformed or repeated line, so auto_memories_areas drops its format check: the `<module> <area>` words are the dict. auto_memories_areas and auto_memories_names read through one helper, auto_memories_words. auto_memories_blackboxes moves from synth_preamble.tcl to util.tcl beside its siblings, and read_liberty.tcl's comment no longer mentions the _pre_layout views, which no step reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
There was a problem hiding this comment.
Code Review
This pull request refactors the generation of memory lists and blackboxes in the AutoMemories flow. Specifically, it consolidates the writing of blackboxes.txt into gen_memories.py to ensure it is written once all views exist, removing this responsibility from FakeRAM generation. It also refactors register file memory handling so that listed register files are correctly recorded in memories.json and replaces duplicate logic in Tcl scripts with helper functions. Unit tests have been added to verify these changes. I have no feedback to provide as there are no review comments to evaluate.
🔍 QoR checkMetrics reflect the PR merge build — i.e. what will land on the target branch. Commit 62 design(s) checked — 0 with regression(s), 0 without a comparable baseline. |
Follow-up to #4810 and its review.
blackboxes.txthad two writers and a format check in one of its three readers. It now has one writer, which writes it once, last.Problem
gen_memories.pyappended a line per register-file RAM. Only the Tcl reader checked the<module> <area>format;generate_klayout_tech.pyanddef2stream.pytake the first field of each line.AUTO_MEMORIES_REGFILESgot FakeRAM views it never uses, andblackboxes.txtstill named the module with FakeRAM's area, beside its RAM when it was placed as a macro. memories.json was written twice to patch that up afterwards.What changed
gen_memories.pyresolves the listed register files before FakeRAM runs. Their records replace the module's in memories.json, so FakeRAM, which builds views for every idiomatic record, never sees them, and memories.json has one record per module from the start. The after-the-fact rewrite is gone.gen_memories.pywritesblackboxes.txtwhole once every view exists, one<module> <area>line per macro (FakeRAM's, then the register files' RAMs) with the area its.libstates, and stops on a macro named twice.run_regfilesreturns the RAMs it made instead of appending.orfs_asap7backend writes only the.lib/.lefviews.util.tcl:auto_memories_areasdrops its format check (the<module> <area>words are the dict), and it andauto_memories_namesread through one helper,auto_memories_words.auto_memories_blackboxesmoves here fromsynth_preamble.tcl(review nit 3).read_liberty.tcl: the comment says only "named by blackboxes.txt" (review nit 4).docs/user/AutoMemories.md: a listed module is a register file even where the idiomatic gate would convert it.AUTO_MEMORIES_REGFILES<m>.lib,<m>.lef)blackboxes.txt, inlined<m> <FakeRAM area>blackboxes.txt,AUTO_MEMORIES_MACRO_PLACE<m> <FakeRAM area>and<m>_ram <area><m>_ram <area><m>as a register fileReview nit 1 (a friendlier message when
blackboxes.txtis missing) is not taken; see the reply on #4810.Testing
tclfmt/tclint0.7.0 andblack26.10.1 are clean.flow/scripts/memories/gen_memories_test.py: new tests that a module both idiomatic and listed gets no FakeRAM views, one memories.json record as a register file and noblackboxes.txtline of its own (inlined and as a macro,generate_ramstubbed), thatblackboxes.txtgives the area as the.libstates it, and that a macro named twice stops. On master the first fails (mem_128x32.libis written) and the last has no writer to call. All 14 tests pass, as dodetect_test.py,idiomatic_test.pyandschema_test.py.tools/FakeRAM2.0/test/spsram_mask_test.py: the backend writes the views and noblackboxes.txt; fails on master, passes here. The other FakeRAM tests pass.flow/test/test_generate_klayout_tech.pyandflow/test/test_def2stream.pypass unchanged.test/auto_memories:am_top(hierarchical synthesis, one FakeRAM macro) built through CTS with and without this change:blackboxes.txt(am_ram_2048x32 2751.882854),memories.json,1_2_yosys.v,4_cts.odband4_cts.sdcare byte-identical. FakeRAM printed its area with%.6fand its.libstates it the same way, so the area text is unchanged.test/regfile:regfile_top, the register-file path: placed as a macro and inlined, through floorplan, and theSYNTH_MINIMUM_KEEP_SIZEvariant through synthesis.blackboxes.txt,inline.txt,regfile_cores.txt,regfiles.txt,memories.json,1_2_yosys.v,1_synth.odb,2_floorplan.odband2_floorplan.sdcare byte-identical with and without this change, and that package's tests pass.Not covered by a run:
generate_ramstubbed, not by a flow run.flow/test/test_auto_memories_blackboxed.pyandtest_auto_memories_parameters.pyneed a yosys withread_slang, which the local one lacks; they source onlycheck_blackboxed.tclanddrop_parameters.tcl, which this does not touch.🤖 Generated with Claude Code