Repository navigation
Conversation
The optional synthesis inputs had no default and were read through env_var_exists_and_non_empty. Give each one `default: ""` and read it as $::env(X). A single file that selects a step is tested with `$::env(X) ne ""`: ABC_SCRIPT, ADDER_MAP_FILE, CLKGATE_MAP_FILE, DFF_LIB_FILE, DFF_MAP_FILE, LATCH_MAP_FILE, SYNTH_BLACKBOXES_FILE, SYNTH_VERILOG_SURGERY, SYNTH_NETLIST_FILES, SYNTH_CHECKPOINT and ADDITIONAL_LIBS (which blackboxes the liberty cells for slang). Configs that set ADDER_MAP_FILE or LATCH_MAP_FILE empty to turn the step off keep working. A list of files iterated with foreach is read without a test: CACHED_REPORTS, VERILOG_INCLUDE_DIRS (yosys, slang and synth_syn.tcl), LEC_AUX_VERILOG_FILES. The verific frontend's VERILOG_INCLUDE_DIRS test is left as it is: The-OpenROAD-Project#4911 rewrites the line next to it. Every stage that reads each of them is already in its stages: list. TclContract.md gets the rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Øyvind Harboe <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request updates the Tcl scripts and variable definitions to align with a new rule in TclContract.md: optional files should default to an empty string and be tested with 'ne ""' only when their absence skips a step, while lists of files should be spliced without a test. To support this, default values of '""' are added to numerous variables in variables.yaml, and env_var_exists_and_non_empty checks are replaced with direct environment variable checks or loops. Feedback on formal_check.tcl suggests lazily opening the output file for appending only when LEC_AUX_VERILOG_FILES is non-empty, preventing unnecessary file I/O on every run when the list is empty.
🔍 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. ✅ QoR is compared against the master build at this PR's merge base |
The optional synthesis input files have no default in
variables.yaml, so every script that reads one guards it withenv_var_exists_and_non_empty. This gives each onedefault: ""and reads it as$::env(X).ABC_SCRIPTsynth_preamble.tclne ""(else the flow's area/speed script)ADDER_MAP_FILEsynth.tclne ""LATCH_MAP_FILEsynth.tclne ""DFF_LIB_FILE,DFF_MAP_FILEsynth.tclne ""(the elif chain is unchanged)CLKGATE_MAP_FILEsynth_preamble.tcl×2,synth_syn.tclne ""SYNTH_BLACKBOXES_FILEsynth.tclne ""SYNTH_CHECKPOINTsynth.tcl×5ne ""/eq ""SYNTH_NETLIST_FILESsynth_preamble.tclne ""SYNTH_VERILOG_SURGERYutil.tcleq ""ADDITIONAL_LIBSsynth_preamble.tcl(slang blackboxes the liberty cells)ne ""CACHED_REPORTSsynth_preamble.tclforeach, no testVERILOG_INCLUDE_DIRSsynth_preamble.tcl,synth_syn.tclforeach, no testLEC_AUX_VERILOG_FILESformal_check.tclforeach, no testA single file whose absence skips a step, or selects the flow's own, keeps an explicit
$::env(X) ne "". A list of files iterated withforeachneeds no test: an empty list does nothing. The verific frontend'sVERILOG_INCLUDE_DIRStest is left as it is, as #4911 rewrites the line next to it.Empty still means "off": nangate45/gcd, sky130hd/gcd, sky130hs/gcd, sky130hd/ibex and ihp-sg13g2/ibex set
ADDER_MAP_FILEempty, and gt2n setsADDER_MAP_FILEandLATCH_MAP_FILEempty; thene ""keeps the step off for them (checked below). A platform's?=is evaluated beforedefaults.py, so a yamldefault: ""never overrides one. Every stage that reads each variable is already in itsstages:list (or the variable has none), soerase_non_stage_variableskeeps it.FlowVariables.mdrendersdefault: ""as it renders no default, so it is unchanged.TclContract.mdgets the rule: an optional file defaults to""and is tested withne ""only where its absence skips a step; a list of files is spliced without a test. #4919 does the same for the physical-design inputs, with the same rule line.Why
Easier to read:
$::env(LATCH_MAP_FILE) ne ""says what it tests. Failures are hard and early: a misspelled or erased variable fails at the line that reads it, where today the step is silently skipped. And fewer squirrels for AI to chase: a helper that asks "does it exist?" about a variable the flow always sets is a code path no CI run takes, and an agent reading the scripts chases it instead of the real problem.Test
Full flows to
6_report, master vs this branch, separate stages andKEEP_VARS=1, logs (runtimes, memory and paths dropped) and every stage metric compared:KEEP_VARS=1KEEP_VARS=1ADDER_MAP_FILEempty, latch map setADDER_MAP_FILEemptyKEEP_VARS=1ADDER_MAP_FILEandLATCH_MAP_FILEemptyKEEP_VARS=1ADDITIONAL_LIBS(fakeram)On nangate45/gcd the latch map is read and the adder map is not; on gt2n/gcd neither is; the same before and after.
A set value takes effect identically before and after (synthesis on nangate45/gcd unless noted; 0 logs and 0 metrics differ in every row):
ABC_SCRIPT=abc_area.script:Using ABC script ...abc_area.script.ADDER_MAP_FILE=cells_adders.v: the adder map is read;LATCH_MAP_FILE=(empty): the latch map is not.DFF_LIB_FILE=<the typical liberty>:dfflibmap -libertywith it;DFF_MAP_FILE=<a one-cell map>:dfflegalizeruns with its cells (and rejects this toy map identically).SYNTH_BLACKBOXES_FILEnaming the subtractor: it is blackboxed (floorplan then stops on the missing master, as expected).SYNTH_CHECKPOINT=<a canonicalized RTLIL>: the partition path (coarse synthesis skipped).SYNTH_NETLIST_FILES(one file, two files) withCACHED_REPORTS: the netlist is copied/concatenated, the report copied.SYNTH_VERILOG_SURGERY=<a pass-through script>: the script runs on the sources.VERILOG_INCLUDE_DIRS:-I<dir>with the yosys frontend, slang andSYNTH_USE_SYN=1; asap7/jpeg (sets it) synthesizes, its include file found.SYNTH_HDL_FRONTEND=slang: the fakeram cells are blackboxed fromADDITIONAL_LIBS;SYNTH_USE_SYN=1also synthesizes.LEC_AUX_VERILOG_FILES(write_lec_verilogon a finished nangate45/gcd, asLEC_CHECKneeds Kepler Formal): set appends the stub, empty appends nothing, before and after.Unset (yosys started with the variable removed from its environment, or the proc run without it): master runs on, skipping the step; this branch stops at the read,
can't read "::env(X)": no such variable, for each of the fourteen.tclint/tclfmt0.9.0 are clean;flow/testtest_generate_vars.pyandtest_make_issue.pypass; this merges cleanly with #4910, #4911, #4912, #4913, #4914 and #4915. (Every full-flow arm, before and after alike, stops at the final GDS merge, as the klayout Python module is not installed here.)🤖 Generated with Claude Code