Skip to content

Commit ac66605

Browse files
committed
grt: fix CUGR ap conversion out of bounds
Signed-off-by: rafaelmoresco <[email protected]>
1 parent 0081945 commit ac66605

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/grt/src/cugr/src/GridGraph.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,13 @@ bool GridGraph::findODBAccessPoints(
386386
for (auto ap : bpin_pas) {
387387
auto point = ap->getPoint();
388388
auto layer = ap->getLayer();
389-
const PointT selected_point = PointT(point.getX() / amount_per_x,
390-
point.getY() / amount_per_y);
389+
const int ap_x = (point.getX() / amount_per_x >= x_size_)
390+
? x_size_ - 1
391+
: point.getX() / amount_per_x;
392+
const int ap_y = (point.getY() / amount_per_y >= y_size_)
393+
? y_size_ - 1
394+
: point.getY() / amount_per_y;
395+
const PointT selected_point = PointT(ap_x, ap_y);
391396
const int num_layer
392397
= ((layer->getNumber() - 2) > (getNumLayers() - 1))
393398
? getNumLayers() - 1
@@ -412,6 +417,13 @@ bool GridGraph::findODBAccessPoints(
412417
iterms->getInst()->getLocation(x, y);
413418
auto point = ap->getPoint();
414419
auto layer = ap->getLayer();
420+
const int ap_x = (point.getX() + x / amount_per_x >= x_size_)
421+
? x_size_ - 1
422+
: point.getX() + x / amount_per_x;
423+
const int ap_y = (point.getY() + y / amount_per_y >= y_size_)
424+
? y_size_ - 1
425+
: point.getY() + y / amount_per_y;
426+
const PointT selected_point = PointT(ap_x, ap_y);
415427
const PointT selected_point
416428
= PointT((point.getX() + x) / amount_per_x,
417429
(point.getY() + y) / amount_per_y);

src/grt/test/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ MANUAL_FOR_BAZEL_TESTS = [
120120
"cugr_adjustment2",
121121
"cugr_adjustment3",
122122
"gcd_cugr",
123+
"pin_access1_cugr",
124+
"pin_access2_cugr",
123125
]
124126

125127
[regression_test(

0 commit comments

Comments
 (0)