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

dpl: add API to get adjacent cells cluster #6522

Merged
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
6 changes: 6 additions & 0 deletions src/dpl/include/dpl/Opendp.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ class Opendp
void addDecapMaster(dbMaster* decap_master, double decap_cap);
void insertDecapCells(double target, IRDropByPoint& psm_ir_drops);

// Get the instance adjacent to the left or right of a given instance
dbInst* getAdjacentInstance(dbInst* inst, bool left) const;

// Find a cluster of instances that are touching each other
std::vector<dbInst*> getAdjacentInstancesCluster(dbInst* inst) const;

private:
using bgPoint
= boost::geometry::model::d2::point_xy<int,
Expand Down
48 changes: 48 additions & 0 deletions src/dpl/src/Opendp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,54 @@ void Opendp::groupInitPixels2()
}
}

dbInst* Opendp::getAdjacentInstance(dbInst* inst, bool left) const
{
const Rect core = grid_->getCore();
const Rect inst_rect = inst->getBBox()->getBox();
DbuX x_dbu = left ? DbuX{inst_rect.xMin() - 1} : DbuX{inst_rect.xMax() + 1};
x_dbu -= core.xMin();
GridX x = grid_->gridX(x_dbu);

GridY y = grid_->gridSnapDownY(DbuY{inst_rect.yMin() - core.yMin()});

Pixel* pixel = grid_->gridPixel(x, y);

dbInst* adjacent_inst = nullptr;

// do not return macros, endcaps and tapcells
if (pixel != nullptr && pixel->cell && pixel->cell->db_inst_->isCore()) {
adjacent_inst = pixel->cell->db_inst_;
}

return adjacent_inst;
}

std::vector<dbInst*> Opendp::getAdjacentInstancesCluster(dbInst* inst) const
{
const bool left = true;
const bool right = false;
std::vector<dbInst*> adj_inst_cluster;

dbInst* left_inst = getAdjacentInstance(inst, left);
while (left_inst != nullptr) {
adj_inst_cluster.push_back(left_inst);
// the right instance can be ignored, since it was added in the line above
left_inst = getAdjacentInstance(left_inst, left);
}

std::reverse(adj_inst_cluster.begin(), adj_inst_cluster.end());
adj_inst_cluster.push_back(inst);

dbInst* right_inst = getAdjacentInstance(inst, right);
while (right_inst != nullptr) {
adj_inst_cluster.push_back(right_inst);
// the left instance can be ignored, since it was added in the line above
right_inst = getAdjacentInstance(right_inst, right);
}
eder-matheus marked this conversation as resolved.
Show resolved Hide resolved

return adj_inst_cluster;
}

/* static */
bool Opendp::isInside(const Rect& cell, const Rect& box)
{
Expand Down
Loading