From c7f0aeef9c4ea93288b5eac0860276df32fa78df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 18 Sep 2026 11:28:03 +0200 Subject: [PATCH 1/2] extract_memories: let detection run before the blackbox list exists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AUTO_MEMORIES is a two step flow and flow/Makefile orders it that way. extract_memories.tcl produces results/memories_inferred.json, and gen_memories.py turns that into results/memories/, which includes blackboxes.txt, the list of modules synthesis is to blackbox. extract_memories.tcl reads its sources through synth_preamble.tcl's read_design_sources, and every frontend branch of that proc calls auto_memories_blackboxes, which errors when results/memories/blackboxes.txt is absent: ERROR: AUTO_MEMORIES=1 but .../results/memories/blackboxes.txt is missing; the do-auto-memories step must run before synthesis So the pass whose output that list is derived from fails because the list does not exist yet. The guard is right for synthesis, where reaching it without a blackbox list means a step was skipped, and wrong for the detection pass, which is the one caller that has to tolerate its absence. Clear AUTO_MEMORIES for the extraction process only. Nothing else clears it, so the guard keeps its full strength everywhere else. Blackboxing during detection would be wrong on its own terms: a blackboxed module has no memory to infer, so the pass would inventory nothing. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Øyvind Harboe --- flow/scripts/memories/extract_memories.tcl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/flow/scripts/memories/extract_memories.tcl b/flow/scripts/memories/extract_memories.tcl index 1bf12eff30..aaa638e5da 100644 --- a/flow/scripts/memories/extract_memories.tcl +++ b/flow/scripts/memories/extract_memories.tcl @@ -4,6 +4,15 @@ source $::env(SCRIPTS_DIR)/synth_preamble.tcl +# This pass runs before gen_memories.py, so results/memories/blackboxes.txt +# does not exist yet and there is nothing to blackbox: this is the pass +# whose output that list is derived from. read_design_sources consults +# auto_memories_blackboxes in every frontend branch, and that proc errors +# out when the file is absent, so reading the sources with AUTO_MEMORIES +# still set fails the step that has to run first. Clear it for this +# process only; the guard keeps its strength for synthesis. +set ::env(AUTO_MEMORIES) 0 + # Read all RTL sources using active frontend (all frontends) read_design_sources From 9e838497bdb2343cf9614b83f532f6c9da8c40c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 18 Sep 2026 11:28:14 +0200 Subject: [PATCH 2/2] extract_memories: call yosys proc, not Tcl's proc keyword MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit extract_memories.tcl runs under yosys's Tcl shell and asks for the process conversion pass by writing proc memory -nomap yosys -import (synth_preamble.tcl line 1) imports yosys commands into the Tcl namespace, but it cannot shadow a Tcl built-in, and proc is the one that defines a procedure. The bare word reaches Tcl instead of yosys and the pass dies: ERROR: TCL interpreter returned an error: wrong # args: should be "proc name args body" memory -nomap on the next line is unaffected because memory is not a Tcl built-in, which is why only one of the two needs qualifying. The yosys prefix is how the rest of the flow already disambiguates: synth_preamble.tcl calls yosys read_slang for the same reason. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Øyvind Harboe --- flow/scripts/memories/extract_memories.tcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flow/scripts/memories/extract_memories.tcl b/flow/scripts/memories/extract_memories.tcl index aaa638e5da..18e5c23717 100644 --- a/flow/scripts/memories/extract_memories.tcl +++ b/flow/scripts/memories/extract_memories.tcl @@ -19,8 +19,10 @@ read_design_sources # Elaborate hierarchy hierarchy -top $::env(DESIGN_NAME) -# Run process execution and memory collection -proc +# Run process execution and memory collection. `yosys proc` rather than +# bare `proc`: yosys -import cannot shadow Tcl's proc keyword, so the +# bare word would define a procedure instead of running the pass. +yosys proc memory -nomap # Write netlist JSON containing inferred $mem_v2 primitives