-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbst_header.h
executable file
·429 lines (340 loc) · 10.6 KB
/
bst_header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
///////////////////////////////////////////////////////////////////////////////
// BSD 3-Clause License
//
// Copyright (c) 2018, The Regents of the University of California
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * Neither the name of the copyright holder nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///////////////////////////////////////////////////////////////////////////////
/*
#**************************************************************************
#** Please read README to see how to run this program
*** Created by Chung-Wen Albert Tsao on May 2, 2000*
#**
#**
#**************************************************************************
*/
#ifndef _HEADER_H
#define _HEADER_H
#include "foundation/Coordinate.h"
#include "foundation/MyInterval.h"
#include "foundation/Trr.h"
#include "bstdme.h"
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <sys/times.h>
#include <sys/types.h>
// #include <sys/param.h>
#include <sys/resource.h>
#include <time.h>
#include <assert.h>
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include "foundation/Trr.h"
typedef F_Interval < double, double, true > R_Interval ;
typedef F_Coord < double, double, true > R_Coord ;
typedef F_Point < double, double, true > PointType ;
typedef F_Trr < double, double, true > TrrType ;
#define H_ 0
#define V_ 1
#define NORMAL 0
#define FAST 1
#define MAX_TURN_PTS 12
#define MAX_mr_PTS 16
#define MAXPTS 10
#define PUCAP_SCALE (1E+12)
#define N_Neighboring_Clusters 6
/* types of interseciton of two line segments */
#define P1 1
#define P2 2
#define P3 3
#define P4 4
#define XING 5
#define OVERLAPPING 6
#define SAME_EDGE 7
#define LINEAR 0
#define ELMORE 1
#define BME_MODE 0
#define IME_MODE 1
#define HYBRID_MODE 2
#define LEFT 0 /* vertical or horizontal line segment */
#define TOP 1
#define RIGHT 2
#define BOTTOM 3
#define PARA_MANHATTAN_ARC 4
#define INSIDE -1
#define ON 0
#define OUTSIDE +1
/* types of a line segment */
#define VERTICAL 0
#define HORIZONTAL 1
#define MANHATTAN_ARC 2 /* include single points */
#define FLAT 3
#define TILT 4
#define NIL -1
#define BUCKET_CAPACITY 240 /* max. number of elements in a bucket */
#define MAX_BUFFER_LEVEL 8
#define MANHATTAN 0
#define EUCLIDEAN 1
#define MAX_N_SKEW_SAMPLES 50
#define N_BUFFER_SIZE 50
#define MAX_N_SINKS 3101
#define MAX_N_NODES (2*MAX_N_SINKS)
class PairType {
public:
int x, y;
double cost;
} ;
/* used for CostFunction == 1 only */
typedef struct clustertype {
double x; /* ever min merging cost since this cluster exists */
double y; /* min merging cost in current Nearest Neighbor Graph */
/* merging cost increase of Cluster = y-x >= 0 */
} ClusterType;
class TmpClusterType {
public:
int n, id, marked;
double capac, t;
TrrType *ms;
TmpClusterType ( ) : ms(0) {
} ;
~TmpClusterType () {
if ( ms ) {
delete ms;
ms = 0 ;
}
}
} ;
typedef struct buckettype {
int num; /* number of elements in the bucket */
int element[BUCKET_CAPACITY];
} BucketType;
class AreaType {
public:
int n_mr; /* number of vertices plus skew turning points */
PointType mr[MAX_mr_PTS]; /* skew turning pts + vertices */
int npts; /* number of vertices */
int vertex[MAXPTS]; /* vertices */
int L_area, R_area; /* which area of child nodes is used */
double L_EdgeLen, R_EdgeLen; /* edge length to its children */
double L_StubLen, R_StubLen; /* edge length of stubs of buffered children */
double subtree_cost; /* the (wire) cost of tree rooted at this node */
double dist; /* the distance between its two children */
/* node.dist = linedist(node.line[2][2]) */
int R_buffer;
double ClusterDelay;
double capac, unbuf_capac; /* capacitance of the subtree */
PointType line[2][2];
AreaType *area_L, *area_R;
TrrType L_MS, R_MS;
} ;
class NodeType {
public:
NodeType ():area(0), ms(0) {
} ;
/*
~NodeType () {
if ( ms ) {
delete ms;
ms = 0 ;
}
if ( area ) {
delete [] area ; // nate
area = 0 ;
}
} ;
*/
/* member function */
void Merge2Nodes( NodeType *node_L,NodeType *node_R) ;
PointType m_stnPt ;
/* construct multiple merging areas for a node */
int n_area, ca;
AreaType *area;
/**************************************************/
TrrType *ms; /* merging segment in ZST, and TRR in BST */
int parent, L, R, id, root_id;
char pattern; /* routing pattern */
char buffered; /* indicated if buffered */
} ;
class AreaSetType {
public:
int npoly;
AreaType *freg;
} ;
/**************************************************/
/**************************************************/
class BstTree {
public:
public:
// constructor
BstTree (
const string &inputSinksFileName,
const string &inputTopologyFileName,
const string &inputObstructionFileName,
double skewBound,
BST_DME::DelayModelType delayModel ) ;
// destructor
~BstTree() ;
/*************************************************/
/* initiate the construction of BST */
/*************************************************/
void ConstructTree ( void ) ;
/*************************************************/
/* total length of the resulting BST after calling ConstructTree() ; */
/*************************************************/
double TotalLength ( void ) const ;
/*************************************************/
/* for internal use only */
/* for internal use only */
/* for internal use only */
/* for internal use only */
/* for internal use only */
/*************************************************/
/* set the file name for input sinks, and per-unit rc */
/* mandotory */
/* set the topology file name if run BST-DME for fixed topology */
/* optinoal, default is null */
void SetTopologyFileName (const string &fn ) {
m_inputTopologyFileName = fn ;
} ;
/* set the global skew bound for BST-DME (default 0ps)*/
void SetSkewBound ( double b ) {
m_skewBound = b ;
}
/* Set the file name for obstruction data (optional) */
void SetObstructionFileName (const string &fn ) {
m_inputObstructionFileName = fn ;
} ;
/* Optional, default is Elmore delay model */
void SetDelayModel ( BST_DME::DelayModelType i ) {
m_delayModel = i ;
}
string SinksFileName () const {
return m_inputSinksFileName ;
} ;
/* if ToplogyFileName() not empty, then run BST-DME on fixed topology */
bool FixedTopology () const {
return !TopologyFileName().empty() ;
};
string TopologyFileName () const {
return m_inputTopologyFileName ;
};
string ObstructionFileName () const {
return m_inputObstructionFileName ;
} ;
double SkewBound ( void ) const {
return m_skewBound ;
} ;
double Orig_Skew_B ( void ) const {
return m_skewBound ;
}
bool LinearDelayModel () const {
return m_delayModel == BST_DME::LINEARMODEL ;
} ;
bool ElmoreDelayModel () const {
return m_delayModel == BST_DME::ELMOREMODEL ;
} ;
int RootNodeIndex () const {
return 2*m_nterms - 1 ;
}
int SuperRootNodeIndex () const {
return m_nterms ;
}
NodeType *SuperRootNode ( ) {
return m_treeNode[ m_nterms ] ;
} ;
NodeType *RootNode ( ) {
return m_treeNode[ 2*m_nterms - 1] ;
} ;
NodeType *TreeNode ( unsigned i ) {
return m_treeNode[i] ;
} ;
NodeType * GetCandiRoot ( unsigned i ) {
return m_candiRoot [i] ;
} ;
NodeType * GetTempNode ( unsigned i ) {
return m_tempNode [i] ;
}
void AddTreeNode ( NodeType * node ) {
m_treeNode.push_back ( node ) ;
}
void AddCandiRoot (NodeType * node ) {
m_candiRoot.push_back ( node ) ;
}
void AddTempNode (NodeType * node ) {
m_tempNode.push_back ( node ) ;
}
const TrrType & Ctrr () const {
return m_ctrr;
}
void BuildTrr ( unsigned n ) ;
NodeType* AddOneNode ( unsigned i , double x, double y,
double cap, double delay) ;
unsigned Nterms () const {
return m_nterms ;
}
void SetNterms ( unsigned i ) {
m_nterms = i ;
}
unsigned Npoints () const {
return 2*Nterms() ;
}
double Pucap ( unsigned i=0 ) {
return m_pucap[i] ;
}
double Pures ( unsigned i=0 ) {
return m_pures[i] ;
}
void SetPerUnitResistance ( double pures[2] ) {
m_pures[0] = pures [0];
m_pures[1] = pures [1];
}
void SetPerUnitCapacitance ( double pucap[2] ) {
m_pucap[0] = pucap [0];
m_pucap[1] = pucap [1];
}
void SetLayerParasitics ( double pures[2], double pucap[2] ) {
SetPerUnitResistance ( pures ) ;
SetPerUnitCapacitance ( pucap ) ;
}
private:
// data:
string m_inputSinksFileName ;
string m_inputTopologyFileName ;
string m_inputObstructionFileName ;
double m_skewBound ;
BST_DME::DelayModelType m_delayModel ;
vector <NodeType *> m_treeNode ;
vector <NodeType *> m_candiRoot ;
vector <NodeType *> m_tempNode ;
unsigned m_nterms ; // num of termianls
TrrType m_ctrr ;
double m_pures[2], m_pucap[2]; /*per unit resistance and capacitance */
} ;
#endif