Skip to content

Commit f4e9e5a

Browse files
committed
gui: add GUI_WNS that prunes to N WNS paths for large designs
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 5dcd585 commit f4e9e5a

4 files changed

Lines changed: 135 additions & 0 deletions

File tree

‎docs/user/FlowVariables.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ configuration file.
152152
| <a name="GPL_ROUTABILITY_DRIVEN"></a>GPL_ROUTABILITY_DRIVEN| Specifies whether the placer should use routability driven placement.| 1|
153153
| <a name="GPL_TIMING_DRIVEN"></a>GPL_TIMING_DRIVEN| Specifies whether the placer should use timing driven placement.| 1|
154154
| <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|
155+
| <a name="GUI_WNS"></a>GUI_WNS| Prune register and pin endpoints not appearing in the N first WNS paths in path groups and histogram buckets. This can be helpful for very large designs of millions of instances. Default, no pruning.| None|
155156
| <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|
156157
| <a name="IO_CONSTRAINTS"></a>IO_CONSTRAINTS| File path to the IO constraints .tcl file. Also used for manual placement.| |
157158
| <a name="IO_PLACER_H"></a>IO_PLACER_H| A list of metal layers on which the I/O pins are placed horizontally (top and bottom of the die).| |
@@ -531,6 +532,7 @@ configuration file.
531532
- [GDS_FILES](#GDS_FILES)
532533
- [GENERATE_ARTIFACTS_ON_FAILURE](#GENERATE_ARTIFACTS_ON_FAILURE)
533534
- [GUI_TIMING](#GUI_TIMING)
535+
- [GUI_WNS](#GUI_WNS)
534536
- [IR_DROP_LAYER](#IR_DROP_LAYER)
535537
- [KLAYOUT_TECH_FILE](#KLAYOUT_TECH_FILE)
536538
- [LAYER_PARASITICS_FILE](#LAYER_PARASITICS_FILE)

‎flow/scripts/open.tcl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ proc read_timing { input_file } {
5858

5959
# Warm up OpenSTA, so clicking on timing related buttons reacts faster
6060
set _tmp [log_cmd sta::find_timing]
61+
log_cmd prune_wns
6162
set _tmp [log_cmd sta::find_requireds]
6263
}
6364

‎flow/scripts/util.tcl‎

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,127 @@ proc orfs_write_sdc { output_file } {
258258
}
259259
log_cmd write_sdc -no_timestamp $output_file
260260
}
261+
262+
proc get_focus_endpoints { n_paths n_buckets } {
263+
puts "Generating Focus List (In-Memory)..."
264+
265+
# 1. Initialize Deduplication Dictionary
266+
set endpoints_to_keep [dict create]
267+
268+
# 2. Get Global WNS to define the Histogram Range
269+
# We assume we are looking for the violating range (WNS to 0.0)
270+
set paths [find_timing_paths -group_path_count 1]
271+
if { [llength $paths] == 0 } {
272+
puts "Warning: No timing paths found."
273+
return [list]
274+
}
275+
276+
set wns [get_property [lindex $paths 0] slack]
277+
278+
# If design is clean (WNS > 0), define a default analysis range
279+
# or just capture the least positive slack.
280+
if { $wns > 0 } {
281+
set wns -0.1
282+
set range_top 0.1
283+
} else {
284+
set range_top 0.0
285+
}
286+
287+
# Calculate Bucket Size
288+
# We span from WNS (e.g. -5.0) up to 0.0
289+
set total_range [expr { $range_top - $wns }]
290+
set step [expr { $total_range / $n_buckets }]
291+
292+
puts " WNS: [format %.3f $wns] | Range: [format %.3f $total_range] | Step: [format %.3f $step]"
293+
294+
puts "Path groups found: [sta::path_group_names]"
295+
296+
# 3. Iterate over All Path Groups
297+
foreach group_name [sta::path_group_names] {
298+
# ignore group names with space in name
299+
if { [string first " " $group_name] != -1 } {
300+
puts " Warning: Skipping path group with space in name: '$group_name'"
301+
continue
302+
}
303+
set group_count 0
304+
305+
# 4. Iterate over Buckets
306+
for { set i 0 } { $i < $n_buckets } { incr i } {
307+
set slack_min [expr { $wns + ($i * $step) }]
308+
set slack_max [expr { $wns + (($i + 1) * $step) }]
309+
310+
# Query the specific slice of the histogram
311+
set paths [find_timing_paths \
312+
-path_group "$group_name" \
313+
-slack_min $slack_min \
314+
-slack_max $slack_max \
315+
-group_path_count $n_paths]
316+
317+
foreach path $paths {
318+
set end_pin [get_property $path endpoint]
319+
set end_name [get_property $end_pin full_name]
320+
321+
# Add to dictionary (Key handles deduplication)
322+
dict set endpoints_to_keep $end_name 1
323+
incr group_count
324+
}
325+
}
326+
}
327+
328+
set total_count [dict size $endpoints_to_keep]
329+
# Return the list of keys (endpoint names)
330+
return [dict keys $endpoints_to_keep]
331+
}
332+
333+
proc prune_wns { } {
334+
if { [env_var_exists_and_non_empty GUI_WNS] } {
335+
puts "Context: Sparse Analysis Mode (WNS Limit: $::env(GUI_WNS))"
336+
337+
# --------------------------------------------------------
338+
# 1. Get "Keep" List (Pure Tcl String Parsing)
339+
# --------------------------------------------------------
340+
set keep_inst_dict [dict create]
341+
set buckets 10
342+
set focus_pin_names [get_focus_endpoints $::env(GUI_WNS) $buckets]
343+
344+
foreach name $focus_pin_names {
345+
# Strip the pin name to get the instance
346+
set inst_name [file dirname $name]
347+
348+
# Handle top-level objects
349+
if { $inst_name eq "." } { set inst_name $name }
350+
351+
dict set keep_inst_dict $inst_name 1
352+
}
353+
puts " Preserving [dict size $keep_inst_dict] critical instances."
354+
355+
# --------------------------------------------------------
356+
# 2. Get "Ignore" List (Database Traversal)
357+
# --------------------------------------------------------
358+
# We must iterate the collection here because 'all_registers'
359+
# returns DB objects, not strings.
360+
set ignore_list [list]
361+
set count 0
362+
363+
foreach reg_obj [all_registers] {
364+
# Only one DB call needed: getting the name
365+
set reg_name [get_property $reg_obj full_name]
366+
367+
if { ![dict exists $keep_inst_dict $reg_name] } {
368+
lappend ignore_list $reg_name
369+
incr count
370+
}
371+
}
372+
373+
# --------------------------------------------------------
374+
# 3. Apply Pruning
375+
# --------------------------------------------------------
376+
if { $count > 0 } {
377+
puts " Pruning $count register instances..."
378+
379+
set_false_path -to $ignore_list
380+
} else {
381+
puts " Warning: No registers found to prune."
382+
}
383+
}
384+
}

‎flow/scripts/variables.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,14 @@ GUI_TIMING:
518518
quite time consuming. Useful to disable when investigating non-timing
519519
aspects like floorplan, placement, routing, etc.
520520
default: 1
521+
GUI_WNS:
522+
description: >
523+
Prune register and pin endpoints not appearing in the N first WNS paths
524+
in path groups and histogram buckets. This can be helpful for very large
525+
designs of millions of instances.
526+
527+
Default, no pruning.
528+
default:
521529
FILL_CELLS:
522530
description: >
523531
Fill cells are used to fill empty sites. If not set or empty, fill cell

0 commit comments

Comments
 (0)