Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces AUTO_MEMORIES_DIR and FLOW_INPUT_VARIANT to allow flow variants to share and read synthesis memories and stage inputs from other variants without copying. The changes update the documentation, Makefile, and Tcl scripts to use these variables and introduce helper functions for robust file handling. The review feedback suggests protecting shared memories from being deleted during clean_synth, using file normalize for path comparisons, and adding explicit error checks with clear messages when required memory list files are missing.
🔍 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. |
Before, synthesis wrote AUTO_MEMORIES' generated views and lists into $(RESULTS_DIR)/memories and every later stage read them from its own RESULTS_DIR. A variant that runs stages on another variant's synthesis (FLOW_INPUT_VARIANT) had no memories of its own, so load_stage_input refused AUTO_MEMORIES=1 outright. Now AUTO_MEMORIES_DIR names the directory, with an overridable default: export AUTO_MEMORIES_DIR ?= $(RESULTS_DIR)/memories Synthesis writes there (gen_memories.py --out-dir), and every reader goes through it: util.tcl's lists and views, synthesis's inlined register files, regfile_dissolve.tcl, the KLayout technology's LEFs and def2stream.py's blackbox list. With the default nothing changes. With FLOW_INPUT_VARIANT: a variant forked off another sets AUTO_MEMORIES_DIR to that variant's memories for every stage it runs, next to FLOW_INPUT_VARIANT=<variant> for the first one, and reads the memories in place, nothing copied. load_stage_input now stops only when AUTO_MEMORIES_DIR is still this variant's own directory, and says to set it. The comparison is by path, not by string (abspath in the Makefile, file normalize in Tcl), so a trailing slash or an absolute spelling of the default still counts as this variant's. A fork's klayout.lyt depends on the other variant's blackboxes.txt, not on this variant's memories.json, so make does not regenerate memories into a directory it only reads, and clean_synth removes AUTO_MEMORIES_DIR only when it is this variant's own. def2stream.auto_memories_cells reads AUTO_MEMORIES_DIR and stops when it is unset; RESULTS_DIR is no stand-in, as the memories may be another variant's. Its tests give AUTO_MEMORIES_DIR accordingly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
87d6a19 to
e100151
Compare
TL;DR:
AUTO_MEMORIES_DIRnames the directory AUTO_MEMORIES writes its generated views and lists to in synthesis and every later stage reads them from. It defaults to$(RESULTS_DIR)/memories, so with the default every path is what it was. Setting it lets aFLOW_INPUT_VARIANTfork run on another variant's AUTO_MEMORIES synthesis, which until now was refused outright.Why
Synthesis wrote AUTO_MEMORIES' views into
$(RESULTS_DIR)/memories, and every later stage read them from its ownRESULTS_DIR. A variant that runs stages on another variant's synthesis (FLOW_INPUT_VARIANT, #4812) has no memories of its own, soload_stage_inputrefusedAUTO_MEMORIES=1in a fork.How it works with FLOW_INPUT_VARIANT
A fork sets
AUTO_MEMORIES_DIRto the memories of the variant that synthesised them, for every stage it runs, andFLOW_INPUT_VARIANTfor the first:The two variables answer different questions, which is why there are two:
FLOW_INPUT_VARIANTis where one stage's input comes from, and holds for the first stage of a fork only;AUTO_MEMORIES_DIRis where synthesis's memories are, and holds for every stage after synthesis. The memories are read in place; nothing is copied.load_stage_inputno longer refuses AUTO_MEMORIES in a fork; it stops only whenAUTO_MEMORIES_DIRis still the fork's own directory, where there are no memories, and says to set it. "Own" is compared as a path, not a string (abspathin the Makefile,file normalizein Tcl), so a trailing slash or an absolute spelling of the default still counts.What reads it
gen_memories.py --out-dir(the writer) andclean_synthutil.tcl: the lists (auto_memories_names) and views (auto_memories_areas,auto_memories_views), soload_design,read_liberty.tclandmacro_place.tclsynth_preamble.tcl(inlined register files),regfile_dissolve.tcl--blackboxes) anddef2stream.py's blackbox listNo
stagesinvariables.yaml, likeAUTO_MEMORIES: every step that reads the views needs it,generate_abstractamong them, anderase_non_stage_variableswould otherwise clear it there.In the Makefile, a fork's
klayout.lytdepends on the other variant'sblackboxes.txt, not on its ownmemories.json, so make does not regenerate memories into a directory it only reads; andclean_synthremovesAUTO_MEMORIES_DIRonly when it is the variant's own, never another variant's memories read in place.def2stream.auto_memories_cellsreadsAUTO_MEMORIES_DIRand stops when it is unset;RESULTS_DIRis no stand-in, since the memories may be another variant's.Testing
tclfmt/tclint0.7.0 (the pinnedrequirements_lock.txt) clean;black26.10.1 clean;FlowVariables.mdregenerated withgenerate-variables-docs.py,yamlfixclean.flow/test/test_def2stream.py: 20 tests pass, including the updatedauto_memories_cellstests;flow/scripts/memories/gen_memories_test.pyandflow/test/test_memory_max_bits.pypass.AUTO_MEMORIES_DIRset once by synthesis to its own results:SYNTH_HIERARCHICAL, a 2048×32 memory), memories not copied2_floorplan.odband.sdcbyte-identical to the synthesising variant's own floorplanAUTO_MEMORIES_DIRleft at the defaultAUTO_MEMORIES=1 reads the memories from AUTO_MEMORIES_DIR, this variant's, shared, and FLOW_INPUT_VARIANT=base reads the design from another. Set AUTO_MEMORIES_DIR ...🤖 Generated with Claude Code