-
Notifications
You must be signed in to change notification settings - Fork 1k
grt: cache per-layer wire resistance #11622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -519,11 +519,19 @@ void FastRouteCore::fixEdgeAssignment(int& net_layer, | |||||||||||||
| // Optimize performance | ||||||||||||||
| void FastRouteCore::preProcessTechLayers() | ||||||||||||||
| { | ||||||||||||||
| dbu_per_micron_ | ||||||||||||||
| = db_->getChip()->getBlock()->getTech()->getDbUnitsPerMicron(); | ||||||||||||||
| layer_res_per_micron_.assign(num_layers_, 0.0f); | ||||||||||||||
|
|
||||||||||||||
| for (int layer = 0; layer < num_layers_; layer++) { | ||||||||||||||
| odb::dbTech* tech = db_->getTech(); | ||||||||||||||
| odb::dbTechLayer* db_layer = tech->findRoutingLayer(layer + 1); | ||||||||||||||
| db_layers_.emplace_back(db_layer); | ||||||||||||||
|
|
||||||||||||||
| // Keep layer_width as float: other rounding perturbs getWireCost() results | ||||||||||||||
| const float layer_width = dbuToMicrons(db_layer->getWidth()); | ||||||||||||||
| layer_res_per_micron_[layer] = db_layer->getResistance() / layer_width; | ||||||||||||||
|
|
||||||||||||||
| // Via | ||||||||||||||
| db_layer = tech->findRoutingLayer(layer + 1)->getUpperLayer(); | ||||||||||||||
| db_layers_.emplace_back(db_layer); | ||||||||||||||
|
|
@@ -543,25 +551,23 @@ float FastRouteCore::getWireResistance(const int layer, | |||||||||||||
| const int length, | ||||||||||||||
| FrNet* net) | ||||||||||||||
| { | ||||||||||||||
| odb::dbTechLayer* db_layer = getTechLayer(layer, false); | ||||||||||||||
| if (layer < net->getMinLayer() || layer > net->getMaxLayer()) { | ||||||||||||||
| return BIG_INT; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+554
to
+556
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Accessing
Suggested change
|
||||||||||||||
|
|
||||||||||||||
| int width = db_layer->getWidth(); | ||||||||||||||
| double resistance = db_layer->getResistance(); | ||||||||||||||
| // Default-width value cached by preProcessTechLayers() | ||||||||||||||
| float res_ohm_per_micron = layer_res_per_micron_[layer]; | ||||||||||||||
|
|
||||||||||||||
| // If net has NDR, get the correct width value | ||||||||||||||
| odb::dbTechNonDefaultRule* ndr = net->getDbNet()->getNonDefaultRule(); | ||||||||||||||
| if (ndr != nullptr) { | ||||||||||||||
| odb::dbTechLayer* db_layer = getTechLayer(layer, false); | ||||||||||||||
| odb::dbTechLayerRule* layerRule = ndr->getLayerRule(db_layer); | ||||||||||||||
| width = layerRule->getWidth(); | ||||||||||||||
| const float layer_width = dbuToMicrons(layerRule->getWidth()); | ||||||||||||||
| res_ohm_per_micron = db_layer->getResistance() / layer_width; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
561
to
568
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Several potential issues exist here:
Adding defensive checks for these cases prevents potential crashes and undefined behavior. // If net has NDR, get the correct width value
odb::dbTechNonDefaultRule* ndr = net->getDbNet()->getNonDefaultRule();
if (ndr != nullptr) {
odb::dbTechLayer* db_layer = getTechLayer(layer, false);
if (db_layer != nullptr) {
odb::dbTechLayerRule* layerRule = ndr->getLayerRule(db_layer);
if (layerRule != nullptr) {
const float layer_width = dbuToMicrons(layerRule->getWidth());
if (layer_width > 0.0f) {
res_ohm_per_micron = db_layer->getResistance() / layer_width;
}
}
}
} |
||||||||||||||
|
|
||||||||||||||
| const float layer_width = dbuToMicrons(width); | ||||||||||||||
| const float res_ohm_per_micron = resistance / layer_width; | ||||||||||||||
| float final_resistance = res_ohm_per_micron * dbuToMicrons(length); | ||||||||||||||
|
|
||||||||||||||
| if (layer < net->getMinLayer() || layer > net->getMaxLayer()) { | ||||||||||||||
| return BIG_INT; | ||||||||||||||
| } | ||||||||||||||
| const float final_resistance = res_ohm_per_micron * dbuToMicrons(length); | ||||||||||||||
|
|
||||||||||||||
| return final_resistance; | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -2808,7 +2814,7 @@ odb::Rect FastRouteCore::globalRoutingToBox(const GSegment& route) | |||||||||||||
|
|
||||||||||||||
| double FastRouteCore::dbuToMicrons(const int dbu) | ||||||||||||||
| { | ||||||||||||||
| return db_->getChip()->getBlock()->dbuToMicrons(dbu); | ||||||||||||||
| return dbu / dbu_per_micron_; | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
2815
to
2818
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If double FastRouteCore::dbuToMicrons(const int dbu)
{
if (dbu_per_micron_ == 0.0) {
return db_->getChip()->getBlock()->dbuToMicrons(dbu);
}
return dbu / dbu_per_micron_;
} |
||||||||||||||
|
|
||||||||||||||
| void FastRouteCore::saveCongestion(const int iter) | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
layer_widthis0.0f(e.g., due to an invalid or uninitialized layer width in the tech file), dividing by it will result in a division-by-zero error. It is safer to guard against this by checking iflayer_widthis greater than zero.