Skip to content

variables.yaml: list every stage that reads a variable, and check it in CI - #4917

Draft
oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:tcl-stage-lists
Draft

oharboe wants to merge 2 commits into
The-OpenROAD-Project:masterfrom
oharboe:tcl-stage-lists

Conversation

@oharboe

@oharboe oharboe commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

The stages: list in variables.yaml is not just documentation:
erase_non_stage_variables <stage> (util.tcl) unsets every variable whose
list leaves out the running stage, unless KEEP_VARS=1. A variable read in a
stage it does not list is silently dropped there in the staged flow, and the
staged flow and KEEP_VARS=1 disagree.

This adds the missing stages. A CI check that keeps the lists complete
follows in a separate PR once #4910 and #4911 have merged (see below).

Fixes

variable added read there by
SETUP_SLACK_MARGIN, HOLD_SLACK_MARGIN, SETUP_MOVE_SEQUENCE place repair_timing_helper, which resize.tcl runs when ENABLE_PLACE_REPAIR_TIMING=1
FOOTPRINT, FOOTPRINT_TCL place global_place.tcl (port buffering) and pins_fixed_in_floorplan (io_placement.tcl, global_place.tcl)

A static scan (to become the follow-up CI check) finds seven more, which
open PRs already fix: MATCH_CELL_FOOTPRINT at grt (#4910, #4911) and the
six SKIP_* repair_timing flags at place (#4911). This PR leaves those lines
to them, so it stays independent of both. docs/user/FlowVariables.md is
generated, so whichever PR lands second regenerates it.

VERILOG_TOP_PARAMS (synth only) is read by
designs/asap7/chi_async_bridge/constraint.sdc. That needs no change: the
SDC's Tcl runs only at synth, and floorplan reads the 1_synth.sdc that
OpenSTA writes, which has no Tcl in it (see Test).

The check (follow-up)

A static scan of flow/scripts/*.tcl that maps each stage script, the files
it sources and the procs it calls to the ::env(X) reads in them, and
compares them with stages:. It reports exactly the seven lines above, so
adding it to CI here would fail until #4910 and #4911 land; it follows as its
own PR then.

TclContract.md gets the rule: a variable that lists stages names every stage
that reads it.

Why

  • Easier to read: stages: says where a variable takes effect, and now that
    is true.
  • Hard and early: once the follow-up check is in CI, a stage that reads a
    variable it does not list fails there, instead of quietly running with the
    variable unset.
  • Fewer squirrels for AI to chase: "my SETUP_SLACK_MARGIN is ignored at
    place, but only without KEEP_VARS=1" is a long afternoon for anyone, human
    or agent.

Test

Local make with the same OpenROAD and yosys binaries for master and this
branch.

Place repair_timing, asap7/gcd, ENABLE_PLACE_REPAIR_TIMING=1 SETUP_SLACK_MARGIN=5 HOLD_SLACK_MARGIN=3 SETUP_MOVE_SEQUENCE=sizeup,swap SKIP_GATE_CLONING=1, the command in 3_4_place_resized.log:

master, staged:      repair_timing -phases PARALLEL_EVAL -repair_tns 100 -verbose
master, KEEP_VARS=1: repair_timing -setup_margin 5 -hold_margin 3 -sequence sizeup,swap -phases PARALLEL_EVAL -repair_tns 100 -skip_gate_cloning -skip_last_gasp -verbose
this PR, staged:     repair_timing -setup_margin 5 -hold_margin 3 -sequence sizeup,swap -phases PARALLEL_EVAL -repair_tns 100 -verbose

The SKIP_* flags are still dropped at place until #4911.

FOOTPRINT at place: asap7/gcd placed, then make do-3_2_place_iop do-3_3_place_gp FOOTPRINT=/dev/null (the file is not read at place):

  • master, staged: FOOTPRINT is unset at place, so the ports are buffered
    ("Perform port buffering...") and global_placement ... -place_ios places
    the pins again.
  • master KEEP_VARS=1 and this PR, staged: no port buffering, no
    -place_ios. gcd has no footprint, so its pins are unplaced and GPL stops
    with GPL-0326 clk toplevel port is not placed, which is what this setup
    should do.

ihp-sg13g2/i2c-gpio-expander (FOOTPRINT_TCL, with BLOCKS= to keep it
flat), through place: on master, staged, io_placement.tcl runs
place_pins; with KEEP_VARS=1 and on this branch it does not. Here
place_pins finds 0 I/Os, so the results are the same.

VERILOG_TOP_PARAMS: asap7/chi_async_bridge FLOW_VARIANT=small
(DEPTH 4), staged, through floorplan: synth passes the SDC's synchroniser
check for DEPTH 4, and 1_synth.sdc, which floorplan reads, is OpenSTA's
output with no Tcl in it. Negative control: rerunning synth with
VERILOG_TOP_PARAMS= fails with expected 134 chains, found 86, the
DEPTH 16 count, so the SDC reads the variable at synth, where it is listed.

Default path unchanged: nangate45/gcd, asap7/gcd and sky130hd/gcd
through 6_report, staged and KEEP_VARS=1, master vs this branch. All
stage logs are identical once runtimes and paths are removed, and every
metric is identical.

Scan: on master it reports the five variables fixed here and the seven
in #4910/#4911. On this branch it reports those seven only. Merged with
#4910 and #4911 it passes. It also passes on this branch merged with each of
the other open Tcl-cleanup branches together with those two.

🤖 Generated with Claude Code

erase_non_stage_variables unsets a variable in every stage its stages:
list leaves out, unless KEEP_VARS=1. A variable read in a stage it does
not list is silently dropped there in the staged flow:

- SETUP_SLACK_MARGIN, HOLD_SLACK_MARGIN and SETUP_MOVE_SEQUENCE lacked
  place, where resize.tcl runs repair_timing_helper when
  ENABLE_PLACE_REPAIR_TIMING=1.
- FOOTPRINT and FOOTPRINT_TCL lacked place, where global_place.tcl and
  pins_fixed_in_floorplan (io_placement.tcl, global_place.tcl) read
  them: the pins a footprint placed were placed again, and the ports
  buffered.

check-variable-stages.py scans the stage scripts, what they source and
the procs they call, and fails when one reads a variable whose stages:
list leaves its stage out. The variables.yaml CI job runs it.

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 introduces a new CI check script, check-variable-stages.py, which statically scans Tcl scripts to ensure that any environment variables they read are correctly listed in the stages section of variables.yaml. It also updates the documentation and adds the place stage to several variables in variables.yaml to resolve mismatches. The review feedback identifies opportunities to improve the robustness of the new Python script, specifically by adding bounds checking in word_end to prevent potential IndexError crashes, and handling cases where a variable entry in variables.yaml might be parsed as None to avoid an AttributeError.

Comment thread flow/scripts/check-variable-stages.py Resolved
Comment thread flow/scripts/check-variable-stages.py Resolved
The check correctly reports the stage lines The-OpenROAD-Project#4910 and The-OpenROAD-Project#4911 add, so it
fails until they land. This PR keeps the stage-list fixes and the rule;
the check and its CI step follow once those have merged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Øyvind Harboe <[email protected]>
@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 d0638e7 · Jenkins build #2 · 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