@@ -257,24 +257,15 @@ odb::Rect getBoundarySegment(const odb::Rect& bbox,
257257 return segment;
258258}
259259
260- // Returns (top_pwr, bot_pwr) for the master's rails. Power_UNK when an edge
261- // has no rail, or when POWER and GROUND both touch it.
262- //
263- // Each MPin rectangle is tested individually, since a single MPin can hold
264- // rails on both edges (e.g. double-height cells with VSS at top and bottom)
265- // or include internal straps that would pull a per-pin bbox center off the
266- // rail. Only ROUTING-layer geometry counts, to ignore NWELL/PWELL implants
267- // (encoded as POWER/GROUND pins on MASTERSLICE layers) from polluting the
268- // rail detection.
269260std::pair<int , int > getMasterPwrs (odb::dbMaster* master)
270261{
271- int maxPwr = std::numeric_limits<int >::min ();
272- int minPwr = std::numeric_limits<int >::max ();
273- int maxGnd = std::numeric_limits<int >::min ();
274- int minGnd = std::numeric_limits<int >::max ();
262+ int max_pwr = std::numeric_limits<int >::min ();
263+ int min_pwr = std::numeric_limits<int >::max ();
264+ int max_gnd = std::numeric_limits<int >::min ();
265+ int min_gnd = std::numeric_limits<int >::max ();
275266
276- bool isVdd = false ;
277- bool isGnd = false ;
267+ bool has_pwr = false ;
268+ bool has_gnd = false ;
278269
279270 for (odb::dbMTerm* mterm : master->getMTerms ()) {
280271 const odb::dbSigType st = mterm->getSigType ();
@@ -294,32 +285,31 @@ std::pair<int, int> getMasterPwrs(odb::dbMaster* master)
294285 continue ;
295286 }
296287
297- // Only count the rail as present when routing geometry is confirmed
298288 const int y = box->getBox ().yCenter ();
299289
300290 if (is_pwr) {
301- isVdd = true ;
302- minPwr = std::min (minPwr , y);
303- maxPwr = std::max (maxPwr , y);
291+ has_pwr = true ;
292+ min_pwr = std::min (min_pwr , y);
293+ max_pwr = std::max (max_pwr , y);
304294 } else {
305- isGnd = true ;
306- minGnd = std::min (minGnd , y);
307- maxGnd = std::max (maxGnd , y);
295+ has_gnd = true ;
296+ min_gnd = std::min (min_gnd , y);
297+ max_gnd = std::max (max_gnd , y);
308298 }
309299 }
310300 }
311301 }
312302
313- int topPwr = Architecture::Row::Power_UNK;
314- int botPwr = Architecture::Row::Power_UNK;
303+ int top_pwr = Architecture::Row::Power_UNK;
304+ int bot_pwr = Architecture::Row::Power_UNK;
315305
316- if (isVdd && isGnd ) {
317- topPwr = (maxPwr > maxGnd ) ? Architecture::Row::Power_VDD
318- : Architecture::Row::Power_VSS;
319- botPwr = (minPwr < minGnd ) ? Architecture::Row::Power_VDD
320- : Architecture::Row::Power_VSS;
306+ if (has_pwr && has_gnd ) {
307+ top_pwr = (max_pwr > max_gnd ) ? Architecture::Row::Power_VDD
308+ : Architecture::Row::Power_VSS;
309+ bot_pwr = (min_pwr < min_gnd ) ? Architecture::Row::Power_VDD
310+ : Architecture::Row::Power_VSS;
321311 }
322- return {topPwr, botPwr };
312+ return {top_pwr, bot_pwr };
323313}
324314
325315} // namespace
0 commit comments