Skip to content

Commit b685814

Browse files
author
osamahammad21
committed
drt: add lef58_area markers and add test case
Signed-off-by: osamahammad21 <osama@precisioninno.com>
1 parent 2ac8616 commit b685814

5 files changed

Lines changed: 106 additions & 19 deletions

File tree

src/drt/src/gc/FlexGC_impl.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,16 @@ class FlexGCWorker::Impl
534534
frMinimumcutConstraint* con);
535535
void checkMinimumCut_main(gcRect* rect);
536536
void checkMinimumCut();
537-
void checkMetalShape_lef58Area(gcPin* pin);
537+
void checkMetalShape_lef58Area(gcPin* pin, bool allow_patching);
538538
bool checkMetalShape_lef58Area_exceptRectangle(
539539
gcPolygon* poly,
540540
odb::dbTechLayerAreaRule* db_rule);
541541
bool checkMetalShape_lef58Area_rectWidth(gcPolygon* poly,
542542
odb::dbTechLayerAreaRule* db_rule);
543543
void checkMetalShape_addPatch(gcPin* pin, int min_area);
544+
void checkMetalShape_addMarker(gcPin* pin,
545+
frConstraint* con,
546+
const odb::Rect& bbox);
544547
void checkMetalShape_patchOwner_helper(drPatchWire* patch,
545548
const std::vector<drNet*>* dr_nets);
546549

src/drt/src/gc/FlexGC_main.cpp

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,16 +1644,7 @@ void FlexGCWorker::Impl::checkMetalShape_minArea(gcPin* pin,
16441644
if (allow_patching) {
16451645
checkMetalShape_addPatch(pin, reqArea);
16461646
} else {
1647-
auto net = poly->getNet();
1648-
auto marker = std::make_unique<frMarker>();
1649-
marker->setBBox(bbox2);
1650-
marker->setLayerNum(layerNum);
1651-
marker->setConstraint(con);
1652-
marker->addSrc(net->getOwner());
1653-
marker->addVictim(net->getOwner(), std::make_tuple(layerNum, bbox2, false));
1654-
marker->addAggressor(net->getOwner(),
1655-
std::make_tuple(layerNum, bbox2, false));
1656-
addMarker(std::move(marker));
1647+
checkMetalShape_addMarker(pin, con, bbox2);
16571648
}
16581649
}
16591650

@@ -2095,9 +2086,15 @@ void FlexGCWorker::Impl::checkMetalShape_minEnclosedArea(gcPin* pin)
20952086
}
20962087
}
20972088

2098-
void FlexGCWorker::Impl::checkMetalShape_lef58Area(gcPin* pin)
2089+
void FlexGCWorker::Impl::checkMetalShape_lef58Area(gcPin* pin,
2090+
bool allow_patching)
20992091
{
2100-
if (ignoreMinArea_ || !targetNet_) {
2092+
if (ignoreMinArea_) {
2093+
return;
2094+
}
2095+
// Patching requires a target net (and an associated drWorker); marking does
2096+
// not.
2097+
if (allow_patching && !targetNet_) {
21012098
return;
21022099
}
21032100

@@ -2113,7 +2110,7 @@ void FlexGCWorker::Impl::checkMetalShape_lef58Area(gcPin* pin)
21132110
gtl::extents(bbox, *pin->getPolygon());
21142111
const odb::Rect bbox2(
21152112
gtl::xl(bbox), gtl::yl(bbox), gtl::xh(bbox), gtl::yh(bbox));
2116-
if (!drWorker_->getDrcBox().contains(bbox2)) {
2113+
if (!drcBox_.contains(bbox2)) {
21172114
return;
21182115
}
21192116
const bool is_rect = poly->size() == 4;
@@ -2125,7 +2122,11 @@ void FlexGCWorker::Impl::checkMetalShape_lef58Area(gcPin* pin)
21252122
// we found a rectwidth constraint that is satisfied
21262123
const auto min_area = db_rule->getArea();
21272124
if (curr_area < min_area) {
2128-
checkMetalShape_addPatch(pin, min_area);
2125+
if (allow_patching) {
2126+
checkMetalShape_addPatch(pin, min_area);
2127+
} else {
2128+
checkMetalShape_addMarker(pin, con, bbox2);
2129+
}
21292130
}
21302131
return;
21312132
}
@@ -2142,7 +2143,11 @@ void FlexGCWorker::Impl::checkMetalShape_lef58Area(gcPin* pin)
21422143
}
21432144
if (!db_rule->isExceptRectangle()
21442145
|| checkMetalShape_lef58Area_exceptRectangle(poly, db_rule)) {
2145-
checkMetalShape_addPatch(pin, min_area);
2146+
if (allow_patching) {
2147+
checkMetalShape_addPatch(pin, min_area);
2148+
} else {
2149+
checkMetalShape_addMarker(pin, con, bbox2);
2150+
}
21462151
break;
21472152
}
21482153
}
@@ -2283,6 +2288,24 @@ void FlexGCWorker::Impl::checkMetalShape_addPatch(gcPin* pin, int min_area)
22832288
pwires_.push_back(std::move(patch));
22842289
}
22852290

