Repository navigation
AUTO_MEMORIES cleanup: read the files blackboxes.txt names, no globs or existence checks - #4810
Conversation
Before, every stage after synthesis globbed $(RESULTS_DIR)/memories for *.lef and *.lib, the klayout tech took $(wildcard memories/*.lef), and macro placement, regfile dissolve and synthesis read regfiles.txt, inline.txt and regfile_cores.txt only if they existed. In a tree that kept files from an earlier run, a .lib or .lef no longer generated was read with the current ones, and a missing list was skipped. Now each step reads the <m>.lib/<m>.lef of every module blackboxes.txt lists, and the lists themselves without an existence check: a file no list names is not read, and a missing list stops the step at the read. The readers move from synth_preamble.tcl to util.tcl so OpenROAD and yosys share them, and generate_klayout_tech.py takes --blackboxes. On a clean tree the files read, and the results, are the same. 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 AUTO_MEMORIES flow to use explicit file lists (such as blackboxes.txt, inline.txt, regfile_cores.txt, and regfiles.txt) instead of globbing files in the memories directory. It introduces centralized helper functions in flow/scripts/util.tcl (auto_memories_areas, auto_memories_names, and auto_memories_views) to handle these lists consistently across synthesis, placement, and layout generation. Additionally, generate_klayout_tech.py is updated to accept a --blackboxes argument to parse the exact LEF files needed, accompanied by new unit tests. I have no feedback to provide.
🔍 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. |
|
@maliberty This blocks another PR for me... |
maliberty
left a comment
There was a problem hiding this comment.
Nits (none blocking):
- Less helpful error. The old "do-auto-memories must run before synthesis" hint becomes Tcl's plain "couldn't open …" error. The Tcl contract allows this, but the old message was more useful when AUTO_MEMORIES is switched on in an existing run directory.
- Two parsers for one file. blackbox_lefs in Python reads blackboxes.txt without the Tcl reader's format check or de-duplication. A malformed or repeated line would quietly give a wrong or duplicated LEF list for klayout.
- One helper left behind. auto_memories_blackboxes stays in synth_preamble.tcl while its siblings moved to util.tcl. It's a one-liner and could move with them.
- Outdated comment. In read_liberty.tcl, the _pre_layout sentence now describes files the code never touches. It could be trimmed to "named by blackboxes.txt".
|
Thanks for the careful read! Follow-up in #4825:
|
This is the cleanup of AUTO_MEMORIES file handling. #4389 merged AUTO_MEMORIES as an experimental baseline, to be cleaned up once we knew what it needed. One gap from then: every step after synthesis globbed
$(RESULTS_DIR)/memoriesfor views, "because the file names are only known at run time". They were already known, though, becauseblackboxes.txt, written in that same PR, names every macro do-auto-memories generates, each with its.liband.lefbeside it.The steps now read what the lists name, through one set of helpers. The flow has fewer code paths and fails loudly where it used to read the wrong thing quietly.
Less code
load.tcl,read_liberty.tcl, the Makefile's klayout LEF list), along with the_pre_layout.libfilter the glob needed.file existsguards on files the flow guarantees are gone, per the Tcl Contract ("A script never guards a read the flow guarantees").auto_memories_inlineandauto_memories_regfile_coreswere near-identical, so they merge into oneauto_memories_names <list>.auto_memories_areasmoves toutil.tcl, so OpenROAD and yosys share one reader.$(wildcard ...)becomes a--blackboxesargument togenerate_klayout_tech.py(Makefile +2/−2, Python +25/−1), so the logic is in Python rather than untested Make.flow/test/test_generate_klayout_tech.py, for logic that had none.More robust
regfiles.txt,inline.txt,regfile_cores.txt)No new file or variable is needed.
Changes
util.tcl:auto_memories_areas(moved fromsynth_preamble.tcl),auto_memories_names <list>, andauto_memories_views <ext>, which gives the views of the macrosblackboxes.txtlists.load.tcl,read_liberty.tcl: readauto_memories_views .lef/.libinstead of globbing.macro_place.tcl,regfile_dissolve.tcl,synth_preamble.tcl: read the lists throughauto_memories_names.generate_klayout_tech.py --blackboxes: the klayout tech's LEF list comes fromblackboxes.txt, in Python with unit tests, not$(shell ...)in the Makefile (Makefile Contract).docs/user/AutoMemories.md: says a file no list names is not read.extract_memories.tclruns before the lists exist and already setsAUTO_MEMORIES=0for its own process, so it is unaffected.Testing
tclfmt/tclint0.7.0 andblack26.10.1 are clean.flow/test/test_generate_klayout_tech.pypasses, with new tests for the listed LEFs, a stray LEF that is ignored and a missing list.test/auto_memories:am_top, one FakeRAM macro) was built through CTS with and without this change.4_cts.odband4_cts.sdcare byte-identical.junk.libandjunk.lefinmemories/: floorplan reads onlyam_ram_2048x32.liband passes. As a control, withjunkadded toblackboxes.txtit stops at[ERROR STA-0164] .../memories/junk.lib line 1, syntax error.am_ram_2048x32.lefremoved,do-1_synthstops at[ERROR ORD-0001] .../memories/am_ram_2048x32.lef does not exist.; restored, it passes.blackboxes.txtremoved,do-1_synthstops atcouldn't open ".../memories/blackboxes.txt": no such file or directory.Not covered by a run:
am_topstops at CTS; tinyRocket, tage_update and cva6 take that path in CI.regfiles.txt/inline.txt/regfile_cores.txt: every AUTO_MEMORIES design reads them empty, and no CI design lists a register file.🤖 Generated with Claude Code