Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drt: elimination of getNoRotationTransform and drt::dbTransform #6326

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
2 changes: 0 additions & 2 deletions src/drt/src/DesignCallBack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
13 changes: 2 additions & 11 deletions src/drt/src/db/obj/frInst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
20 changes: 7 additions & 13 deletions src/drt/src/db/obj/frInst.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,20 @@ 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 { return db_inst_->getTransform(); }
bnmfw marked this conversation as resolved.
Show resolved Hide resolved
bnmfw marked this conversation as resolved.
Show resolved Hide resolved

/* from frPinFig
* hasPin
Expand Down Expand Up @@ -138,7 +134,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);
Expand All @@ -149,7 +144,6 @@ class frInst : public frRef
std::vector<std::unique_ptr<frInstTerm>> instTerms_;
std::vector<std::unique_ptr<frInstBlockage>> instBlockages_;
odb::dbInst* db_inst_;
dbTransform xform_;
int pinAccessIdx_;
bool toBeDeleted_;
};
Expand Down
15 changes: 8 additions & 7 deletions src/drt/src/db/obj/frInstTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ 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 shiftXform;
inst->getTransform().invert(shiftXform);
Point pt(x, y);
shiftXform.apply(pt);
return term_->getAccessPoint(
pt.getX(), pt.getY(), lNum, inst->getPinAccessIdx());
}

bool frInstTerm::hasAccessPoint(frCoord x, frCoord y, frLayerNum lNum)
Expand All @@ -56,15 +57,15 @@ void frInstTerm::getShapes(std::vector<frRect>& outShapes) const
{
term_->getShapes(outShapes);
for (auto& shape : outShapes) {
dbTransform trans = getInst()->getDBTransform();
dbTransform trans = getInst()->getTransform();
shape.move(trans);
}
}

Rect frInstTerm::getBBox() const
{
Rect bbox(term_->getBBox());
dbTransform trans = getInst()->getDBTransform();
dbTransform trans = getInst()->getTransform();
trans.apply(bbox);
return bbox;
}
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/db/obj/frRPin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Rect frRPin::getBBox()
switch (term->typeId()) {
case frcInstTerm: {
auto inst = static_cast<frInstTerm*>(term)->getInst();
dbTransform shiftXform = inst->getNoRotationTransform();
dbTransform shiftXform = inst->getTransform();

pt = accessPoint->getPoint();
shiftXform.apply(pt);
Expand Down
4 changes: 0 additions & 4 deletions src/drt/src/db/obj/frRef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
bnmfw marked this conversation as resolved.
Show resolved Hide resolved

protected:
// constructors
Expand Down
6 changes: 3 additions & 3 deletions src/drt/src/db/obj/frVia.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ class frVia : public frRef
*/

dbOrientType getOrient() const override { return dbOrientType(); }
void setOrient(const dbOrientType& tmpOrient) override { ; }
void setOrient(const dbOrientType& tmpOrient) { ; }
bnmfw marked this conversation as resolved.
Show resolved Hide resolved
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 origin_; }
void setTransform(const dbTransform& xformIn) override {}
void setTransform(const dbTransform& xformIn) {}
bnmfw marked this conversation as resolved.
Show resolved Hide resolved

