Skip to content

Commit

Permalink
gpl: the pin location for instance not in R0/N is wrong
Browse files Browse the repository at this point in the history
Pin::updateCoordi ignored instance orientation.  This caused instances
to be pull towards the wrong edge of macros not in R0/N.

Signed-off-by: Matt Liberty <[email protected]>
  • Loading branch information
maliberty committed Nov 27, 2024
1 parent ce6ff66 commit 10a5df2
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 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 @@ -468,30 +468,38 @@ void Pin::updateCoordi(odb::dbITerm* iTerm)
}
}

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)
// Pin has no shapes (rare/odd)
if (offsetLx == INT_MAX || offsetLy == INT_MAX || offsetUx == INT_MIN
|| offsetUy == INT_MIN) {
// offset is center of instances
// offset is center of the instance
offsetCx_ = offsetCy_ = 0;
}
// usual case
else {
} 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}));
Rect pin_bbox(offsetLx, offsetLy, offsetUx, offsetUy);
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

0 comments on commit 10a5df2

Please sign in to comment.