Skip to content

Commit

Permalink
Merge pull request The-OpenROAD-Project#4536 from arthurjolo/grt_floa…
Browse files Browse the repository at this point in the history
…ting_pin_fix

Grt floating pin fix
  • Loading branch information
eder-matheus authored Jan 24, 2024
2 parents efb1f59 + 83a28bc commit d1f4cec
Show file tree
Hide file tree
Showing 53 changed files with 2,891 additions and 2,959 deletions.
12 changes: 12 additions & 0 deletions src/grt/src/fastroute/src/FastRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,18 @@ NetRouteMap FastRouteCore::getRoutes()
lastY = yreal;
lastL = gridsL[i];
if (net_segs.find(segment) == net_segs.end()) {
if (segment.init_layer != segment.final_layer) {
GSegment invet_via = GSegment(segment.final_x,
segment.final_y,
segment.final_layer,
segment.init_x,
segment.init_y,
segment.init_layer);
if (net_segs.find(invet_via) != net_segs.end()) {
continue;
}
}

net_segs.insert(segment);
route.push_back(segment);
}
Expand Down
191 changes: 97 additions & 94 deletions src/grt/src/fastroute/src/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,139 +190,126 @@ void FastRouteCore::fillVIA()

for (int edgeID = 0; edgeID < sttrees_[netID].num_edges(); edgeID++) {
TreeEdge* treeedge = &(treeedges[edgeID]);
int node1_alias = treeedge->n1a;
int node2_alias = treeedge->n2a;
if (treeedge->len > 0) {
int newCNT = 0;
int routeLen = treeedge->route.routelen;
const std::vector<short>& gridsX = treeedge->route.gridsX;
const std::vector<short>& gridsY = treeedge->route.gridsY;
const std::vector<short>& gridsL = treeedge->route.gridsL;

int node1_alias = treeedge->n1a;
int node2_alias = treeedge->n2a;

if (node1_alias < num_terminals) {
if (treenodes[node1_alias].hID == BIG_INT
&& edgeID == treenodes[node1_alias].lID) {
if (treenodes[node1_alias].hID == edgeID
|| (edgeID == treenodes[node1_alias].lID
&& treenodes[node1_alias].hID == BIG_INT
&& node1_alias < num_terminals)) {
int bottom_layer = treenodes[node1_alias].botL;
int top_layer = treenodes[node1_alias].topL;
int edge_init_layer = gridsL[0];
if (node1_alias < num_terminals) {
int16_t pin_botL, pin_topL;
int16_t edge_init = gridsL[0];
getViaStackRange(netID, node1_alias, pin_botL, pin_topL);
pin_botL = std::min(pin_botL, edge_init);
pin_topL = std::max(pin_topL, edge_init);
for (int16_t l = pin_botL; l < pin_topL; l++) {
bottom_layer = std::min((int) pin_botL, bottom_layer);
top_layer = std::max((int) pin_topL, top_layer);

for (int l = bottom_layer; l < top_layer; l++) {
tmpX[newCNT] = gridsX[0];
tmpY[newCNT] = gridsY[0];
tmpL[newCNT] = l;
newCNT++;
numVIAT1++;
}
for (int l = pin_topL; l > edge_init; l--) {

for (int l = top_layer; l > edge_init_layer; l--) {
tmpX[newCNT] = gridsX[0];
tmpY[newCNT] = gridsY[0];
tmpL[newCNT] = l;
newCNT++;
numVIAT1++;
}
}
}
if (edgeID == treenodes[node1_alias].hID
|| edgeID == treenodes[node2_alias].hID) {
if (edgeID == treenodes[node1_alias].hID) {
for (int k = treenodes[node1_alias].botL;
k < treenodes[node1_alias].topL;
k++) {
} else {
for (int l = bottom_layer; l < edge_init_layer; l++) {
tmpX[newCNT] = gridsX[0];
tmpY[newCNT] = gridsY[0];
tmpL[newCNT] = k;
tmpL[newCNT] = l;
newCNT++;
if (node1_alias < num_terminals) {
numVIAT1++;
} else {
if (node1_alias >= num_terminals) {
numVIAT2++;
}
}
}
}

// finish from n1->real route

int j;
for (j = 0; j < routeLen; j++) {
tmpX[newCNT] = gridsX[j];
tmpY[newCNT] = gridsY[j];
tmpL[newCNT] = gridsL[j];
newCNT++;
}
for (int j = 0; j <= routeLen; j++) {
tmpX[newCNT] = gridsX[j];
tmpY[newCNT] = gridsY[j];
tmpL[newCNT] = gridsL[j];
newCNT++;
}

if (edgeID == treenodes[node2_alias].hID) {
if (treenodes[node2_alias].topL != treenodes[node2_alias].botL)
for (int k = treenodes[node2_alias].topL - 1;
k >= treenodes[node2_alias].botL;
k--) {
tmpX[newCNT] = gridsX[routeLen];
tmpY[newCNT] = gridsY[routeLen];
tmpL[newCNT] = k;
newCNT++;
if (node2_alias < num_terminals) {
numVIAT1++;
} else {
numVIAT2++;
}
}
}
// last grid -> node2 finished
} else {
for (int j = 0; j <= routeLen; j++) {
tmpX[newCNT] = gridsX[j];
tmpY[newCNT] = gridsY[j];
tmpL[newCNT] = gridsL[j];
newCNT++;
}
if (routeLen <= 0) {
logger_->error(GRT, 254, "Edge has no previous routing.");
}

if (node2_alias < num_terminals && treenodes[node2_alias].hID == BIG_INT
&& edgeID == treenodes[node2_alias].lID) {
int16_t pin_botL, pin_topL;
getViaStackRange(netID, node2_alias, pin_botL, pin_topL);
pin_botL = std::min(pin_botL, tmpL[newCNT - 1]);
pin_topL = std::max(pin_topL, tmpL[newCNT - 1]);
if (pin_botL == tmpL[newCNT - 1]) {
pin_botL++;
}
if (treenodes[node2_alias].hID == edgeID
|| (edgeID == treenodes[node2_alias].lID
&& treenodes[node2_alias].hID == BIG_INT
&& node2_alias < num_terminals)) {
int bottom_layer = treenodes[node2_alias].botL;
int top_layer = treenodes[node2_alias].topL;
if (node2_alias < num_terminals) {
int16_t pin_botL, pin_topL;
getViaStackRange(netID, node2_alias, pin_botL, pin_topL);
bottom_layer = std::min((int) pin_botL, bottom_layer);
top_layer = std::max((int) pin_topL, top_layer);
if (bottom_layer == tmpL[newCNT - 1]) {
bottom_layer++;
}

for (int16_t l = tmpL[newCNT - 1] - 1; l > pin_botL; l--) {
tmpX[newCNT] = tmpX[newCNT - 1];
tmpY[newCNT] = tmpY[newCNT - 1];
tmpL[newCNT] = l;
newCNT++;
numVIAT1++;
}
for (int16_t l = tmpL[newCNT - 1] - 1; l > bottom_layer; l--) {
tmpX[newCNT] = tmpX[newCNT - 1];
tmpY[newCNT] = tmpY[newCNT - 1];
tmpL[newCNT] = l;
newCNT++;
}

for (int l = pin_botL; l <= pin_topL; l++) {
tmpX[newCNT] = tmpX[newCNT - 1];
tmpY[newCNT] = tmpY[newCNT - 1];
tmpL[newCNT] = l;
newCNT++;
numVIAT1++;
for (int l = bottom_layer; l <= top_layer; l++) {
tmpX[newCNT] = tmpX[newCNT - 1];
tmpY[newCNT] = tmpY[newCNT - 1];
tmpL[newCNT] = l;
newCNT++;
numVIAT1++;
}
} else {
for (int l = top_layer - 1; l >= bottom_layer; l--) {
tmpX[newCNT] = tmpX[newCNT - 1];
tmpY[newCNT] = tmpY[newCNT - 1];
tmpL[newCNT] = l;
newCNT++;
if (node1_alias >= num_terminals) {
numVIAT2++;
}
}
}
}
if (treeedges[edgeID].route.type == RouteType::MazeRoute) {
treeedges[edgeID].route.gridsX.clear();
treeedges[edgeID].route.gridsY.clear();
treeedges[edgeID].route.gridsL.clear();
}
treeedge->route.gridsX.resize(newCNT, 0);
treeedge->route.gridsY.resize(newCNT, 0);
treeedge->route.gridsL.resize(newCNT, 0);
treeedge->route.type = RouteType::MazeRoute;
treeedge->route.routelen = newCNT - 1;

for (int k = 0; k < newCNT; k++) {
treeedge->route.gridsX[k] = tmpX[k];
treeedge->route.gridsY[k] = tmpY[k];
treeedge->route.gridsL[k] = tmpL[k];
// Update the edge's route only if there were VIAs added for this edge
if (newCNT != routeLen) {
if (treeedges[edgeID].route.type == RouteType::MazeRoute) {
treeedges[edgeID].route.gridsX.clear();
treeedges[edgeID].route.gridsY.clear();
treeedges[edgeID].route.gridsL.clear();
}
treeedge->route.gridsX.resize(newCNT, 0);
treeedge->route.gridsY.resize(newCNT, 0);
treeedge->route.gridsL.resize(newCNT, 0);
treeedge->route.type = RouteType::MazeRoute;
treeedge->route.routelen = newCNT - 1;

for (int k = 0; k < newCNT; k++) {
treeedge->route.gridsX[k] = tmpX[k];
treeedge->route.gridsY[k] = tmpY[k];
treeedge->route.gridsL[k] = tmpL[k];
}
}
} else if ((treenodes[treeedge->n1].hID == BIG_INT
&& treenodes[treeedge->n1].lID == BIG_INT)
Expand All @@ -339,12 +326,28 @@ void FastRouteCore::fillVIA()

int l1 = treenodes[node1].botL;
int l2 = treenodes[node2].botL;
auto [bottom_layer, top_layer] = std::minmax(l1, l2);
int bottom_layer = std::min(l1, l2);
int top_layer = std::max(l1, l2);
if (node1 < num_terminals) {
int16_t pin_botL, pin_topL;
getViaStackRange(netID, node1, pin_botL, pin_topL);
bottom_layer = std::min((int) pin_botL, bottom_layer);
top_layer = std::max((int) pin_topL, top_layer);
}

if (node2 < num_terminals) {
int16_t pin_botL, pin_topL;
getViaStackRange(netID, node2, pin_botL, pin_topL);
bottom_layer = std::min((int) pin_botL, bottom_layer);
top_layer = std::max((int) pin_topL, top_layer);
}

treeedge->route.gridsX.resize(top_layer - bottom_layer + 1, 0);
treeedge->route.gridsY.resize(top_layer - bottom_layer + 1, 0);
treeedge->route.gridsL.resize(top_layer - bottom_layer + 1, 0);
treeedge->route.type = RouteType::MazeRoute;
treeedge->route.routelen = top_layer - bottom_layer;

int count = 0;
for (int l = bottom_layer; l <= top_layer; l++) {
treeedge->route.gridsX[count] = treenodes[node1].x;
Expand Down
8 changes: 4 additions & 4 deletions src/grt/test/clock_route.ok
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ met4 Vertical 8968 4366 51.32%
met5 Horizontal 2964 1443 51.32%
---------------------------------------------------------------

[INFO GRT-0197] Via related to pin nodes: 120
[INFO GRT-0198] Via related Steiner nodes: 11
[INFO GRT-0197] Via related to pin nodes: 152
[INFO GRT-0198] Via related Steiner nodes: 7
[INFO GRT-0199] Via filling finished.
[INFO GRT-0111] Final number of vias: 141
[INFO GRT-0112] Final usage 3D: 580
[INFO GRT-0111] Final number of vias: 202
[INFO GRT-0112] Final usage 3D: 763

[INFO GRT-0096] Final congestion report:
Layer Resource Demand Usage (%) Max H / Max V / Total Overflow
Expand Down
8 changes: 4 additions & 4 deletions src/grt/test/clock_route_alpha.ok
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ met4 Vertical 8968 4366 51.32%
met5 Horizontal 2964 1443 51.32%
---------------------------------------------------------------

[INFO GRT-0197] Via related to pin nodes: 118
[INFO GRT-0198] Via related Steiner nodes: 13
[INFO GRT-0197] Via related to pin nodes: 150
[INFO GRT-0198] Via related Steiner nodes: 12
[INFO GRT-0199] Via filling finished.
[INFO GRT-0111] Final number of vias: 137
[INFO GRT-0112] Final usage 3D: 568
[INFO GRT-0111] Final number of vias: 196
[INFO GRT-0112] Final usage 3D: 745

[INFO GRT-0096] Final congestion report:
Layer Resource Demand Usage (%) Max H / Max V / Total Overflow
Expand Down
Loading

0 comments on commit d1f4cec

Please sign in to comment.