Repository navigation
Expand file tree
/
Copy pathsubcell.h
More file actions
155 lines (128 loc) · 3.96 KB
/
Copy pathsubcell.h
File metadata and controls
155 lines (128 loc) · 3.96 KB
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
/*************************************************************************
*
* Copyright (c) 2024 Rajit Manohar
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
**************************************************************************
*/
#ifndef __ACT_LAYOUT_SUBCELL_H__
#define __ACT_LAYOUT_SUBCELL_H__
#include "geom.h"
class SubcellInst {
private:
LayoutBlob *_b; //< the actual layout (subcell)
TransformMat _m; //< geometric transformations to get
// the tiles into global coordinates
const char *_uid; //< unique identifier for the subcell
const char *_name; //< cell name
int _nx, _ny; //< array size
int _px, _py; //< x,y pitch
public:
/** We use aliases for the id and name pointers, so they should be
persistent pointers.
**/
SubcellInst (LayoutBlob *b, const char *id, const char *name,
TransformMat *m = NULL);
void mkArray (int nx, int pitchx, int ny, int pitchy);
LayoutEdgeAttrib *getLayoutEdgeAttrib ();
Rectangle getBBox();
Rectangle getBloatBBox();
Rectangle getAbutBox ();
void PrintRect (FILE *fp, TransformMat *mat);
};
class SubcellList {
private:
SubcellList *_next; /* linked-list of subcells */
SubcellInst *_cell; /* actual subcell */
public:
SubcellList (SubcellInst *c) {
_cell = c;
_next = NULL;
}
~SubcellList () {
if (_next) {
delete _next;
}
if (_cell) {
delete _cell;
}
}
void append (SubcellInst *c, bool sort_x);
SubcellList *del (SubcellInst *c);
SubcellList *getNext() { return _next; }
SubcellInst *getCell() { return _cell; }
void clearCell() { _cell = NULL; }
SubcellList *flushClear();
};
/*
* Recursively partition space
*/
class LayerSubcell {
private:
unsigned int _splitx:1; /* 1 if my split was in the x-direction */
long _splitval:62; /* location of split. the split
coordinate is in the "_leq" box. */
Rectangle _region; /* owned region */
Rectangle _bbox; /* actual bounding box */
Rectangle _bloatbbox; /* bloated bbox */
Rectangle _abutbox; /* abutment box */
LayerSubcell *_leq, *_gt; /* split tile */
SubcellList *_lst; /* list of subcells here */
int _levelcount; /* list length */
void _computeBBox();
public:
static int subcell_level_threshold; // if you exceed this threshold,
// then add sub-trees
static int subcell_recompute_threshold; // if you exceed this
// threshold, then
// re-compute the entire subtree!
LayerSubcell(bool sort_x = true) {
Assert (subcell_recompute_threshold > subcell_level_threshold, "What?");
_splitx = sort_x ? 1 : 0;
_splitval = 0;
_leq = NULL;
_gt = NULL;
_lst = NULL;
_levelcount = 0;
}
~LayerSubcell() {
if (_leq) {
delete _leq;
}
if (_gt) {
delete _gt;
}
if (_lst) {
delete _lst;
}
}
void initGlobal() {
if (_leq || _gt || _lst) {
fatal_error ("LayerSubcell:: initGlobal() called after subcells were added!");
}
_region.setRect (MIN_VALUE, MIN_VALUE, MAX_VALUE, MAX_VALUE);
}
void setRegion (Rectangle &r) {
_region = r;
}
void addSubcell (SubcellInst *s);
void delSubcell (SubcellInst *s);
Rectangle getBBox ();
Rectangle getBloatBBox ();
Rectangle getAbutBox();
};
#endif /* __ACT_LAYOUT_SUBCELL_H__ */