From 45bddde7fe0636e8012b75f53a701cb4e0b75dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 10 Jul 2025 11:41:02 +0200 Subject: [PATCH] dbSta: Fix swap master callbacks after sta change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin PoviĊĦer --- src/dbSta/src/dbSta.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/dbSta/src/dbSta.cc b/src/dbSta/src/dbSta.cc index 51000ae67cc..da91bf7d6a7 100644 --- a/src/dbSta/src/dbSta.cc +++ b/src/dbSta/src/dbSta.cc @@ -166,6 +166,9 @@ class dbStaCbk : public dbBlockCallBackObj void inDbBTermSetSigType(dbBTerm* bterm, const dbSigType& sig_type) override; private: + // for inDbInstSwapMasterBefore/inDbInstSwapMasterAfter + bool swap_master_arcs_equiv_ = false; + dbSta* sta_; dbNetwork* network_ = nullptr; Logger* logger_; @@ -724,7 +727,10 @@ void dbSta::deleteInstance(Instance* inst) void dbSta::replaceCell(Instance* inst, Cell* to_cell, LibertyCell* to_lib_cell) { - Sta::replaceCell(inst, to_cell, to_lib_cell); + // do not call `Sta::replaceCell` as sta's before/after hooks are called + // from db callbacks + NetworkEdit* network = networkCmdEdit(); + network->replaceCell(inst, to_cell); } void dbSta::deleteNet(Net* net) @@ -923,20 +929,25 @@ void dbStaCbk::inDbInstSwapMasterBefore(dbInst* inst, dbMaster* master) LibertyCell* to_lib_cell = network_->libertyCell(network_->dbToSta(master)); LibertyCell* from_lib_cell = network_->libertyCell(inst); Instance* sta_inst = network_->dbToSta(inst); - if (sta::equivCells(from_lib_cell, to_lib_cell)) { + + swap_master_arcs_equiv_ = sta::equivCellsArcs(from_lib_cell, to_lib_cell); + + if (swap_master_arcs_equiv_) { sta_->replaceEquivCellBefore(sta_inst, to_lib_cell); } else { - logger_->error(STA, - 1000, - "instance {} swap master {} is not equivalent", - inst->getConstName(), - master->getConstName()); + sta_->replaceCellBefore(sta_inst, to_lib_cell); } } void dbStaCbk::inDbInstSwapMasterAfter(dbInst* inst) { - sta_->replaceEquivCellAfter(network_->dbToSta(inst)); + Instance* sta_inst = network_->dbToSta(inst); + + if (swap_master_arcs_equiv_) { + sta_->replaceEquivCellAfter(sta_inst); + } else { + sta_->replaceCellAfter(sta_inst); + } } void dbStaCbk::inDbNetDestroy(dbNet* db_net)