Skip to content

flow: optional values for grt..final default to "" and are read without a helper - #4921

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

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

Conversation

@oharboe

@oharboe oharboe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Thirteen optional values read by repair, global and detailed route, the timing load and the reports have no default in variables.yaml; their absence means "let the tool choose", and every read is guarded. This gives each one default: "". Where the value decides whether an option is passed, the guard becomes an explicit $::env(X) ne "", which is exactly what the helper tested; where it goes through append_env_var ... 1, the call is left alone, as an empty value passes nothing there.

ABSTRACT_SOURCE is the exception: its fallback, 6_final, is the flow's own, not the tool's, so it becomes the variables.yaml default and generate_abstract.tcl reads the variable plainly. FlowVariables.md now shows it.

variable script now
GRT_SEED global_route.tcl ne "" (set_global_routing_random -seed), was env_var_or_empty into a local
WIRE_LOAD_MODEL load.tcl, open.tcl ne "" (set_wire_load_model)
POWER_FILE_SCOPE report_metrics.tcl ne "" (-scope)
ABSTRACT_SOURCE generate_abstract.tcl default: 6_final, plain read
SETUP_MOVE_SEQUENCE, SETUP_REPAIR_PHASES, CAP_MARGIN, SLEW_MARGIN util.tcl (repair helpers) default only (append_env_var ... 1)
VIA_IN_PIN_MIN_LAYER, VIA_IN_PIN_MAX_LAYER global_route.tcl, detail_route.tcl default only
OR_SEED, OR_K, REPAIR_PDN_VIA_LAYER detail_route.tcl default only

No in-tree config sets any of the thirteen to empty, so nothing relies on empty meaning something else than unset. Platform and design values are unaffected: their config.mk is read before the variables.yaml defaults, and the defaults assign with ?=. Every stage that reads each variable is in its stages: list, or the variable has no stages: list (REPAIR_PDN_VIA_LAYER, CAP_MARGIN, SLEW_MARGIN, WIRE_LOAD_MODEL, POWER_FILE_SCOPE). The one gap, SETUP_MOVE_SEQUENCE lacking place (read there with ENABLE_PLACE_REPAIR_TIMING=1), is #4917's line and is left to it; append_env_var still guards that read, so nothing changes there.

TclContract.md gets the rule: an optional value the tool chooses when it is absent defaults to "" and is tested with ne "" where it decides whether an option is passed. #4922, the same cleanup for the synth..cts values, adds the same line.

Why

Easier to read: if { $::env(GRT_SEED) ne "" } says what it tests, without a local copy. Failures are hard and early: a misspelled or erased variable fails at the line that reads it, where today it silently lets the tool choose. And fewer squirrels for AI to chase: an expr ternary that supplies 6_final behind a guard is a default hiding in a script, where variables.yaml and FlowVariables.md do not show it.

Test

Full flows to 6_report, master vs this branch, logs (runtimes, memory and paths dropped) and every stage metric compared:

design flow logs differing metrics differing
asap7/gcd (sets SETUP_REPAIR_PHASES) separate stages / KEEP_VARS=1 0 / 0 0 / 0
nangate45/gcd separate stages / KEEP_VARS=1 0 / 0 0 / 0
sky130hd/gcd separate stages / KEEP_VARS=1 0 / 0 0 / 0

On nangate45/gcd, set values take effect, identically before and after (0 logs, 0 metrics differ):

  • GRT_SEED=42: set_global_routing_random -seed 42 at grt.
  • OR_SEED=7: -or_seed 7 in detailed_route.
  • WIRE_LOAD_MODEL=5K_hvratio_1_1: set_wire_load_model -name 5K_hvratio_1_1 in every stage through floorplan, and in open.tcl (make open_floorplan GUI_TIMING=1).
  • make generate_abstract after the full flow loads 6_final.odb by default and 4_cts.odb with ABSTRACT_SOURCE=4_cts; the .lef and .lib are byte-identical before and after.
  • POWER_FILE_SCOPE, called through get_power_file_scope_args (nothing in-tree sets SAIF_FILE or VCD_FILE): tb/dut.core[0] gives -scope {tb/dut\.core\[0\]} and "" gives no option, before and after.

Unset in the tool's environment: master runs on (the tool chooses, ABSTRACT_SOURCE falls back to 6_final); this branch stops at the read, can't read "::env(X)": no such variable: GRT_SEED in 5_1_grt, WIRE_LOAD_MODEL in 1_synth (the first load.tcl) and in open.tcl, POWER_FILE_SCOPE in the first report_metrics (2_1_floorplan), ABSTRACT_SOURCE in generate_abstract. The nine append_env_var variables still pass nothing when unset; that helper's guard is a separate change.

tclint/tclfmt 0.9.0 are clean; flow/test test_generate_vars.py and test_make_issue.py pass; this merges cleanly with each of #4910-#4920, and with the other open Tcl cleanup branches.

🤖 Generated with Claude Code

Thirteen optional values read by repair, global and detailed route,
the timing load and the reports have no default in variables.yaml;
their absence means "let the tool choose". Give each `default: ""`,
except ABSTRACT_SOURCE, whose fallback is the flow's own: it gets
`default: 6_final` and generate_abstract.tcl reads it plainly. The
`if` guards become `$::env(X) ne ""`, which keeps exactly what the
helpers tested; the `append_env_var ... 1` calls are left alone, as
an empty value passes nothing there.

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 establishes a cleaner contract for optional flow variables by defining explicit default values (such as "" or "6_final") in variables.yaml and updating the documentation in TclContract.md and FlowVariables.md. Tcl scripts (generate_abstract.tcl, global_route.tcl, load.tcl, open.tcl, and report_metrics.tcl) are simplified to directly reference $::env(VAR) or check $::env(VAR) ne "" instead of using defensive helper functions like env_var_exists_and_non_empty. There are no review comments to assess, and I have no feedback to provide.

@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 bf6e12f · 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