From ce82952c5a3f50e1cb7e88b3c9b8e4b16d9d5cd6 Mon Sep 17 00:00:00 2001
From: bernardo <bernardoborgessandoval@gmail.com>
Date: Tue, 10 Dec 2024 15:47:14 +0000
Subject: [PATCH] drt: grt conformance to new and better pin access orientation

Signed-off-by: bernardo <bernardoborgessandoval@gmail.com>
---
 src/drt/src/db/obj/frInst.h       |  2 +-
 src/drt/src/db/obj/frInstTerm.cpp |  6 +++---
 src/drt/src/db/obj/frRPin.cpp     |  4 ++--
 src/drt/src/db/obj/frVia.h        |  2 --
 src/drt/src/dr/FlexDR.h           |  2 +-
 src/drt/src/dr/FlexDR_init.cpp    | 12 ++++++------
 src/drt/src/gr/FlexGR.cpp         |  4 ++--
 src/drt/src/pa/FlexPA_prep.cpp    | 10 +++++-----
 src/drt/src/ta/FlexTA_init.cpp    |  8 ++++----
 src/grt/src/GlobalRouter.cpp      |  6 +-----
 10 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/src/drt/src/db/obj/frInst.h b/src/drt/src/db/obj/frInst.h
index d5829ed734f..bd060e346d6 100644
--- a/src/drt/src/db/obj/frInst.h
+++ b/src/drt/src/db/obj/frInst.h
@@ -96,7 +96,7 @@ class frInst : public frRef
     return db_inst_->getTransform().getOffset();
   }
   odb::dbInst* getDBInst() const { return db_inst_; }
-  dbTransform getTransform() const { return db_inst_->getTransform(); }
+  dbTransform getTransform() const override { return db_inst_->getTransform(); }
 
   /* from frPinFig
    * hasPin
diff --git a/src/drt/src/db/obj/frInstTerm.cpp b/src/drt/src/db/obj/frInstTerm.cpp
index e9940f3313d..27a1bc1decd 100644
--- a/src/drt/src/db/obj/frInstTerm.cpp
+++ b/src/drt/src/db/obj/frInstTerm.cpp
@@ -40,10 +40,10 @@ frString frInstTerm::getName() const
 frAccessPoint* frInstTerm::getAccessPoint(frCoord x, frCoord y, frLayerNum lNum)
 {
   auto inst = getInst();
-  dbTransform shiftXform;
-  inst->getTransform().invert(shiftXform);
+  dbTransform transform;
+  inst->getTransform().invert(transform);
   Point pt(x, y);
-  shiftXform.apply(pt);
+  transform.apply(pt);
   return term_->getAccessPoint(
       pt.getX(), pt.getY(), lNum, inst->getPinAccessIdx());
 }
diff --git a/src/drt/src/db/obj/frRPin.cpp b/src/drt/src/db/obj/frRPin.cpp
index a9d4c0858a9..a810b7ebaa4 100644
--- a/src/drt/src/db/obj/frRPin.cpp
+++ b/src/drt/src/db/obj/frRPin.cpp
@@ -40,10 +40,10 @@ Rect frRPin::getBBox()
   switch (term->typeId()) {
     case frcInstTerm: {
       auto inst = static_cast<frInstTerm*>(term)->getInst();
-      dbTransform shiftXform = inst->getTransform();
+      dbTransform = inst->getTransform();
 
       pt = accessPoint->getPoint();
-      shiftXform.apply(pt);
+      .apply(pt);
       break;
     }
     case frcBTerm:
diff --git a/src/drt/src/db/obj/frVia.h b/src/drt/src/db/obj/frVia.h
index 668feb4a8d8..c0920c78ed9 100644
--- a/src/drt/src/db/obj/frVia.h
+++ b/src/drt/src/db/obj/frVia.h
@@ -102,11 +102,9 @@ class frVia : public frRef
    */
 
   dbOrientType getOrient() const override { return dbOrientType(); }
-  void setOrient(const dbOrientType& tmpOrient) { ; }
   Point getOrigin() const override { return origin_; }
   void setOrigin(const Point& tmpPoint) { origin_ = tmpPoint; }
   dbTransform getTransform() const override { return origin_; }
