Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#3792 from openroadie/recover_…
Browse files Browse the repository at this point in the history
…power

Recover power
  • Loading branch information
maliberty authored Aug 7, 2023
2 parents 6fe5668 + 4425eb0 commit 185d909
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 24 deletions.
22 changes: 14 additions & 8 deletions src/rsz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,23 @@ repair_timing [-setup]
[-setup_margin setup_margin]
[-hold_margin hold_margin]
[-allow_setup_violations]
[-recover_power percent_of_paths_with_slack]
[-repair_tns tns_end_percent]
[-max_utilization util]
[-max_buffer_percent buffer_percent]
[-verbose]
```

The `repair_timing` command repairs setup and hold violations. It
should be run after clock tree synthesis with propagated clocks.
Setup repair is done before hold repair so that hold repair does not
cause setup checks to fail. While repairing hold violations buffers
are not inserted that will cause setup violations unless
`-allow_setup_violations` is specified.
The `repair_timing` command repairs setup and hold violations. It can also
recover power from paths with positive slack by downsizing or using higher
Vt cells (if they are available). It should be run after clock tree synthesis
with propagated clocks. Setup repair is done before hold repair so that hold
repair does not cause setup checks to fail. While repairing hold violations buffers
are not inserted that will cause setup violations unless `-allow_setup_violations`
is specified.

Use `-setup_margin/-hold_margin` to add additional slack margin.
Use `-verbose` to print more information about the progress of the
repair.
Use `-verbose` to print more information about the progress of the repair.

The worst setup path is always repaired. Next, violating paths to
endpoints are repaired to reduced the total negative slack. The
Expand All @@ -196,6 +198,10 @@ Use`-max_buffer_percent` to specify a maximum number of buffers to insert
to repair hold violations as a percentage of the number of instances
in the design. The default value for `buffer_percent` is 20, for 20%.

Use`-recover_power` to specify the percent of paths with positive slack which
will be considered for gate resizing to save power. It is recommended that
this option be used with global routing based parasitics.

### Repair Clock Nets

```
Expand Down
2 changes: 1 addition & 1 deletion src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public:
int holdBufferCount() const;

////////////////////////////////////////////////////////////////
void recoverPower();
void recoverPower(float recover_power_percent);

////////////////////////////////////////////////////////////////
// Area of the design in meter^2.
Expand Down
11 changes: 7 additions & 4 deletions src/rsz/src/RecoverPower.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ RecoverPower::init()
}

void
RecoverPower::recoverPower()
RecoverPower::recoverPower(float recover_power_percent)
{
init();
float setup_slack_margin = 1e-11;
Expand Down Expand Up @@ -140,7 +140,12 @@ RecoverPower::recoverPower()
int(ends_with_slack.size() / double(endpoints->size()) * 100));

int end_index = 0;
int max_end_count = ends_with_slack.size()/5; // 20%
int max_end_count = ends_with_slack.size()*recover_power_percent;

// As long as we are here fix at least one path
if (max_end_count == 0) {
max_end_count = 1;
}

resizer_->incrementalParasiticsBegin();
for (Vertex *end : ends_with_slack) {
Expand Down Expand Up @@ -194,7 +199,6 @@ RecoverPower::recoverPower()
}

resizer_->incrementalParasiticsEnd();

// TODO: Add the appropriate metric here
// logger_->metric("design__instance__count__setup_buffer", inserted_buffer_count_);
if (resize_count_ > 0) {
Expand All @@ -203,7 +207,6 @@ RecoverPower::recoverPower()
if (resizer_->overMaxArea()) {
logger_->error(RSZ, 125, "max utilization reached.");
}

}

// For testing.
Expand Down
2 changes: 1 addition & 1 deletion src/rsz/src/RecoverPower.hh
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class RecoverPower : StaState
{
public:
RecoverPower(Resizer *resizer);
void recoverPower();
void recoverPower(float recover_power_percent);
// For testing.
void recoverPower(const Pin *end_pin);
// Rebuffer one net (for testing).
Expand Down
4 changes: 2 additions & 2 deletions src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2640,13 +2640,13 @@ Resizer::holdBufferCount() const

////////////////////////////////////////////////////////////////
void
Resizer::recoverPower()
Resizer::recoverPower(float recover_power_percent)
{
resizePreamble();
if (parasitics_src_ == ParasiticsSrc::global_routing) {
opendp_->initMacrosAndGrid();
}
recover_power_->recoverPower();
recover_power_->recoverPower(recover_power_percent);
}
////////////////////////////////////////////////////////////////
// Journal to roll back changes (OpenDB not up to the task).
Expand Down
4 changes: 2 additions & 2 deletions src/rsz/src/Resizer.i
Original file line number Diff line number Diff line change
Expand Up @@ -537,11 +537,11 @@ hold_buffer_count()

////////////////////////////////////////////////////////////////
void
recover_power()
recover_power(float recover_power_percent)
{
ensureLinked();
Resizer *resizer = getResizer();
resizer->recoverPower();
resizer->recoverPower(recover_power_percent);
}

////////////////////////////////////////////////////////////////
Expand Down
19 changes: 13 additions & 6 deletions src/rsz/src/Resizer.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ proc repair_tie_fanout { args } {

# -max_passes is for developer debugging so intentionally not documented
# in define_cmd_args
sta::define_cmd_args "repair_timing" {[-setup] [-hold] [-recover_power]\
sta::define_cmd_args "repair_timing" {[-setup] [-hold] [-recover_power percent_of_paths_with_slack]\
[-setup_margin setup_margin]\
[-hold_margin hold_margin]\
[-allow_setup_violations]\
Expand All @@ -404,12 +404,12 @@ proc repair_timing { args } {
sta::parse_key_args "repair_timing" args \
keys {-setup_margin -hold_margin -slack_margin \
-libraries -max_utilization -max_buffer_percent \
-repair_tns -max_passes} \
flags {-setup -hold -recover_power -allow_setup_violations -skip_pin_swap -skip_gate_cloning -verbose}
-recover_power -repair_tns -max_passes} \
flags {-setup -hold -allow_setup_violations -skip_pin_swap -skip_gate_cloning -verbose}

set setup [info exists flags(-setup)]
set hold [info exists flags(-hold)]
set recover_power [info exists flags(-recover_power)]

if { !$setup && !$hold } {
set setup 1
set hold 1
Expand Down Expand Up @@ -448,6 +448,13 @@ proc repair_timing { args } {
set repair_tns_end_percent [expr $repair_tns_end_percent / 100.0]
}

set recover_power_percent -1
if { [info exists keys(-recover_power)] } {
set recover_power_percent $keys(-recover_power)
sta::check_percent "-recover_power" $recover_power_percent
set recover_power_percent [expr $recover_power_percent / 100.0]
}

set verbose 0
if { [info exists flags(-verbose)] } {
set verbose 1
Expand All @@ -459,8 +466,8 @@ proc repair_timing { args } {
}
sta::check_argc_eq0 "repair_timing" $args
rsz::check_parasitics
if { $recover_power } {
rsz::recover_power
if { $recover_power_percent >= 0 } {
rsz::recover_power $recover_power_percent
} else {
if { $setup } {
rsz::repair_setup $setup_margin $repair_tns_end_percent $max_passes \
Expand Down

0 comments on commit 185d909

Please sign in to comment.