Skip to content

Commit 38f818d

Browse files
committed
find bounding box {xmin, ymin, xmax, ymax} of each net
1) Type 1: Most nets have regular wiring statements in DEF-NETS, where many points (x, y) will be given to define the wire location. Use the min & max all points (x, y) to find the bounding box. 2) Type 2: A few nets only have pin name defined, no regular wiring statements, therefore no point (x, y). In such cases, set bounding box as [0,0,0,0]. Similar to provided SPEF, keep the net name in file, but do not simulate the net nor extract RC.
1 parent dcdefa3 commit 38f818d

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/autoPortFromDefLef.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace CustomDefParser {
77

88
// define as global to access retrieved data inside customized callback function
99
DefDataBase* defDB = NULL;
10+
int indexOfNet = 0; // 0-based index of regualr net in DEF-NETS
1011

1112
int custom_netf(defrCallbackType_e c, defiNet* net, defiUserData ud) {
1213
#define IGNORE_DEBUG_PRINT_defiNet_
@@ -22,6 +23,8 @@ namespace CustomDefParser {
2223
// Via information from Regular Wiring Statement in DEF-NETS
2324
/* refer to Limbo\limbo\thirdparty\lefdef\5.8\def\def\defiNet.hpp */
2425
int x, y; // current point
26+
int xmin = INT_MAX, ymin = INT_MAX; // track the bounding box of this net
27+
int xmax = INT_MIN, ymax = INT_MIN;
2528
ViaInfo curVia;
2629
for (int i = 0; i < net->numWires(); i++) {
2730
int newLayer = 0;
@@ -76,6 +79,11 @@ namespace CustomDefParser {
7679
break;
7780
case DEFIPATH_POINT:
7881
p->getPoint(&x, &y);
82+
// get bounding box from min & max of all points in the wires
83+
xmin = min(xmin, x);
84+
ymin = min(ymin, y);
85+
xmax = max(xmax, x);
86+
ymax = max(ymax, y);
7987
#ifndef IGNORE_DEBUG_PRINT_defiNet_
8088
fprintf(stdout, "( %d %d ) ", x, y);
8189
#endif
@@ -91,7 +99,26 @@ namespace CustomDefParser {
9199
}
92100

93101
defDB->netName_to_vVias[netName] = vVias;
94-
102+
103+
auto& curNet = defDB->allNets[indexOfNet];
104+
// bounding box should also be bounded by the die area of the DEF design
105+
curNet.boundBoxInUm[0] = max(xmin * 1.0 / defDB->defUnit, defDB->dieAreaInUm[0]);
106+
curNet.boundBoxInUm[1] = max(ymin * 1.0 / defDB->defUnit, defDB->dieAreaInUm[1]);
107+
curNet.boundBoxInUm[2] = min(xmax * 1.0 / defDB->defUnit, defDB->dieAreaInUm[2]);
108+
curNet.boundBoxInUm[3] = min(ymax * 1.0 / defDB->defUnit, defDB->dieAreaInUm[3]);
109+
if (curNet.netName != netName || xmin == INT_MAX) {
110+
if (curNet.netName != netName) {
111+
cerr << "Warning: netName NOT matched! Bounding box is set to [0,0,0,0] for net \"" << curNet.netName << "\" \n";
112+
}
113+
else if (xmin == INT_MAX) {
114+
cerr << "Warning: NO point found in net wiring statement! Bounding box is set to [0,0,0,0] for net \"" << curNet.netName << "\" \n";
115+
}
116+
for (int i = 0; i < 4; i++) {
117+
curNet.boundBoxInUm[i] = 0;
118+
}
119+
}
120+
121+
indexOfNet++;
95122
return 0;
96123
}
97124

@@ -138,6 +165,7 @@ namespace CustomDefParser {
138165

139166
bool customDefRead(DefDataBase& dbDef, const string& defFile) {
140167
defDB = &dbDef; // set dbDef as global defDB
168+
indexOfNet = 0; // init index of net in DEF-NETS
141169

142170
CustomDefDriver driver(dbDef);
143171
bool res = driver.custom_parse_file(defFile);
@@ -164,6 +192,8 @@ void DefDataBase::print_allNets() {
164192
cout << " " << via.viaName << " ( " << via.xInUm << ", " << via.yInUm << " ) \n";
165193
}
166194
}
195+
cout << " Bounding box (xmin, ymin, xmax, ymax) in um: ( " << net.boundBoxInUm[0] << ", "
196+
<< net.boundBoxInUm[1] << ", " << net.boundBoxInUm[2] << ", " << net.boundBoxInUm[3] << " ) \n";
167197
}
168198
}
169199

src/autoPortFromDefLef.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <iostream>
66
#include <string>
77
#include <vector>
8+
#include <algorithm>
89
#include <unordered_map>
910
#include <fstream>
1011
#include <sstream>
@@ -68,6 +69,7 @@ struct NetInfo { // same as DefParser::Net, redefine here for easier refe
6869
string netName = "";
6970
int netWeight = 1; // net weight, used in automatic layout tools, not used in gds2Para.
7071
vector<std::pair<string, string> > vNodenamePin; // array of (node, pin) pair. vNetPin[i].first = componentName.
72+
double boundBoxInUm[4]; // bounding box {xmin, ymin, xmax, ymax} in um of this net
7173
};
7274

7375
class DefDataBase : public DefParser::DefDataBase

0 commit comments

Comments
 (0)