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

gpl: the pin location for instance not in R0/N is wrong #6249

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions src/gpl/src/placerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

#include "placerBase.h"

#include <odb/db.h>

#include <iostream>
#include <utility>

#include "nesterovBase.h"
#include "odb/db.h"
#include "odb/dbTransform.h"
#include "utl/Logger.h"

namespace gpl {
Expand Down Expand Up @@ -454,44 +454,44 @@ odb::dbBTerm* Pin::dbBTerm() const

void Pin::updateCoordi(odb::dbITerm* iTerm)
{
int offsetLx = INT_MAX;
int offsetLy = INT_MAX;
int offsetUx = INT_MIN;
int offsetUy = INT_MIN;
Rect pin_bbox;
pin_bbox.mergeInit();

for (dbMPin* mPin : iTerm->getMTerm()->getMPins()) {
for (dbBox* box : mPin->getGeometry()) {
offsetLx = std::min(box->xMin(), offsetLx);
offsetLy = std::min(box->yMin(), offsetLy);
offsetUx = std::max(box->xMax(), offsetUx);
offsetUy = std::max(box->yMax(), offsetUy);
pin_bbox.merge(box->getBox());
}
}

int lx = iTerm->getInst()->getBBox()->xMin();
int ly = iTerm->getInst()->getBBox()->yMin();
odb::dbInst* inst = iTerm->getInst();
const int lx = inst->getBBox()->xMin();
const int ly = inst->getBBox()->yMin();

int instCenterX = iTerm->getInst()->getMaster()->getWidth() / 2;
int instCenterY = iTerm->getInst()->getMaster()->getHeight() / 2;
odb::dbMaster* master = iTerm->getInst()->getMaster();
const int instCenterX = master->getWidth() / 2;
const int instCenterY = master->getHeight() / 2;

// Pin SHAPE is NOT FOUND;
// (may happen on OpenDB bug case)
if (offsetLx == INT_MAX || offsetLy == INT_MAX || offsetUx == INT_MIN
|| offsetUy == INT_MIN) {
// offset is center of instances
offsetCx_ = offsetCy_ = 0;
}
// usual case
else {
// Pin has no shapes (rare/odd)
if (pin_bbox.isInverted()) {
offsetCx_ = offsetCy_ = 0; // offset is center of the instance
} else {
// Rotate the pin's bbox in correspondence to the instance's orientation.
// Rotation consists of (1) shift the instance center to the origin
// (2) rotate (3) shift back.
const auto inst_orient = inst->getTransform().getOrient();
odb::dbTransform xfm({-instCenterX, -instCenterY});
xfm.concat(inst_orient);
xfm.concat(odb::dbTransform({instCenterX, instCenterY}));
xfm.apply(pin_bbox);
// offset is Pin BBoxs' center, so
// subtract the Origin coordinates (e.g. instCenterX, instCenterY)
//
// Transform coordinates
// from (origin: 0,0)
// to (origin: instCenterX, instCenterY)
//
offsetCx_ = (offsetLx + offsetUx) / 2 - instCenterX;
offsetCy_ = (offsetLy + offsetUy) / 2 - instCenterY;
offsetCx_ = pin_bbox.xCenter() - instCenterX;
offsetCy_ = pin_bbox.yCenter() - instCenterY;
}

cx_ = lx + instCenterX + offsetCx_;
Expand Down
23 changes: 23 additions & 0 deletions src/odb/include/odb/geom.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,19 @@ class Rect
// Return the point inside rect that is closest to pt.
Point closestPtInside(Point pt) const;

// Compute the union of this rectangle and a point.
void merge(const Point& p, Rect& result);

// Compute the union of these two rectangles.
void merge(const Rect& r, Rect& result);

// Compute the union of this rectangle and an octagon.
void merge(const Oct& o, Rect& result);

// Compute the union of this rectangle an point.
// The result is stored in this rectangle.
void merge(const Point& p);

// Compute the union of these two rectangles. The result is stored in this
// rectangle.
void merge(const Rect& r);
Expand Down Expand Up @@ -642,6 +649,14 @@ inline Point Rect::closestPtInside(const Point pt) const
std::min(std::max(pt.getY(), yMin()), yMax()));
}

inline void Rect::merge(const Point& p, Rect& result)
{
result.xlo_ = std::min(xlo_, p.getX());
result.ylo_ = std::min(ylo_, p.getY());
result.xhi_ = std::max(xhi_, p.getX());
result.yhi_ = std::max(yhi_, p.getY());
}

// Compute the union of these two rectangles.
inline void Rect::merge(const Rect& r, Rect& result)
{
Expand All @@ -659,6 +674,14 @@ inline void Rect::merge(const Oct& o, Rect& result)
result.yhi_ = std::max(yhi_, o.yMax());
}

inline void Rect::merge(const Point& p)
{
xlo_ = std::min(xlo_, p.getX());
ylo_ = std::min(ylo_, p.getY());
xhi_ = std::max(xhi_, p.getX());
yhi_ = std::max(yhi_, p.getY());
}

// Compute the union of these two rectangles.
inline void Rect::merge(const Rect& r)
{
Expand Down