diff --git a/src/rsz/README.md b/src/rsz/README.md index 188fbc3c6ae..5783e326eb2 100644 --- a/src/rsz/README.md +++ b/src/rsz/README.md @@ -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. diff --git a/src/rsz/include/rsz/Resizer.hh b/src/rsz/include/rsz/Resizer.hh index a18881abaf2..8fd1e8aaa04 100644 --- a/src/rsz/include/rsz/Resizer.hh +++ b/src/rsz/include/rsz/Resizer.hh @@ -39,6 +39,7 @@ #include #include +#include "db_sta/dbNetwork.hh" #include "db_sta/dbSta.hh" #include "dpl/Opendp.h" #include "rsz/OdbCallBack.hh" @@ -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; @@ -183,7 +185,7 @@ struct BufferData class OdbCallBack; -class Resizer : public dbStaState +class Resizer : public dbStaState, public dbNetworkObserver { public: Resizer(); @@ -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); @@ -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(); @@ -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(); diff --git a/src/rsz/src/Resizer.cc b/src/rsz/src/Resizer.cc index 0c370ef5e28..6f9a6493bfa 100644 --- a/src/rsz/src/Resizer.cc +++ b/src/rsz/src/Resizer.cc @@ -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; @@ -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(this, network_, db_network_); + + db_network_->addObserver(this); } //////////////////////////////////////////////////////////////// @@ -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(cell)); + return dont_use_.hasKey(const_cast(cell)); } void Resizer::reportDontUse() const @@ -4005,4 +4020,32 @@ void Resizer::eliminateDeadLogic(bool clean_nets) remove_net_count); } +void Resizer::postReadLiberty() +{ + copyDontUseFromLiberty(); +} + +void Resizer::copyDontUseFromLiberty() +{ + std::unique_ptr itr( + db_network_->libertyLibraryIterator()); + + while (itr->hasNext()) { + sta::LibertyLibrary* lib = itr->next(); + + std::unique_ptr 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 diff --git a/src/rsz/src/Resizer.i b/src/rsz/src/Resizer.i index 5f25a66774c..7d936f06579 100644 --- a/src/rsz/src/Resizer.i +++ b/src/rsz/src/Resizer.i @@ -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) diff --git a/src/rsz/src/Resizer.tcl b/src/rsz/src/Resizer.tcl index 516c74511ff..5b7b4d006e8 100644 --- a/src/rsz/src/Resizer.tcl +++ b/src/rsz/src/Resizer.tcl @@ -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] { diff --git a/src/rsz/test/CMakeLists.txt b/src/rsz/test/CMakeLists.txt index c2af54ae80b..b8305afe2ff 100644 --- a/src/rsz/test/CMakeLists.txt +++ b/src/rsz/test/CMakeLists.txt @@ -18,6 +18,7 @@ or_integration_tests( fanin_fanout1 gain_buffering1 gcd_resize + liberty_dont_use make_parasitics1 make_parasitics2 make_parasitics3 diff --git a/src/rsz/test/liberty_dont_use.ok b/src/rsz/test/liberty_dont_use.ok new file mode 100644 index 00000000000..c7217b2cb89 --- /dev/null +++ b/src/rsz/test/liberty_dont_use.ok @@ -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 diff --git a/src/rsz/test/liberty_dont_use.tcl b/src/rsz/test/liberty_dont_use.tcl new file mode 100644 index 00000000000..14a8c525bc4 --- /dev/null +++ b/src/rsz/test/liberty_dont_use.tcl @@ -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 diff --git a/src/rsz/test/report_dont_use.ok b/src/rsz/test/report_dont_use.ok index f6b907cee8d..d2745ecb25f 100644 --- a/src/rsz/test/report_dont_use.ok +++ b/src/rsz/test/report_dont_use.ok @@ -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 diff --git a/src/rsz/test/report_dont_use_corners.ok b/src/rsz/test/report_dont_use_corners.ok index f6b907cee8d..d2745ecb25f 100644 --- a/src/rsz/test/report_dont_use_corners.ok +++ b/src/rsz/test/report_dont_use_corners.ok @@ -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