Skip to content

synth: optional input files default to "" and are read without a helper - #4918

Open
oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:tcl-defaults-files
Open

oharboe wants to merge 1 commit into
The-OpenROAD-Project:masterfrom
oharboe:tcl-defaults-files

Conversation

@oharboe

@oharboe oharboe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

The optional synthesis input files have no default in variables.yaml, so every script that reads one guards it with env_var_exists_and_non_empty. This gives each one default: "" and reads it as $::env(X).

variable script now
ABC_SCRIPT synth_preamble.tcl ne "" (else the flow's area/speed script)
ADDER_MAP_FILE synth.tcl ne ""
LATCH_MAP_FILE synth.tcl ne ""
DFF_LIB_FILE, DFF_MAP_FILE synth.tcl ne "" (the elif chain is unchanged)
CLKGATE_MAP_FILE synth_preamble.tcl ×2, synth_syn.tcl ne ""
SYNTH_BLACKBOXES_FILE synth.tcl ne ""
SYNTH_CHECKPOINT synth.tcl ×5 ne "" / eq ""
SYNTH_NETLIST_FILES synth_preamble.tcl ne ""
SYNTH_VERILOG_SURGERY util.tcl eq ""
ADDITIONAL_LIBS synth_preamble.tcl (slang blackboxes the liberty cells) ne ""
CACHED_REPORTS synth_preamble.tcl foreach, no test
VERILOG_INCLUDE_DIRS synth_preamble.tcl, synth_syn.tcl foreach, no test
LEC_AUX_VERILOG_FILES formal_check.tcl foreach, no test

A single file whose absence skips a step, or selects the flow's own, keeps an explicit $::env(X) ne "". A list of files iterated with foreach needs no test: an empty list does nothing. The verific frontend's VERILOG_INCLUDE_DIRS test 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_FILE empty, and gt2n sets ADDER_MAP_FILE and LATCH_MAP_FILE empty; the ne "" keeps the step off for them (checked below). A platform's ?= is evaluated before defaults.py, so a yaml default: "" never overrides one. Every stage that reads each variable is already in its stages: list (or the variable has none), so erase_non_stage_variables keeps it. FlowVariables.md renders default: "" as it renders no default, so it is unchanged.

TclContract.md gets the rule: an optional file defaults to "" and is tested with ne "" 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 and KEEP_VARS=1, logs (runtimes, memory and paths dropped) and every stage metric compared:

design flow covers logs differing metrics differing
asap7/gcd separate / KEEP_VARS=1 platform adder/latch/clock-gate maps 0 / 0 0 / 0
nangate45/gcd separate / KEEP_VARS=1 ADDER_MAP_FILE empty, latch map set 0 / 0 0 / 0
sky130hd/gcd separate ADDER_MAP_FILE empty 0 0
gt2n/gcd separate / KEEP_VARS=1 ADDER_MAP_FILE and LATCH_MAP_FILE empty 0 / 0 0 / 0
asap7/riscv32i separate / KEEP_VARS=1 ADDITIONAL_LIBS (fakeram) 0 / 0 0 / 0

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 -liberty with it; DFF_MAP_FILE=<a one-cell map>: dfflegalize runs with its cells (and rejects this toy map identically).
  • SYNTH_BLACKBOXES_FILE naming 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) with CACHED_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 and SYNTH_USE_SYN=1; asap7/jpeg (sets it) synthesizes, its include file found.
  • asap7/riscv32i SYNTH_HDL_FRONTEND=slang: the fakeram cells are blackboxed from ADDITIONAL_LIBS; SYNTH_USE_SYN=1 also synthesizes.
  • LEC_AUX_VERILOG_FILES (write_lec_verilog on a finished nangate45/gcd, as LEC_CHECK needs 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/tclfmt 0.9.0 are clean; flow/test test_generate_vars.py and test_make_issue.py pass; 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

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]>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread flow/scripts/formal_check.tcl Resolved
@openroad-ci

openroad-ci commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

🔍 QoR check

Metrics reflect the PR merge build — i.e. what will land on the target branch.

Commit 65a3bcc · Jenkins build #1 · Baseline: build · View build on dashboard

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 58710a4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants