Skip to content

Commit 71876a0

Browse files
committed
gpl: Expose PDK-aware GPL parameters and tuning defaults
- 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 <oyvind.harboe@zylin.com>
1 parent fcc3cf5 commit 71876a0

8 files changed

Lines changed: 240 additions & 0 deletions

File tree

‎docs/user/FlowVariables.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ configuration file.
165165
| <a name="GPL_RANDOM_SEED"></a>GPL_RANDOM_SEED| Specifies a random seed for global placement. Useful for perturbation studies.| |
166166
| <a name="GPL_ROUTABILITY_DRIVEN"></a>GPL_ROUTABILITY_DRIVEN| Specifies whether the placer should use routability driven placement.| 1|
167167
| <a name="GPL_TIMING_DRIVEN"></a>GPL_TIMING_DRIVEN| Specifies whether the placer should use timing driven placement.| 1|
168+
| <a name="GPL_TIMING_SPAN_CLOCK_PERCENT"></a>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|
169+
| <a name="GPL_USE_ENGINE_DEFAULTS"></a>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|
170+
| <a name="GPL_WIRELENGTH_PENALTY"></a>GPL_WIRELENGTH_PENALTY| Global placement wirelength penalty (passed as -init_wirelength_coef or similar logic).| 0.0627|
168171
| <a name="GRT_SEED"></a>GRT_SEED| Specifies a random seed for global routing. Useful for perturbation studies.| |
169172
| <a name="GUI_TIMING"></a>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|
170173
| <a name="HOLD_SLACK_MARGIN"></a>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.
325328
| <a name="TIEHI_CELL_AND_PORT"></a>TIEHI_CELL_AND_PORT| Tie high cells used in Yosys synthesis to replace a logical 1 in the Netlist.| |
326329
| <a name="TIELO_CELL_AND_PORT"></a>TIELO_CELL_AND_PORT| Tie low cells used in Yosys synthesis to replace a logical 0 in the Netlist.| |
327330
| <a name="TIE_SEPARATION"></a>TIE_SEPARATION| Distance separating tie high/low instances from the load.| 0|
331+
| <a name="TIGHTEN_CLOCK_PERIOD"></a>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|
328332
| <a name="TNS_END_PERCENT"></a>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|
329333
| <a name="UNSET_ABC9_BOX_CELLS"></a>UNSET_ABC9_BOX_CELLS| List of cells to unset the abc9_box attribute on| |
330334
| <a name="USE_FILL"></a>USE_FILL| Whether to perform metal density filling.| 0|
@@ -477,6 +481,9 @@ configuration file.
477481
- [GPL_RANDOM_SEED](#GPL_RANDOM_SEED)
478482
- [GPL_ROUTABILITY_DRIVEN](#GPL_ROUTABILITY_DRIVEN)
479483
- [GPL_TIMING_DRIVEN](#GPL_TIMING_DRIVEN)
484+
- [GPL_TIMING_SPAN_CLOCK_PERCENT](#GPL_TIMING_SPAN_CLOCK_PERCENT)
485+
- [GPL_USE_ENGINE_DEFAULTS](#GPL_USE_ENGINE_DEFAULTS)
486+
- [GPL_WIRELENGTH_PENALTY](#GPL_WIRELENGTH_PENALTY)
480487
- [IO_PLACER_H](#IO_PLACER_H)
481488
- [IO_PLACER_V](#IO_PLACER_V)
482489
- [MATCH_CELL_FOOTPRINT](#MATCH_CELL_FOOTPRINT)
@@ -499,6 +506,7 @@ configuration file.
499506
- [PRE_RESIZE_TCL](#PRE_RESIZE_TCL)
500507
- [ROUTING_LAYER_ADJUSTMENT](#ROUTING_LAYER_ADJUSTMENT)
501508
- [SKIP_REPORT_METRICS](#SKIP_REPORT_METRICS)
509+
- [TIGHTEN_CLOCK_PERIOD](#TIGHTEN_CLOCK_PERIOD)
502510
- [TNS_END_PERCENT](#TNS_END_PERCENT)
503511

504512
## cts variables

‎flow/platforms/asap7/config.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"GPL_TIMING_SPAN_CLOCK_PERCENT": 0.22968514538823603,
3+
"GPL_WIRELENGTH_PENALTY": 0.06456297861599444,
4+
"TIGHTEN_CLOCK_PERIOD": 0.018604621846273695
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"GPL_TIMING_SPAN_CLOCK_PERCENT": 0.188034183753787,
3+
"GPL_WIRELENGTH_PENALTY": 0.028702330955746383,
4+
"TIGHTEN_CLOCK_PERIOD": 0.04743068706084326
5+
}

‎flow/scripts/defaults.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@
99
with open(json_path, "r") as file:
1010
data = json.load(file)
1111

12+
platform_dir = os.environ.get("PLATFORM_DIR")
13+
if platform_dir:
14+
platform_config_path = os.path.join(platform_dir, "config.json")
15+
if os.path.exists(platform_config_path):
16+
with open(platform_config_path, "r") as file:
17+
try:
18+
platform_data = json.load(file)
19+
for key, value in platform_data.items():
20+
if key in data:
21+
data[key]["default"] = value
22+
else:
23+
data[key] = {"default": value}
24+
except json.JSONDecodeError:
25+
pass
26+
1227
for key, value in data.items():
1328
if value.get("default", None) is None:
1429
continue

‎flow/scripts/global_place.tcl‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ append_env_var global_placement_args GPL_ROUTABILITY_DRIVEN -routability_driven
2828

2929
append_env_var global_placement_args GPL_RANDOM_SEED -random_seed 1
3030

31+
if { !$::env(GPL_USE_ENGINE_DEFAULTS) } {
32+
lappend global_placement_args -init_wirelength_coef $::env(GPL_WIRELENGTH_PENALTY)
33+
lappend global_placement_args -virtual_cts_max_skew_fraction $::env(GPL_TIMING_SPAN_CLOCK_PERCENT)
34+
}
35+
36+
3137
# Parameters for timing driven mode in global placement
3238
if { $::env(GPL_TIMING_DRIVEN) } {
3339
lappend global_placement_args {-timing_driven}

‎flow/scripts/variables.json‎

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎flow/scripts/variables.yaml‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,24 @@ GPL_TIMING_DRIVEN:
664664
stages:
665665
- place
666666
default: 1
667+
GPL_USE_ENGINE_DEFAULTS:
668+
description: |
669+
If set to 1, ignores ORFS-specific parameters and forces the global placement engine to use its internal hardcoded defaults.
670+
stages:
671+
- place
672+
default: 0
673+
GPL_WIRELENGTH_PENALTY:
674+
description: |
675+
Global placement wirelength penalty (passed as -init_wirelength_coef or similar logic).
676+
stages:
677+
- place
678+
default: 0.0627
679+
GPL_TIMING_SPAN_CLOCK_PERCENT:
680+
description: |
681+
Global placement timing weight span as a percent of clock (passed to virtual_cts_max_skew_fraction or similar logic).
682+
stages:
683+
- place
684+
default: 0.240
667685
GPL_ROUTABILITY_DRIVEN:
668686
description: |
669687
Specifies whether the placer should use routability driven placement.
@@ -1644,3 +1662,9 @@ GRT_SEED:
16441662
- grt
16451663
tunable: 1
16461664
type: int
1665+
TIGHTEN_CLOCK_PERIOD:
1666+
description: >
1667+
Tighten the clock period by this fraction (e.g. 0.1 for 10%) before measuring minimum clock period. Used by the autotuner.
1668+
stages:
1669+
- place
1670+
default: 0.0638
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
From 06b8b5d592a51490cad48bff036b81b5264106f9 Mon Sep 17 00:00:00 2001
2+
From: Øyvind Harboe <oyvind.harboe@zylin.com>
3+
Date: Wed, 12 Aug 2026 17:48:28 +0200
4+
Subject: [PATCH] Add PDK-aware GPL parameters
5+
6+
---
7+
src/gpl/include/gpl/Replace.h | 2 ++
8+
src/gpl/src/nesterovBase.cpp | 1 +
9+
src/gpl/src/nesterovBase.h | 1 +
10+
src/gpl/src/replace.cpp | 1 +
11+
src/gpl/src/replace.i | 2 ++
12+
src/gpl/src/replace.tcl | 4 ++++
13+
src/gpl/src/timingBase.cpp | 9 ++++++---
14+
src/gpl/src/timingBase.h | 5 +++++
15+
8 files changed, 24 insertions(+), 5 deletions(-)
16+
17+
diff --git a/src/gpl/include/gpl/Replace.h b/src/gpl/include/gpl/Replace.h
18+
index b73e2a12..a5d89d42 100644
19+
--- a/src/gpl/include/gpl/Replace.h
20+
+++ b/src/gpl/include/gpl/Replace.h
21+
@@ -56,6 +56,8 @@ struct PlaceOptions
22+
bool skipIoMode = false;
23+
bool forceCenterInitialPlace = false;
24+
bool timingDrivenMode = false;
25+
+ float wirelengthPenalty = 1.0;
26+
+ float timingWeightSpanClockPercent = -1.0;
27+
bool timingDrivenRepairTiming = false;
28+
float timingDrivenRepairTnsEndPercent = 1.0;
29+
bool routabilityDrivenMode = false;
30+
diff --git a/src/gpl/src/nesterovBase.cpp b/src/gpl/src/nesterovBase.cpp
31+
index 3ad4e0e5..70752538 100644
32+
--- a/src/gpl/src/nesterovBase.cpp
33+
+++ b/src/gpl/src/nesterovBase.cpp
34+
@@ -1160,6 +1160,7 @@ NesterovBaseVars::NesterovBaseVars(const PlaceOptions& options)
35+
binCntY(isSetBinCnt ? options.binGridCntY : 0),
36+
minPhiCoef(options.minPhiCoef),
37+
maxPhiCoef(options.maxPhiCoef),
38+
+ wirelengthPenalty(options.wirelengthPenalty),
39+
initialPlacePerturbationSeed(options.initialPlacePerturbationSeed),
40+
initialPlacePerturbationDist(options.initialPlacePerturbationDist)
41+
{
42+
diff --git a/src/gpl/src/nesterovBase.h b/src/gpl/src/nesterovBase.h
43+
index ebcfebe3..591e605d 100644
44+
--- a/src/gpl/src/nesterovBase.h
45+
+++ b/src/gpl/src/nesterovBase.h
46+
@@ -785,6 +785,7 @@ struct NesterovBaseVars
47+
48+
const float minPhiCoef;
49+
float maxPhiCoef; // may be updated after initialization
50+
+ float wirelengthPenalty = 1.0;
51+
const int initialPlacePerturbationSeed;
52+
const float initialPlacePerturbationDist;
53+
54+
diff --git a/src/gpl/src/replace.cpp b/src/gpl/src/replace.cpp
55+
index de52bcbc..58bf1d55 100644
56+
--- a/src/gpl/src/replace.cpp
57+
+++ b/src/gpl/src/replace.cpp
58+
@@ -319,6 +319,7 @@ void Replace::doNesterovPlace(const int threads,
59+
tb_->setTimingNetsPercentage(options.timingDrivenNetsPercentage);
60+
tb_->setRepairTiming(options.timingDrivenRepairTiming);
61+
tb_->setRepairTnsEndPercent(options.timingDrivenRepairTnsEndPercent);
62+
+ tb_->setTimingWeightSpanClockPercent(options.timingWeightSpanClockPercent);
63+
}
64+
65+
if (!cb_ && options.virtualCtsMode) {
66+
diff --git a/src/gpl/src/replace.i b/src/gpl/src/replace.i
67+
index dc3ea329..443302bc 100644
68+
--- a/src/gpl/src/replace.i
69+
+++ b/src/gpl/src/replace.i
70+
@@ -24,6 +24,8 @@ static gpl::PlaceOptions getOptions(
71+
72+
gpl::PlaceOptions options;
73+
checkFlag(flags, "-timing_driven", options.timingDrivenMode);
74+
+ checkKey(keys, "-wirelength_penalty", options.wirelengthPenalty);
75+
+ checkKey(keys, "-timing_weight_span_clock_percent", options.timingWeightSpanClockPercent);
76+
checkFlag(flags, "-timing_driven_repair_timing", options.timingDrivenRepairTiming);
77+
checkFlag(flags, "-routability_driven", options.routabilityDrivenMode);
78+
checkFlag(flags, "-virtual_cts", options.virtualCtsMode);
79+
diff --git a/src/gpl/src/replace.tcl b/src/gpl/src/replace.tcl
80+
index def690fa..aee4e101 100644
81+
--- a/src/gpl/src/replace.tcl
82+
+++ b/src/gpl/src/replace.tcl
83+
@@ -6,6 +6,8 @@ sta::define_cmd_args "global_placement" {\
84+
[-force_center_initial_place]\
85+
[-skip_nesterov_place]\
86+
[-timing_driven]\
87+
+ [-wirelength_penalty wirelength_penalty]\
88+
+ [-timing_weight_span_clock_percent timing_weight_span_clock_percent]\
89+
[-timing_driven_repair_timing]\
90+
[-routability_driven]\
91+
[-virtual_cts]\
92+
@@ -63,6 +65,8 @@ proc global_placement { args } {
93+
-timing_driven_net_weight_max \
94+
-timing_driven_nets_percentage \
95+
-timing_driven_repair_tns_end_percent \
96+
+ -wirelength_penalty \
97+
+ -timing_weight_span_clock_percent \
98+
-keep_resize_below_overflow \
99+
-virtual_cts_max_skew_fraction \
100+
-random_seed \
101+
diff --git a/src/gpl/src/timingBase.cpp b/src/gpl/src/timingBase.cpp
102+
index dbbdc437..cff5c65f 100644
103+
--- a/src/gpl/src/timingBase.cpp
104+
+++ b/src/gpl/src/timingBase.cpp
105+
@@ -180,11 +180,14 @@ bool TimingBase::executeTimingDriven(bool run_journal_restore,
106+
if (slack_max == slack_min) {
107+
gNet->setTimingWeight(1.0);
108+
} else {
109+
- // weight(min_slack) = net_weight_max_
110+
- // weight(max_slack) = 1
111+
+ float effective_slack_max = slack_max;
112+
+ if (timing_weight_span_clock_percent_ >= 0.0f) {
113+
+ float clock_period = 1.0f; // placeholder/normalized
114+
+ effective_slack_max = slack_min + (timing_weight_span_clock_percent_ / 100.0f) * clock_period;
115+
+ }
116+
const float weight = 1
117+
- + (net_weight_max_ - 1) * (slack_max - net_slack)
118+
- / (slack_max - slack_min);
119+
- gNet->setTimingWeight(weight);
120+
+ + (net_weight_max_ - 1) * (effective_slack_max - net_slack)
121+
+ / (effective_slack_max - slack_min);
122+
+ gNet->setTimingWeight(std::max(1.0f, std::min(net_weight_max_, weight)));
123+
}
124+
weighted_net_count++;
125+
}
126+
diff --git a/src/gpl/src/timingBase.h b/src/gpl/src/timingBase.h
127+
index bf406c11..6dc9aa8e 100644
128+
--- a/src/gpl/src/timingBase.h
129+
+++ b/src/gpl/src/timingBase.h
130+
@@ -51,6 +51,10 @@ class TimingBase
131+
{
132+
repair_tns_end_percent_ = percent / 100.0f;
133+
}
134+
+ void setTimingWeightSpanClockPercent(float percent)
135+
+ {
136+
+ timing_weight_span_clock_percent_ = percent;
137+
+ }
138+
139+
// updateNetWeight.
140+
// True: successfully reweighted gnets
141+
@@ -74,6 +78,7 @@ class TimingBase
142+
float nets_percentage_ = 10;
143+
bool repair_timing_ = false;
144+
float repair_tns_end_percent_ = 0.01;
145+
+ float timing_weight_span_clock_percent_ = -1.0;
146+
void initTimingOverflowChk();
147+
};
148+
149+
--

0 commit comments

Comments
 (0)