Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / tas / tas / tas_cnsmemory.c
1 #include "tas.h"
2
3 void fillloconsize( locon_list *locon, sizelocon *size )
4 {
5 num_list *pnode ;
6 ptype_list *ptl ;
7 char found ;
8 chain_list *chain ;
9
10 size->NB++ ;
11 size->SIZE = size->SIZE + sizeof( locon_list );
12 size->SIZENAME = size->SIZENAME + (strlen( locon->NAME )+1 )*sizeof( char );
13
14 for( pnode = locon->PNODE ; pnode ; pnode = pnode->NEXT ) {
15 size->SIZE = size->SIZE + sizeof( num_list );
16 }
17
18 for( ptl = locon->USER ; ptl ; ptl = ptl->NEXT ) {
19
20 size->SIZEPTYPE = size->SIZEPTYPE + sizeof( ptype_list );
21
22 found = 0 ;
23
24 if( ptl->TYPE == RCXNAME ) {
25 size->SIZERCXNAME = size->SIZERCXNAME + (strlen( (char*)ptl->DATA )+1 )*sizeof( char );
26 found = 1 ;
27 }
28
29 if( ptl->TYPE == PNODENAME ) {
30 for( chain = (chain_list*)ptl->DATA ; chain ; chain = chain->NEXT ) {
31 size->SIZEPNODENAME = size->SIZEPNODENAME + sizeof( chain_list ) + (strlen( (char*)chain->DATA )+1 )*sizeof( char );
32 }
33 found = 1 ;
34 }
35
36 if( ptl->TYPE == RCX_LOCONCAPA_SPACE )
37 found = 1 ;
38
39 if( !found )
40 printf( "unknown ptype 0x%X / %lu for locon %s\n", (unsigned)ptl->TYPE, ptl->TYPE, locon->NAME );
41 }
42
43 }
44
45 void filllotrssize( lotrs_list *lotrs, sizelotrs *size )
46 {
47 ptype_list *ptl ;
48 int found=0;
49 chain_list *chain ;
50
51 if( !lotrs )
52 return ;
53
54 size->NB++ ;
55 size->SIZE = size->SIZE + sizeof( lotrs_list );
56 if( lotrs->GRID ) fillloconsize( lotrs->GRID, &size->LOCON );
57 if( lotrs->SOURCE ) fillloconsize( lotrs->SOURCE, &size->LOCON );
58 if( lotrs->DRAIN ) fillloconsize( lotrs->DRAIN, &size->LOCON );
59 if( lotrs->BULK ) fillloconsize( lotrs->BULK, &size->LOCON );
60 if( lotrs->TRNAME )
61 size->SIZENAME = size->SIZENAME + (strlen(lotrs->TRNAME)+1)*sizeof(char) ;
62
63 for( ptl = lotrs->USER ; ptl ; ptl = ptl->NEXT ) {
64
65 size->SIZEPTYPE = size->SIZEPTYPE + sizeof( ptype_list );
66
67 if( ptl->TYPE == MBK_TRANS_PARALLEL ||
68 ptl->TYPE == TAS_TRANS_LINK ) {
69 for( chain = (chain_list*)ptl->DATA ; chain ; chain = chain->NEXT )
70 size->SIZE = size->SIZE + sizeof( chain_list );
71 found = 1 ;
72 }
73
74 if( ptl->TYPE == CNS_INDEX ||
75 ptl->TYPE == ELP_LOTRS_MODEL ||
76 ptl->TYPE == CNS_DRIVINGCONE ||
77 ptl->TYPE == TAS_TRANS_USED ||
78 ptl->TYPE == TAS_CAPA_USED ||
79 ptl->TYPE == TAS_TRANS_SWITCH )
80 found = 1 ;
81
82 if( !found )
83 printf( "unknown ptype 0x%X / %lu for lotrs %s\n", (unsigned)ptl->TYPE, ptl->TYPE, lotrs->TRNAME );
84 }
85 }
86
87 void fillcnssize( cnsfig_list *cns, sizecns *size )
88 {
89 lotrs_list *lotrs ;
90
91 for( lotrs = cns->LOTRS ; lotrs ; lotrs = lotrs->NEXT ) {
92 filllotrssize( lotrs, &size->SIZELOTRS );
93 }
94 }
95
96 void displaycnssize( sizecns *size )
97 {
98 size_t sizelotrs ;
99 size_t sizelotrslocon ;
100
101 sizelotrslocon = size->SIZELOTRS.LOCON.SIZE +
102 size->SIZELOTRS.LOCON.SIZENAME +
103 size->SIZELOTRS.LOCON.SIZERCXNAME +
104 size->SIZELOTRS.LOCON.SIZEPTYPE +
105 size->SIZELOTRS.LOCON.SIZEPNODENAME ;
106 sizelotrs = size->SIZELOTRS.SIZE +
107 size->SIZELOTRS.SIZENAME +
108 size->SIZELOTRS.SIZEPTYPE +
109 sizelotrslocon ;
110
111 printf( "lotrs : %10lu\n", (unsigned long)sizelotrs );
112 printf( " lotrs %6d -> %10lu\n", size->SIZELOTRS.NB, (unsigned long)size->SIZELOTRS.SIZE );
113 printf( " name %10lu\n", (unsigned long)size->SIZELOTRS.SIZENAME );
114 printf( " ptype %10lu\n", (unsigned long)size->SIZELOTRS.SIZEPTYPE );
115 printf( " locon %10lu\n", (unsigned long)sizelotrslocon );
116 printf( " locon %6d -> %10lu\n", size->SIZELOTRS.LOCON.NB, (unsigned long)size->SIZELOTRS.LOCON.SIZE );
117 printf( " name %10lu\n", (unsigned long)size->SIZELOTRS.LOCON.SIZENAME );
118 printf( " rcxname %10lu\n", (unsigned long)size->SIZELOTRS.LOCON.SIZERCXNAME );
119 printf( " ptype %10lu\n", (unsigned long)size->SIZELOTRS.LOCON.SIZEPTYPE );
120 printf( " pnodename %10lu\n", (unsigned long)size->SIZELOTRS.LOCON.SIZEPNODENAME );
121 }
122
123 void tas_displaymemoryusage( cnsfig_list *cnsfig )
124 {
125 cone_list *cone ;
126 edge_list *incone ;
127 ptype_list *ptl ;
128 branch_list *tabbranch[3] ;
129 branch_list *branch ;
130 locon_list *tablocon[2] ;
131 locon_list *locon ;
132 int i ;
133 link_list *link ;
134 sizecns size ;
135
136 int nbdelay = 0 ;
137 int nbfront = 0 ;
138 int nbcaraclink = 0 ;
139 int nbcaraccon = 0 ;
140 int nbptypecone = 0 ;
141 int nbptypeedge = 0 ;
142 int nbptypelink = 0 ;
143 int nbptypelocon = 0 ;
144 int nbptype = 0 ;
145 int sizedelay = 0 ;
146 int sizefront = 0 ;
147 int sizecaraclink = 0 ;
148 int sizecaraccon = 0 ;
149 int sizeptype = 0 ;
150 int total ;
151
152 if( !cnsfig )
153 return ;
154
155 size.SIZELOTRS.SIZE = 0 ;
156 size.SIZELOTRS.NB = 0 ;
157 size.SIZELOTRS.SIZENAME = 0 ;
158 size.SIZELOTRS.SIZEPTYPE = 0 ;
159 size.SIZELOTRS.LOCON.SIZE = 0 ;
160 size.SIZELOTRS.LOCON.NB = 0 ;
161 size.SIZELOTRS.LOCON.SIZEPTYPE = 0 ;
162 size.SIZELOTRS.LOCON.SIZENAME = 0 ;
163 size.SIZELOTRS.LOCON.SIZERCXNAME = 0 ;
164 size.SIZELOTRS.LOCON.SIZEPNODENAME = 0 ;
165
166 fillcnssize( cnsfig, &size );
167 displaycnssize( &size );
168
169
170 for( cone = cnsfig->CONE ; cone ; cone = cone->NEXT ) {
171
172 for( ptl = cone->USER ; ptl ; ptl = ptl->NEXT ) {
173
174 nbptypecone++ ;
175
176 if( ptl->TYPE == TAS_SLOPE_MAX )
177 nbfront++ ;
178
179 if( ptl->TYPE == TAS_SLOPE_MIN )
180 nbfront++ ;
181 }
182
183 for( incone = cone->INCONE ; incone ; incone = incone->NEXT ) {
184
185
186 for( ptl = incone->USER ; ptl ; ptl = ptl->NEXT ) {
187
188 nbptypeedge++ ;
189
190 if( ptl->TYPE == TAS_DELAY_MAX )
191 nbdelay++ ;
192
193 if( ptl->TYPE == TAS_DELAY_MIN )
194 nbdelay++ ;
195 }
196 }
197
198 tabbranch[0]=cone->BREXT ;
199 tabbranch[1]=cone->BRVDD ;
200 tabbranch[2]=cone->BRVSS ;
201
202 for( i=0 ; i<=2 ; i++ ) {
203
204 for( branch = tabbranch[i] ; branch ; branch = branch->NEXT ) {
205
206 for( link = branch->LINK ; link ; link = link->NEXT ) {
207
208 for( ptl = link->USER ; ptl ; ptl = ptl->NEXT ) {
209 nbptypelink++ ;
210
211 if( ptl->TYPE == TAS_LINK_CARAC )
212 nbcaraclink++ ;
213 }
214 }
215 }
216 }
217 }
218
219 tablocon[0] = cnsfig->LOCON ;
220 tablocon[1] = cnsfig->INTCON ;
221
222 for( i=0 ; i<=1 ; i++ ) {
223
224 for( locon = tablocon[i] ; locon ; locon = locon->NEXT ) {
225
226 for( ptl = locon->USER ; ptl ; ptl = ptl->NEXT ) {
227
228 nbptypelocon++ ;
229
230 if( ptl->TYPE == TAS_CON_CARAC )
231 nbcaraccon++ ;
232
233 if( ptl->TYPE == TAS_SLOPE_MIN )
234 nbcaraccon++ ;
235
236 if( ptl->TYPE == TAS_SLOPE_MAX )
237 nbcaraccon++ ;
238
239 if( ptl->TYPE == TAS_DELAY_MAX )
240 nbcaraccon++ ;
241
242 if( ptl->TYPE == TAS_DELAY_MIN )
243 nbcaraccon++ ;
244 }
245 }
246 }
247
248 sizedelay = nbdelay * sizeof( delay_list ) ;
249 sizefront = nbfront * sizeof( front_list ) ;
250 sizecaraclink = nbcaraclink * sizeof( caraclink_list ) ;
251 sizecaraccon = nbcaraccon * sizeof( caraccon_list ) ;
252 nbptype = nbptypecone + nbptypeedge + nbptypelink + nbptypelocon ;
253 sizeptype = nbptype * sizeof( ptype_list ) ;
254
255 total = sizedelay + sizefront + sizecaraclink + sizecaraccon + sizeptype ;
256
257 printf( "structure delay_list : %6d %10d\n", nbdelay, sizedelay );
258 printf( "structure front_list : %6d %10d\n", nbfront, sizefront );
259 printf( "structure caraclink_list : %6d %10d\n", nbcaraclink, sizecaraclink );
260 printf( "structure caraccon_list : %6d %10d\n", nbcaraccon, sizecaraccon );
261 printf( "ptype cone : %6d\n", nbptypecone );
262 printf( "ptype edge : %6d\n", nbptypeedge );
263 printf( "ptype link : %6d\n", nbptypelink );
264 printf( "ptype locon : %6d\n", nbptypelocon );
265 printf( "structure ptype : %6d %10d\n", nbptype, sizeptype );
266 printf( " total : %10d\n", total );
267
268 }