Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / cns / inoutcone.c
1 /*
2 * This file is part of the Alliance CAD System
3 * Copyright (C) Laboratoire LIP6 - D\8epartement ASIM
4 * Universite Pierre et Marie Curie
5 *
6 * Home page : http://www-asim.lip6.fr/alliance/
7 * E-mail support : mailto:alliance-support@asim.lip6.fr
8 *
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Library General Public License as published
11 * by the Free Software Foundation; either version 2 of the License, or (at
12 * your option) any later version.
13 *
14 * Alliance VLSI CAD System is distributed in the hope that it will be
15 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 * Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with the GNU C Library; see the file COPYING. If not, write to the Free
21 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24 /* 10/26/95 Cone Netlist Structure functions: inoutcone.c */
25
26 #include"cnsall.h"
27
28 /*============================================================================*
29 | function checkincone(); |
30 | return a number, sum of the links and branches of a specified cone (that |
31 | may eventually be deprived of one branch and, or of one link) being driven |
32 | by a certain cone or connector |
33 *============================================================================*/
34 int
35 checkincone(ptcone, ptbranch, ptlink, data)
36 cone_list *ptcone;
37 branch_list *ptbranch;
38 link_list *ptlink;
39 void *data;
40
41 {
42 branch_list *ptbranch1;
43 link_list *ptlink1;
44 ptype_list *ptptype1;
45 int counter = 0;
46
47 if (CNS_TRACE_MODE >= CNS_TRACE)
48 (void) printf("TRA_cns checkincone\n");
49
50 if (ptcone == NULL) {
51 (void) fflush(stdout);
52 (void) fprintf(stderr, "*** cns error ***");
53 (void) fprintf(stderr, " checkincone() impossible: NULL pointer !\n");
54 EXIT(-1);
55 }
56
57 for (ptbranch1 = ptcone->BREXT; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
58 if (ptbranch1 != ptbranch) {
59 for (ptlink1 = ptbranch1->LINK; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
60 if (ptlink1 != ptlink) {
61 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
62 if ((ptptype1 = getptype(ptlink1->ULINK.LOTRS->USER, (long) CNS_DRIVINGCONE)) != NULL) {
63 if (ptptype1->DATA == data) {
64 counter++;
65 }
66 }
67 }
68 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
69 if (ptlink1->ULINK.LOCON == (locon_list *) data) {
70 counter++;
71 }
72 }
73 }
74 }
75 }
76 }
77 for (ptbranch1 = ptcone->BRVDD; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
78 if (ptbranch1 != ptbranch) {
79 for (ptlink1 = ptbranch1->LINK; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
80 if (ptlink1 != ptlink) {
81 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
82 if ((ptptype1 = getptype(ptlink1->ULINK.LOTRS->USER, (long) CNS_DRIVINGCONE)) != NULL) {
83 if (ptptype1->DATA == data) {
84 counter++;
85 }
86 }
87 }
88 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
89 if (ptlink1->ULINK.LOCON == (locon_list *) data) {
90 counter++;
91 }
92 }
93 }
94 }
95 }
96 }
97 for (ptbranch1 = ptcone->BRGND; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
98 if (ptbranch1 != ptbranch) {
99 for (ptlink1 = ptbranch1->LINK; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
100 if (ptlink1 != ptlink) {
101 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
102 if ((ptptype1 = getptype(ptlink1->ULINK.LOTRS->USER, (long) CNS_DRIVINGCONE)) != NULL) {
103 if (ptptype1->DATA == data) {
104 counter++;
105 }
106 }
107 }
108 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
109 if (ptlink1->ULINK.LOCON == (locon_list *) data) {
110 counter++;
111 }
112 }
113 }
114 }
115 }
116 }
117 for (ptbranch1 = ptcone->BRVSS; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
118 if (ptbranch1 != ptbranch) {
119 for (ptlink1 = ptbranch1->LINK; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
120 if (ptlink1 != ptlink) {
121 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
122 if ((ptptype1 = getptype(ptlink1->ULINK.LOTRS->USER, (long) CNS_DRIVINGCONE)) != NULL) {
123 if (ptptype1->DATA == data) {
124 counter++;
125 }
126 }
127 }
128 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
129 if (ptlink1->ULINK.LOCON == (locon_list *) data) {
130 counter++;
131 }
132 }
133 }
134 }
135 }
136 }
137 return (counter);
138 }
139
140 /*============================================================================*
141 | function addincone(); |
142 | add an element to a cone's INCONE field after having checked its unicity |
143 *============================================================================*/
144 void
145 addincone(ptcone, type, data)
146 cone_list *ptcone;
147 long type;
148 void *data;
149
150 {
151 edge_list *ptedge;
152 int found = 0;
153
154 if (CNS_TRACE_MODE >= CNS_TRACE)
155 (void) printf("TRA_cns addincone in\n");
156
157 if ((ptcone == NULL) || (type == 0) || (data == NULL)) {
158 (void) fflush(stdout);
159 (void) fprintf(stderr, "*** cns error ***");
160 (void) fprintf(stderr, " addincone() impossible: NULL pointer(s) !\n");
161 if (CNS_TRACE_MODE >= CNS_TRACE)
162 (void) printf("TRA_cns addincone out\n");
163 EXIT(-1);
164 }
165
166 for (ptedge = ptcone->INCONE; ptedge != NULL; ptedge = ptedge->NEXT) {
167 if (ptedge->UEDGE.PTR == data) {
168 found = 1;
169 break;
170 }
171 }
172 if (!found) {
173 ptcone->INCONE = addedge(ptcone->INCONE, type, data);
174 }
175
176 if (CNS_TRACE_MODE >= CNS_TRACE)
177 (void) printf("TRA_cns addincone out\n");
178 }
179
180 /*============================================================================*
181 | function delincone(); |
182 | delete an element of a cone's INCONE field |
183 *============================================================================*/
184 void
185 delincone(ptcone, type, data)
186 cone_list *ptcone;
187 long type;
188 void *data;
189
190 {
191 edge_list *ptedge;
192
193 if (CNS_TRACE_MODE >= CNS_TRACE)
194 (void) printf("TRA_cns delincone in\n");
195
196 if ((ptcone == NULL) || (type == 0) || (data == NULL)) {
197 (void) fflush(stdout);
198 (void) fprintf(stderr, "*** cns error ***");
199 (void) fprintf(stderr, " delincone() impossible: NULL pointer(s) !\n");
200 if (CNS_TRACE_MODE >= CNS_TRACE)
201 (void) printf("TRA_cns delincone out\n");
202 EXIT(-1);
203 }
204
205 for (ptedge = ptcone->INCONE; ptedge != NULL; ptedge = ptedge->NEXT) {
206 if (ptedge->UEDGE.PTR == data) {
207 ptcone->INCONE = deledge(ptcone->INCONE, ptedge);
208 break;
209 }
210 }
211
212 if (CNS_TRACE_MODE >= CNS_TRACE)
213 (void) printf("TRA_cns delincone out\n");
214 }
215
216 /*============================================================================*
217 | function appendincone(); |
218 | chain two INCONE edge lists while verifying unicity |
219 *============================================================================*/
220 void
221 appendincone(ptcone1, ptcone2)
222 cone_list *ptcone1;
223 cone_list *ptcone2;
224
225 {
226 edge_list *ptedge2;
227
228 if (CNS_TRACE_MODE >= CNS_TRACE)
229 (void) printf("TRA_cns appendincone in\n");
230
231 if ((ptcone1 == NULL) || (ptcone2 == NULL)) {
232 (void) fflush(stdout);
233 (void) fprintf(stderr, "*** cns error ***");
234 (void) fprintf(stderr, " appendincone() impossible: NULL pointer(s) !\n");
235 if (CNS_TRACE_MODE >= CNS_TRACE)
236 (void) printf("TRA_cns appendincone out\n");
237 EXIT(-1);
238 }
239
240 for (ptedge2 = ptcone2->INCONE; ptedge2 != NULL; ptedge2 = ptedge2->NEXT) {
241 addincone(ptcone1, ptedge2->TYPE, ptedge2->UEDGE.PTR);
242 }
243
244 if (CNS_TRACE_MODE >= CNS_TRACE)
245 (void) printf("TRA_cns appendincone out\n");
246 }
247
248 /*============================================================================*
249 | function viewincone(); |
250 | display the content of any given incone structure |
251 *============================================================================*/
252 void
253 viewincone(ptincone, depth)
254 edge_list *ptincone;
255 int depth;
256
257 {
258 char *margin = (char *) mbkalloc(80);
259 int k = 1;
260 ptype_list *ptptype;
261
262 if (CNS_TRACE_MODE >= CNS_TRACE)
263 (void) printf("TRA_cns viewincone in\n");
264
265 if (ptincone == NULL) {
266 (void) fflush(stdout);
267 (void) fprintf(stderr, "*** cns error ***");
268 (void) fprintf(stderr, " viewincone() impossible: NULL pointer !\n");
269 if (CNS_TRACE_MODE >= CNS_TRACE)
270 (void) printf("TRA_cns viewincone out\n");
271 EXIT(-1);
272 }
273
274 if (depth < 0) {
275 depth = CNS_IC_VIEW;
276 }
277
278 margin = strcpy(margin, " ");
279 while (k <= CNS_VIEW_LEVEL) {
280 margin = strcat(margin, " ");
281 k++;
282 }
283
284 CNS_VIEW_LEVEL++;
285 printf("%sincone->NEXT = 0x%lx\n", margin, (unsigned long)ptincone->NEXT);
286 printf("%sincone->TYPE = 0x%lx\n", margin, (unsigned long)ptincone->TYPE);
287 printf("%sincone->UEDGE.PTR = 0x%lx\n", margin, (unsigned long)ptincone->UEDGE.PTR);
288 if ((ptincone->TYPE & CNS_EXT) != CNS_EXT) {
289 if ((depth >= 1) && (ptincone->UEDGE.CONE != NULL)) {
290 viewcone(ptincone->UEDGE.CONE, depth - 1);
291 }
292 }
293 else {
294 if ((depth >= 1) && (ptincone->UEDGE.LOCON != NULL)) {
295 viewcnslocon(ptincone->UEDGE.LOCON, depth - 1);
296 }
297 }
298 printf("%sincone->USER = 0x%lx\n", margin, (unsigned long)ptincone->USER);
299 if ((depth >= 1) && (ptincone->USER != NULL)) {
300 for (ptptype = ptincone->USER; ptptype != NULL; ptptype = ptptype->NEXT) {
301 viewcnsptype(ptptype);
302 }
303 }
304 else {
305 printf("\n");
306 }
307 CNS_VIEW_LEVEL--;
308 mbkfree((void *) margin);
309
310 if (CNS_TRACE_MODE >= CNS_TRACE)
311 (void) printf("TRA_cns viewincone out\n");
312 }
313
314 /*============================================================================*
315 | function addoutcone(); |
316 | add an element to a cone's OUTCONE field after having checked its unicity |
317 *============================================================================*/
318 void
319 addoutcone(ptcone, type, data)
320 cone_list *ptcone;
321 long type;
322 void *data;
323
324 {
325 edge_list *ptedge;
326 int found = 0;
327
328 if (CNS_TRACE_MODE >= CNS_TRACE)
329 (void) printf("TRA_cns addoutcone in\n");
330
331 if ((ptcone == NULL) || (type == 0) || (data == NULL)) {
332 (void) fflush(stdout);
333 (void) fprintf(stderr, "*** cns error ***");
334 (void) fprintf(stderr, " addoutcone() impossible: NULL pointer(s) !\n");
335 if (CNS_TRACE_MODE >= CNS_TRACE)
336 (void) printf("TRA_cns addoutcone out\n");
337 EXIT(-1);
338 }
339
340 for (ptedge = ptcone->OUTCONE; ptedge != NULL; ptedge = ptedge->NEXT) {
341 if (ptedge->UEDGE.PTR == data) {
342 found = 1;
343 break;
344 }
345 }
346 if (!found) {
347 ptcone->OUTCONE = addedge(ptcone->OUTCONE, type, data);
348 }
349
350 if (CNS_TRACE_MODE >= CNS_TRACE)
351 (void) printf("TRA_cns addoutcone out\n");
352 }
353
354 /*============================================================================*
355 | function deloutcone(); |
356 | delete an element of a cone's OUTCONE field |
357 *============================================================================*/
358 void
359 deloutcone(ptcone, type, data)
360 cone_list *ptcone;
361 long type;
362 void *data;
363
364 {
365 edge_list *ptedge;
366
367 if (CNS_TRACE_MODE >= CNS_TRACE)
368 (void) printf("TRA_cns deloutcone in\n");
369
370 if ((ptcone == NULL) || (type == 0) || (data == NULL)) {
371 (void) fflush(stdout);
372 (void) fprintf(stderr, "*** cns error ***");
373 (void) fprintf(stderr, " deloutcone() impossible: NULL pointer(s) !\n");
374 if (CNS_TRACE_MODE >= CNS_TRACE)
375 (void) printf("TRA_cns deloutcone out\n");
376 EXIT(-1);
377 }
378
379 for (ptedge = ptcone->OUTCONE; ptedge != NULL; ptedge = ptedge->NEXT) {
380 if (ptedge->UEDGE.PTR == data) {
381 ptcone->OUTCONE = deledge(ptcone->OUTCONE, ptedge);
382 break;
383 }
384 }
385
386 if (CNS_TRACE_MODE >= CNS_TRACE)
387 (void) printf("TRA_cns deloutcone out\n");
388 }
389
390 /*============================================================================*
391 | function appendoutcone(); |
392 | chain two OUTCONE edge lists while verifying unicity |
393 *============================================================================*/
394 void
395 appendoutcone(ptcone1, ptcone2)
396 cone_list *ptcone1;
397 cone_list *ptcone2;
398
399 {
400 edge_list *ptedge2;
401
402 if (CNS_TRACE_MODE >= CNS_TRACE)
403 (void) printf("TRA_cns appendoutcone in\n");
404
405 if ((ptcone1 == NULL) || (ptcone2 == NULL)) {
406 (void) fflush(stdout);
407 (void) fprintf(stderr, "*** cns error ***");
408 (void) fprintf(stderr, " appendoutcone() impossible: NULL pointer(s) !\n");
409 if (CNS_TRACE_MODE >= CNS_TRACE)
410 (void) printf("TRA_cns appendoutcone out\n");
411 EXIT(-1);
412 }
413
414 for (ptedge2 = ptcone2->OUTCONE; ptedge2 != NULL; ptedge2 = ptedge2->NEXT) {
415 addoutcone(ptcone1, ptedge2->TYPE, ptedge2->UEDGE.PTR);
416 }
417
418 if (CNS_TRACE_MODE >= CNS_TRACE)
419 (void) printf("TRA_cns appendoutcone out\n");
420 }
421
422 /*============================================================================*
423 | function viewoutcone(); |
424 | display the content of any given outcone structure |
425 *============================================================================*/
426 void
427 viewoutcone(ptoutcone, depth)
428 edge_list *ptoutcone;
429 int depth;
430
431 {
432 char *margin = (char *) mbkalloc(80);
433 int k = 1;
434 ptype_list *ptptype;
435
436 if (CNS_TRACE_MODE >= CNS_TRACE)
437 (void) printf("TRA_cns viewoutcone in\n");
438
439 if (ptoutcone == NULL) {
440 (void) fflush(stdout);
441 (void) fprintf(stderr, "*** cns error ***");
442 (void) fprintf(stderr, " viewoutcone() impossible: NULL pointer(s) !\n");
443 if (CNS_TRACE_MODE >= CNS_TRACE)
444 (void) printf("TRA_cns viewoutcone out\n");
445 EXIT(-1);
446 }
447
448 if (depth < 0) {
449 depth = CNS_OC_VIEW;
450 }
451
452 margin = strcpy(margin, " ");
453 while (k <= CNS_VIEW_LEVEL) {
454 margin = strcat(margin, " ");
455 k++;
456 }
457
458 CNS_VIEW_LEVEL++;
459 printf("%soutcone->NEXT = 0x%lx\n", margin, (unsigned long)ptoutcone->NEXT);
460 printf("%soutcone->TYPE = 0x%lx\n", margin, (unsigned long)ptoutcone->TYPE);
461 printf("%soutcone->UEDGE.PTR = 0x%lx\n", margin, (unsigned long)ptoutcone->UEDGE.PTR);
462 if ((ptoutcone->TYPE & CNS_EXT) != CNS_EXT) {
463 if ((depth >= 1) && (ptoutcone->UEDGE.CONE != NULL)) {
464 viewcone(ptoutcone->UEDGE.CONE, depth - 1);
465 }
466 }
467 else {
468 if ((depth >= 1) && (ptoutcone->UEDGE.LOCON != NULL)) {
469 viewcnslocon(ptoutcone->UEDGE.LOCON, depth - 1);
470 }
471 }
472 printf("%soutcone->USER = 0x%lx\n", margin, (unsigned long)ptoutcone->USER);
473 if ((depth >= 1) && (ptoutcone->USER != NULL)) {
474 for (ptptype = ptoutcone->USER; ptptype != NULL; ptptype = ptptype->NEXT) {
475 viewcnsptype(ptptype);
476 }
477 }
478 else {
479 printf("\n");
480 }
481 CNS_VIEW_LEVEL--;
482 mbkfree((void *) margin);
483
484 if (CNS_TRACE_MODE >= CNS_TRACE)
485 (void) printf("TRA_cns viewoutcone out\n");
486 }