@@ -1001,7 +1001,6 @@ void Resizer::bufferInputs(sta::LibertyCell* buffer_cell, bool verbose)
10011001
10021002 sta_->ensureClkNetwork (sta_->cmdMode ());
10031003 inserted_buffer_count_ = 0 ;
1004- buffer_moved_into_core_ = false ;
10051004
10061005 {
10071006 est::IncrementalParasiticsGuard guard (estimate_parasitics_);
@@ -1139,7 +1138,6 @@ void Resizer::bufferOutputs(sta::LibertyCell* buffer_cell, bool verbose)
11391138 }
11401139
11411140 inserted_buffer_count_ = 0 ;
1142- buffer_moved_into_core_ = false ;
11431141
11441142 {
11451143 est::IncrementalParasiticsGuard guard (estimate_parasitics_);
@@ -5123,6 +5121,11 @@ sta::Instance* Resizer::makeInstance(sta::LibertyCell* cell,
51235121
51245122void Resizer::insertBufferPostProcess (dbInst* buffer_inst)
51255123{
5124+ // ODB's insertBuffer* already placed the instance; re-run through
5125+ // setLocation so clampLocToCore can pull it back inside the core if
5126+ // the insertion point landed in the die-core gap.
5127+ setLocation (buffer_inst, buffer_inst->getLocation ());
5128+
51265129 // Legalize the cell position for accurate parasitic estimation
51275130 if (estimate_parasitics_->getParasiticsSrc ()
51285131 == est::ParasiticsSrc::kGlobalRouting
@@ -5145,33 +5148,35 @@ void Resizer::insertBufferPostProcess(dbInst* buffer_inst)
51455148
51465149void Resizer::setLocation (dbInst* db_inst, const odb::Point& pt)
51475150{
5148- int x = pt.x ();
5149- int y = pt.y ();
5150- // Stay inside the lines.
5151- if (core_exists_) {
5152- dbMaster* master = db_inst->getMaster ();
5153- int width = master->getWidth ();
5154- if (x < core_.xMin ()) {
5155- x = core_.xMin ();
5156- buffer_moved_into_core_ = true ;
5157- } else if (x > core_.xMax () - width) {
5158- // Make sure the instance is entirely inside core.
5159- x = core_.xMax () - width;
5160- buffer_moved_into_core_ = true ;
5161- }
5162-
5163- int height = master->getHeight ();
5164- if (y < core_.yMin ()) {
5165- y = core_.yMin ();
5166- buffer_moved_into_core_ = true ;
5167- } else if (y > core_.yMax () - height) {
5168- y = core_.yMax () - height;
5169- buffer_moved_into_core_ = true ;
5170- }
5151+ const odb::Point loc = clampLocToCore (pt, db_inst->getMaster ());
5152+ db_inst->setPlacementStatus (dbPlacementStatus::PLACED );
5153+ db_inst->setLocation (loc.x (), loc.y ());
5154+ if (loc != pt) {
5155+ debugPrint (logger_,
5156+ RSZ ,
5157+ " buffer_clamp" ,
5158+ 1 ,
5159+ " {} clamped to core ({}, {}) -> ({}, {})" ,
5160+ db_inst->getName (),
5161+ pt.x (),
5162+ pt.y (),
5163+ loc.x (),
5164+ loc.y ());
51715165 }
5166+ }
51725167
5173- db_inst->setPlacementStatus (dbPlacementStatus::PLACED );
5174- db_inst->setLocation (x, y);
5168+ odb::Point Resizer::clampLocToCore (const odb::Point& loc,
5169+ odb::dbMaster* master) const
5170+ {
5171+ if (!core_exists_) {
5172+ return loc;
5173+ }
5174+ const int x_max = std::max (
5175+ core_.xMin (), core_.xMax () - static_cast <int >(master->getWidth ()));
5176+ const int y_max = std::max (
5177+ core_.yMin (), core_.yMax () - static_cast <int >(master->getHeight ()));
5178+ return {std::clamp (loc.x (), core_.xMin (), x_max),
5179+ std::clamp (loc.y (), core_.yMin (), y_max)};
51755180}
51765181
51775182float Resizer::portCapacitance (sta::LibertyPort* input,
@@ -5281,13 +5286,6 @@ void Resizer::checkLoadSlews(const sta::Pin* drvr_pin,
52815286 delete pin_iter;
52825287}
52835288
5284- void Resizer::warnBufferMovedIntoCore ()
5285- {
5286- if (buffer_moved_into_core_) {
5287- logger_->warn (RSZ , 77 , " some buffers were moved inside the core." );
5288- }
5289- }
5290-
52915289void Resizer::setDebugPin (const sta::Pin* pin)
52925290{
52935291 debug_pin_ = pin;
0 commit comments