@@ -647,6 +647,93 @@ void Grid::checkSetup() const
647647 }
648648 }
649649 }
650+
651+ // Check connectivity
652+ std::set<odb::dbTechLayer*> check_layers;
653+ for (const auto & ring : rings_) {
654+ for (auto * layer : ring->getLayers ()) {
655+ check_layers.insert (layer);
656+ }
657+ }
658+ for (const auto & strap : straps_) {
659+ check_layers.insert (strap->getLayer ());
660+ }
661+
662+ // Check that pin layers actually exists in stack
663+ for (auto * layer : pin_layers_) {
664+ if (check_layers.find (layer) == check_layers.end ()) {
665+ getLogger ()->error (utl::PDN,
666+ 111 ,
667+ " Pin layer {} is not a valid shape in {}" ,
668+ layer->getName (),
669+ name_);
670+ }
671+ }
672+
673+ // add instance layers
674+ const auto nets_vec = getNets ();
675+ const std::set<odb::dbNet*> nets (nets_vec.begin (), nets_vec.end ());
676+
677+ for (auto * inst : getInstances ()) {
678+ if (!inst->isFixed ()) {
679+ continue ;
680+ }
681+ for (auto * iterm : inst->getITerms ()) {
682+ if (nets.find (iterm->getNet ()) != nets.end ()) {
683+ for (const auto & [layer, shape] : iterm->getGeometries ()) {
684+ check_layers.insert (layer);
685+ }
686+ }
687+ }
688+ }
689+ if (domain_->hasSwitchedPower ()) {
690+ for (const auto & powercell :
691+ domain_->getPDNGen ()->getSwitchedPowerCells ()) {
692+ for (auto * mterm : powercell->getMaster ()->getMTerms ()) {
693+ for (auto * mpin : mterm->getMPins ()) {
694+ for (auto * box : mpin->getGeometry ()) {
695+ auto * layer = box->getTechLayer ();
696+ if (layer) {
697+ check_layers.insert (layer);
698+ }
699+ }
700+ }
701+ }
702+ }
703+ }
704+
705+ // add bterms
706+ for (auto * net : nets) {
707+ for (auto * bterm : net->getBTerms ()) {
708+ for (auto * bpin : bterm->getBPins ()) {
709+ if (!bpin->getPlacementStatus ().isFixed ()) {
710+ continue ;
711+ }
712+ for (auto * box : bpin->getBoxes ()) {
713+ auto * layer = box->getTechLayer ();
714+ if (layer) {
715+ check_layers.insert (layer);
716+ }
717+ }
718+ }
719+ }
720+ }
721+
722+ // Check that connect statement actually point to something
723+ for (const auto & connect : connect_) {
724+ if (check_layers.find (connect->getLowerLayer ()) == check_layers.end ()) {
725+ getLogger ()->error (utl::PDN,
726+ 112 ,
727+ " Cannot find shapes to connect to on {}" ,
728+ connect->getLowerLayer ()->getName ());
729+ }
730+ if (check_layers.find (connect->getUpperLayer ()) == check_layers.end ()) {
731+ getLogger ()->error (utl::PDN,
732+ 113 ,
733+ " Cannot find shapes to connect to on {}" ,
734+ connect->getLowerLayer ()->getName ());
735+ }
736+ }
650737}
651738
652739void Grid::getObstructions (Shape::ObstructionTreeMap& obstructions) const
0 commit comments