@@ -614,6 +614,14 @@ void PadDirectConnectionStraps::initialize(ConnectionType type)
614614 pins_ = getPinsFormingRing ();
615615 break ;
616616 }
617+
618+ debugPrint (getLogger (),
619+ utl::PDN,
620+ " Pad" ,
621+ 2 ,
622+ " {} has {} pins" ,
623+ getName (),
624+ pins_.size ());
617625}
618626
619627std::map<odb::dbTechLayer*, std::vector<odb::dbBox*>>
@@ -653,8 +661,6 @@ std::vector<odb::dbBox*> PadDirectConnectionStraps::getPinsFacingCore()
653661
654662 const bool is_horizontal = is_west || is_east;
655663
656- std::vector<odb::dbBox*> pins;
657-
658664 auto pins_by_layer = getPinsByLayer ();
659665 if (!layers_.empty ()) {
660666 // remove unspecified layers
@@ -669,37 +675,6 @@ std::vector<odb::dbBox*> PadDirectConnectionStraps::getPinsFacingCore()
669675 }
670676 }
671677
672- // check for pin directions
673- bool has_horizontal_pins = false ;
674- bool has_vertical_pins = false ;
675- for (const auto & [layer, layer_pins] : pins_by_layer) {
676- if (layer->getDirection () == odb::dbTechLayerDir::HORIZONTAL) {
677- has_horizontal_pins = true ;
678- }
679- if (layer->getDirection () == odb::dbTechLayerDir::VERTICAL) {
680- has_vertical_pins = true ;
681- }
682- }
683-
684- const bool has_multiple_directions = has_horizontal_pins && has_vertical_pins;
685-
686- for (const auto & [layer, layer_pins] : pins_by_layer) {
687- if (has_multiple_directions) {
688- // only add pins that would yield correct routing directions,
689- // otherwise keep non-preferred directions too
690- if (is_horizontal) {
691- if (layer->getDirection () != odb::dbTechLayerDir::HORIZONTAL) {
692- continue ;
693- }
694- } else {
695- if (layer->getDirection () != odb::dbTechLayerDir::VERTICAL) {
696- continue ;
697- }
698- }
699- }
700- pins.insert (pins.end (), layer_pins.begin (), layer_pins.end ());
701- }
702-
703678 const odb::dbTransform transform = inst->getTransform ();
704679
705680 // remove all pins that do not face the core
@@ -730,8 +705,52 @@ std::vector<odb::dbBox*> PadDirectConnectionStraps::getPinsFacingCore()
730705 };
731706 }
732707
733- pins.erase (std::remove_if (pins.begin (), pins.end (), std::move (remove_func)),
734- pins.end ());
708+ for (auto & [layer, layerpins] : pins_by_layer) {
709+ layerpins.erase (
710+ std::remove_if (layerpins.begin (), layerpins.end (), remove_func),
711+ layerpins.end ());
712+ }
713+
714+ for (auto itr = pins_by_layer.begin (); itr != pins_by_layer.end ();) {
715+ if (itr->second .empty ()) {
716+ // remove empty layer
717+ itr = pins_by_layer.erase (itr);
718+ } else {
719+ itr++;
720+ }
721+ }
722+
723+ // check for pin directions
724+ bool has_horizontal_pins = false ;
725+ bool has_vertical_pins = false ;
726+ for (const auto & [layer, layer_pins] : pins_by_layer) {
727+ if (layer->getDirection () == odb::dbTechLayerDir::HORIZONTAL) {
728+ has_horizontal_pins = true ;
729+ }
730+ if (layer->getDirection () == odb::dbTechLayerDir::VERTICAL) {
731+ has_vertical_pins = true ;
732+ }
733+ }
734+
735+ const bool has_multiple_directions = has_horizontal_pins && has_vertical_pins;
736+
737+ std::vector<odb::dbBox*> pins;
738+ for (const auto & [layer, layer_pins] : pins_by_layer) {
739+ if (has_multiple_directions) {
740+ // only add pins that would yield correct routing directions,
741+ // otherwise keep non-preferred directions too
742+ if (is_horizontal) {
743+ if (layer->getDirection () != odb::dbTechLayerDir::HORIZONTAL) {
744+ continue ;
745+ }
746+ } else {
747+ if (layer->getDirection () != odb::dbTechLayerDir::VERTICAL) {
748+ continue ;
749+ }
750+ }
751+ }
752+ pins.insert (pins.end (), layer_pins.begin (), layer_pins.end ());
753+ }
735754
736755 if (!pins.empty ()) {
737756 type_ = ConnectionType::Edge;
0 commit comments