Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/user/FlowVariables.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ configuration file.
| <a name="DPO_MAX_DISPLACEMENT"></a>DPO_MAX_DISPLACEMENT| Specifies how far an instance can be moved when optimizing.| 5 1|
| <a name="EARLY_SIZING_CAP_RATIO"></a>EARLY_SIZING_CAP_RATIO| Ratio between the input pin capacitance and the output pin load during initial gate sizing.| |
| <a name="ENABLE_DPO"></a>ENABLE_DPO| Enable detail placement with improve_placement feature.| 1|
| <a name="ENABLE_PLACE_REPAIR_TIMING"></a>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|
| <a name="ENABLE_PLACE_REPAIR_TIMING"></a>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|
| <a name="ENABLE_RESISTANCE_AWARE"></a>ENABLE_RESISTANCE_AWARE| Passed as -resistance_aware to global_route.| |
| <a name="FASTROUTE_TCL"></a>FASTROUTE_TCL| Specifies a Tcl script with commands to run before FastRoute.| |
| <a name="FILL_CELLS"></a>FILL_CELLS| Fill cells are used to fill empty sites. If not set or empty, fill cell insertion is skipped.| |
Expand Down
36 changes: 29 additions & 7 deletions flow/scripts/resize.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions flow/scripts/util.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Comment on lines +305 to +320

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling ord::dbu_to_microns twice per instance inside the loop introduces a significant performance bottleneck for large designs with millions of instances due to the overhead of Tcl-to-C++ SWIG calls.

We can optimize this by summing the area in DBUs (integers) inside the loop, and then converting the total sum to square microns once at the end using a single conversion factor. This avoids millions of SWIG calls and speeds up the procedure significantly.

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_dbu 0
  foreach inst [[ord::get_db_block] getInsts] {
    if { $unplaced_only && [$inst isPlaced] } {
      continue
    }
    set master [$inst getMaster]
    set area_dbu [expr { $area_dbu + [$master getWidth] * [$master getHeight] }]
  }
  set dbu_factor [ord::dbu_to_microns 1]
  return [expr { $area_dbu * $dbu_factor * $dbu_factor }]
}


proc is_physical_only_master { master } {
set physical_only_type_patterns [list \
"COVER" \
Expand Down
6 changes: 3 additions & 3 deletions flow/scripts/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down