/* from frPinFig
* hasPin
Expand Down
10 changes: 3 additions & 7 deletions src/drt/src/dr/FlexDR_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,15 +1177,12 @@ 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;
switch (term->typeId()) {
case frcInstTerm: {
auto instTerm = static_cast<frInstTerm*>(term);
frInst* inst = instTerm->getInst();
shiftXform = inst->getNoRotationTransform();
instXform = inst->getDBTransform();
shiftXform = inst->getTransform();
auto trueTerm = instTerm->getTerm();
const std::string name = inst->getName() + "/" + trueTerm->getName();
initNet_term_helper(
Expand Down Expand Up @@ -2900,8 +2897,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set<frBlockObject*>& objs,
} else if (obj->typeId() == frcInstTerm) {
auto instTerm = static_cast<frInstTerm*>(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;
Expand Down Expand Up @@ -2970,7 +2966,7 @@ void FlexDRWorker::initMazeCost_terms(const std::set<frBlockObject*>& 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/dr/FlexDR_maze.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2779,7 +2779,7 @@ bool FlexDRWorker::addApPathSegs(const FlexMazeIdx& apIdx, drNet* net)
connecting = &end;
}
if (inst) {
dbTransform trans = inst->getNoRotationTransform();
dbTransform trans = inst->getTransform();
trans.apply(begin);
trans.apply(end);
if (end < begin) { // if rotation swapped order, correct it
Expand Down
12 changes: 6 additions & 6 deletions src/drt/src/frRegionQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj)
switch (obj->typeId()) {
case frcInstTerm: {
auto instTerm = static_cast<frInstTerm*>(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();
Expand All @@ -201,7 +201,7 @@ void frRegionQuery::addBlockObj(frBlockObject* obj)
}
case frcInstBlockage: {
auto instBlk = static_cast<frInstBlockage*>(obj);
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -260,7 +260,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj)
switch (obj->typeId()) {
case frcInstTerm: {
auto instTerm = static_cast<frInstTerm*>(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();
Expand All @@ -274,7 +274,7 @@ void frRegionQuery::removeBlockObj(frBlockObject* obj)
}
case frcInstBlockage: {
auto instBlk = static_cast<frInstBlockage*>(obj);
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -458,7 +458,7 @@ void frRegionQuery::addGRObj(grVia* via)
void frRegionQuery::Impl::add(frInstTerm* instTerm,
ObjectsByLayer<frBlockObject>& allShapes)
{
dbTransform xform = instTerm->getInst()->getDBTransform();
dbTransform xform = instTerm->getInst()->getTransform();

for (auto& pin : instTerm->getTerm()->getPins()) {
for (auto& uFig : pin->getFigs()) {
Expand Down Expand Up @@ -495,7 +495,7 @@ void frRegionQuery::Impl::add(frBTerm* term,
void frRegionQuery::Impl::add(frInstBlockage* instBlk,
ObjectsByLayer<frBlockObject>& allShapes)
{
dbTransform xform = instBlk->getInst()->getDBTransform();
dbTransform xform = instBlk->getInst()->getTransform();
auto blk = instBlk->getBlockage();
auto pin = blk->getPin();
for (auto& uFig : pin->getFigs()) {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/gr/FlexGR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ 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->getNoRotationTransform();
dbTransform shiftXform = inst->getTransform();
pt = rpin->getAccessPoint()->getPoint();
shiftXform.apply(pt);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/drt/src/io/GuideProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::vector<Point3D> getAccessPoints(const frBlockObject* pin)
std::vector<Point3D> result;
if (pin->typeId() == frcInstTerm) {
auto iterm = static_cast<const frInstTerm*>(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()) {
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions src/drt/src/io/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ void io::Parser::setInst(odb::dbInst* inst)
auto uInst = std::make_unique<frInst>(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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/drt/src/io/io_parser_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,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;
Expand Down
15 changes: 7 additions & 8 deletions src/drt/src/pa/FlexPA_prep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,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();
Expand Down Expand Up @@ -1789,9 +1789,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 revertXform;
bnmfw marked this conversation as resolved.
Show resolved Hide resolved
inst->getTransform().invert(revertXform);

const auto pin_access_idx = unique_insts_.getPAIndex(inst);
for (auto& inst_term : inst->getInstTerms()) {
Expand Down Expand Up @@ -2092,7 +2091,7 @@ void FlexPA::addAccessPatternObj(
std::vector<std::unique_ptr<frVia>>& 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();

Expand Down Expand Up @@ -2542,7 +2541,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<std::pair<frConnFig*, frBlockObject*>> objs;
const auto& [pin_1, inst_term_1] = pins[prev_pin_idx];
Expand Down Expand Up @@ -2711,7 +2710,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);
Expand Down Expand Up @@ -2803,7 +2802,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:";
Expand Down
4 changes: 2 additions & 2 deletions src/drt/src/ta/FlexTA_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ bool FlexTAWorker::initIroute_helper_pin(frGuide* guide,
continue;
}
frInst* inst = iterm->getInst();
dbTransform shiftXform = inst->getNoRotationTransform();
dbTransform shiftXform = inst->getTransform();
frMTerm* mterm = iterm->getTerm();
int pinIdx = 0;
for (auto& pin : mterm->getPins()) {
Expand Down Expand Up @@ -258,7 +258,7 @@ void FlexTAWorker::initIroute_helper_generic_helper(frGuide* guide,
continue;
}
frInst* inst = iterm->getInst();
dbTransform shiftXform = inst->getNoRotationTransform();
dbTransform shiftXform = inst->getTransform();
frMTerm* mterm = iterm->getTerm();
int pinIdx = 0;
for (auto& pin : mterm->getPins()) {
Expand Down
Loading