2291+
void FlexGCWorker::Impl::checkMetalShape_addMarker(gcPin* pin,
2292+
frConstraint* con,
2293+
const odb::Rect& bbox)
2294+
{
2295+
auto poly = pin->getPolygon();
2296+
auto layer_num = poly->getLayerNum();
2297+
auto net = poly->getNet();
2298+
auto marker = std::make_unique<frMarker>();
2299+
marker->setBBox(bbox);
2300+
marker->setLayerNum(layer_num);
2301+
marker->setConstraint(con);
2302+
marker->addSrc(net->getOwner());
2303+
marker->addVictim(net->getOwner(), std::make_tuple(layer_num, bbox, false));
2304+
marker->addAggressor(net->getOwner(),
2305+
std::make_tuple(layer_num, bbox, false));
2306+
addMarker(std::move(marker));
2307+
}
2308+
22862309
void FlexGCWorker::Impl::checkMetalShape_patchOwner_helper(
22872310
drPatchWire* patch,
22882311
const std::vector<drNet*>* dr_nets)
@@ -2353,9 +2376,7 @@ void FlexGCWorker::Impl::checkMetalShape_main(gcPin* pin, bool allow_patching)
23532376
checkMetalShape_minEnclosedArea(pin);
23542377

23552378
// lef58 area
2356-
if (allow_patching) {
2357-
checkMetalShape_lef58Area(pin);
2358-
}
2379+
checkMetalShape_lef58Area(pin, allow_patching);
23592380
}
23602381

23612382
void FlexGCWorker::Impl::checkMetalShape(bool allow_patching)

src/drt/test/fixture.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,33 @@ void Fixture::makeMinEnclosedAreaConstraint(frLayerNum layer_num)
344344
tech->addUConstraint(std::move(con));
345345
}
346346

347+
odb::dbTechLayerAreaRule* Fixture::makeLef58AreaConstraint(
348+
frLayerNum layer_num,
349+
int64_t area,
350+
int rect_width,
351+
bool except_rectangle)
352+
{
353+
frTechObject* tech = design->getTech();
354+
frLayer* layer = tech->getLayer(layer_num);
355+
odb::dbTechLayer* db_layer = db_tech->findLayer(layer->getName().c_str());
356+
357+
auto rule = odb::dbTechLayerAreaRule::create(db_layer);
358+
rule->setArea(area);
359+
if (rect_width > 0) {
360+
rule->setRectWidth(rect_width);
361+
}
362+
rule->setExceptRectangle(except_rectangle);
363+
364+
auto con = std::make_unique<frLef58AreaConstraint>(rule);
365+
if (rule->getRectWidth() > 0) {
366+
layer->addLef58AreaConstraintRectWidth(con.get());
367+
} else {
368+
layer->addLef58AreaConstraint(con.get());
369+
}
370+
tech->addUConstraint(std::move(con));
371+
return rule;
372+
}
373+
347374
void Fixture::makeSpacingEndOfLineConstraint(frLayerNum layer_num,
348375
frCoord par_space,
349376
frCoord par_within,

src/drt/test/fixture.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ class Fixture : public ::testing::Test
9292

9393
void makeMinEnclosedAreaConstraint(frLayerNum layer_num);
9494

95+
odb::dbTechLayerAreaRule* makeLef58AreaConstraint(frLayerNum layer_num,
96+
int64_t area,
97+
int rect_width = -1,
98+
bool except_rectangle
99+
= false);
100+
95101
void makeSpacingEndOfLineConstraint(frLayerNum layer_num,
96102
frCoord par_space = -1,
97103
frCoord par_within = -1,

src/drt/test/gcTest.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,36 @@ TEST_F(GCFixture, min_enclosed_area)
600600
odb::Rect(50, 50, 150, 150));
601601
}
602602

603+
using Lef58AreaFixture = FixtureWithParam<bool>;
604+
605+
TEST_P(Lef58AreaFixture, lef58_area)
606+
{
607+
const bool legal = GetParam();
608+
// The wire below provides 200 x 100 = 20000 DBU^2. Require just under that
609+
// when legal and just over it when illegal.
610+
makeLef58AreaConstraint(2, /* area */ legal ? 20000 : 30000);
611+
612+
frNet* n1 = makeNet("n1");
613+
614+
makePathseg(n1, 2, {0, 100}, {200, 100});
615+
616+
runGC();
617+
618+
// Test the results
619+
auto& markers = worker.getMarkers();
620+
if (legal) {
621+
EXPECT_EQ(markers.size(), 0);
622+
} else {
623+
EXPECT_EQ(markers.size(), 1);
624+
testMarker(markers[0].get(),
625+
2,
626+
frConstraintTypeEnum::frcLef58AreaConstraint,
627+
odb::Rect(0, 50, 200, 150));
628+
}
629+
}
630+
631+
INSTANTIATE_TEST_SUITE_P(Lef58AreaSuite, Lef58AreaFixture, testing::Bool());
632+
603633
// Check for a spacing table influence violation.
604634
TEST_F(GCFixture, spacing_table_infl_vertical)
605635
{

0 commit comments

Comments
 (0)