Skip to content

Commit 2949545

Browse files
committed
grt: consider iterms and bterms in estimatePathResistance
Signed-off-by: Jonas Gava <[email protected]>
1 parent a4045d9 commit 2949545

File tree

4 files changed

+78
-24
lines changed

4 files changed

+78
-24
lines changed

src/grt/include/grt/GlobalRouter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ class GlobalRouter
290290
float getLayerResistance(int layer, int length, odb::dbNet* net);
291291
float getViaResistance(int from_layer, int to_layer);
292292
double dbuToMicrons(int dbu);
293-
float estimatePathResistance(odb::dbITerm* pin1,
294-
odb::dbITerm* pin2,
293+
float estimatePathResistance(odb::dbObject* pin1,
294+
odb::dbObject* pin2,
295295
bool verbose = false);
296-
float estimatePathResistance(odb::dbITerm* pin1,
297-
odb::dbITerm* pin2,
296+
float estimatePathResistance(odb::dbObject* pin1,
297+
odb::dbObject* pin2,
298298
odb::dbTechLayer* layer1,
299299
odb::dbTechLayer* layer2,
300300
bool verbose = false);

src/grt/src/GlobalRouter.cpp

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,7 +3179,7 @@ void GlobalRouter::checkPinPlacement()
31793179

31803180
double GlobalRouter::dbuToMicrons(int dbu)
31813181
{
3182-
return (double) dbu / db_->getTech()->getDbUnitsPerMicron();
3182+
return (double) dbu / db_->getDbuPerMicron();
31833183
}
31843184

31853185
float GlobalRouter::getLayerResistance(int layer,
@@ -3234,11 +3234,19 @@ float GlobalRouter::getViaResistance(int from_layer, int to_layer)
32343234
return total_via_resistance;
32353235
}
32363236

3237-
float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
3238-
odb::dbITerm* pin2,
3237+
float GlobalRouter::estimatePathResistance(odb::dbObject* pin1,
3238+
odb::dbObject* pin2,
32393239
bool verbose)
32403240
{
3241-
odb::dbNet* db_net = pin1->getNet();
3241+
odb::dbNet* db_net = nullptr;
3242+
if (pin1->getObjectType() == odb::dbITermObj) {
3243+
db_net = ((odb::dbITerm*) pin1)->getNet();
3244+
} else if (pin1->getObjectType() == odb::dbBTermObj) {
3245+
db_net = ((odb::dbBTerm*) pin1)->getNet();
3246+
} else {
3247+
return 0.0;
3248+
}
3249+
32423250
if (routes_.find(db_net) == routes_.end()) {
32433251
return 0.0;
32443252
}
@@ -3249,9 +3257,9 @@ float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
32493257
odb::dbTech* tech = db_->getTech();
32503258

32513259
for (auto& loc : pin_locs) {
3252-
if (loc.iterm == pin1) {
3260+
if (loc.iterm == pin1 || loc.bterm == pin1) {
32533261
start_loc = &loc;
3254-
} else if (loc.iterm == pin2) {
3262+
} else if (loc.iterm == pin2 || loc.bterm == pin2) {
32553263
end_loc = &loc;
32563264
}
32573265
}
@@ -3261,11 +3269,17 @@ float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
32613269
}
32623270

32633271
if (verbose) {
3272+
std::string pin1_name = (pin1->getObjectType() == odb::dbITermObj)
3273+
? ((odb::dbITerm*) pin1)->getName()
3274+
: ((odb::dbBTerm*) pin1)->getName();
3275+
std::string pin2_name = (pin2->getObjectType() == odb::dbITermObj)
3276+
? ((odb::dbITerm*) pin2)->getName()
3277+
: ((odb::dbBTerm*) pin2)->getName();
32643278
logger_->report(
32653279
"Estimating Path Resistance between pin ({}) and pin ({}) through net "
32663280
"({})",
3267-
start_loc->iterm->getName(),
3268-
end_loc->iterm->getName(),
3281+
pin1_name,
3282+
pin2_name,
32693283
db_net->getConstName());
32703284
}
32713285

@@ -3364,22 +3378,30 @@ float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
33643378

33653379
// Estimate Path Resistance between two pins considering the vertical and
33663380
// horizontal metal layers defined by the user
3367-
float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
3368-
odb::dbITerm* pin2,
3381+
float GlobalRouter::estimatePathResistance(odb::dbObject* pin1,
3382+
odb::dbObject* pin2,
33693383
odb::dbTechLayer* layer1,
33703384
odb::dbTechLayer* layer2,
33713385
bool verbose)
33723386
{
3373-
odb::dbNet* db_net = pin1->getNet();
3387+
odb::dbNet* db_net = nullptr;
3388+
if (pin1->getObjectType() == odb::dbITermObj) {
3389+
db_net = ((odb::dbITerm*) pin1)->getNet();
3390+
} else if (pin1->getObjectType() == odb::dbBTermObj) {
3391+
db_net = ((odb::dbBTerm*) pin1)->getNet();
3392+
} else {
3393+
return 0.0;
3394+
}
3395+
33743396
std::vector<PinGridLocation> pin_locs = getPinGridPositions(db_net);
33753397
PinGridLocation* start_loc = nullptr;
33763398
PinGridLocation* end_loc = nullptr;
33773399
odb::dbTech* tech = db_->getTech();
33783400

33793401
for (auto& loc : pin_locs) {
3380-
if (loc.iterm == pin1) {
3402+
if (loc.iterm == pin1 || loc.bterm == pin1) {
33813403
start_loc = &loc;
3382-
} else if (loc.iterm == pin2) {
3404+
} else if (loc.iterm == pin2 || loc.bterm == pin2) {
33833405
end_loc = &loc;
33843406
}
33853407
}
@@ -3389,11 +3411,17 @@ float GlobalRouter::estimatePathResistance(odb::dbITerm* pin1,
33893411
}
33903412

33913413
if (verbose) {
3414+
std::string pin1_name = (pin1->getObjectType() == odb::dbITermObj)
3415+
? ((odb::dbITerm*) pin1)->getName()
3416+
: ((odb::dbBTerm*) pin1)->getName();
3417+
std::string pin2_name = (pin2->getObjectType() == odb::dbITermObj)
3418+
? ((odb::dbITerm*) pin2)->getName()
3419+
: ((odb::dbBTerm*) pin2)->getName();
33923420
logger_->report(
33933421
"Estimating Path Resistance between pin ({}) and pin ({}) using layers "
33943422
"{} and {}",
3395-
start_loc->iterm->getName(),
3396-
end_loc->iterm->getName(),
3423+
pin1_name,
3424+
pin2_name,
33973425
layer1->getName(),
33983426
layer2->getName());
33993427
}

src/grt/src/GlobalRouter.i

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,15 +269,25 @@ void write_pin_locations(const char* file_name)
269269
getGlobalRouter()->writePinLocations(file_name);
270270
}
271271

272-
float estimate_path_resistance(odb::dbITerm* pin1,
273-
odb::dbITerm* pin2,
272+
odb::dbObject* iterm_to_object(odb::dbITerm* iterm)
273+
{
274+
return (odb::dbObject*) iterm;
275+
}
276+
277+
odb::dbObject* bterm_to_object(odb::dbBTerm* bterm)
278+
{
279+
return (odb::dbObject*) bterm;
280+
}
281+
282+
float estimate_path_resistance(odb::dbObject* pin1,
283+
odb::dbObject* pin2,
274284
bool verbose = false)
275285
{
276286
return getGlobalRouter()->estimatePathResistance(pin1, pin2, verbose);
277287
}
278288

279-
float estimate_path_resistance(odb::dbITerm* pin1,
280-
odb::dbITerm* pin2,
289+
float estimate_path_resistance(odb::dbObject* pin1,
290+
odb::dbObject* pin2,
281291
odb::dbTechLayer* layer1,
282292
odb::dbTechLayer* layer2,
283293
bool verbose = false)

src/grt/src/GlobalRouter.tcl

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,27 @@ proc estimate_path_resistance { args } {
484484
}
485485

486486
set pin1 [$block findITerm $pin1_name]
487+
if { $pin1 != "NULL" } {
488+
set pin1 [grt::iterm_to_object $pin1]
489+
} else {
490+
set pin1 [$block findBTerm $pin1_name]
491+
if { $pin1 != "NULL" } {
492+
set pin1 [grt::bterm_to_object $pin1]
493+
}
494+
}
487495
if { $pin1 == "NULL" } {
488496
utl::error GRT 284 "Pin $pin1_name not found."
489497
}
490498

491499
set pin2 [$block findITerm $pin2_name]
500+
if { $pin2 != "NULL" } {
501+
set pin2 [grt::iterm_to_object $pin2]
502+
} else {
503+
set pin2 [$block findBTerm $pin2_name]
504+
if { $pin2 != "NULL" } {
505+
set pin2 [grt::bterm_to_object $pin2]
506+
}
507+
}
492508
if { $pin2 == "NULL" } {
493509
utl::error GRT 285 "Pin $pin2_name not found."
494510
}
@@ -516,7 +532,7 @@ proc estimate_path_resistance { args } {
516532

517533
return [grt::estimate_path_resistance $pin1 $pin2 $layer1 $layer2 $verbose]
518534
} elseif { [info exists keys(-layer1)] || [info exists keys(-layer2)] } {
519-
utl::error GRT 288 "Both -layer1 and -layer2 must be provided."
535+
utl::error GRT 288 "Both or neither -layer1 and -layer2 must be provided."
520536
}
521537

522538
return [grt::estimate_path_resistance $pin1 $pin2 $verbose]

0 commit comments

Comments
 (0)