From 71876a0787a57596e311a875651ebaa1d7b012d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Fri, 14 Aug 2026 19:33:21 +0200 Subject: [PATCH] gpl: Expose PDK-aware GPL parameters and tuning defaults MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Expose OpenROAD global placement tuning parameters (-init_wirelength_coef and -virtual_cts_max_skew_fraction) in variables.yaml and global_place.tcl. - Provide OpenROAD patch 0001-Add-PDK-aware-GPL-parameters.patch to enable these features. - Set optimized default values for these variables in sky130hd and asap7 config.json files. - Update variables.json and FlowVariables.md via generation scripts. - Update defaults.py to correctly inject these variables. Signed-off-by: Øyvind Harboe --- docs/user/FlowVariables.md | 8 + flow/platforms/asap7/config.json | 5 + flow/platforms/sky130hd/config.json | 5 + flow/scripts/defaults.py | 15 ++ flow/scripts/global_place.tcl | 6 + flow/scripts/variables.json | 28 ++++ flow/scripts/variables.yaml | 24 +++ .../0001-Add-PDK-aware-GPL-parameters.patch | 149 ++++++++++++++++++ 8 files changed, 240 insertions(+) create mode 100644 flow/platforms/asap7/config.json create mode 100644 flow/platforms/sky130hd/config.json create mode 100644 patches/openroad/0001-Add-PDK-aware-GPL-parameters.patch diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index 4653658a6b..4f683e8614 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -165,6 +165,9 @@ configuration file. | GPL_RANDOM_SEED| Specifies a random seed for global placement. Useful for perturbation studies.| | | GPL_ROUTABILITY_DRIVEN| Specifies whether the placer should use routability driven placement.| 1| | GPL_TIMING_DRIVEN| Specifies whether the placer should use timing driven placement.| 1| +| GPL_TIMING_SPAN_CLOCK_PERCENT| Global placement timing weight span as a percent of clock (passed to virtual_cts_max_skew_fraction or similar logic).| 0.24| +| GPL_USE_ENGINE_DEFAULTS| If set to 1, ignores ORFS-specific parameters and forces the global placement engine to use its internal hardcoded defaults.| 0| +| GPL_WIRELENGTH_PENALTY| Global placement wirelength penalty (passed as -init_wirelength_coef or similar logic).| 0.0627| | GRT_SEED| Specifies a random seed for global routing. Useful for perturbation studies.| | | GUI_TIMING| Load timing information when opening GUI. For large designs, this can be quite time consuming. Useful to disable when investigating non-timing aspects like floorplan, placement, routing, etc.| 1| | HOLD_SLACK_MARGIN| Specifies a time margin for the slack when fixing hold violations. This option allows you to overfix or underfix (negative value, terminate retiming before 0 or positive slack). floorplan.tcl uses min of HOLD_SLACK_MARGIN and 0 (default hold slack margin). This avoids overrepair in floorplan for hold by default, but allows skipping hold repair using a negative HOLD_SLACK_MARGIN. Exiting timing repair early is useful in exploration where the .sdc has a fixed clock period at the design's target clock period and where HOLD/SETUP_SLACK_MARGIN is used to avoid overrepair (extremely long running times) when exploring different parameter settings. When an ideal clock is used, that is before CTS, a clock insertion delay of 0 is used in timing paths. This creates a mismatch between macros that have a .lib file from after CTS, when the clock is propagated. To mitigate this, OpenSTA will use subtract the clock insertion delay of macros when calculating timing with ideal clock. Provided that min_clock_tree_path and max_clock_tree_path are in the .lib file, which is the case for macros built with OpenROAD. This is less accurate than if OpenROAD had created a placeholder clock tree for timing estimation purposes prior to CTS. There will inevitably be inaccuracies in the timing calculation prior to CTS. Use a slack margin that is low enough, even negative, to avoid overrepair. Inaccuracies in the timing prior to CTS can also lead to underrepair, but there no obvious and simple way to avoid underrapir in these cases. Overrepair can lead to excessive runtimes in repair or too much buffering being added, which can present itself as congestion of hold cells or buffer cells. Another use of SETUP/HOLD_SLACK_MARGIN is design parameter exploration when trying to find the minimum clock period for a design. The SDC_FILE for a design can be quite complicated and instead of modifying the clock period in the SDC_FILE, which can be non-trivial, the clock period can be fixed at the target frequency and the SETUP/HOLD_SLACK_MARGIN can be swept to find a plausible current minimum clock period.| 0| @@ -325,6 +328,7 @@ configuration file. | TIEHI_CELL_AND_PORT| Tie high cells used in Yosys synthesis to replace a logical 1 in the Netlist.| | | TIELO_CELL_AND_PORT| Tie low cells used in Yosys synthesis to replace a logical 0 in the Netlist.| | | TIE_SEPARATION| Distance separating tie high/low instances from the load.| 0| +| TIGHTEN_CLOCK_PERIOD| Tighten the clock period by this fraction (e.g. 0.1 for 10%) before measuring minimum clock period. Used by the autotuner.| 0.0638| | TNS_END_PERCENT| Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all violating endpoints by default (reduce to 5% for runtime). Specifies how many percent of violating paths to fix [0-100]. Worst path will always be fixed.| 100| | UNSET_ABC9_BOX_CELLS| List of cells to unset the abc9_box attribute on| | | USE_FILL| Whether to perform metal density filling.| 0| @@ -477,6 +481,9 @@ configuration file. - [GPL_RANDOM_SEED](#GPL_RANDOM_SEED) - [GPL_ROUTABILITY_DRIVEN](#GPL_ROUTABILITY_DRIVEN) - [GPL_TIMING_DRIVEN](#GPL_TIMING_DRIVEN) +- [GPL_TIMING_SPAN_CLOCK_PERCENT](#GPL_TIMING_SPAN_CLOCK_PERCENT) +- [GPL_USE_ENGINE_DEFAULTS](#GPL_USE_ENGINE_DEFAULTS) +- [GPL_WIRELENGTH_PENALTY](#GPL_WIRELENGTH_PENALTY) - [IO_PLACER_H](#IO_PLACER_H) - [IO_PLACER_V](#IO_PLACER_V) - [MATCH_CELL_FOOTPRINT](#MATCH_CELL_FOOTPRINT) @@ -499,6 +506,7 @@ configuration file. - [PRE_RESIZE_TCL](#PRE_RESIZE_TCL) - [ROUTING_LAYER_ADJUSTMENT](#ROUTING_LAYER_ADJUSTMENT) - [SKIP_REPORT_METRICS](#SKIP_REPORT_METRICS) +- [TIGHTEN_CLOCK_PERIOD](#TIGHTEN_CLOCK_PERIOD) - [TNS_END_PERCENT](#TNS_END_PERCENT) ## cts variables diff --git a/flow/platforms/asap7/config.json b/flow/platforms/asap7/config.json new file mode 100644 index 0000000000..94d7cc80df --- /dev/null +++ b/flow/platforms/asap7/config.json @@ -0,0 +1,5 @@ +{ + "GPL_TIMING_SPAN_CLOCK_PERCENT": 0.22968514538823603, + "GPL_WIRELENGTH_PENALTY": 0.06456297861599444, + "TIGHTEN_CLOCK_PERIOD": 0.018604621846273695 +} \ No newline at end of file diff --git a/flow/platforms/sky130hd/config.json b/flow/platforms/sky130hd/config.json new file mode 100644 index 0000000000..c637a5dc6c --- /dev/null +++ b/flow/platforms/sky130hd/config.json @@ -0,0 +1,5 @@ +{ + "GPL_TIMING_SPAN_CLOCK_PERCENT": 0.188034183753787, + "GPL_WIRELENGTH_PENALTY": 0.028702330955746383, + "TIGHTEN_CLOCK_PERIOD": 0.04743068706084326 +} \ No newline at end of file diff --git a/flow/scripts/defaults.py b/flow/scripts/defaults.py index b0c8a112b1..c79fee8e3c 100755 --- a/flow/scripts/defaults.py +++ b/flow/scripts/defaults.py @@ -9,6 +9,21 @@ with open(json_path, "r") as file: data = json.load(file) +platform_dir = os.environ.get("PLATFORM_DIR") +if platform_dir: + platform_config_path = os.path.join(platform_dir, "config.json") + if os.path.exists(platform_config_path): + with open(platform_config_path, "r") as file: + try: + platform_data = json.load(file) + for key, value in platform_data.items(): + if key in data: + data[key]["default"] = value + else: + data[key] = {"default": value} + except json.JSONDecodeError: + pass + for key, value in data.items(): if value.get("default", None) is None: continue diff --git a/flow/scripts/global_place.tcl b/flow/scripts/global_place.tcl index 5822ef47c2..dafb81a2a9 100644 --- a/flow/scripts/global_place.tcl +++ b/flow/scripts/global_place.tcl @@ -28,6 +28,12 @@ append_env_var global_placement_args GPL_ROUTABILITY_DRIVEN -routability_driven append_env_var global_placement_args GPL_RANDOM_SEED -random_seed 1 +if { !$::env(GPL_USE_ENGINE_DEFAULTS) } { + lappend global_placement_args -init_wirelength_coef $::env(GPL_WIRELENGTH_PENALTY) + lappend global_placement_args -virtual_cts_max_skew_fraction $::env(GPL_TIMING_SPAN_CLOCK_PERCENT) +} + + # Parameters for timing driven mode in global placement if { $::env(GPL_TIMING_DRIVEN) } { lappend global_placement_args {-timing_driven} diff --git a/flow/scripts/variables.json b/flow/scripts/variables.json index 84f0e85818..8f4d6a3208 100644 --- a/flow/scripts/variables.json +++ b/flow/scripts/variables.json @@ -443,6 +443,27 @@ "place" ] }, + "GPL_TIMING_SPAN_CLOCK_PERCENT": { + "default": 0.24, + "description": "Global placement timing weight span as a percent of clock (passed to virtual_cts_max_skew_fraction or similar logic).\n", + "stages": [ + "place" + ] + }, + "GPL_USE_ENGINE_DEFAULTS": { + "default": 0, + "description": "If set to 1, ignores ORFS-specific parameters and forces the global placement engine to use its internal hardcoded defaults.\n", + "stages": [ + "place" + ] + }, + "GPL_WIRELENGTH_PENALTY": { + "default": 0.0627, + "description": "Global placement wirelength penalty (passed as -init_wirelength_coef or similar logic).\n", + "stages": [ + "place" + ] + }, "GRT_SEED": { "description": "Specifies a random seed for global routing. Useful for perturbation studies.\n", "stages": [ @@ -1448,6 +1469,13 @@ "floorplan" ] }, + "TIGHTEN_CLOCK_PERIOD": { + "default": 0.0638, + "description": "Tighten the clock period by this fraction (e.g. 0.1 for 10%) before measuring minimum clock period. Used by the autotuner.\n", + "stages": [ + "place" + ] + }, "TNS_END_PERCENT": { "default": 100, "description": "Default TNS_END_PERCENT value for post CTS timing repair. Try fixing all violating endpoints by default (reduce to 5% for runtime). Specifies how many percent of violating paths to fix [0-100]. Worst path will always be fixed.\n", diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 696b04278f..a3531e4bd1 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -664,6 +664,24 @@ GPL_TIMING_DRIVEN: stages: - place default: 1 +GPL_USE_ENGINE_DEFAULTS: + description: | + If set to 1, ignores ORFS-specific parameters and forces the global placement engine to use its internal hardcoded defaults. + stages: + - place + default: 0 +GPL_WIRELENGTH_PENALTY: + description: | + Global placement wirelength penalty (passed as -init_wirelength_coef or similar logic). + stages: + - place + default: 0.0627 +GPL_TIMING_SPAN_CLOCK_PERCENT: + description: | + Global placement timing weight span as a percent of clock (passed to virtual_cts_max_skew_fraction or similar logic). + stages: + - place + default: 0.240 GPL_ROUTABILITY_DRIVEN: description: | Specifies whether the placer should use routability driven placement. @@ -1644,3 +1662,9 @@ GRT_SEED: - grt tunable: 1 type: int +TIGHTEN_CLOCK_PERIOD: + description: > + Tighten the clock period by this fraction (e.g. 0.1 for 10%) before measuring minimum clock period. Used by the autotuner. + stages: + - place + default: 0.0638 diff --git a/patches/openroad/0001-Add-PDK-aware-GPL-parameters.patch b/patches/openroad/0001-Add-PDK-aware-GPL-parameters.patch new file mode 100644 index 0000000000..b05bee9572 --- /dev/null +++ b/patches/openroad/0001-Add-PDK-aware-GPL-parameters.patch @@ -0,0 +1,149 @@ +From 06b8b5d592a51490cad48bff036b81b5264106f9 Mon Sep 17 00:00:00 2001 +From: Øyvind Harboe +Date: Wed, 12 Aug 2026 17:48:28 +0200 +Subject: [PATCH] Add PDK-aware GPL parameters + +--- + src/gpl/include/gpl/Replace.h | 2 ++ + src/gpl/src/nesterovBase.cpp | 1 + + src/gpl/src/nesterovBase.h | 1 + + src/gpl/src/replace.cpp | 1 + + src/gpl/src/replace.i | 2 ++ + src/gpl/src/replace.tcl | 4 ++++ + src/gpl/src/timingBase.cpp | 9 ++++++--- + src/gpl/src/timingBase.h | 5 +++++ + 8 files changed, 24 insertions(+), 5 deletions(-) + +diff --git a/src/gpl/include/gpl/Replace.h b/src/gpl/include/gpl/Replace.h +index b73e2a12..a5d89d42 100644 +--- a/src/gpl/include/gpl/Replace.h ++++ b/src/gpl/include/gpl/Replace.h +@@ -56,6 +56,8 @@ struct PlaceOptions + bool skipIoMode = false; + bool forceCenterInitialPlace = false; + bool timingDrivenMode = false; ++ float wirelengthPenalty = 1.0; ++ float timingWeightSpanClockPercent = -1.0; + bool timingDrivenRepairTiming = false; + float timingDrivenRepairTnsEndPercent = 1.0; + bool routabilityDrivenMode = false; +diff --git a/src/gpl/src/nesterovBase.cpp b/src/gpl/src/nesterovBase.cpp +index 3ad4e0e5..70752538 100644 +--- a/src/gpl/src/nesterovBase.cpp ++++ b/src/gpl/src/nesterovBase.cpp +@@ -1160,6 +1160,7 @@ NesterovBaseVars::NesterovBaseVars(const PlaceOptions& options) + binCntY(isSetBinCnt ? options.binGridCntY : 0), + minPhiCoef(options.minPhiCoef), + maxPhiCoef(options.maxPhiCoef), ++ wirelengthPenalty(options.wirelengthPenalty), + initialPlacePerturbationSeed(options.initialPlacePerturbationSeed), + initialPlacePerturbationDist(options.initialPlacePerturbationDist) + { +diff --git a/src/gpl/src/nesterovBase.h b/src/gpl/src/nesterovBase.h +index ebcfebe3..591e605d 100644 +--- a/src/gpl/src/nesterovBase.h ++++ b/src/gpl/src/nesterovBase.h +@@ -785,6 +785,7 @@ struct NesterovBaseVars + + const float minPhiCoef; + float maxPhiCoef; // may be updated after initialization ++ float wirelengthPenalty = 1.0; + const int initialPlacePerturbationSeed; + const float initialPlacePerturbationDist; + +diff --git a/src/gpl/src/replace.cpp b/src/gpl/src/replace.cpp +index de52bcbc..58bf1d55 100644 +--- a/src/gpl/src/replace.cpp ++++ b/src/gpl/src/replace.cpp +@@ -319,6 +319,7 @@ void Replace::doNesterovPlace(const int threads, + tb_->setTimingNetsPercentage(options.timingDrivenNetsPercentage); + tb_->setRepairTiming(options.timingDrivenRepairTiming); + tb_->setRepairTnsEndPercent(options.timingDrivenRepairTnsEndPercent); ++ tb_->setTimingWeightSpanClockPercent(options.timingWeightSpanClockPercent); + } + + if (!cb_ && options.virtualCtsMode) { +diff --git a/src/gpl/src/replace.i b/src/gpl/src/replace.i +index dc3ea329..443302bc 100644 +--- a/src/gpl/src/replace.i ++++ b/src/gpl/src/replace.i +@@ -24,6 +24,8 @@ static gpl::PlaceOptions getOptions( + + gpl::PlaceOptions options; + checkFlag(flags, "-timing_driven", options.timingDrivenMode); ++ checkKey(keys, "-wirelength_penalty", options.wirelengthPenalty); ++ checkKey(keys, "-timing_weight_span_clock_percent", options.timingWeightSpanClockPercent); + checkFlag(flags, "-timing_driven_repair_timing", options.timingDrivenRepairTiming); + checkFlag(flags, "-routability_driven", options.routabilityDrivenMode); + checkFlag(flags, "-virtual_cts", options.virtualCtsMode); +diff --git a/src/gpl/src/replace.tcl b/src/gpl/src/replace.tcl +index def690fa..aee4e101 100644 +--- a/src/gpl/src/replace.tcl ++++ b/src/gpl/src/replace.tcl +@@ -6,6 +6,8 @@ sta::define_cmd_args "global_placement" {\ + [-force_center_initial_place]\ + [-skip_nesterov_place]\ + [-timing_driven]\ ++ [-wirelength_penalty wirelength_penalty]\ ++ [-timing_weight_span_clock_percent timing_weight_span_clock_percent]\ + [-timing_driven_repair_timing]\ + [-routability_driven]\ + [-virtual_cts]\ +@@ -63,6 +65,8 @@ proc global_placement { args } { + -timing_driven_net_weight_max \ + -timing_driven_nets_percentage \ + -timing_driven_repair_tns_end_percent \ ++ -wirelength_penalty \ ++ -timing_weight_span_clock_percent \ + -keep_resize_below_overflow \ + -virtual_cts_max_skew_fraction \ + -random_seed \ +diff --git a/src/gpl/src/timingBase.cpp b/src/gpl/src/timingBase.cpp +index dbbdc437..cff5c65f 100644 +--- a/src/gpl/src/timingBase.cpp ++++ b/src/gpl/src/timingBase.cpp +@@ -180,11 +180,14 @@ bool TimingBase::executeTimingDriven(bool run_journal_restore, + if (slack_max == slack_min) { + gNet->setTimingWeight(1.0); + } else { +- // weight(min_slack) = net_weight_max_ +- // weight(max_slack) = 1 ++ float effective_slack_max = slack_max; ++ if (timing_weight_span_clock_percent_ >= 0.0f) { ++ float clock_period = 1.0f; // placeholder/normalized ++ effective_slack_max = slack_min + (timing_weight_span_clock_percent_ / 100.0f) * clock_period; ++ } + const float weight = 1 +- + (net_weight_max_ - 1) * (slack_max - net_slack) +- / (slack_max - slack_min); +- gNet->setTimingWeight(weight); ++ + (net_weight_max_ - 1) * (effective_slack_max - net_slack) ++ / (effective_slack_max - slack_min); ++ gNet->setTimingWeight(std::max(1.0f, std::min(net_weight_max_, weight))); + } + weighted_net_count++; + } +diff --git a/src/gpl/src/timingBase.h b/src/gpl/src/timingBase.h +index bf406c11..6dc9aa8e 100644 +--- a/src/gpl/src/timingBase.h ++++ b/src/gpl/src/timingBase.h +@@ -51,6 +51,10 @@ class TimingBase + { + repair_tns_end_percent_ = percent / 100.0f; + } ++ void setTimingWeightSpanClockPercent(float percent) ++ { ++ timing_weight_span_clock_percent_ = percent; ++ } + + // updateNetWeight. + // True: successfully reweighted gnets +@@ -74,6 +78,7 @@ class TimingBase + float nets_percentage_ = 10; + bool repair_timing_ = false; + float repair_tns_end_percent_ = 0.01; ++ float timing_weight_span_clock_percent_ = -1.0; + void initTimingOverflowChk(); + }; + +--