Skip to content

Commit 0b2b56c

Browse files
authored
Merge pull request #7885 from gadfort/gui-guide-centering
gui: use gcell centers for drawing routing
2 parents 056094a + e90f991 commit 0b2b56c

File tree

1 file changed

+61
-40
lines changed

1 file changed

+61
-40
lines changed

src/gui/src/dbDescriptors.cpp

Lines changed: 61 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,53 +1450,74 @@ std::set<odb::Line> DbNetDescriptor::convertGuidesToLines(
14501450
}
14511451
}
14521452

1453+
// Build gcell grid centers
1454+
std::vector<int> grid;
1455+
net->getBlock()->getGCellGrid()->getGridX(grid);
1456+
grid.push_back(net->getBlock()->getDieArea().xMax());
1457+
std::vector<int> x_grid;
1458+
x_grid.reserve(grid.size() - 1);
1459+
for (int i = 1; i < grid.size(); i++) {
1460+
x_grid.push_back((grid[i - 1] + grid[i]) / 2);
1461+
}
1462+
1463+
grid.clear();
1464+
net->getBlock()->getGCellGrid()->getGridY(grid);
1465+
grid.push_back(net->getBlock()->getDieArea().yMax());
1466+
std::vector<int> y_grid;
1467+
y_grid.reserve(grid.size() - 1);
1468+
for (int i = 1; i < grid.size(); i++) {
1469+
y_grid.push_back((grid[i - 1] + grid[i]) / 2);
1470+
}
1471+
14531472
for (const auto* guide : guides) {
14541473
const auto& box = guide->getBox();
1455-
const auto center = box.center();
1456-
const int width_half = box.minDXDY() / 2;
1457-
odb::Point p0, p1;
1458-
switch (box.getDir()) {
1459-
case 0: {
1460-
// DX < DY
1461-
p0 = odb::Point(center.x(), box.yMin() + width_half);
1462-
p1 = odb::Point(center.x(), box.yMax() - width_half);
1463-
break;
1464-
}
1465-
case 1: {
1466-
p0 = odb::Point(box.xMin() + width_half, center.y());
1467-
p1 = odb::Point(box.xMax() - width_half, center.y());
1468-
break;
1474+
1475+
std::vector<odb::Point> guide_pts;
1476+
for (const auto& x : x_grid) {
1477+
if (x < box.xMin()) {
1478+
continue;
14691479
}
1470-
default: {
1471-
p0 = center;
1472-
p1 = center;
1480+
if (x > box.xMax()) {
14731481
break;
14741482
}
1475-
}
1476-
lines.emplace(p0, center);
1477-
lines.emplace(center, p1);
1478-
1479-
if (guide->isConnectedToTerm()) {
1480-
std::vector<odb::Point> anchors = {p0, center, p1};
1481-
1482-
auto find_term_connection = [&anchors, &lines, &io_map, &sources, &sinks](
1483-
odb::dbObject* dbterm,
1484-
const odb::Point& term) {
1485-
// draw shortest flywire
1486-
std::stable_sort(anchors.begin(),
1487-
anchors.end(),
1488-
[&term](const odb::Point& pt0, const odb::Point& pt1) {
1489-
return odb::Point::manhattanDistance(term, pt0)
1490-
< odb::Point::manhattanDistance(term, pt1);
1491-
});
1492-
lines.emplace(term, anchors[0]);
1493-
if (io_map[dbterm].is_sink) {
1494-
sinks[dbterm].insert(term);
1483+
1484+
for (const auto& y : y_grid) {
1485+
if (y < box.yMin()) {
1486+
continue;
14951487
}
1496-
if (io_map[dbterm].is_source) {
1497-
sources[dbterm].insert(term);
1488+
if (y > box.yMax()) {
1489+
break;
14981490
}
1499-
};
1491+
1492+
guide_pts.emplace_back(x, y);
1493+
}
1494+
}
1495+
1496+
std::sort(guide_pts.begin(), guide_pts.end());
1497+
for (int i = 1; i < guide_pts.size(); i++) {
1498+
lines.emplace(guide_pts[i - 1], guide_pts[i]);
1499+
}
1500+
1501+
if (!guide_pts.empty() && guide->isConnectedToTerm()) {
1502+
auto find_term_connection
1503+
= [&guide_pts, &lines, &io_map, &sources, &sinks](
1504+
odb::dbObject* dbterm, const odb::Point& term) {
1505+
// draw shortest flywire
1506+
std::stable_sort(
1507+
guide_pts.begin(),
1508+
guide_pts.end(),
1509+
[&term](const odb::Point& pt0, const odb::Point& pt1) {
1510+
return odb::Point::manhattanDistance(term, pt0)
1511+
< odb::Point::manhattanDistance(term, pt1);
1512+
});
1513+
lines.emplace(term, guide_pts[0]);
1514+
if (io_map[dbterm].is_sink) {
1515+
sinks[dbterm].insert(term);
1516+
}
1517+
if (io_map[dbterm].is_source) {
1518+
sources[dbterm].insert(term);
1519+
}
1520+
};
15001521

15011522
for (const auto& [obj, objbox] : terms[guide->getLayer()]) {
15021523
std::vector<const odb::Rect*> candidates;

0 commit comments

Comments
 (0)