diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md
index 59d919b223..c2ce9a3b83 100644
--- a/docs/user/FlowVariables.md
+++ b/docs/user/FlowVariables.md
@@ -152,6 +152,7 @@ configuration file.
| 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|
| 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|
+| 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|
| 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|
| IO_CONSTRAINTS| File path to the IO constraints .tcl file. Also used for manual placement.| |
| 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.
- [GDS_FILES](#GDS_FILES)
- [GENERATE_ARTIFACTS_ON_FAILURE](#GENERATE_ARTIFACTS_ON_FAILURE)
- [GUI_TIMING](#GUI_TIMING)
+- [GUI_WNS](#GUI_WNS)
- [IR_DROP_LAYER](#IR_DROP_LAYER)
- [KLAYOUT_TECH_FILE](#KLAYOUT_TECH_FILE)
- [LAYER_PARASITICS_FILE](#LAYER_PARASITICS_FILE)
diff --git a/flow/scripts/open.tcl b/flow/scripts/open.tcl
index 48d881afca..8ac6ce4621 100644
--- a/flow/scripts/open.tcl
+++ b/flow/scripts/open.tcl
@@ -58,6 +58,7 @@ proc read_timing { input_file } {
# Warm up OpenSTA, so clicking on timing related buttons reacts faster
set _tmp [log_cmd sta::find_timing]
+ log_cmd prune_wns
set _tmp [log_cmd sta::find_requireds]
}
diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl
index 04b4d3727e..d150dbb68d 100644
--- a/flow/scripts/util.tcl
+++ b/flow/scripts/util.tcl
@@ -258,3 +258,127 @@ proc orfs_write_sdc { output_file } {
}
log_cmd write_sdc -no_timestamp $output_file
}
+
+proc get_focus_endpoints { n_paths n_buckets } {
+ puts "Generating Focus List (In-Memory)..."
+
+ # 1. Initialize Deduplication Dictionary
+ set endpoints_to_keep [dict create]
+
+ # 2. Get Global WNS to define the Histogram Range
+ # We assume we are looking for the violating range (WNS to 0.0)
+ set paths [find_timing_paths -group_path_count 1]
+ if { [llength $paths] == 0 } {
+ puts "Warning: No timing paths found."
+ return [list]
+ }
+
+ set wns [get_property [lindex $paths 0] slack]
+
+ # If design is clean (WNS > 0), define a default analysis range
+ # or just capture the least positive slack.
+ if { $wns > 0 } {
+ set wns -0.1
+ set range_top 0.1
+ } else {
+ set range_top 0.0
+ }
+
+ # Calculate Bucket Size
+ # We span from WNS (e.g. -5.0) up to 0.0
+ set total_range [expr { $range_top - $wns }]
+ set step [expr { $total_range / $n_buckets }]
+
+ puts " WNS: [format %.3f $wns] | Range: [format %.3f $total_range] | Step: [format %.3f $step]"
+
+ puts "Path groups found: [sta::path_group_names]"
+
+ # 3. Iterate over All Path Groups
+ foreach group_name [sta::path_group_names] {
+ # ignore group names with space in name
+ if { [string first " " $group_name] != -1 } {
+ puts " Warning: Skipping path group with space in name: '$group_name'"
+ continue
+ }
+ set group_count 0
+
+ # 4. Iterate over Buckets
+ for { set i 0 } { $i < $n_buckets } { incr i } {
+ set slack_min [expr { $wns + ($i * $step) }]
+ set slack_max [expr { $wns + (($i + 1) * $step) }]
+
+ # Query the specific slice of the histogram
+ set paths [find_timing_paths \
+ -path_group "$group_name" \
+ -slack_min $slack_min \
+ -slack_max $slack_max \
+ -group_path_count $n_paths]
+
+ foreach path $paths {
+ set end_pin [get_property $path endpoint]
+ set end_name [get_property $end_pin full_name]
+
+ # Add to dictionary (Key handles deduplication)
+ dict set endpoints_to_keep $end_name 1
+ incr group_count
+ }
+ }
+ }
+
+ set total_count [dict size $endpoints_to_keep]
+ # Return the list of keys (endpoint names)
+ return [dict keys $endpoints_to_keep]
+}
+
+proc prune_wns { } {
+ if { [env_var_exists_and_non_empty GUI_WNS] } {
+ puts "Context: Sparse Analysis Mode (WNS Limit: $::env(GUI_WNS))"
+
+ # --------------------------------------------------------
+ # 1. Get "Keep" List (Pure Tcl String Parsing)
+ # --------------------------------------------------------
+ set keep_inst_dict [dict create]
+ set buckets 10
+ set focus_pin_names [get_focus_endpoints $::env(GUI_WNS) $buckets]
+
+ foreach name $focus_pin_names {
+ # Strip the pin name to get the instance
+ set inst_name [file dirname $name]
+
+ # Handle top-level objects
+ if { $inst_name eq "." } { set inst_name $name }
+
+ dict set keep_inst_dict $inst_name 1
+ }
+ puts " Preserving [dict size $keep_inst_dict] critical instances."
+
+ # --------------------------------------------------------
+ # 2. Get "Ignore" List (Database Traversal)
+ # --------------------------------------------------------
+ # We must iterate the collection here because 'all_registers'
+ # returns DB objects, not strings.
+ set ignore_list [list]
+ set count 0
+
+ foreach reg_obj [all_registers] {
+ # Only one DB call needed: getting the name
+ set reg_name [get_property $reg_obj full_name]
+
+ if { ![dict exists $keep_inst_dict $reg_name] } {
+ lappend ignore_list $reg_name
+ incr count
+ }
+ }
+
+ # --------------------------------------------------------
+ # 3. Apply Pruning
+ # --------------------------------------------------------
+ if { $count > 0 } {
+ puts " Pruning $count register instances..."
+
+ set_false_path -to $ignore_list
+ } else {
+ puts " Warning: No registers found to prune."
+ }
+ }
+}
diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml
index 9483713f27..a43f36ab8e 100644
--- a/flow/scripts/variables.yaml
+++ b/flow/scripts/variables.yaml
@@ -518,6 +518,14 @@ GUI_TIMING:
quite time consuming. Useful to disable when investigating non-timing
aspects like floorplan, placement, routing, etc.
default: 1
+GUI_WNS:
+ description: >
+ 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.
+ default:
FILL_CELLS:
description: >
Fill cells are used to fill empty sites. If not set or empty, fill cell