Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the Tcl contract documentation and various Tcl scripts to check optional environment variables using $::env(X) ne "" instead of env_var_exists_and_non_empty or info exists, while defining their default values as "" in variables.yaml. The review feedback suggests using $::env instead of $env inside flow/scripts/resize.tcl to ensure consistency and prevent potential runtime errors if the script is sourced within a non-global scope.
Sixteen optional values read in synthesis, floorplan, place and CTS have no default in variables.yaml; their absence means "let the tool choose". Give each `default: ""`. The five `if` guards become `$::env(X) ne ""`, which keeps exactly what the helpers tested; the eleven `append_env_var ... 1` calls are left alone, as an empty value passes nothing there. GPL_KEEP_OVERFLOW was tested with `info exists`, so an explicitly empty value passed `-keep_resize_below_overflow ""`; it now passes nothing. TclContract.md gets the rule. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Øyvind Harboe <[email protected]>
a35d603 to
48f3b77
Compare
🔍 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 |
Sixteen optional values read in synthesis, floorplan, place and CTS have no default in
variables.yaml; their absence means "let the tool choose", and every read is guarded. This gives each onedefault: "". 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 throughappend_env_var ... 1, the call is left alone, as an empty value passes nothing there.INFER_CLKGATES_MIN_NET_SIZEsynth.tclne ""(-min_net_size)TAP_CELL_NAMEregfile_dissolve.tclne ""(-endcap_master)PLACE_DENSITY_LB_ADDONutil.tclne ""(elsePLACE_DENSITY)GPL_KEEP_OVERFLOWglobal_place.tclne "", wasinfo existsEARLY_SIZING_CAP_RATIOresize.tclne ""ADDITIONAL_SITES,RTLMP_MAX_INST,RTLMP_MIN_INST,RTLMP_MAX_MACRO,RTLMP_MIN_MACRO,GPL_RANDOM_SEED,CTS_BUF_DISTANCE,CTS_CLUSTER_SIZE,CTS_CLUSTER_DIAMETER,CTS_BUF_LIST,CTS_LIB_NAMEfloorplan.tcl,macro_place_util.tcl,global_place*.tcl,cts.tclappend_env_var ... 1)One behaviour change, on a value nobody sets:
GPL_KEEP_OVERFLOWwas tested withinfo exists, so an explicitly empty value passed-keep_resize_below_overflow {}, andglobal_placementstopped on it (on master, nangate45/gcd). It now passes nothing, as when unset.No in-tree config sets any of the sixteen to empty. Platform values are unaffected: the platform
config.mkis read before thevariables.yamldefaults, which assign with?=(asap7'sADDITIONAL_SITES +=included). Every stage that reads each variable is in itsstages:list, or the variable has nostages:list (TAP_CELL_NAME).FlowVariables.mdrendersdefault: ""as it renders no default, so it is unchanged.TclContract.mdgets the rule: an optional value the tool chooses when it is absent defaults to""and is tested withne ""where it decides whether an option is passed. #4921, the same cleanup for the grt..final values, adds the same line.Why
Easier to read:
if { $::env(EARLY_SIZING_CAP_RATIO) ne "" }says what it tests. 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: aninfo existsthat lets""through to a command that rejects it 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, logs (runtimes, memory and paths dropped) and every stage metric compared:KEEP_VARS=1ADDITIONAL_SITES(platform), place, ctsKEEP_VARS=1PLACE_DENSITY_LB_ADDON(design), place, ctsKEEP_VARS=1KEEP_VARS=1rtl_macro_placer, theRTLMP_*values)Set values take effect, identically before and after (0 logs, 0 metrics differ):
INFER_CLKGATES=1 INFER_CLKGATES_MIN_NET_SIZE=4:clockgate ... -min_net_size 4.GPL_KEEP_OVERFLOW=0.3:-keep_resize_below_overflow 0.3.EARLY_SIZING_CAP_RATIO=4:set_opt_config -set_early_sizing_cap_ratio 4.PLACE_DENSITY_LB_ADDON=(empty):global_placement -density 0.3, the design'sPLACE_DENSITY, as before.CTS_CLUSTER_SIZE=10 CTS_BUF_DISTANCE=60 GPL_RANDOM_SEED=3:-distance_between_buffers 60 -sink_clustering_size 10and-random_seed 3.Unset in the tool's environment: master runs on and lets the tool choose; this branch stops at the read,
can't read "::env(X)": no such variable:INFER_CLKGATES_MIN_NET_SIZEin yosys,GPL_KEEP_OVERFLOWandPLACE_DENSITY_LB_ADDONin3_3_place_gp,EARLY_SIZING_CAP_RATIOin3_4_place_resized. The elevenappend_env_varvariables still pass nothing when unset; that helper's guard is a separate change. No in-tree design reaches theTAP_CELL_NAMEread inregfile_dissolve.tcl(it needs anAUTO_MEMORIES_REGFILESspec); every platform with tap cells sets it.tclint/tclfmt0.9.0 are clean;flow/testtest_generate_vars.pyandtest_make_issue.pypass; this merges cleanly with each of #4910-#4921, and with the other open Tcl cleanup branches.🤖 Generated with Claude Code