diff --git a/docs/user/FlowVariables.md b/docs/user/FlowVariables.md index b031f9bca2..1066f80f54 100644 --- a/docs/user/FlowVariables.md +++ b/docs/user/FlowVariables.md @@ -147,7 +147,7 @@ configuration file. | DPO_MAX_DISPLACEMENT| Specifies how far an instance can be moved when optimizing.| 5 1| | EARLY_SIZING_CAP_RATIO| Ratio between the input pin capacitance and the output pin load during initial gate sizing.| | | ENABLE_DPO| Enable detail placement with improve_placement feature.| 1| -| ENABLE_PLACE_REPAIR_TIMING| Run repair_timing during the placement resize stage using placement parasitics. Disabled by default; pre-CTS setup/hold repair is skipped unless this is set to 1.| 0| +| ENABLE_PLACE_REPAIR_TIMING| Run setup repair_timing (without the last-gasp phase) during the placement resize stage using placement parasitics. Disabled by default; the repair also runs when SWAP_ARITH_OPERATORS swaps a module.| 0| | ENABLE_RESISTANCE_AWARE| Passed as -resistance_aware to global_route.| | | FASTROUTE_TCL| Specifies a Tcl script with commands to run before FastRoute.| | | FILL_CELLS| Fill cells are used to fill empty sites. If not set or empty, fill cell insertion is skipped.| | diff --git a/flow/scripts/resize.tcl b/flow/scripts/resize.tcl index 1cfd01b08b..0cb0e3b9c1 100644 --- a/flow/scripts/resize.tcl +++ b/flow/scripts/resize.tcl @@ -15,22 +15,44 @@ if { [env_var_exists_and_non_empty EARLY_SIZING_CAP_RATIO] } { log_cmd set_opt_config -set_early_sizing_cap_ratio $env(EARLY_SIZING_CAP_RATIO) } +set swapped 0 if { [env_var_equals SWAP_ARITH_OPERATORS 1] } { # Enable sanity checker until replace_arith_modules becomes stable set_debug_level ODB replace_design_check_sanity 1 - set density [estimate_target_density -overflow 0.1] - log_cmd replace_arith_modules - log_cmd global_placement -incremental -density $density + set overflow 0.1 + set density [estimate_target_density -overflow $overflow] + set area_before [instance_area_um2] + set swapped [log_cmd replace_arith_modules] + + # The swapped modules' cells are the unplaced ones. The cells they replaced + # account for the rest of the area change, so their area as placed (sizing + # and buffers included) is the room the new cells have. Whatever does not + # fit is let overflow there in phase 1, rather than spreading the new + # modules out to resolve it. + set new_area [instance_area_um2 -unplaced] + set old_area [expr { $new_area + $area_before - [instance_area_um2] }] + if { $new_area > 0 } { + set excess [expr { max(0.0, ($new_area - $old_area) / $new_area) }] + set overflow [expr { min(1.0, $overflow + $excess) }] + puts [format "Swapped modules: %.3f um^2 replaced by %.3f um^2,\ + incremental placement overflow target %.3f" \ + $old_area $new_area $overflow] + } + # Phase 1 stops at the looser target above; phase 2 then unlocks every + # instance and brings the whole design back to 0.1. + log_cmd global_placement -incremental -density $density -overflow $overflow \ + -incremental_phase2_overflow 0.1 } repair_design_helper -if { $::env(ENABLE_PLACE_REPAIR_TIMING) } { - # Repair timing using placement parasitics. - puts "Repair setup and hold violations..." +if { $::env(ENABLE_PLACE_REPAIR_TIMING) || $swapped } { + # Repair setup using placement parasitics, always after a swap. Hold is + # left to CTS, where the clock tree exists. + puts "Repair setup violations..." log_cmd estimate_parasitics - repair_timing_helper + repair_timing_helper -setup -skip_last_gasp } # post report diff --git a/flow/scripts/util.tcl b/flow/scripts/util.tcl index 49862dfa60..d03010c6ec 100644 --- a/flow/scripts/util.tcl +++ b/flow/scripts/util.tcl @@ -300,6 +300,25 @@ proc hier_options { } { } } +# Total area of the block's instances in um^2; with -unplaced, only of the +# instances that are not placed yet. +proc instance_area_um2 { args } { + sta::parse_key_args "instance_area_um2" args keys {} flags {-unplaced} + set unplaced_only [info exists flags(-unplaced)] + set area 0.0 + foreach inst [[ord::get_db_block] getInsts] { + if { $unplaced_only && [$inst isPlaced] } { + continue + } + set master [$inst getMaster] + set area [expr { + $area + [ord::dbu_to_microns [$master getWidth]] + * [ord::dbu_to_microns [$master getHeight]] + }] + } + return $area +} + proc is_physical_only_master { master } { set physical_only_type_patterns [list \ "COVER" \ diff --git a/flow/scripts/variables.yaml b/flow/scripts/variables.yaml index 21b48f712c..d478e22818 100644 --- a/flow/scripts/variables.yaml +++ b/flow/scripts/variables.yaml @@ -990,9 +990,9 @@ SKIP_FLOORPLAN_REPAIR_TIMING: default: 0 ENABLE_PLACE_REPAIR_TIMING: description: > - Run repair_timing during the placement resize stage using placement - parasitics. Disabled by default; pre-CTS setup/hold repair is skipped - unless this is set to 1. + Run setup repair_timing (without the last-gasp phase) during the + placement resize stage using placement parasitics. Disabled by default; + the repair also runs when SWAP_ARITH_OPERATORS swaps a module. stages: - place default: 0