diff --git a/src/drt/src/DesignCallBack.cpp b/src/drt/src/DesignCallBack.cpp index 955aa28ff6..722319a7d3 100644 --- a/src/drt/src/DesignCallBack.cpp +++ b/src/drt/src/DesignCallBack.cpp @@ -66,8 +66,6 @@ void DesignCallBack::inDbPostMoveInst(odb::dbInst* db_inst) auto block = db_inst->getBlock(); x = defdist(block, x); y = defdist(block, y); - inst->setOrigin({x, y}); - inst->setOrient(db_inst->getOrient()); if (design->getRegionQuery() != nullptr) { design->getRegionQuery()->addBlockObj(inst); } diff --git a/src/drt/src/db/obj/frInst.cpp b/src/drt/src/db/obj/frInst.cpp index c8f05497fb..fc9d67632d 100644 --- a/src/drt/src/db/obj/frInst.cpp +++ b/src/drt/src/db/obj/frInst.cpp @@ -35,26 +35,17 @@ namespace drt { Rect frInst::getBBox() const { Rect box = getMaster()->getBBox(); - dbTransform xform = getDBTransform(); - xform.apply(box); + getTransform().apply(box); return box; } Rect frInst::getBoundaryBBox() const { Rect box = getMaster()->getDieBox(); - dbTransform xform = getDBTransform(); - xform.apply(box); + getTransform().apply(box); return box; } -dbTransform frInst::getNoRotationTransform() const -{ - dbTransform xfm = getTransform(); - xfm.setOrient(dbOrientType(dbOrientType::R0)); - return xfm; -} - frInstTerm* frInst::getInstTerm(const int index) { return instTerms_.at(index).get(); diff --git a/src/drt/src/db/obj/frInst.h b/src/drt/src/db/obj/frInst.h index fa3eeecf7b..03018ab985 100644 --- a/src/drt/src/db/obj/frInst.h +++ b/src/drt/src/db/obj/frInst.h @@ -83,24 +83,26 @@ class frInst : public frRef /* from frRef * getOrient - * setOrient * getOrigin - * setOrigin * getTransform - * setTransform */ - dbOrientType getOrient() const override { return xform_.getOrient(); } - void setOrient(const dbOrientType& tmpOrient) override + dbOrientType getOrient() const override { - xform_.setOrient(tmpOrient); + return db_inst_->getTransform().getOrient(); + } + Point getOrigin() const override + { + return db_inst_->getTransform().getOffset(); } - Point getOrigin() const override { return xform_.getOffset(); } - void setOrigin(const Point& tmpPoint) override { xform_.setOffset(tmpPoint); } - dbTransform getTransform() const override { return xform_; } - void setTransform(const dbTransform& xformIn) override { xform_ = xformIn; } odb::dbInst* getDBInst() const { return db_inst_; } - dbTransform getDBTransform() const { return db_inst_->getTransform(); } + dbTransform getTransform() const override { return db_inst_->getTransform(); } + dbTransform getBadTransform() const + { + int x, y; + db_inst_->getLocation(x, y); + return dbTransform(Point(x, y)); + } /* from frPinFig * hasPin @@ -138,7 +140,6 @@ class frInst : public frRef void move(const dbTransform& xform) override { ; } bool intersects(const Rect& box) const override { return false; } // others - dbTransform getNoRotationTransform() const; Rect getBoundaryBBox() const; frInstTerm* getInstTerm(int index); @@ -149,7 +150,6 @@ class frInst : public frRef std::vector> instTerms_; std::vector> instBlockages_; odb::dbInst* db_inst_; - dbTransform xform_; int pinAccessIdx_; bool toBeDeleted_; }; diff --git a/src/drt/src/db/obj/frInstTerm.cpp b/src/drt/src/db/obj/frInstTerm.cpp index 7f96389998..ec50cd5d68 100644 --- a/src/drt/src/db/obj/frInstTerm.cpp +++ b/src/drt/src/db/obj/frInstTerm.cpp @@ -40,11 +40,13 @@ frString frInstTerm::getName() const frAccessPoint* frInstTerm::getAccessPoint(frCoord x, frCoord y, frLayerNum lNum) { auto inst = getInst(); - dbTransform shiftXform = inst->getTransform(); - Point offset(shiftXform.getOffset()); - x = x - offset.getX(); - y = y - offset.getY(); - return term_->getAccessPoint(x, y, lNum, inst->getPinAccessIdx()); + dbTransform transform; + inst->getTransform().invert(transform); + Point pt(x, y); + transform.apply(pt); + + return term_->getAccessPoint( + pt.getX(), pt.getY(), lNum, inst->getPinAccessIdx()); } bool frInstTerm::hasAccessPoint(frCoord x, frCoord y, frLayerNum lNum) @@ -56,7 +58,7 @@ void frInstTerm::getShapes(std::vector& outShapes) const { term_->getShapes(outShapes); for (auto& shape : outShapes) { - dbTransform trans = getInst()->getDBTransform(); + dbTransform trans = getInst()->getTransform(); shape.move(trans); } } @@ -64,7 +66,7 @@ void frInstTerm::getShapes(std::vector& outShapes) const Rect frInstTerm::getBBox() const { Rect bbox(term_->getBBox()); - dbTransform trans = getInst()->getDBTransform(); + dbTransform trans = getInst()->getTransform(); trans.apply(bbox); return bbox; } diff --git a/src/drt/src/db/obj/frRPin.cpp b/src/drt/src/db/obj/frRPin.cpp index 85686186c8..ca74c65e39 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(term)->getInst(); - dbTransform shiftXform = inst->getNoRotationTransform(); + dbTransform transform = inst->getTransform(); pt = accessPoint->getPoint(); - shiftXform.apply(pt); + transform.apply(pt); break; } case frcBTerm: diff --git a/src/drt/src/db/obj/frRef.h b/src/drt/src/db/obj/frRef.h index 583babb546..6358214b41 100644 --- a/src/drt/src/db/obj/frRef.h +++ b/src/drt/src/db/obj/frRef.h @@ -39,10 +39,6 @@ class frRef : public frPinFig virtual dbOrientType getOrient() const = 0; virtual Point getOrigin() const = 0; virtual dbTransform getTransform() const = 0; - // setters - virtual void setOrient(const dbOrientType& tmpOrient) = 0; - virtual void setOrigin(const Point& tmpPoint) = 0; - virtual void setTransform(const dbTransform& xform) = 0; protected: // constructors diff --git a/src/drt/src/db/obj/frVia.h b/src/drt/src/db/obj/frVia.h index 5bd86f7ce6..887e62c2da 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) override { ; } Point getOrigin() const override { return origin_; } - void setOrigin(const Point& tmpPoint) override { origin_ = tmpPoint; } + void setOrigin(const Point& tmpPoint) { origin_ = tmpPoint; } dbTransform getTransform() const override { return dbTransform(origin_); } - void setTransform(const dbTransform& xformIn) override {} /* from frPinFig * hasPin diff --git a/src/drt/src/dr/FlexDR.h b/src/drt/src/dr/FlexDR.h index 7b2a03f0b1..489ec4505b 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 in); void getTrackLocs(bool isHorzTracks, diff --git a/src/drt/src/dr/FlexDR_init.cpp b/src/drt/src/dr/FlexDR_init.cpp index ffc8b5d530..674a2d54f7 100644 --- a/src/drt/src/dr/FlexDR_init.cpp +++ b/src/drt/src/dr/FlexDR_init.cpp @@ -1186,26 +1186,23 @@ void FlexDRWorker::initNet_term(const frDesign* design, { for (auto term : terms) { // ap - // TODO is instXform used properly here? - dbTransform instXform; // (0,0), R0 - dbTransform shiftXform; + dbTransform transform; switch (term->typeId()) { case frcInstTerm: { auto instTerm = static_cast(term); frInst* inst = instTerm->getInst(); - shiftXform = inst->getNoRotationTransform(); - instXform = inst->getDBTransform(); + 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(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: @@ -1222,7 +1219,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(); dPin->setFrTerm(term); @@ -1240,7 +1237,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(); dAp->setPoint(bp); @@ -2909,8 +2906,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set& objs, } else if (obj->typeId() == frcInstTerm) { auto instTerm = static_cast(obj); auto inst = instTerm->getInst(); - const dbTransform xform = inst->getDBTransform(); - const dbTransform shiftXform = inst->getNoRotationTransform(); + const dbTransform xform = inst->getTransform(); const dbMasterType masterType = inst->getMaster()->getMasterType(); bool accessHorz = false; bool accessVert = false; @@ -2979,7 +2975,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set& objs, if (masterType.isBlock()) { modCornerToCornerSpacing( box, zIdx, type); // temp solution for ISPD19 benchmarks - modBlockedEdgesForMacroPin(instTerm, shiftXform, isAddPathCost); + modBlockedEdgesForMacroPin(instTerm, xform, isAddPathCost); if (isAddPathCost) { type = ModCostType::setFixedShape; } else { diff --git a/src/drt/src/dr/FlexDR_maze.cpp b/src/drt/src/dr/FlexDR_maze.cpp index 458972a133..ddf1221390 100644 --- a/src/drt/src/dr/FlexDR_maze.cpp +++ b/src/drt/src/dr/FlexDR_maze.cpp @@ -2774,7 +2774,7 @@ bool FlexDRWorker::addApPathSegs(const FlexMazeIdx& apIdx, drNet* net) connecting = &end; } if (inst) { - dbTransform trans = inst->getNoRotationTransform(); + dbTransform trans = inst->getBadTransform(); trans.apply(begin); trans.apply(end); if (end < begin) { // if rotation swapped order, correct it diff --git a/src/drt/src/frRegionQuery.cpp b/src/drt/src/frRegionQuery.cpp index 76ca45eb6f..261eaa333a 100644 --- a/src/drt/src/frRegionQuery.cpp +++ b/src/drt/src/frRegionQuery.cpp @@ -187,7 +187,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj) switch (obj->typeId()) { case frcInstTerm: { auto instTerm = static_cast(obj); - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { auto shape = uFig.get(); @@ -201,7 +201,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj) } case frcInstBlockage: { auto instBlk = static_cast(obj); - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { @@ -260,7 +260,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj) switch (obj->typeId()) { case frcInstTerm: { auto instTerm = static_cast(obj); - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { auto shape = uFig.get(); @@ -274,7 +274,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj) } case frcInstBlockage: { auto instBlk = static_cast(obj); - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { @@ -456,7 +456,7 @@ void frRegionQuery::addGRObj(grVia* via) void frRegionQuery::Impl::add(frInstTerm* instTerm, ObjectsByLayer& allShapes) { - dbTransform xform = instTerm->getInst()->getDBTransform(); + dbTransform xform = instTerm->getInst()->getTransform(); for (auto& pin : instTerm->getTerm()->getPins()) { for (auto& uFig : pin->getFigs()) { @@ -493,7 +493,7 @@ void frRegionQuery::Impl::add(frBTerm* term, void frRegionQuery::Impl::add(frInstBlockage* instBlk, ObjectsByLayer& allShapes) { - dbTransform xform = instBlk->getInst()->getDBTransform(); + dbTransform xform = instBlk->getInst()->getTransform(); auto blk = instBlk->getBlockage(); auto pin = blk->getPin(); for (auto& uFig : pin->getFigs()) { diff --git a/src/drt/src/gr/FlexGR.cpp b/src/drt/src/gr/FlexGR.cpp index 55257f9544..ad8c3f7307 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(rpin->getFrTerm())->getInst(); - dbTransform shiftXform = inst->getNoRotationTransform(); + dbTransform transform = inst->getTransform(); pt = rpin->getAccessPoint()->getPoint(); - shiftXform.apply(pt); + transform.apply(pt); } else { pt = rpin->getAccessPoint()->getPoint(); } diff --git a/src/drt/src/io/GuideProcessor.cpp b/src/drt/src/io/GuideProcessor.cpp index 448a680461..83e4125275 100644 --- a/src/drt/src/io/GuideProcessor.cpp +++ b/src/drt/src/io/GuideProcessor.cpp @@ -112,7 +112,7 @@ std::vector getAccessPoints(const frBlockObject* pin) std::vector result; if (pin->typeId() == frcInstTerm) { auto iterm = static_cast(pin); - auto transform = iterm->getInst()->getNoRotationTransform(); + auto transform = iterm->getInst()->getTransform(); const int pin_access_idx = iterm->getInst()->getPinAccessIdx(); for (const auto& mpin : iterm->getTerm()->getPins()) { if (!mpin->hasPinAccess()) { @@ -1327,7 +1327,7 @@ void GuideProcessor::genGuides_addCoverGuide_helper(frInstTerm* iterm, { const frInst* inst = iterm->getInst(); const size_t num_pins = iterm->getTerm()->getPins().size(); - dbTransform transform = inst->getNoRotationTransform(); + dbTransform transform = inst->getTransform(); for (int pin_idx = 0; pin_idx < num_pins; pin_idx++) { const frAccessPoint* pref_ap = getPrefAp(iterm, pin_idx); if (pref_ap) { diff --git a/src/drt/src/io/io.cpp b/src/drt/src/io/io.cpp index acf14dda33..e5f82285ec 100644 --- a/src/drt/src/io/io.cpp +++ b/src/drt/src/io/io.cpp @@ -128,10 +128,6 @@ void io::Parser::setInst(odb::dbInst* inst) auto uInst = std::make_unique(inst->getName(), master, inst); auto tmpInst = uInst.get(); - int x, y; - inst->getLocation(x, y); - tmpInst->setOrigin(Point(x, y)); - tmpInst->setOrient(inst->getOrient()); int numInstTerms = 0; tmpInst->setPinAccessIdx(inst->getPinAccessIdx()); for (auto& uTerm : tmpInst->getMaster()->getTerms()) { diff --git a/src/drt/src/io/io_parser_helper.cpp b/src/drt/src/io/io_parser_helper.cpp index e3b4f3b06f..ae3dba478c 100644 --- a/src/drt/src/io/io_parser_helper.cpp +++ b/src/drt/src/io/io_parser_helper.cpp @@ -879,7 +879,7 @@ void io::Parser::checkPins() if (!inst->getMaster()->getMasterType().isBlock()) { continue; } - dbTransform xform = inst->getDBTransform(); + dbTransform xform = inst->getTransform(); for (auto& iTerm : inst->getInstTerms()) { if (!iTerm->hasNet() || iTerm->getNet()->isSpecial()) { continue; diff --git a/src/drt/src/pa/FlexPA_acc_pattern.cpp b/src/drt/src/pa/FlexPA_acc_pattern.cpp index fe04cd0d83..8350c1706e 100644 --- a/src/drt/src/pa/FlexPA_acc_pattern.cpp +++ b/src/drt/src/pa/FlexPA_acc_pattern.cpp @@ -559,7 +559,7 @@ int FlexPA::getEdgeCost( has_vio = (vio_edges[edge_idx] == 1); } else { auto curr_unique_inst = unique_insts_.getUnique(curr_unique_inst_idx); - dbTransform xform = curr_unique_inst->getNoRotationTransform(); + dbTransform xform = curr_unique_inst->getTransform(); // check DRC std::vector> objs; const auto& [pin_1, inst_term_1] = pins[prev_pin_idx]; @@ -728,7 +728,7 @@ bool FlexPA::genPatterns_commit( auto rvia = via.get(); temp_vias.push_back(std::move(via)); - dbTransform xform = inst->getNoRotationTransform(); + dbTransform xform = inst->getTransform(); Point pt(access_point->getPoint()); xform.apply(pt); rvia->setOrigin(pt); @@ -820,7 +820,7 @@ void FlexPA::genPatternsPrintDebug( auto& [pin, inst_term] = pins[0]; if (inst_term) { frInst* inst = inst_term->getInst(); - xform = inst->getNoRotationTransform(); + xform = inst->getTransform(); } std::cout << "failed pattern:"; diff --git a/src/drt/src/pa/FlexPA_acc_point.cpp b/src/drt/src/pa/FlexPA_acc_point.cpp index 661774fd0a..5e7a6160b3 100644 --- a/src/drt/src/pa/FlexPA_acc_point.cpp +++ b/src/drt/src/pa/FlexPA_acc_point.cpp @@ -958,7 +958,6 @@ bool FlexPA::checkDirectionalViaAccess( via->getViaDef()->getLayer2Num(), dir, is_block); - if (inst_term && inst_term->hasNet()) { via->addToNet(inst_term->getNet()); } else { @@ -1251,7 +1250,7 @@ FlexPA::mergePinShapes(T* pin, frInstTerm* inst_term, const bool is_shrink) dbTransform xform; if (inst) { - xform = inst->getDBTransform(); + xform = inst->getTransform(); } frTechObject* tech = getDesign()->getTech(); @@ -1481,9 +1480,8 @@ void FlexPA::revertAccessPoints() { const auto& unique = unique_insts_.getUnique(); for (auto& inst : unique) { - const dbTransform xform = inst->getTransform(); - const Point offset(xform.getOffset()); - dbTransform revertXform(Point(-offset.getX(), -offset.getY())); + dbTransform revert_transform; + inst->getTransform().invert(revert_transform); const auto pin_access_idx = unique_insts_.getPAIndex(inst); for (auto& inst_term : inst->getInstTerms()) { @@ -1495,13 +1493,15 @@ 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); + dbTransform bad_transform; + inst->getBadTransform().invert(bad_transform); + bad_transform.apply(begin); + bad_transform.apply(end); if (end < begin) { Point tmp = begin; begin = end; diff --git a/src/drt/src/pa/FlexPA_row_pattern.cpp b/src/drt/src/pa/FlexPA_row_pattern.cpp index 112349c1d4..40a9086f9b 100644 --- a/src/drt/src/pa/FlexPA_row_pattern.cpp +++ b/src/drt/src/pa/FlexPA_row_pattern.cpp @@ -415,7 +415,7 @@ void FlexPA::addAccessPatternObj( std::vector>& vias, const bool isPrev) { - const dbTransform xform = inst->getNoRotationTransform(); + const dbTransform xform = inst->getTransform(); int access_point_idx = 0; auto& access_points = access_pattern->getPattern(); diff --git a/src/drt/src/ta/FlexTA_init.cpp b/src/drt/src/ta/FlexTA_init.cpp index 02940b40f6..f48209ae51 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->getNoRotationTransform(); + dbTransform transform = 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); + transform.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->getNoRotationTransform(); + dbTransform transform = 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); + transform.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 7cb3b33e57..c1a964d1f2 100644 --- a/src/grt/src/GlobalRouter.cpp +++ b/src/grt/src/GlobalRouter.cpp @@ -936,11 +936,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); }