Skip to content

Commit

Permalink
Merge pull request #6529 from gadfort/rsz-dont-use
Browse files Browse the repository at this point in the history
rsz: copy dontuse from liberty cell to allow for user control
  • Loading branch information
maliberty authored Jan 14, 2025
2 parents e2388a3 + 6bd980c commit beba944
Show file tree
Hide file tree
Showing 10 changed files with 165 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/rsz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ The `unset_dont_use` command reverses the `set_dont_use` command.
unset_dont_use lib_cells
```

### Reset Don't Use

The `reset_dont_use` restores the default dont use list.

```tcl
reset_dont_use
```

### Report Don't Use

The `report_dont_use` reports all the cells that are marked as dont use.
Expand Down
9 changes: 8 additions & 1 deletion src/rsz/include/rsz/Resizer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <optional>
#include <string>

#include "db_sta/dbNetwork.hh"
#include "db_sta/dbSta.hh"
#include "dpl/Opendp.h"
#include "rsz/OdbCallBack.hh"
Expand Down Expand Up @@ -81,6 +82,7 @@ using sta::ArcDelay;
using sta::Cell;
using sta::Corner;
using sta::dbNetwork;
using sta::dbNetworkObserver;
using sta::dbSta;
using sta::dbStaState;
using sta::DcalcAnalysisPt;
Expand Down Expand Up @@ -183,7 +185,7 @@ struct BufferData

class OdbCallBack;

class Resizer : public dbStaState
class Resizer : public dbStaState, public dbNetworkObserver
{
public:
Resizer();
Expand Down Expand Up @@ -261,6 +263,7 @@ class Resizer : public dbStaState
double maxArea() const;

void setDontUse(LibertyCell* cell, bool dont_use);
void resetDontUse();
bool dontUse(const LibertyCell* cell);
void reportDontUse() const;
void setDontTouch(const Instance* inst, bool dont_touch);
Expand All @@ -275,6 +278,9 @@ class Resizer : public dbStaState
void bufferInputs();
void bufferOutputs();

// from sta::dbNetworkObserver callbacks
void postReadLiberty() override;

// Balance the usage of hybrid rows
void balanceRowUsage();

Expand Down Expand Up @@ -440,6 +446,7 @@ class Resizer : public dbStaState
bool hasTristateOrDontTouchDriver(const Net* net);
bool isTristateDriver(const Pin* pin);
void checkLibertyForAllCorners();
void copyDontUseFromLiberty();
void findBuffers();
bool isLinkCell(LibertyCell* cell) const;
void findTargetLoads();
Expand Down
45 changes: 44 additions & 1 deletion src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ using odb::dbInst;
using odb::dbMaster;
using odb::dbPlacementStatus;

using sta::ConcreteLibraryCellIterator;
using sta::FindNetDrvrLoads;
using sta::FuncExpr;
using sta::InstancePinIterator;
Expand Down Expand Up @@ -174,6 +175,8 @@ void Resizer::init(Logger* logger,
all_swapped_pin_inst_set_ = InstanceSet(db_network_);
all_cloned_inst_set_ = InstanceSet(db_network_);
db_cbk_ = std::make_unique<OdbCallBack>(this, network_, db_network_);

db_network_->addObserver(this);
}

////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -1803,9 +1806,21 @@ void Resizer::setDontUse(LibertyCell* cell, bool dont_use)
buffer_lowest_drive_ = nullptr;
}

void Resizer::resetDontUse()
{
dont_use_.clear();

// Reset buffer set to ensure it honors dont_use_
buffer_cells_.clear();
buffer_lowest_drive_ = nullptr;

// recopy in liberty cell dont uses
copyDontUseFromLiberty();
}

bool Resizer::dontUse(const LibertyCell* cell)
{
return cell->dontUse() || dont_use_.hasKey(const_cast<LibertyCell*>(cell));
return dont_use_.hasKey(const_cast<LibertyCell*>(cell));
}

void Resizer::reportDontUse() const
Expand Down Expand Up @@ -4005,4 +4020,32 @@ void Resizer::eliminateDeadLogic(bool clean_nets)
remove_net_count);
}

void Resizer::postReadLiberty()
{
copyDontUseFromLiberty();
}

void Resizer::copyDontUseFromLiberty()
{
std::unique_ptr<LibertyLibraryIterator> itr(
db_network_->libertyLibraryIterator());

while (itr->hasNext()) {
sta::LibertyLibrary* lib = itr->next();

std::unique_ptr<ConcreteLibraryCellIterator> cells(lib->cellIterator());

while (cells->hasNext()) {
LibertyCell* lib_cell = cells->next()->libertyCell();
if (lib_cell == nullptr) {
continue;
}

if (lib_cell->dontUse()) {
setDontUse(lib_cell, true);
}
}
}
}

} // namespace rsz
8 changes: 8 additions & 0 deletions src/rsz/src/Resizer.i
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ set_dont_use(LibertyCell *lib_cell,
resizer->setDontUse(lib_cell, dont_use);
}

void
reset_dont_use()
{
ensureLinked();
Resizer *resizer = getResizer();
resizer->resetDontUse();
}

void
set_dont_touch_instance(Instance *inst,
bool dont_touch)
Expand Down
7 changes: 7 additions & 0 deletions src/rsz/src/Resizer.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ proc unset_dont_use { args } {
set_dont_use_cmd "unset_dont_use" $args 0
}

sta::define_cmd_args "reset_dont_use" {}

proc reset_dont_use { args } {
sta::parse_key_args "reset_dont_use" args keys {} flags {}
rsz::reset_dont_use
}

proc set_dont_use_cmd { cmd cmd_args dont_use } {
sta::check_argc_eq1 $cmd $cmd_args
foreach lib_cell [sta::get_lib_cells_arg $cmd [lindex $cmd_args 0] sta::sta_warn] {
Expand Down
1 change: 1 addition & 0 deletions src/rsz/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ or_integration_tests(
fanin_fanout1
gain_buffering1
gcd_resize
liberty_dont_use
make_parasitics1
make_parasitics2
make_parasitics3
Expand Down
35 changes: 35 additions & 0 deletions src/rsz/test/liberty_dont_use.ok
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
[INFO ODB-0128] Design: gcd
[INFO ODB-0130] Created 54 pins.
[INFO ODB-0131] Created 571 components and 2554 component-terminals.
[INFO ODB-0132] Created 5 special nets and 1142 connections.
[INFO ODB-0133] Created 528 nets and 1412 connections.
Don't Use Cells:
ANTENNA_X1
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
LOGIC0_X1
LOGIC1_X1
Don't Use Cells:
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
LOGIC0_X1
LOGIC1_X1
Don't Use Cells:
ANTENNA_X1
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
LOGIC0_X1
LOGIC1_X1
18 changes: 18 additions & 0 deletions src/rsz/test/liberty_dont_use.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# check for library set dont use

source "helpers.tcl"

read_liberty Nangate45/Nangate45_typ.lib
read_lef Nangate45/Nangate45.lef
read_def "gcd_nangate45_placed.def"

report_dont_use

# unset dont_use from library
unset_dont_use "ANTENNA_X1"

report_dont_use

reset_dont_use

report_dont_use
19 changes: 18 additions & 1 deletion src/rsz/test/report_dont_use.ok
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@
[INFO ODB-0132] Created 5 special nets and 1142 connections.
[INFO ODB-0133] Created 528 nets and 1412 connections.
Don't Use Cells:
none
ANTENNA_X1
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
LOGIC0_X1
LOGIC1_X1
Don't Use Cells:
ANTENNA_X1
CLKBUF_X1
CLKBUF_X2
CLKBUF_X3
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
INV_X1
INV_X2
INV_X4
INV_X8
INV_X16
INV_X32
LOGIC0_X1
LOGIC1_X1
19 changes: 18 additions & 1 deletion src/rsz/test/report_dont_use_corners.ok
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,31 @@
[INFO ODB-0132] Created 5 special nets and 1142 connections.
[INFO ODB-0133] Created 528 nets and 1412 connections.
Don't Use Cells:
none
ANTENNA_X1
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
LOGIC0_X1
LOGIC1_X1
Don't Use Cells:
ANTENNA_X1
CLKBUF_X1
CLKBUF_X2
CLKBUF_X3
FILLCELL_X1
FILLCELL_X2
FILLCELL_X4
FILLCELL_X8
FILLCELL_X16
FILLCELL_X32
INV_X1
INV_X2
INV_X4
INV_X8
INV_X16
INV_X32
LOGIC0_X1
LOGIC1_X1

0 comments on commit beba944

Please sign in to comment.