@@ -166,6 +166,9 @@ class dbStaCbk : public dbBlockCallBackObj
166166 void inDbBTermSetSigType (dbBTerm* bterm, const dbSigType& sig_type) override ;
167167
168168 private:
169+ // for inDbInstSwapMasterBefore/inDbInstSwapMasterAfter
170+ bool swap_master_arcs_equiv_ = false ;
171+
169172 dbSta* sta_;
170173 dbNetwork* network_ = nullptr ;
171174 Logger* logger_;
@@ -724,7 +727,10 @@ void dbSta::deleteInstance(Instance* inst)
724727
725728void dbSta::replaceCell (Instance* inst, Cell* to_cell, LibertyCell* to_lib_cell)
726729{
727- Sta::replaceCell (inst, to_cell, to_lib_cell);
730+ // do not call `Sta::replaceCell` as sta's before/after hooks are called
731+ // from db callbacks
732+ NetworkEdit* network = networkCmdEdit ();
733+ network->replaceCell (inst, to_cell);
728734}
729735
730736void dbSta::deleteNet (Net* net)
@@ -923,20 +929,25 @@ void dbStaCbk::inDbInstSwapMasterBefore(dbInst* inst, dbMaster* master)
923929 LibertyCell* to_lib_cell = network_->libertyCell (network_->dbToSta (master));
924930 LibertyCell* from_lib_cell = network_->libertyCell (inst);
925931 Instance* sta_inst = network_->dbToSta (inst);
926- if (sta::equivCells (from_lib_cell, to_lib_cell)) {
932+
933+ swap_master_arcs_equiv_ = sta::equivCellsArcs (from_lib_cell, to_lib_cell);
934+
935+ if (swap_master_arcs_equiv_) {
927936 sta_->replaceEquivCellBefore (sta_inst, to_lib_cell);
928937 } else {
929- logger_->error (STA,
930- 1000 ,
931- " instance {} swap master {} is not equivalent" ,
932- inst->getConstName (),
933- master->getConstName ());
938+ sta_->replaceCellBefore (sta_inst, to_lib_cell);
934939 }
935940}
936941
937942void dbStaCbk::inDbInstSwapMasterAfter (dbInst* inst)
938943{
939- sta_->replaceEquivCellAfter (network_->dbToSta (inst));
944+ Instance* sta_inst = network_->dbToSta (inst);
945+
946+ if (swap_master_arcs_equiv_) {
947+ sta_->replaceEquivCellAfter (sta_inst);
948+ } else {
949+ sta_->replaceCellAfter (sta_inst);
950+ }
940951}
941952
942953void dbStaCbk::inDbNetDestroy (dbNet* db_net)
0 commit comments