Skip to content

Commit 58de265

Browse files
authored
Merge pull request #10367 from naveenvenk17/nv-worker10-pdn-stable-order-7746
pdn: stabilize floating shape cleanup order
2 parents b80056f + 750f0b6 commit 58de265

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

src/pdn/src/PdnGen.cc

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,34 @@ void PdnGen::writeToDb(bool add_pins, const std::string& report_file) const
881881
}
882882
}
883883

884-
std::map<Shape*, std::vector<odb::dbBox*>> shape_map;
884+
const auto shape_less = [](const Shape* lhs, const Shape* rhs) {
885+
const int lhs_layer = lhs->getLayer()->getNumber();
886+
const int rhs_layer = rhs->getLayer()->getNumber();
887+
if (lhs_layer != rhs_layer) {
888+
return lhs_layer < rhs_layer;
889+
}
890+
891+
auto* lhs_net = lhs->getNet();
892+
auto* rhs_net = rhs->getNet();
893+
if (lhs_net != rhs_net) {
894+
if (lhs_net == nullptr) {
895+
return true;
896+
}
897+
if (rhs_net == nullptr) {
898+
return false;
899+
}
900+
const auto lhs_net_id = lhs_net->getId();
901+
const auto rhs_net_id = rhs_net->getId();
902+
if (lhs_net_id != rhs_net_id) {
903+
return lhs_net_id < rhs_net_id;
904+
}
905+
}
906+
907+
return lhs->getRect() < rhs->getRect();
908+
};
909+
910+
std::map<Shape*, std::vector<odb::dbBox*>, decltype(shape_less)> shape_map(
911+
shape_less);
885912
for (auto* domain : domains) {
886913
for (const auto& grid : domain->getGrids()) {
887914
const auto db_shapes
@@ -892,7 +919,7 @@ void PdnGen::writeToDb(bool add_pins, const std::string& report_file) const
892919
}
893920
}
894921

895-
// Cleanup floating shapes due to failed vias
922+
// Cleanup floating shapes due to failed vias.
896923
for (const auto& [shape, db_shapes] : shape_map) {
897924
if (!shape->isLocked() && !shape->hasInternalConnections()) {
898925
for (odb::dbBox* db_box : db_shapes) {

0 commit comments

Comments
 (0)