Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / cns / branch.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: branch.c */
25
26 #include"cnsall.h"
27
28 static void *addbranchpage();
29 static branch_list *getfreebranch();
30
31 /* define number of branches per page */
32 #define BRANCHESPERPAGE 200
33
34 static chain_list *BRANCHPAGES; /* chain list of branch pages */
35 static int PAGEBRANCHINDEX = 0; /* branch index in current page */
36 static branch_list *FREEBRANCHLIST; /* list of free branches in current page */
37 static branch_list *FREEDBRANCHLIST; /* list of freed branches */
38
39 /*============================================================================*
40 | function initbranchmem(); |
41 | initialize branch memory structure |
42 *============================================================================*/
43 void *
44 initbranchmem()
45 {
46 branch_list *ptbranch;
47
48 if (CNS_TRACE_MODE >= CNS_TRACE)
49 (void) printf("TRA_cns initbranchmem\n");
50
51 ptbranch = (branch_list *) mbkalloc(BRANCHESPERPAGE * (sizeof(branch_list)));
52 BRANCHPAGES = addchain((chain_list *) NULL, (void *) ptbranch);
53 FREEDBRANCHLIST = NULL;
54 PAGEBRANCHINDEX = 1;
55 FREEBRANCHLIST = ptbranch;
56
57 return NULL;
58 }
59
60 /*============================================================================*
61 | function addbranchpage(); |
62 | add a new branch page |
63 *============================================================================*/
64 static void *
65 addbranchpage()
66 {
67 branch_list *ptbranch;
68
69 if (CNS_TRACE_MODE >= CNS_TRACE)
70 (void) printf("TRA_cns addbranchpage\n");
71
72 ptbranch = (branch_list *) mbkalloc(BRANCHESPERPAGE * (sizeof(branch_list)));
73 BRANCHPAGES = addchain(BRANCHPAGES, (void *) ptbranch);
74 PAGEBRANCHINDEX = 1;
75 FREEBRANCHLIST = ptbranch;
76
77 return NULL;
78 }
79
80 /*============================================================================*
81 | function getfreebranch(); |
82 | get a new branch |
83 *============================================================================*/
84 static branch_list *
85 getfreebranch()
86 {
87 branch_list *ptbranch;
88
89 if (CNS_TRACE_MODE >= CNS_TRACE)
90 (void) printf("TRA_cns getfreebranch in\n");
91
92 if (FREEDBRANCHLIST != NULL) {
93 ptbranch = FREEDBRANCHLIST;
94 FREEDBRANCHLIST = FREEDBRANCHLIST->NEXT;
95 ptbranch->NEXT = NULL;
96 if (CNS_TRACE_MODE >= CNS_TRACE)
97 (void) printf("TRA_cns getfreebranch out\n");
98 return (ptbranch);
99 }
100 else if (PAGEBRANCHINDEX < BRANCHESPERPAGE) {
101 PAGEBRANCHINDEX++;
102 FREEBRANCHLIST++;
103 FREEBRANCHLIST->NEXT = NULL;
104 if (CNS_TRACE_MODE >= CNS_TRACE)
105 (void) printf("TRA_cns getfreebranch out\n");
106 return (FREEBRANCHLIST);
107 }
108 else {
109 addbranchpage();
110 FREEBRANCHLIST->NEXT = NULL;
111 if (CNS_TRACE_MODE >= CNS_TRACE)
112 (void) printf("TRA_cns getfreebranch out\n");
113 return (FREEBRANCHLIST);
114 }
115 }
116
117 /*============================================================================*
118 | function freebranch(); |
119 | free a branch |
120 *============================================================================*/
121 void *
122 freebranch(ptbranch)
123 branch_list *ptbranch;
124
125 {
126 link_list *ptlklist;
127
128 if (CNS_TRACE_MODE >= CNS_TRACE)
129 (void) printf("TRA_cns freebranch in\n");
130
131 if (ptbranch == NULL) {
132 (void) fflush(stdout);
133 (void) fprintf(stderr, "*** cns error ***");
134 (void) fprintf(stderr, " freebranch() impossible: NULL pointer !\n");
135 if (CNS_TRACE_MODE >= CNS_TRACE)
136 (void) printf("TRA_cns freebranch out\n");
137 EXIT(-1);
138 }
139
140 if ((ptlklist = ptbranch->LINK) != NULL)
141 freelklist(ptlklist);
142 ptbranch->NEXT = FREEDBRANCHLIST;
143 FREEDBRANCHLIST = ptbranch;
144
145 if (CNS_TRACE_MODE >= CNS_TRACE)
146 (void) printf("TRA_cns freebranch out\n");
147
148 return NULL;
149 }
150
151 /*============================================================================*
152 | function freebrlist(); |
153 | free a branch list |
154 *============================================================================*/
155 void *
156 freebrlist(ptbrlist)
157 branch_list *ptbrlist;
158
159 {
160 branch_list *ptbranch;
161 link_list *ptlklist;
162
163 if (CNS_TRACE_MODE >= CNS_TRACE)
164 (void) printf("TRA_cns freebrlist in\n");
165
166 if (ptbrlist == NULL) {
167 (void) fflush(stdout);
168 (void) fprintf(stderr, "*** cns error ***");
169 (void) fprintf(stderr, " freebrlist() impossible: NULL pointer !\n");
170 if (CNS_TRACE_MODE >= CNS_TRACE)
171 (void) printf("TRA_cns freebrlist out\n");
172 EXIT(-1);
173 }
174
175 for (ptbranch = ptbrlist; ptbranch->NEXT != NULL; ptbranch = ptbranch->NEXT) {
176 if ((ptlklist = ptbranch->LINK) != NULL)
177 freelklist(ptlklist);
178 }
179 if ((ptlklist = ptbranch->LINK) != NULL)
180 freelklist(ptlklist);
181 ptbranch->NEXT = FREEDBRANCHLIST;
182 FREEDBRANCHLIST = ptbrlist;
183
184 if (CNS_TRACE_MODE >= CNS_TRACE)
185 (void) printf("TRA_cns freebrlist out\n");
186
187 return NULL;
188 }
189
190 /*============================================================================*
191 | function addbranch(); |
192 | add an element to a branch list |
193 *============================================================================*/
194 branch_list *
195 addbranch(ptbranchhead, type, ptlink)
196 branch_list *ptbranchhead;
197 long type;
198 link_list *ptlink;
199
200 {
201 branch_list *ptbranch;
202
203 if (CNS_TRACE_MODE >= CNS_TRACE)
204 (void) printf("TRA_cns addbranch in\n");
205
206 ptbranch = getfreebranch();
207 ptbranch->NEXT = ptbranchhead;
208 ptbranch->TYPE = type;
209 ptbranch->LINK = ptlink;
210 ptbranch->USER = NULL;
211
212 if (CNS_TRACE_MODE >= CNS_TRACE)
213 (void) printf("TRA_cns addbranch out\n");
214 return (ptbranch);
215 }
216
217 /*============================================================================*
218 | function addconebranch(); |
219 | add a branch to a cone and update its INCONE field and the OUTCONE fields |
220 | of the respective driving cones. WARNING: the cone's information on |
221 | parallel branches is not updated. |
222 *============================================================================*/
223 void
224 addconebranch(ptcone, ptconebr, type, ptlink)
225 cone_list *ptcone;
226 branch_list *ptconebr;
227 long type;
228 link_list *ptlink;
229
230 {
231 branch_list *ptbranch;
232 link_list *ptlink1;
233 lotrs_list *ptlotrs1;
234 ptype_list *ptptype1;
235 cone_list *ptcone1;
236
237 if (CNS_TRACE_MODE >= CNS_TRACE)
238 (void) printf("TRA_cns addconebranch in\n");
239
240 ptbranch = getfreebranch();
241 ptbranch->NEXT = ptconebr;
242 ptbranch->TYPE = type;
243 ptbranch->LINK = ptlink;
244 ptbranch->USER = NULL;
245 ptconebr = ptbranch;
246
247 for (ptlink1 = ptlink; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
248 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
249 ptlotrs1 = ptlink1->ULINK.LOTRS;
250 if ((ptptype1 = getptype(ptlotrs1->USER, (long) CNS_DRIVINGCONE)) != NULL) {
251 ptcone1 = (cone_list *) ptptype1->DATA;
252 addincone(ptcone, (long) CNS_CONE, (void *) ptcone1);
253 addoutcone(ptcone1, (long) CNS_CONE, (void *) ptcone);
254 }
255 else {
256 (void) fflush(stdout);
257 (void) fprintf(stderr, "*** cns error ***");
258 (void) fprintf(stderr, " addconebranch() impossible: no cone drives transistor !\n");
259 if (CNS_TRACE_MODE >= CNS_TRACE)
260 (void) printf("TRA_cns addconebranch out\n");
261 EXIT(-1);
262 }
263 }
264 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
265 addincone(ptcone, (long) CNS_EXT, (void *) ptlink1->ULINK.LOCON);
266 }
267 else if ((ptlink1->TYPE & CNS_PASSIVE) != CNS_PASSIVE) {
268 (void) fflush(stdout);
269 (void) fprintf(stderr, "*** cns error ***");
270 (void) fprintf(stderr, " addconebranch() impossible: unknown link type !\n");
271 if (CNS_TRACE_MODE >= CNS_TRACE)
272 (void) printf("TRA_cns addconebranch out\n");
273 EXIT(-1);
274 }
275 }
276
277 if (CNS_TRACE_MODE >= CNS_TRACE)
278 (void) printf("TRA_cns addconebranch out\n");
279 }
280
281 /*============================================================================*
282 | function delbranch(); |
283 | delete an element from a branch list and free that element from memory |
284 *============================================================================*/
285 branch_list *
286 delbranch(ptbranchhead, ptbranch2del)
287 branch_list *ptbranchhead;
288 branch_list *ptbranch2del;
289
290 {
291 short flag = 0;
292 branch_list *ptbranch;
293 chain_list *ptchain;
294 branch_list *ptbranch2sav;
295
296 if (CNS_TRACE_MODE >= CNS_TRACE)
297 (void) printf("TRA_cns delbranch in\n");
298
299 if ((ptbranchhead == NULL) || (ptbranch2del == NULL)) {
300 (void) fflush(stdout);
301 (void) fprintf(stderr, "*** cns error ***");
302 (void) fprintf(stderr, " delbranch() impossible: NULL pointer !\n");
303 if (CNS_TRACE_MODE >= CNS_TRACE)
304 (void) printf("TRA_cns delbranch out\n");
305 EXIT(-1);
306 }
307
308 if ((ptbranch2del->TYPE & CNS_PARALLEL) == CNS_PARALLEL) {
309 if ((ptbranch2del->TYPE & CNS_PARALLEL_INS) != CNS_PARALLEL_INS)
310 flag = 1;
311 }
312
313 if (ptbranch2del == ptbranchhead) {
314 ptbranch = ptbranchhead->NEXT;
315 ptbranchhead->NEXT = NULL;
316 freebranch(ptbranchhead);
317 if (flag)
318 ptchain = parabrs(ptbranch);
319 if (CNS_TRACE_MODE >= CNS_TRACE)
320 (void) printf("TRA_cns delbranch out\n");
321 return (ptbranch);
322 }
323 else {
324 for (ptbranch = ptbranchhead; ptbranch; ptbranch = ptbranch->NEXT) {
325 if (ptbranch == ptbranch2del) {
326 break;
327 }
328 ptbranch2sav = ptbranch;
329 }
330 if (ptbranch != NULL) {
331 ptbranch2sav->NEXT = ptbranch->NEXT;
332 ptbranch2del->NEXT = NULL;
333 freebranch(ptbranch2del);
334 }
335 if (flag)
336 ptchain = parabrs(ptbranchhead);
337 if (CNS_TRACE_MODE >= CNS_TRACE)
338 (void) printf("TRA_cns delbranch out\n");
339 return (ptbranchhead);
340 }
341 }
342
343 /*============================================================================*
344 | function delconebranch(); |
345 | delete a branch from a cone and update its INCONE field and the OUTCONE |
346 | fields of the respective driving cones |
347 *============================================================================*/
348 void
349 delconebranch(ptcone, ptconebr, ptbranch2del)
350 cone_list *ptcone;
351 branch_list *ptconebr;
352 branch_list *ptbranch2del;
353
354 {
355 short flag = 0;
356 branch_list *ptbranch;
357 branch_list *value = NULL;
358 branch_list *ptbranch2sav;
359 link_list *ptlink1;
360 lotrs_list *ptlotrs1;
361 ptype_list *ptptype1;
362 cone_list *ptcone1;
363
364 if (CNS_TRACE_MODE >= CNS_TRACE)
365 (void) printf("TRA_cns delconebranch in\n");
366
367 if ((ptconebr == NULL) || (ptbranch2del == NULL)) {
368 (void) fflush(stdout);
369 (void) fprintf(stderr, "*** cns error ***");
370 (void) fprintf(stderr, " delconebranch() impossible: NULL pointer !\n");
371 if (CNS_TRACE_MODE >= CNS_TRACE)
372 (void) printf("TRA_cns delconebranch out\n");
373 EXIT(-1);
374 }
375
376 if ((ptbranch2del->TYPE & CNS_PARALLEL) == CNS_PARALLEL) {
377 if ((ptbranch2del->TYPE & CNS_PARALLEL_INS) != CNS_PARALLEL_INS)
378 flag = 1;
379 }
380
381 if (ptbranch2del == ptconebr) {
382 ptbranch = ptconebr->NEXT;
383 ptconebr->NEXT = NULL;
384 value = ptconebr;
385 ptconebr = ptbranch;
386 }
387 else {
388 for (ptbranch = ptconebr; ptbranch; ptbranch = ptbranch->NEXT) {
389 if (ptbranch == ptbranch2del) {
390 break;
391 }
392 ptbranch2sav = ptbranch;
393 }
394 if (ptbranch != NULL) {
395 ptbranch2sav->NEXT = ptbranch->NEXT;
396 ptbranch2del->NEXT = NULL;
397 value = ptbranch2del;
398 }
399 }
400
401 for (ptlink1 = ptbranch2del->LINK; ptlink1 != NULL; ptlink1 = ptlink1->NEXT) {
402 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
403 ptlotrs1 = ptlink1->ULINK.LOTRS;
404 if ((ptptype1 = getptype(ptlotrs1->USER, (long) CNS_DRIVINGCONE)) != NULL) {
405 ptcone1 = (cone_list *) ptptype1->DATA;
406 if (checkincone(ptcone, (branch_list *) NULL, (link_list *) NULL, (void *) ptcone1) == 0) {
407 delincone(ptcone, 1, (void *) ptcone1);
408 deloutcone(ptcone1, 1, (void *) ptcone);
409 }
410 }
411 else {
412 (void) fflush(stdout);
413 (void) fprintf(stderr, "*** cns error ***");
414 (void) fprintf(stderr, " addconebranch() impossible: no cone drives transistor !\n");
415 if (CNS_TRACE_MODE >= CNS_TRACE)
416 (void) printf("TRA_cns addconebranch out\n");
417 EXIT(-1);
418 }
419 }
420 else if ((ptlink1->TYPE & CNS_EXT) == CNS_EXT) {
421 if (checkincone(ptcone, (branch_list *) NULL, (link_list *) NULL, (void *) ptlink1->ULINK.LOCON) == 0) {
422 delincone(ptcone, 1, (void *) ptlink1->ULINK.LOCON);
423 }
424 }
425 else if ((ptlink1->TYPE & CNS_PASSIVE) != CNS_PASSIVE) {
426 (void) fflush(stdout);
427 (void) fprintf(stderr, "*** cns error ***");
428 (void) fprintf(stderr, " delconebranch() impossible: unknown link type !\n");
429 if (CNS_TRACE_MODE >= CNS_TRACE)
430 (void) printf("TRA_cns delconebranch out\n");
431 EXIT(-1);
432 }
433 }
434 freebranch(value);
435
436 if (flag)
437 coneparabrs(ptcone);
438
439 if (CNS_TRACE_MODE >= CNS_TRACE)
440 (void) printf("TRA_cns delconebranch out\n");
441 }
442
443 /*============================================================================*
444 | function appendbranch(); |
445 | chain two branch lists. WARNING: no consistency check |
446 *============================================================================*/
447 branch_list *
448 appendbranch(ptbranch1, ptbranch2)
449 branch_list *ptbranch1;
450 branch_list *ptbranch2;
451
452 {
453 branch_list *ptbranch = NULL;
454
455 if (CNS_TRACE_MODE >= CNS_TRACE)
456 (void) printf("TRA_cns appendbranch\n");
457
458 if (ptbranch1 == NULL) {
459 return (ptbranch2);
460 }
461 else {
462 for (ptbranch = ptbranch1; ptbranch->NEXT != NULL; ptbranch = ptbranch->NEXT) {
463 }
464 ptbranch->NEXT = ptbranch2;
465 return (ptbranch1);
466 }
467 }
468
469 /*============================================================================*
470 | function appendconebranch(); |
471 | chain a branch list to that of a cone and update its INCONE field |
472 *============================================================================*/
473 void
474 appendconebranch(ptcone, ptconebr, ptbranch2)
475 cone_list *ptcone;
476 branch_list *ptconebr;
477 branch_list *ptbranch2;
478
479 {
480 branch_list *ptbranch;
481 link_list *ptlink;
482
483 if (CNS_TRACE_MODE >= CNS_TRACE)
484 (void) printf("TRA_cns appendconebranch in\n");
485
486 if (ptconebr == NULL) {
487 ptconebr = ptbranch2;
488 }
489 else {
490 for (ptbranch = ptconebr; ptbranch->NEXT != NULL; ptbranch = ptbranch->NEXT);
491 ptbranch->NEXT = ptbranch2;
492 }
493
494 for (ptbranch = ptbranch2; ptbranch->NEXT != NULL; ptbranch = ptbranch->NEXT) {
495 for (ptlink = ptbranch->LINK; ptlink != NULL; ptlink = ptlink->NEXT) {
496 if ((ptlink->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
497 addincone(ptcone, (long) CNS_CONE, (void *) ptlink->ULINK.LOTRS->GRID);
498 }
499 else if ((ptlink->TYPE & CNS_EXT) == CNS_EXT) {
500 addincone(ptcone, (long) CNS_EXT, (void *) ptlink->ULINK.LOCON);
501 }
502 else if ((ptlink->TYPE & CNS_PASSIVE) != CNS_PASSIVE) {
503 (void) fflush(stdout);
504 (void) fprintf(stderr, "*** cns error ***");
505 (void) fprintf(stderr, " appendbranch() impossible: unknown link type !\n");
506 if (CNS_TRACE_MODE >= CNS_TRACE)
507 (void) printf("TRA_cns appendconebranch out\n");
508 EXIT(-1);
509 }
510 }
511 }
512
513 if (CNS_TRACE_MODE >= CNS_TRACE)
514 (void) printf("TRA_cns appendconebranch out\n");
515 }
516
517 /*============================================================================*
518 | function viewbranch(); |
519 | display the content of a given branch structure |
520 *============================================================================*/
521 void
522 viewbranch(ptbranch, depth)
523 branch_list *ptbranch;
524 int depth;
525
526 {
527 char *margin = (char *) mbkalloc(80);
528 int k = 1;
529 link_list *ptlink;
530 ptype_list *ptptype;
531
532 if (CNS_TRACE_MODE >= CNS_TRACE)
533 (void) printf("TRA_cns viewbranch in\n");
534
535 if (ptbranch == NULL) {
536 (void) fflush(stdout);
537 (void) fprintf(stderr, "*** cns error ***");
538 (void) fprintf(stderr, " viewbranch() impossible: NULL pointer !\n");
539 if (CNS_TRACE_MODE >= CNS_TRACE)
540 (void) printf("TRA_cns viewbranch out\n");
541 EXIT(-1);
542 }
543
544 if (depth < 0) {
545 depth = CNS_BH_VIEW;
546 }
547
548 margin = strcpy(margin, " ");
549 while (k <= CNS_VIEW_LEVEL) {
550 margin = strcat(margin, " ");
551 k++;
552 }
553
554 CNS_VIEW_LEVEL++;
555 printf("%sbranch->NEXT = 0x%lx\n", margin, (unsigned long)ptbranch->NEXT);
556 printf("%sbranch->TYPE = 0x%lx\n", margin, (unsigned long)ptbranch->TYPE);
557 printf("%sbranch->LINK = 0x%lx\n", margin, (unsigned long)ptbranch->LINK);
558 if ((depth >= 1) && (ptbranch->LINK != NULL)) {
559 for (ptlink = ptbranch->LINK; ptlink != NULL; ptlink = ptlink->NEXT) {
560 viewlink(ptlink, depth - 1);
561 }
562 }
563 printf("%sbranch->USER = 0x%lx\n", margin, (unsigned long)ptbranch->USER);
564 if ((depth >= 1) && (ptbranch->USER != NULL)) {
565 for (ptptype = ptbranch->USER; ptptype != NULL; ptptype = ptptype->NEXT) {
566 viewcnsptype(ptptype);
567 }
568 }
569 else {
570 printf("\n");
571 }
572 CNS_VIEW_LEVEL--;
573 mbkfree((void *) margin);
574
575 if (CNS_TRACE_MODE >= CNS_TRACE)
576 (void) printf("TRA_cns viewbranch out\n");
577 }
578
579 /*============================================================================*
580 | function parabrs(); |
581 | identify and type parallel branches within input list and return a chain |
582 | list that contains chain lists of parallel branches |
583 *============================================================================*/
584 chain_list *
585 parabrs(ptbranch)
586 branch_list *ptbranch;
587
588 {
589 branch_list *ptbranch1;
590 branch_list *ptbranch2;
591 chain_list *ptchain1;
592 short found;
593 chain_list *ptchain = NULL;
594
595 if (CNS_TRACE_MODE >= CNS_TRACE)
596 (void) printf("TRA_cns parabrs in\n");
597
598 for (ptbranch1 = ptbranch; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
599 ptbranch1->TYPE &= ~CNS_PARALLEL_INS;
600 }
601 for (ptbranch1 = ptbranch; ptbranch1 != NULL; ptbranch1 = ptbranch1->NEXT) {
602 if ((ptbranch1->TYPE & CNS_PARALLEL) == CNS_PARALLEL)
603 continue;
604 found = 0;
605 if ((ptbranch2 = ptbranch1->NEXT) != NULL) {
606 ptchain1 = addchain((chain_list *) NULL, (void *) ptbranch1);
607 for (ptbranch2 = ptbranch1->NEXT; ptbranch2 != NULL; ptbranch2 = ptbranch2->NEXT) {
608 if (testparabrs(ptbranch1, ptbranch2)) {
609 found = 1;
610 ptbranch2->TYPE |= CNS_PARALLEL_INS;
611 ptchain1 = addchain(ptchain1, (void *) ptbranch2);
612 }
613 }
614 if (ptchain1->NEXT != NULL) {
615 ptchain = addchain(ptchain, (void *) ptchain1);
616 }
617 else
618 freechain(ptchain1);
619 if (found) {
620 ptbranch1->TYPE |= CNS_PARALLEL;
621 }
622 }
623 }
624
625 if (CNS_TRACE_MODE >= CNS_TRACE)
626 (void) printf("TRA_cns parabrs out\n");
627
628 return (ptchain);
629 }
630
631 /*============================================================================*
632 | function testparabrs(); |
633 | test to see if the two input branches are parallel and return 1 if it is |
634 | the case. WARNING: this function may be eroneous if the two branches are |
635 | from two different cones |
636 *============================================================================*/
637 short
638 testparabrs(ptbranch1, ptbranch2)
639 branch_list *ptbranch1;
640 branch_list *ptbranch2;
641
642 {
643 link_list *ptlink1;
644 link_list *ptlink2;
645 short result = 0;
646 lotrs_list *ptlotrs1;
647 lotrs_list *ptlotrs2;
648 ptype_list *ptptype1;
649 ptype_list *ptptype2;
650
651 if (CNS_TRACE_MODE >= CNS_TRACE)
652 (void) printf("TRA_cns testparabrs\n");
653
654 ptlink1 = ptbranch1->LINK;
655 ptlink2 = ptbranch2->LINK;
656
657 while ((ptlink1 != NULL) && (ptlink2 != NULL)) {
658 if (((ptlink1->TYPE & CNS_EXT) == CNS_EXT) && (ptlink1->TYPE == ptlink2->TYPE)) {
659 if (ptlink1->ULINK.LOCON != ptlink2->ULINK.LOCON)
660 return (0);
661 else
662 result = 1;
663 }
664 else if (ptlink1->TYPE == ptlink2->TYPE) {
665 if ((ptlink1->TYPE & CNS_ACTIVE) == CNS_ACTIVE) {
666 ptlotrs1 = ptlink1->ULINK.LOTRS;
667 ptlotrs2 = ptlink2->ULINK.LOTRS;
668 if (((ptptype1 = getptype(ptlotrs1->USER, (long) CNS_DRIVINGCONE)) != NULL) && ((ptptype2 = getptype(ptlotrs2->USER, (long) CNS_DRIVINGCONE)) != NULL)) {
669 if (ptptype1->DATA != ptptype2->DATA)
670 return (0);
671 else
672 result = 1;
673 }
674 else
675 return (0);
676 }
677 else
678 result = 1;
679 }
680 else
681 return (0);
682 ptlink1 = ptlink1->NEXT;
683 ptlink2 = ptlink2->NEXT;
684 }
685
686 if ((ptlink1 != NULL) || (ptlink2 != NULL))
687 return (0);
688
689 return (result);
690 }
691
692 /*============================================================================*
693 | function brlotrsnum(); |
694 | returns the maximum number of series transistors found in the input |
695 | branch list |
696 *============================================================================*/
697 short
698 brlotrsnum(ptbrlist)
699 branch_list *ptbrlist;
700
701 {
702 branch_list *ptbranch;
703 short number;
704 short result = 0;
705
706 if (CNS_TRACE_MODE >= CNS_TRACE)
707 (void) printf("TRA_cns brlotrsnum in\n");
708
709 for (ptbranch = ptbrlist; ptbranch != NULL; ptbranch = ptbranch->NEXT) {
710 if ((ptbranch->TYPE & CNS_PARALLEL_INS) == CNS_PARALLEL_INS)
711 continue;
712 if ((number = lotrsnum(ptbranch->LINK)) > result)
713 result = number;
714 }
715
716 if (CNS_TRACE_MODE >= CNS_TRACE)
717 (void) printf("TRA_cns brlotrsnum out\n");
718
719 return (result);
720 }