-  void setTransform(const dbTransform& xformIn) {}
 
   /* from frPinFig
    * hasPin
diff --git a/src/drt/src/dr/FlexDR.h b/src/drt/src/dr/FlexDR.h
index 6a3620ad87a..fd35ce94652 100644
--- a/src/drt/src/dr/FlexDR.h
+++ b/src/drt/src/dr/FlexDR.h
@@ -709,7 +709,7 @@ class FlexDRWorker
                            frInst* inst,
                            drNet* dNet,
                            const std::string& name,
-                           const dbTransform& shiftXform);
+                           const dbTransform&);
   bool isRestrictedRouting(frLayerNum lNum);
   void initNet_addNet(std::unique_ptr<drNet> in);
   void getTrackLocs(bool isHorzTracks,
diff --git a/src/drt/src/dr/FlexDR_init.cpp b/src/drt/src/dr/FlexDR_init.cpp
index ed97850da43..0a69e5a8b11 100644
--- a/src/drt/src/dr/FlexDR_init.cpp
+++ b/src/drt/src/dr/FlexDR_init.cpp
@@ -1177,23 +1177,23 @@ void FlexDRWorker::initNet_term(const frDesign* design,
 {
   for (auto term : terms) {
     // ap
-    dbTransform shiftXform;
+    dbTransform transform;
     switch (term->typeId()) {
       case frcInstTerm: {
         auto instTerm = static_cast<frInstTerm*>(term);
         frInst* inst = instTerm->getInst();
-        shiftXform = inst->getTransform();
+        transform = inst->getTransform();
         auto trueTerm = instTerm->getTerm();
         const std::string name = inst->getName() + "/" + trueTerm->getName();
         initNet_term_helper(
-            design, trueTerm, term, inst, dNet, name, shiftXform);
+            design, trueTerm, term, inst, dNet, name, transform);
         break;
       }
       case frcBTerm: {
         auto trueTerm = static_cast<frBTerm*>(term);
         const std::string name = "PIN/" + trueTerm->getName();
         initNet_term_helper(
-            design, trueTerm, term, nullptr, dNet, name, shiftXform);
+            design, trueTerm, term, nullptr, dNet, name, transform);
         break;
       }
       default:
@@ -1210,7 +1210,7 @@ void FlexDRWorker::initNet_term_helper(const frDesign* design,
                                        frInst* inst,
                                        drNet* dNet,
                                        const std::string& name,
-                                       const dbTransform& shiftXform)
+                                       const dbTransform& transform)
 {
   auto dPin = std::make_unique<drPin>();
   dPin->setFrTerm(term);
@@ -1228,7 +1228,7 @@ void FlexDRWorker::initNet_term_helper(const frDesign* design,
     for (auto& ap : pin->getPinAccess(pinAccessIdx)->getAccessPoints()) {
       Point bp = ap->getPoint();
       const auto bNum = ap->getLayerNum();
-      shiftXform.apply(bp);
+      transform.apply(bp);
 
       auto dAp = std::make_unique<drAccessPattern>();
       dAp->setPoint(bp);
diff --git a/src/drt/src/gr/FlexGR.cpp b/src/drt/src/gr/FlexGR.cpp
index 764389b9a02..7034e0ff293 100644
--- a/src/drt/src/gr/FlexGR.cpp
+++ b/src/drt/src/gr/FlexGR.cpp
@@ -1642,9 +1642,9 @@ void FlexGR::initGR_genTopology_net(frNet* net)
       Point pt;
       if (rpin->getFrTerm()->typeId() == frcInstTerm) {
         auto inst = static_cast<frInstTerm*>(rpin->getFrTerm())->getInst();
-        dbTransform shiftXform = inst->getTransform();
+        dbTransform = inst->getTransform();
         pt = rpin->getAccessPoint()->getPoint();
-        shiftXform.apply(pt);
+        .apply(pt);
       } else {
         pt = rpin->getAccessPoint()->getPoint();
       }
diff --git a/src/drt/src/pa/FlexPA_prep.cpp b/src/drt/src/pa/FlexPA_prep.cpp
index 319475bb260..8671318adf6 100644
--- a/src/drt/src/pa/FlexPA_prep.cpp
+++ b/src/drt/src/pa/FlexPA_prep.cpp
@@ -1789,8 +1789,8 @@ void FlexPA::revertAccessPoints()
 {
   const auto& unique = unique_insts_.getUnique();
   for (auto& inst : unique) {
-    dbTransform revertXform;
-    inst->getTransform().invert(revertXform);
+    dbTransform revert_transform;
+    inst->getTransform().invert(revert_transform);
 
     const auto pin_access_idx = unique_insts_.getPAIndex(inst);
     for (auto& inst_term : inst->getInstTerms()) {
@@ -1802,13 +1802,13 @@ void FlexPA::revertAccessPoints()
         auto pin_access = pin->getPinAccess(pin_access_idx);
         for (auto& access_point : pin_access->getAccessPoints()) {
           Point unique_AP_point(access_point->getPoint());
-          revertXform.apply(unique_AP_point);
+          revert_transform.apply(unique_AP_point);
           access_point->setPoint(unique_AP_point);
           for (auto& ps : access_point->getPathSegs()) {
             Point begin = ps.getBeginPoint();
             Point end = ps.getEndPoint();
-            revertXform.apply(begin);
-            revertXform.apply(end);
+            revert_transform.apply(begin);
+            revert_transform.apply(end);
             if (end < begin) {
               Point tmp = begin;
               begin = end;
diff --git a/src/drt/src/ta/FlexTA_init.cpp b/src/drt/src/ta/FlexTA_init.cpp
index e35bb572be6..b792e51cea1 100644
--- a/src/drt/src/ta/FlexTA_init.cpp
+++ b/src/drt/src/ta/FlexTA_init.cpp
@@ -137,7 +137,7 @@ bool FlexTAWorker::initIroute_helper_pin(frGuide* guide,
           continue;
         }
         frInst* inst = iterm->getInst();
-        dbTransform shiftXform = inst->getTransform();
+        dbTransform = inst->getTransform();
         frMTerm* mterm = iterm->getTerm();
         int pinIdx = 0;
         for (auto& pin : mterm->getPins()) {
@@ -153,7 +153,7 @@ bool FlexTAWorker::initIroute_helper_pin(frGuide* guide,
           }
           Point bp = ap->getPoint();
           auto bNum = ap->getLayerNum();
-          shiftXform.apply(bp);
+          .apply(bp);
           if (layerNum == bNum && getRouteBox().intersects(bp)) {
             pinCoord = isH ? bp.y() : bp.x();
             maxBegin = isH ? bp.x() : bp.y();
@@ -258,7 +258,7 @@ void FlexTAWorker::initIroute_helper_generic_helper(frGuide* guide,
           continue;
         }
         frInst* inst = iterm->getInst();
-        dbTransform shiftXform = inst->getTransform();
+        dbTransform = inst->getTransform();
         frMTerm* mterm = iterm->getTerm();
         int pinIdx = 0;
         for (auto& pin : mterm->getPins()) {
@@ -285,7 +285,7 @@ void FlexTAWorker::initIroute_helper_generic_helper(frGuide* guide,
             }
           }
           Point bp = ap->getPoint();
-          shiftXform.apply(bp);
+          .apply(bp);
           if (getRouteBox().intersects(bp)) {
             pinCoord = isH ? bp.y() : bp.x();
             return;
diff --git a/src/grt/src/GlobalRouter.cpp b/src/grt/src/GlobalRouter.cpp
index 4d5ee665932..a27ab17e2c0 100644
--- a/src/grt/src/GlobalRouter.cpp
+++ b/src/grt/src/GlobalRouter.cpp
@@ -904,11 +904,7 @@ bool GlobalRouter::findPinAccessPointPositions(
   for (const odb::dbAccessPoint* ap : access_points) {
     odb::Point ap_position = ap->getPoint();
     if (!pin.isPort()) {
-      odb::dbTransform xform;
-      int x, y;
-      pin.getITerm()->getInst()->getLocation(x, y);
-      xform.setOffset({x, y});
-      xform.setOrient(odb::dbOrientType(odb::dbOrientType::R0));
+      odb::dbTransform xform = pin.getITerm()->getInst()->getTransform();
       xform.apply(ap_position);
     }