@@ -7,6 +7,7 @@ namespace CustomDefParser {
7
7
8
8
// define as global to access retrieved data inside customized callback function
9
9
DefDataBase* defDB = NULL ;
10
+ int indexOfNet = 0 ; // 0-based index of regualr net in DEF-NETS
10
11
11
12
int custom_netf (defrCallbackType_e c, defiNet* net, defiUserData ud) {
12
13
#define IGNORE_DEBUG_PRINT_defiNet_
@@ -22,6 +23,8 @@ namespace CustomDefParser {
22
23
// Via information from Regular Wiring Statement in DEF-NETS
23
24
/* refer to Limbo\limbo\thirdparty\lefdef\5.8\def\def\defiNet.hpp */
24
25
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;
25
28
ViaInfo curVia;
26
29
for (int i = 0 ; i < net->numWires (); i++) {
27
30
int newLayer = 0 ;
@@ -76,6 +79,11 @@ namespace CustomDefParser {
76
79
break ;
77
80
case DEFIPATH_POINT:
78
81
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);
79
87
#ifndef IGNORE_DEBUG_PRINT_defiNet_
80
88
fprintf (stdout, " ( %d %d ) " , x, y);
81
89
#endif
@@ -91,7 +99,26 @@ namespace CustomDefParser {
91
99
}
92
100
93
101
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++;
95
122
return 0 ;
96
123
}
97
124
@@ -138,6 +165,7 @@ namespace CustomDefParser {
138
165
139
166
bool customDefRead (DefDataBase& dbDef, const string& defFile) {
140
167
defDB = &dbDef; // set dbDef as global defDB
168
+ indexOfNet = 0 ; // init index of net in DEF-NETS
141
169
142
170
CustomDefDriver driver (dbDef);
143
171
bool res = driver.custom_parse_file (defFile);
@@ -164,6 +192,8 @@ void DefDataBase::print_allNets() {
164
192
cout << " " << via.viaName << " ( " << via.xInUm << " , " << via.yInUm << " ) \n " ;
165
193
}
166
194
}
195
+ cout << " Bounding box (xmin, ymin, xmax, ymax) in um: ( " << net.boundBoxInUm [0 ] << " , "
196
+ << net.boundBoxInUm [1 ] << " , " << net.boundBoxInUm [2 ] << " , " << net.boundBoxInUm [3 ] << " ) \n " ;
167
197
}
168
198
}
169
199
0 commit comments