1
2 /*
3 * $Id: DEF_actions.c,v 1.5 2006/06/28 13:25:06 jpc Exp $
4 *
5 * /----------------------------------------------------------------\
6 * | |
7 * | A l l i a n c e C A D S y s t e m |
8 * | S i l i c o n E n s e m b l e / A l l i a n c e |
9 * | |
10 * | Author : Jean-Paul CHAPUT |
11 * | E-mail : alliance-users@asim.lip6.fr |
12 * | ============================================================== |
13 * | C Module : "./DEF_actions.c" |
14 * | ************************************************************** |
15 * | U p d a t e s |
16 * | |
17 * \----------------------------------------------------------------/
18 */
19
20
21 # include "debugoff.h"
22 # include "util_Defs.h"
23 # include "DEF_actions.h"
24 # include "DEF_grammar.h"
25
26
27 /* Flex substitutions. */
28 # define yylex DEF_grammarlex
29 # define yyin DEF_grammarin
30 # define yylineno DEF_grammarlineno
31
32 /* Bison substitutions. */
33 # define yyparse DEF_grammarparse
34 # define yydebug DEF_grammardebug
35
36
37 # define SIZE_TPT 1024
38 # define SIZE_TDATALAYER 16
39 # define SIZE_TDATACUT 16
40 # define SIZE_TDATAVIA 128
41 # define SIZE_TPIN 512
42 # define F_DATA_SET 0x00000001
43 # define F_PIN_STATE 0x00000001
44 # define F_PIN_LAYER 0x00000002
45 # define F_PIN_DIRECTION 0x00000004
46 # define M_PIN_ISPLACED (F_PIN_STATE | F_PIN_LAYER)
47 # define F_VIA_CUT 0x00000001
48 # define F_VIA_PATTERN 0x00000002
49 # define F_SEG_INITIAL 0x00000001
50 # define F_SEG_SPECIAL 0x00000002
51 # define F_SEG_PIN 0x00000004
52 # define F_SEG_BLOCKAGE 0x00000008
53
54
55 /* ------------------------------------------------------------------
56 * Internal types.
57 */
58
59
60 typedef struct dataLayer_s {
61 char layer; /* MBK layer. */
62 char clayer; /* MBK terminal layer. */
63 char flags; /* Tell if this entry is set. */
64 char *name; /* "nameallocatted" name of the layer. */
65 long width; /* layer minimal width. */
66 } dataLayer_t;
67
68
69 typedef struct dataCut_s {
70 char VIA; /* MBK VIA. */
71 char flags; /* Tell if this entry is set . */
72 char *name; /* "namellocatted" name of the cut layer. */
73 } dataCut_t;
74
75
76 typedef struct dataVIA_s {
77 char VIA; /* MBK VIA or TURN_VIA. */
78 char flags; /* Tell if this entry is set . */
79 char *name; /* "namellocatted" name of the via . */
80 long width; /* VIA width. */
81 long height; /* VIA height. */
82 } dataVIA_t;
83
84
85 typedef struct pin_s {
86 char *pinName;
87 char *netName;
88 } pin_t;
89
90
91 /* ------------------------------------------------------------------
92 * Local variables (prefix 'LV_').
93 */
94
95 static char *LV_IN_PH = "def";
96 static struct lofig *LV_pLoFig;
97 static struct phfig *LV_pPhFig;
98 static struct phins *LV_pPhIns;
99 static char *LV_name;
100 static char LV_mode;
101 static char LV_defFlags;
102 static char *LV_blockageName;
103 static struct dataLayer_s tDataLayer[SIZE_TDATALAYER];
104 static struct dataCut_s tDataCut[SIZE_TDATACUT];
105 static struct dataVIA_s tDataVIA[SIZE_TDATAVIA];
106 static long LV_mVIA = 0L;
107 static long LV_mPin;
108 static struct pin_s *LV_tPin;
109 static struct authtable *LV_htPin;
110 static char *LV_modelName;
111 static long LV_flags;
112 static long LV_orient;
113 static char LV_layer;
114 static char LV_VIA;
115 static long LV_width;
116 static long LV_height;
117 static long LV_lastX;
118 static long LV_lastY;
119 static struct pt *LV_ptCurrent;
120 static struct pt *LV_pt1;
121 static struct pt *LV_pt2;
122 static long LV_numPins;
123 static long LV_numObjects;
124 static long LV_numObjectsRead;
125 static long LV_direction;
126 static long LV_mSig;
127 static struct losig *LV_pLoSig;
128 static struct tLoseg_s *LV_ptLoseg;
129
130
131 /* ------------------------------------------------------------------
132 * Internal functions.
133 */
134
135 # define IS_X_PT(pt) ((pt)->x != HUGE_VAL)
136 # define IS_Y_PT(pt) ((pt)->y != HUGE_VAL)
137 # define IS_XY_PT(pt) (IS_X_PT(pt) && IS_Y_PT(pt))
138
139
140 static void initDataTables __FP((void));
141 static void setDataLayer __FP(( int aN,
142 char *aName,
143 char aLayer,
144 char aCLayer,
145 long aWidth));
146 static void setDataCut __FP(( int aN,
147 char *aName,
148 char aCut));
149 static void addDataVIA __FP((char *aName,
150 char aCut,
151 long width,
152 long height));
153 static dataVIA_t *DEF2MBK_dataVIA __FP((char *aName));
154 static long DEF_isLayer __FP((char *aName));
155 static char DEF2MBK_layer __FP((char *aName));
156 static long DEF2MBK_layerWidth __FP((char *aName));
157 static long MBK_layerWidth __FP((char aLayer));
158 static char DEF2MBK_dataCut __FP((char *aName));
159 static void orderCoord __FP((long *aX1, long *aX2));
160 static void DEF_pinxyflat __FP((long *apX_flat, long *apY_flat,
161 long aX , long aY ,
162 long aX_ins , long aY_ins ,
163 char aT));
164
165
166 /* ------------------------------------------------------------------
167 * Functions from Bison/flex.
168 */
169
170 extern FILE *yyin;
171 extern long yylineno;
172 extern int yydebug;
173 extern int yyparse __FP((void));
174
175
176
177 /*
178 * /----------------------------------------------------------------\
179 * | Functions Definitions |
180 * \----------------------------------------------------------------/
181 */
182
183 /* ------------------------------------------------------------------
184 * Function : "def_design_name()".
185 */
186
187 extern void def_design_name(name)
188 char *name;
189 {
190 if (strcmp (name, LV_pPhFig->NAME)) {
191 warnMBK ("DEFloadphlofig");
192 wprintf ("\n The design name \"%s\" doesn't match with the", name);
193 wprintf (" file name \"%s\" (.%s).\n", LV_pPhFig->NAME, LV_IN_PH);
194 }
195 }
196
197
198 /* ------------------------------------------------------------------
199 * Function : "def_tech_name()".
200 */
201
def_tech_name(char * name)202 extern void def_tech_name(char *name)
203 {
204 }
205
206
207 /* ------------------------------------------------------------------
208 * Function : "def_end_design()".
209 */
210
def_end_design(void)211 extern void def_end_design(void)
212 {
213 }
214
215
216 /* ------------------------------------------------------------------
217 * Function : "def_units()".
218 */
219
220 extern void def_units(number)
221 double number;
222 {
223 DEF_UNITS_MICRONS = (long)number;
224 }
225
226
227 /* ------------------------------------------------------------------
228 * Function : "def_die_area()".
229 */
230
def_die_area(ab1,ab2)231 extern void def_die_area(ab1, ab2)
232 struct pt *ab1, *ab2;
233 {
234 if ( !IS_XY_PT (ab1) || !IS_XY_PT (ab2) ) {
235 errMBK ("defloadlophfig");
236 eprintf ("Invalid coordinate '*' in DIEAREA at line %ld.\n",
237 yylineno);
238 EXIT (1);
239 }
240
241 if (LV_pPhFig)
242 defab(LV_pPhFig, DEF2MBK_length ((long)(ab1->x)),
243 DEF2MBK_length ((long)(ab1->y)),
244 DEF2MBK_length ((long)(ab2->x)),
245 DEF2MBK_length ((long)(ab2->y)));
246
247 def_free_pt (ab1);
248 def_free_pt (ab2);
249 }
250
251
252 /* ------------------------------------------------------------------
253 * Function : "def_row_rule()".
254 */
255
256 extern void def_row_rule(row_name, row_type, x, y, orient,
257 do_number, by_number, step_x, step_y)
258 char *row_name;
259 char *row_type;
260 double x, y, orient, do_number, by_number, step_x, step_y;
261 {
262 if (LV_pPhFig) {
263 DEF2MBK_row(LV_pPhFig,
264 row_name,
265 row_type,
266 (long)orient,
267 (long)do_number,
268 (long)by_number,
269 (long)step_x,
270 (long)step_y,
271 DEF2MBK_length ((long)x),
272 DEF2MBK_length ((long)y));
273 }
274
275
276 free (row_name);
277 free (row_type);
278 }
279
280
281 /* ------------------------------------------------------------------
282 * Function : "def_track_rule()".
283 */
284
285 extern void def_track_rule(axis_name, start, do_number, step, layer_list)
286 char *axis_name;
287 double start;
288 double do_number;
289 double step;
290 char *layer_list;
291 {
292 long xREF, yREF;
293
294
295
296 if (LV_pPhFig) {
297 switch (axis_name[0]) {
298 case 'Y':
299 case 'y':
300 xREF = LV_pPhFig->XAB1;
301 yREF = DEF2MBK_length ((long)start);
302 break;
303 case 'X':
304 case 'x':
305 default:
306 xREF = DEF2MBK_length ((long)start);
307 yREF = LV_pPhFig->YAB1;
308 }
309
310 DEF2MBK_track(LV_pPhFig,
311 axis_name,
312 (long)start,
313 (long)do_number,
314 (long)step,
315 layer_list,
316 xREF,
317 yREF);
318 }
319
320
321 free (axis_name);
322 }
323
324
325 /* ------------------------------------------------------------------
326 * Function : "def_track_layers()".
327 */
328
329 extern char *def_track_layers(layer_name, layer_list)
330 char *layer_name;
331 char *layer_list;
332 {
333 char *layerList;
334
335
336 layerList = s64printf ("%s.%s", layer_name, layer_list);
337
338 free (layer_name);
339
340 return (layerList);
341 }
342
343
344 /* ------------------------------------------------------------------
345 * Function : "def_start_pins()".
346 */
347
348
349 extern void def_start_pins(number)
350 double number;
351 {
352 LV_numObjects = (long)number;
353 LV_numObjectsRead = 0L;
354 LV_numPins = 0L;
355 LV_mPin = LV_numObjects;
356
357 LV_tPin = (pin_t*)malloc (sizeof (pin_t) * LV_numObjects);
358
359 /* Half empty HT are faster. */
360 LV_htPin = createauthtable (LV_numObjects);
361 }
362
363
364 /* ------------------------------------------------------------------
365 * Function : "def_end_pins()".
366 */
367
def_end_pins(void)368 extern void def_end_pins(void)
369 {
370 if (LV_numObjects != LV_numObjectsRead) {
371 warnMBK ("DEFloadlophig");
372 wprintf ("Invalid pins number : %d, (%d read)\n",
373 LV_numObjects, LV_numObjectsRead);
374 }
375 }
376
377
378 /* ------------------------------------------------------------------
379 * Function : "def_pin_start()".
380 */
381
def_pin_start(char * pin_name,char * net_name)382 extern void def_pin_start(char *pin_name, char *net_name)
383 {
384 char *netName;
385
386
387 netName = DEF2MBK_name (net_name);
388
389 if ((searchauthelem (LV_htPin, netName)) == NULL) {
390 addauthelem (LV_htPin, netName, LV_numPins);
391
392 if (LV_numPins >= LV_mPin) {
393 LV_mPin += SIZE_TPIN;
394 LV_tPin = (struct pin_s*)realloc (
395 LV_tPin, sizeof (struct pin_s) * LV_mPin);
396
397 if (!LV_tPin) {
398 eprinth ("defloadlophfig");
399 eprintf ("\n Not enougth memory to re-allocate \"LV_tPin[]\".\n");
400 EXIT (1);
401 }
402 }
403
404 LV_tPin[LV_numPins].netName = netName;
405 LV_tPin[LV_numPins].pinName = DEF2MBK_name (pin_name);
406
407 LV_numPins++;
408 }
409
410 LV_flags = 0L;
411 LV_direction = UNKNOWN;
412
413 LV_numObjectsRead++;
414
415 free (pin_name);
416 free (net_name);
417 }
418
419
420 /* ------------------------------------------------------------------
421 * Function : "def_pin_options()".
422 */
423
def_pin_options()424 extern void def_pin_options()
425 {
426 char *netName;
427 char *pinName;
428 char orientCon;
429 long xCon, yCon, widthCon, lengthCon, fakeCon;
430 long xR1 , yR1 , xR2 , yR2;
431 long xFR1, yFR1, xFR2, yFR2;
432 losig_list *pLoSig;
433 phseg_list *pPhSeg;
434 phcon_list *pPhCon;
435 authelem *pElem;
436
437
438 netName = LV_tPin[LV_numPins - 1].netName;
439 pinName = LV_tPin[LV_numPins - 1].pinName;
440
441
442 /* Process the logical terminal. */
443
444 if (LV_pLoFig) {
445 /* The logical terminal/signal pair must be created only once. */
446 if (!findlocon (LV_pLoFig, pinName)) {
447 pLoSig = addlosig (LV_pLoFig,
448 LV_mSig++,
449 addchain (NULL, (void*)pinName),
450 EXTERNAL);
451 addlocon (LV_pLoFig, pinName, pLoSig, LV_direction);
452 }
453 }
454
455
456 /* Process the physical terminal, if any. */
457
458 /* Shuts up "gcc -w" ... */
459 xR1 = 0;
460 yR1 = 0;
461 xR2 = 0;
462 yR2 = 0;
463 xCon = 0;
464 yCon = 0;
465
466 if (LV_flags & F_PIN_LAYER) {
467 xR1 = DEF2MBK_length ((long)(LV_pt1->x));
468 yR1 = DEF2MBK_length ((long)(LV_pt1->y));
469 xR2 = DEF2MBK_length ((long)(LV_pt2->x));
470 yR2 = DEF2MBK_length ((long)(LV_pt2->y)) - MBKSCALE(1);
471
472 def_free_pt (LV_pt1);
473 def_free_pt (LV_pt2);
474 }
475
476 if (LV_flags & F_PIN_STATE) {
477 xCon = DEF2MBK_length ((long)(LV_ptCurrent->x));
478 yCon = DEF2MBK_length ((long)(LV_ptCurrent->y));
479
480 def_free_pt (LV_ptCurrent);
481 }
482
483
484 if ((LV_pPhFig) && ((LV_flags & M_PIN_ISPLACED) == M_PIN_ISPLACED)) {
485 pElem = gettlosegitem (LV_ptLoseg, netName);
486
487 /* Transform (flatten) the PIN segment. */
488 DEF_pinxyflat (&xFR1, &yFR1, xR1, yR1, xCon, yCon, LV_orient);
489 DEF_pinxyflat (&xFR2, &yFR2, xR2, yR2, xCon, yCon, LV_orient);
490
491 orderCoord (&xFR1, &xFR2);
492 orderCoord (&yFR1, &yFR2);
493
494
495 fakeCon = FALSE;
496 pPhSeg = NULL; /* Shut up "gcc -w ..." */
497 /* if (!(LV_defFlags & F_DEF_NO_IOS)) { */
498 /* Add the physical segment. */
499 switch (LV_orient) {
500 case NOSYM:
501 case SYM_X:
502 case SYM_Y:
503 case SYMXY:
504 /* Vertical segment. */
505 widthCon = xFR2 - xFR1;
506 lengthCon = yFR2 - yFR1 + MBKSCALE(1);
507
508 if (lengthCon + widthCon < MBK_X_GRID + FLOOR_XY_EXPAND) {
509 fakeCon = (LV_defFlags & F_DEF_SHRINK) ? TRUE : FALSE;
510 __DBG( fprintf (stderr, " - Terminal \"%s\" is fake.\n",
511 netName); )
512 } else {
513 __DBG( fprintf (stderr, " - Terminal \"%s\" is not fake",
514 netName);
515 fprintf (stderr, " DY := %ld\n", MBKUNSCALE(lengthCon));
516 )
517 fakeCon = FALSE;
518 }
519
520 if (!fakeCon) {
521 pPhSeg = addphseg (LV_pPhFig,
522 getCALU (LV_layer),
523 widthCon,
524 xFR1 + widthCon / 2,
525 yFR1,
526 xFR1 + widthCon / 2,
527 yFR2,
528 netName);
529 }
530 break;
531 default:
532 case ROT_P:
533 case ROT_M:
534 case SY_RP:
535 case SY_RM:
536 /* horizontal segment. */
537 widthCon = yFR2 - yFR1;
538 lengthCon = xFR2 - xFR1 + MBKSCALE(1);
539
540 if (lengthCon + widthCon < MBK_X_GRID + FLOOR_XY_EXPAND) {
541 fakeCon = (LV_defFlags & F_DEF_SHRINK) ? TRUE : FALSE;
542 __DBG( fprintf (stderr, " - Terminal \"%s\" is fake.\n",
543 netName); )
544 } else {
545 __DBG( fprintf (stderr, " - Terminal \"%s\" is not fake",
546 netName);
547 fprintf (stderr, " DX := %ld\n", MBKUNSCALE(lengthCon));
548 )
549 fakeCon = FALSE;
550 }
551
552 if (!fakeCon) {
553 pPhSeg = addphseg (LV_pPhFig,
554 getCALU (LV_layer),
555 widthCon,
556 xFR1,
557 yFR1 + widthCon / 2,
558 xFR2,
559 yFR1 + widthCon / 2,
560 netName);
561 }
562 break;
563 } /* End of "switch (LV_orient)". */
564
565 if (!fakeCon || (LV_defFlags & F_DEF_KEEP_IOS)) {
566 if (!fakeCon)
567 LV_ptLoseg->tLoseg[pElem->VALUE] = addloseg (
568 LV_ptLoseg->tLoseg[pElem->VALUE], LOSEG_SEGCON, (void*)pPhSeg);
569
570
571 /* Add the old-style terminal. */
572 switch (LV_orient) {
573
574 case NOSYM: /* DEF : N (North). */
575 case SYM_X: /* DEF : FN (Flipped North). */
576 orientCon = SOUTH;
577 xCon = xFR1 + widthCon / 2;
578 yCon = yFR1;
579 break;
580
581 case SYM_Y: /* DEF : FS (Flipped South). */
582 case SYMXY: /* DEF : S (South). */
583 orientCon = NORTH;
584 xCon = xFR1 + widthCon / 2;
585 yCon = yFR2;
586 break;
587
588 case ROT_M: /* DEF : E (East). */
589 case SY_RM: /* DEF : FE (Flipped East). */
590 orientCon = WEST;
591 xCon = xFR1;
592 yCon = yFR1 + widthCon / 2;
593 break;
594
595 default:
596 case ROT_P: /* DEF : W (West). */
597 case SY_RP: /* DEF : FW (Flipped West). */
598 orientCon = EAST;
599 xCon = xFR2;
600 yCon = yFR1 + widthCon / 2;
601 break;
602 } /* End of "switch (LV_orient)". */
603
604 pPhCon = addphcon (LV_pPhFig,
605 orientCon,
606 netName,
607 xCon,
608 yCon,
609 LV_layer,
610 widthCon);
611
612 LV_ptLoseg->tLoseg[pElem->VALUE] = addloseg (
613 LV_ptLoseg->tLoseg[pElem->VALUE], LOSEG_CON, (void*)pPhCon);
614 }
615 }
616 /* } */
617 }
618
619
620 /* ------------------------------------------------------------------
621 * Function : "def_pin_option_direction()".
622 */
623
624 extern void def_pin_option_direction(dir)
625 double dir;
626 {
627 LV_flags |= F_PIN_DIRECTION;
628 LV_direction = DEF2MBK_direction (dir);
629 }
630
631
632 /* ------------------------------------------------------------------
633 * Function : "def_pin_option_place()".
634 */
635
def_pin_option_place(ptcon,orient)636 extern void def_pin_option_place(ptcon, orient)
637 struct pt *ptcon;
638 double orient;
639 {
640 LV_flags |= F_PIN_STATE;
641 LV_ptCurrent = ptcon;
642 LV_orient = DEF2MBK_transf (orient);
643 }
644
645
646 /* ------------------------------------------------------------------
647 * Function : "def_pin_option_layer()".
648 */
649
650 extern void def_pin_option_layer(layer_name, pt1, pt2)
651 char *layer_name;
652 struct pt *pt1;
653 struct pt *pt2;
654 {
655 LV_flags |= F_PIN_LAYER;
656 LV_layer = getALU (DEF2MBK_layer (namealloc (layer_name)));
657
658 LV_pt1 = pt1;
659 LV_pt2 = pt2;
660 }
661
662
663 /* ------------------------------------------------------------------
664 * Function : "def_start_vias()".
665 */
666
667
668 extern void def_start_vias(number)
669 double number;
670 {
671 LV_numObjects = (long)number;
672 LV_numObjectsRead = 0L;
673 LV_flags = 0L;
674 /* Reset the VIA table. */
675 LV_mVIA = 0L;
676 }
677
678
679 /* ------------------------------------------------------------------
680 * Function : "def_end_vias()".
681 */
682
def_end_vias(void)683 extern void def_end_vias(void)
684 {
685 if (LV_numObjects != LV_numObjectsRead) {
686 warnMBK ("DEFloadlophig");
687 wprintf ("Invalid VIAs number : %d, (%d read)\n",
688 LV_numObjects, LV_numObjectsRead);
689 }
690 }
691
692
693 /* ------------------------------------------------------------------
694 * Function : "def_via_start()".
695 */
696
697 extern void def_via_start(via_name)
698 char *via_name;
699 {
700 LV_modelName = namealloc (via_name);
701 LV_numObjectsRead++;
702
703 free (via_name);
704 }
705
706
707 /* ------------------------------------------------------------------
708 * Function : "def_via_stmt_rect()".
709 */
710
711 extern void def_via_stmt_rect(layer_name, pt1, pt2)
712 char *layer_name;
713 struct pt *pt1, *pt2;
714 {
715 char *DEF_layer;
716
717
718 DEF_layer = namealloc (layer_name);
719
720 if (DEF_isLayer (DEF_layer)) {
721 LV_layer = DEF2MBK_layer (DEF_layer);
722
723 /* This is one of the layer geometry. */
724 LV_width = DEF2MBK_length ((long)(pt2->x) - (long)(pt1->x));
725 LV_height = DEF2MBK_length ((long)(pt2->y) - (long)(pt1->y));
726
727 LV_width = ABS(LV_width);
728 LV_height = ABS(LV_height);
729
730 if ( (LV_height <= MBKSCALE(2))
731 && (LV_width <= MBKSCALE(2))) {
732 LV_width = 0;
733 LV_height = 0;
734 }
735 } else {
736 /* This is the cut layer. */
737 LV_VIA = DEF2MBK_dataCut (DEF_layer);
738
739 LV_flags |= F_VIA_CUT;
740 }
741
742 def_free_pt (pt1);
743 def_free_pt (pt2);
744 free (layer_name);
745 }
746
747
748 /* ------------------------------------------------------------------
749 * Function : "def_via_stmt_pattern()".
750 */
751
752 extern void def_via_stmt_pattern(pattern_name)
753 char *pattern_name;
754 {
755 LV_flags |= F_VIA_PATTERN;
756
757 free (pattern_name);
758 }
759
760
761 /* ------------------------------------------------------------------
762 * Function : "def_via_end()".
763 */
764
def_via_end()765 extern void def_via_end()
766 {
767 if (!(LV_flags & F_VIA_CUT))
768 LV_VIA = getTurnVIA (LV_layer);
769
770 mprintf2 (" - \"%20s\" id %02d %5ldx%-5ld.\n",
771 LV_modelName, LV_VIA, LV_width, LV_height);
772
773 addDataVIA (LV_modelName, LV_VIA, LV_width, LV_height);
774
775 LV_flags = 0;
776 }
777
778
779 /* ------------------------------------------------------------------
780 * Function : "def_start_comps()".
781 */
782
783
784 extern void def_start_comps(number)
785 double number;
786 {
787 LV_numObjects = (long)number;
788 LV_numObjectsRead = 0L;
789 }
790
791
792 /* ------------------------------------------------------------------
793 * Function : "def_end_comps()".
794 */
795
def_end_comps(void)796 extern void def_end_comps(void)
797 {
798 if (LV_numObjects != LV_numObjectsRead) {
799 warnMBK ("DEFloadlophig");
800 wprintf ("Invalid components number : %d, (%d read)",
801 LV_numObjects, LV_numObjectsRead);
802 }
803 }
804
805
806 /* ------------------------------------------------------------------
807 * Function : "def_comp_start()".
808 */
809
def_comp_start(char * ins_name,char * cell_name)810 extern void def_comp_start(char *ins_name, char *cell_name)
811 {
812 LV_numObjectsRead++;
813
814 if (LV_pPhFig) {
815 /* Coordinates and symetry will be filled by "comp_options()". */
816 LV_pPhIns = addphins (LV_pPhFig, cell_name, ins_name, NOSYM, 0, 0);
817 }
818
819 if (LV_pLoFig) {
820 /* Assignement of signals to terminals will be done in the "net"
821 * section.
822 */
823 addloins_noSig (LV_pLoFig, ins_name, getlofig (cell_name, 'P'));
824 }
825
826 free ( ins_name);
827 free (cell_name);
828 }
829
830
831 /* ------------------------------------------------------------------
832 * Function : "def_comp_net_list()".
833 */
834
def_comp_net_list(char * name)835 extern void def_comp_net_list(char *name)
836 {
837 }
838
839
840 /* ------------------------------------------------------------------
841 * Function : "def_comp_type()".
842 */
843
def_comp_type(pt,orient)844 extern void def_comp_type(pt, orient)
845 struct pt *pt;
846 double orient;
847 {
848 if (LV_pPhFig) {
849 if (!IS_XY_PT (pt)) {
850 errMBK ("defloadlophfig");
851 eprintf ("\n Invalid coordinate '*' for instance placement \"%s\"\n",
852 LV_pPhIns->INSNAME);
853 eprintf (" at line %ld.\n", yylineno);
854 EXIT (1);
855 }
856
857 LV_pPhIns->XINS = DEF2MBK_length ((long)(pt->x));
858 LV_pPhIns->YINS = DEF2MBK_length ((long)(pt->y));
859 LV_pPhIns->TRANSF = DEF2MBK_transf (orient);
860 }
861
862 def_free_pt (pt);
863 }
864
865
866 /* ------------------------------------------------------------------
867 * Function : "def_start_nets()".
868 */
869
870
def_start_nets(double number)871 extern void def_start_nets(double number)
872 {
873 LV_numObjects = (long)number;
874 LV_numObjectsRead = 0L;
875
876 mprintf1 (" o Reading NETS section (%ld nets)\n", LV_numObjects);
877 }
878
879
880 /* ------------------------------------------------------------------
881 * Function : "def_end_nets()".
882 */
883
def_end_nets(void)884 extern void def_end_nets(void)
885 {
886 if (LV_numObjects != LV_numObjectsRead) {
887 warnMBK ("DEFloadlophig");
888 wprintf ("Invalid net number : %d, (%d read)",
889 LV_numObjects, LV_numObjectsRead);
890 }
891 }
892
893
894 /* ------------------------------------------------------------------
895 * Function : "def_net_start()".
896 */
897
def_net_start(char * name)898 extern void def_net_start(char *name)
899 {
900 struct authelem *pElem;
901
902
903 LV_numObjectsRead++;
904 LV_modelName = DEF2MBK_name (name);
905
906 mprintf2 (" - \"%s\"\n", LV_modelName);
907
908 if ((pElem = searchauthelem (LV_htPin, LV_modelName)) != NULL) {
909 /* The terminal name no longer override the net name. But we keep
910 * the pin hash table because we must know if the net is external
911 * or internal (i.e. the layer is ALU or CALU.
912 *
913 * LV_modelName = LV_tPin[pElem->VALUE].pinName;
914 */
915 LV_flags = F_SEG_PIN;
916 if (LV_pLoFig) {
917 LV_pLoSig = getlosig (LV_pLoFig, pElem->VALUE);
918 }
919 } else {
920 /* This not is not linked to a terminal. So it has not been created
921 * while reading the PIN section. We do it now.
922 */
923 if (LV_pLoFig) {
924 LV_pLoSig = addlosig (LV_pLoFig,
925 LV_mSig++,
926 addchain (NULL, (void*)LV_modelName),
927 INTERNAL);
928 }
929 LV_flags = 0L;
930 }
931
932 free (name);
933 }
934
935
936 /* ------------------------------------------------------------------
937 * Function : "def_path_start()".
938 */
939
940 extern void def_path_start(layer_name)
941 char *layer_name;
942 {
943 char *DEF_layer;
944
945
946 DEF_layer = namealloc (layer_name);
947
948 LV_layer = DEF2MBK_layer (DEF_layer);
949 LV_width = DEF2MBK_layerWidth (DEF_layer);
950 LV_flags |= F_SEG_INITIAL;
951
952 free (layer_name);
953 }
954
955
956 /* ------------------------------------------------------------------
957 * Function : "def_path_item_via()".
958 */
959
960 extern void def_path_item_via(via_name)
961 char *via_name;
962 {
963 char *DEF_viaLayer;
964 dataVIA_t *pDataVIA;
965 authelem *pElem;
966 phvia_list *pPhvia;
967
968
969 /* This a VIA and maybe a layer change. */
970 DEF_viaLayer = namealloc (via_name);
971
972
973 if (LV_flags & F_SEG_INITIAL) {
974 errMBK ("defloadlophfig");
975 eprintf ("Net path cannot begin by a VIA at line %ld", yylineno);
976 EXIT (1);
977 }
978
979
980 pDataVIA = DEF2MBK_dataVIA (DEF_viaLayer);
981 LV_layer = getAltVIALayer (pDataVIA->VIA, LV_layer);
982
983 if (!(LV_flags & F_SEG_SPECIAL)) {
984 LV_width = MBK_layerWidth (LV_layer);
985 }
986
987
988 if (LV_pPhFig && !(LV_flags & F_SEG_BLOCKAGE)) {
989 pPhvia = addphvia(LV_pPhFig,
990 pDataVIA->VIA,
991 LV_lastX,
992 LV_lastY,
993 pDataVIA->width,
994 pDataVIA->height,
995 LV_modelName);
996
997 if (!getmvia (LV_ptLoseg->tMVIA, pPhvia)) {
998 LV_ptLoseg->tMVIA = addmvia (LV_ptLoseg->tMVIA, pPhvia);
999 }
1000
1001 pElem = gettlosegitem (LV_ptLoseg, LV_modelName);
1002
1003 LV_ptLoseg->tLoseg[pElem->VALUE] = addloseg (
1004 LV_ptLoseg->tLoseg[pElem->VALUE], LOSEG_VIA, (void*)pPhvia);
1005 }
1006
1007
1008 free (via_name);
1009 }
1010
1011
1012 /* ------------------------------------------------------------------
1013 * Function : "def_path_item_pt()".
1014 */
1015
def_path_item_pt(pt)1016 extern void def_path_item_pt(pt)
1017 struct pt *pt;
1018 {
1019 long curX, curY;
1020 char *sigName, powerName[64];
1021 authelem *pElem;
1022 phseg_list *pPhSeg;
1023
1024
1025 if (IS_X_PT(pt)) { curX = DEF2MBK_length ((long)pt->x); }
1026 else { curX = LV_lastX; }
1027
1028
1029 if (IS_Y_PT(pt)) { curY = DEF2MBK_length ((long)pt->y); }
1030 else { curY = LV_lastY; }
1031
1032
1033 if (LV_flags & F_SEG_INITIAL) {
1034 if (!IS_XY_PT(pt)) {
1035 errMBK ("defloadlophfig");
1036 eprintf ("Invalid first net path point at line %ld", yylineno);
1037 EXIT (1);
1038 }
1039
1040 LV_flags &= ~F_SEG_INITIAL;
1041 } else {
1042 if (LV_pPhFig) {
1043 if ( (LV_defFlags & F_DEF_SPLIT_POWER)
1044 && (isvdd (LV_modelName) || isvss (LV_modelName))) {
1045 sigName = powerName;
1046 sprintf (sigName,
1047 "%s.%ld",
1048 LV_modelName,
1049 (curY - LV_pPhFig->XAB1 + MBKSCALE(25)) / MBKSCALE(50));
1050 } else
1051 sigName = LV_modelName;
1052
1053 if (!(LV_flags & F_SEG_BLOCKAGE)) {
1054 pPhSeg = addphseg (LV_pPhFig,
1055 (LV_flags & F_SEG_PIN) ? getCALU (LV_layer)
1056 : LV_layer,
1057 LV_width,
1058 LV_lastX,
1059 LV_lastY,
1060 curX,
1061 curY,
1062 sigName);
1063
1064 pElem = gettlosegitem (LV_ptLoseg, sigName);
1065
1066 LV_ptLoseg->tLoseg[pElem->VALUE] = addloseg (
1067 LV_ptLoseg->tLoseg[pElem->VALUE], LOSEG_SEG, (void*)pPhSeg);
1068 }
1069 }
1070 }
1071
1072
1073 LV_lastX = curX;
1074 LV_lastY = curY;
1075
1076 def_free_pt (pt);
1077 }
1078
1079
1080 /* ------------------------------------------------------------------
1081 * Function : "def_opt_width()".
1082 */
1083
1084 extern void def_opt_width(number)
1085 double number;
1086 {
1087 LV_width = DEF2MBK_length ((long)number);
1088 }
1089
1090
1091 /* ------------------------------------------------------------------
1092 * Function : "def_net_conn_start()".
1093 */
1094
def_net_conn_start(char * ins_name,char * pin_name)1095 extern void def_net_conn_start(char *ins_name, char *pin_name)
1096 {
1097 if (LV_pLoFig) {
1098 if (strcmp (ins_name, "PIN")) {
1099 addlosig_insCon (getloins (LV_pLoFig,
1100 ins_name),
1101 DEF2MBK_name (pin_name),
1102 LV_pLoSig);
1103
1104 free (ins_name);
1105 }
1106 }
1107
1108
1109 free (pin_name);
1110 }
1111
1112
1113 /* ------------------------------------------------------------------
1114 * Function : "def_net_conn_opt_synthesized()".
1115 */
1116
def_net_conn_opt_synthesized()1117 extern void def_net_conn_opt_synthesized()
1118 {
1119 }
1120
1121
1122 /* ------------------------------------------------------------------
1123 * Function : "def_start_snets()".
1124 */
1125
1126
def_start_snets(double number)1127 extern void def_start_snets(double number)
1128 {
1129 LV_numObjects = (long)number;
1130 LV_numObjectsRead = 0L;
1131
1132 mprintf1 (" o Reading SPECIALNETS section.\n");
1133 }
1134
1135
1136 /* ------------------------------------------------------------------
1137 * Function : "def_end_snets()".
1138 */
1139
def_end_snets(void)1140 extern void def_end_snets(void)
1141 {
1142 if (LV_numObjects != LV_numObjectsRead) {
1143 warnMBK ("DEFloadlophig");
1144 wprintf ("Invalid special nets number : %d, (%d read)",
1145 LV_numObjects, LV_numObjectsRead);
1146 }
1147 }
1148
1149
1150 /* ------------------------------------------------------------------
1151 * Function : "def_snet_start()".
1152 */
1153
def_snet_start(char * name)1154 extern void def_snet_start(char *name)
1155 {
1156 struct authelem *pElem;
1157
1158
1159 LV_numObjectsRead++;
1160 LV_modelName = namealloc (name);
1161 LV_flags = F_SEG_SPECIAL;
1162
1163 if (LV_modelName == LV_blockageName) {
1164 /* This is a special net named "_BLOCKAGE_RESERVED" used to forbid
1165 * the corners of the design when placing the IO pins. Must not be
1166 * driven in the MBK data-base.
1167 */
1168 LV_flags |= F_SEG_BLOCKAGE;
1169 } else {
1170 if ((pElem = searchauthelem (LV_htPin, LV_modelName)) != NULL) {
1171 /* The terminal name no longer override the net name. But we keep
1172 * the pin hash table because we must know if the net is external
1173 * or internal (i.e. the layer is ALU or CALU.
1174 *
1175 * LV_modelName = LV_tPin[pElem->VALUE].pinName;
1176 */
1177 LV_flags |= F_SEG_PIN;
1178 if (LV_pLoFig) {
1179 LV_pLoSig = getlosig (LV_pLoFig, pElem->VALUE);
1180 }
1181 } else {
1182 /* This not is not linked to a terminal. So it has not been created
1183 * while reading the PIN section. We do it now.
1184 */
1185 if (LV_pLoFig) {
1186 LV_pLoSig = addlosig (LV_pLoFig,
1187 LV_mSig++,
1188 addchain (NULL,
1189 (void*)DEF2MBK_name(LV_modelName)),
1190 INTERNAL);
1191 }
1192 LV_flags = 0L;
1193 }
1194 }
1195
1196 mprintf2 (" - \"%s\".\n", LV_modelName);
1197
1198
1199 free (name);
1200 }
1201
1202
1203 /* ------------------------------------------------------------------
1204 * Function : "def_snet_conn_start()".
1205 */
1206
def_snet_conn_start(char * ins_name,char * pin_name)1207 extern void def_snet_conn_start(char *ins_name, char *pin_name)
1208 {
1209 if (LV_pLoFig) {
1210 if (strcmp (ins_name, "PIN")) {
1211 addlosig_insCon (getloins (LV_pLoFig,
1212 ins_name),
1213 pin_name,
1214 LV_pLoSig);
1215
1216 free (ins_name);
1217 }
1218 }
1219
1220
1221 free (pin_name);
1222 }
1223
1224
1225 /* ------------------------------------------------------------------
1226 * Function : "def_snet_conn_opt_synthesized()".
1227 */
1228
def_snet_conn_opt_synthesized()1229 extern void def_snet_conn_opt_synthesized()
1230 {
1231 }
1232
1233
1234 /* ------------------------------------------------------------------
1235 * Function : "def_snet_conn_opt_synthesized()".
1236 */
1237
1238 extern void def_parse_error(str)
1239 char *str;
1240 {
1241 errMBK ("DEFloadphlofig");
1242 eprintf ("%s line %d.\n", str, yylineno);
1243 EXIT (1);
1244 }
1245
1246
1247 /* ------------------------------------------------------------------
1248 * Function : "def_alloc_pt()".
1249 */
1250
1251 extern struct pt *def_alloc_pt(x, y)
1252 double x, y;
1253 {
1254 struct pt *pt;
1255
1256
1257 pt = (struct pt*)malloc (sizeof (struct pt));
1258
1259 if (!pt) {
1260 errMBK ("DEFloadlophig");
1261 eprintf ("Not enougth memory in \"def_alloc_pt()\"!\n");
1262 EXIT (1);
1263 }
1264
1265 pt->x = x;
1266 pt->y = y;
1267
1268 return (pt);
1269 }
1270
1271
1272 /* ------------------------------------------------------------------
1273 * Function : "def_free_pt()".
1274 */
1275
def_free_pt(pt)1276 extern void def_free_pt(pt)
1277 struct pt *pt;
1278 {
1279 free (pt);
1280 }
1281
1282
1283 /* ------------------------------------------------------------------
1284 * Function : "initDataTables()".
1285 */
1286
initDataTables()1287 static void initDataTables()
1288 {
1289 int iData;
1290
1291
1292 for (iData = 0; iData < SIZE_TDATALAYER; iData++) {
1293 tDataLayer[iData].flags = 0L;
1294 }
1295
1296 for (iData = 0; iData < SIZE_TDATACUT; iData++) {
1297 tDataCut[iData].flags = 0L;
1298 }
1299
1300 for (iData = 0; iData < SIZE_TDATAVIA; iData++) {
1301 tDataVIA[iData].flags = 0L;
1302 }
1303 }
1304
1305
1306 /* ------------------------------------------------------------------
1307 * Function : "setDataLayer()".
1308 */
1309
setDataLayer(aN,aName,aLayer,aCLayer,aWidth)1310 static void setDataLayer(aN, aName, aLayer, aCLayer, aWidth)
1311 int aN;
1312 char *aName;
1313 char aLayer;
1314 char aCLayer;
1315 long aWidth;
1316 {
1317 tDataLayer[aN].name = namealloc (aName);
1318 tDataLayer[aN].layer = aLayer;
1319 tDataLayer[aN].clayer = aCLayer;
1320 tDataLayer[aN].width = aWidth;
1321 tDataLayer[aN].flags |= F_DATA_SET;
1322 }
1323
1324
1325 /* ------------------------------------------------------------------
1326 * Function : "setDataCut()".
1327 */
1328
setDataCut(aN,aName,aCut)1329 static void setDataCut(aN, aName, aCut)
1330 int aN;
1331 char *aName;
1332 char aCut;
1333 {
1334 tDataCut[aN].name = namealloc (aName);
1335 tDataCut[aN].VIA = aCut;
1336 tDataCut[aN].flags |= F_DATA_SET;
1337 }
1338
1339
1340 /* ------------------------------------------------------------------
1341 * Function : "addDataVIA()".
1342 */
1343
addDataVIA(aName,aCut,aWidth,aHeight)1344 static void addDataVIA(aName, aCut, aWidth, aHeight)
1345 char *aName;
1346 char aCut;
1347 long aWidth;
1348 long aHeight;
1349 {
1350 if (LV_mVIA > SIZE_TDATAVIA) {
1351 errMBK ("DEFloadlophig");
1352 eprintf ("VIA table overfow (more than %d VIAs).\n", SIZE_TDATAVIA);
1353 EXIT (1);
1354 }
1355
1356 tDataVIA[LV_mVIA].name = namealloc (aName);
1357 tDataVIA[LV_mVIA].VIA = aCut;
1358 tDataVIA[LV_mVIA].flags |= F_DATA_SET;
1359 tDataVIA[LV_mVIA].width = aWidth;
1360 tDataVIA[LV_mVIA].height = aHeight;
1361
1362 LV_mVIA++;
1363 }
1364
1365
1366 /* ------------------------------------------------------------------
1367 * Function : "DEF2MBK_dataVIA()".
1368 */
1369
DEF2MBK_dataVIA(aName)1370 static dataVIA_t *DEF2MBK_dataVIA(aName)
1371 char *aName;
1372 {
1373 int iDV;
1374
1375
1376 for (iDV = 0; iDV < SIZE_TDATAVIA; iDV++) {
1377 if ( (tDataVIA[iDV].flags & F_DATA_SET)
1378 && (tDataVIA[iDV].name == aName)) {
1379 return (&(tDataVIA[iDV]));
1380 }
1381 }
1382
1383 errMBK ("DEFloadphlofig");
1384 eprintf ("\n Unknown DEF VIA name \"%s\" at line %d.\n",
1385 aName, yylineno);
1386 EXIT (1);
1387
1388 /* Only to shut up GCC... */
1389 return (NULL);
1390 }
1391
1392
1393 /* ------------------------------------------------------------------
1394 * Function : "DEF_isLayer()".
1395 */
1396
DEF_isLayer(aName)1397 static long DEF_isLayer(aName)
1398 char *aName;
1399 {
1400 int iDL;
1401
1402
1403 for (iDL = 0; iDL < SIZE_TDATALAYER; iDL++) {
1404 if ( (tDataLayer[iDL].flags & F_DATA_SET)
1405 && (tDataLayer[iDL].name == aName)) {
1406 return (TRUE);
1407 }
1408 }
1409
1410 return (FALSE);
1411 }
1412
1413
1414 /* ------------------------------------------------------------------
1415 * Function : "DEF2MBK_layer()".
1416 */
1417
DEF2MBK_layer(aName)1418 static char DEF2MBK_layer(aName)
1419 char *aName;
1420 {
1421 int iDL;
1422
1423
1424 for (iDL = 0; iDL < SIZE_TDATALAYER; iDL++) {
1425 if ( (tDataLayer[iDL].flags & F_DATA_SET)
1426 && (tDataLayer[iDL].name == aName)) {
1427 return (tDataLayer[iDL].layer);
1428 }
1429 }
1430
1431 errMBK ("DEFloadphlofig");
1432 eprintf ("\n Unknown DEF layer name \"%s\" at line %d.\n",
1433 aName, yylineno);
1434 EXIT (1);
1435
1436 /* Only to shut up GCC... */
1437 return ('\0');
1438 }
1439
1440
1441 /* ------------------------------------------------------------------
1442 * Function : "DEF2MBK_layerWidth()".
1443 */
1444
DEF2MBK_layerWidth(aName)1445 static long DEF2MBK_layerWidth(aName)
1446 char *aName;
1447 {
1448 int iDL;
1449
1450
1451 for (iDL = 0; iDL < SIZE_TDATALAYER; iDL++) {
1452 if ( (tDataLayer[iDL].flags & F_DATA_SET)
1453 && (tDataLayer[iDL].name == aName)) {
1454 return (tDataLayer[iDL].width);
1455 }
1456 }
1457
1458 errMBK ("DEFloadphlofig");
1459 eprintf ("\n Unknown DEF layer name \"%s\" at line %d.\n",
1460 aName, yylineno);
1461 EXIT (1);
1462
1463 /* Only to shut up GCC... */
1464 return (0L);
1465 }
1466
1467
1468 /* ------------------------------------------------------------------
1469 * Function : "MBK_layerWidth()".
1470 */
1471
MBK_layerWidth(aLayer)1472 static long MBK_layerWidth(aLayer)
1473 char aLayer;
1474 {
1475 int iDL;
1476
1477
1478 for (iDL = 0; iDL < SIZE_TDATALAYER; iDL++) {
1479 if ( (tDataLayer[iDL].flags & F_DATA_SET)
1480 && ( (tDataLayer[iDL].layer == aLayer)
1481 || (tDataLayer[iDL].clayer == aLayer))) {
1482 return (tDataLayer[iDL].width);
1483 }
1484 }
1485
1486 errMBK ("DEFloadphlofig");
1487 eprintf ("\n Unknown MBK layer id \"%d\" at line %d.\n",
1488 (int)aLayer, yylineno);
1489 EXIT (1);
1490
1491 /* Only to shut up GCC... */
1492 return (0L);
1493 }
1494
1495
1496 /* ------------------------------------------------------------------
1497 * Function : "DEF2MBK_dataCut()".
1498 */
1499
DEF2MBK_dataCut(aName)1500 static char DEF2MBK_dataCut(aName)
1501 char *aName;
1502 {
1503 int iDC;
1504
1505
1506 for (iDC = 0; iDC < SIZE_TDATACUT; iDC++) {
1507 if ( (tDataCut[iDC].flags & F_DATA_SET)
1508 && (tDataCut[iDC].name == aName)) {
1509 return (tDataCut[iDC].VIA);
1510 }
1511 }
1512
1513 errMBK ("DEFloadphlofig");
1514 eprintf ("\n Unknown DEF cut layer name \"%s\" at line %d.\n",
1515 aName, yylineno);
1516 EXIT (1);
1517
1518 /* Only to shut up GCC... */
1519 return ('\0');
1520 }
1521
1522
1523 /* ------------------------------------------------------------------
1524 * Function : "orderCoord()".
1525 */
1526
orderCoord(aX1,aX2)1527 static void orderCoord (aX1, aX2)
1528 long *aX1, *aX2;
1529 {
1530 long tmp;
1531
1532
1533 if (*aX1 > *aX2)
1534 { tmp = *aX1; *aX1 = *aX2; *aX2 = tmp; }
1535 }
1536
1537
1538 /* ------------------------------------------------------------------
1539 * Function : "DEF_pinxyflat()".
1540 */
1541
DEF_pinxyflat(apX_flat,apY_flat,aX,aY,aX_ins,aY_ins,aT)1542 static void DEF_pinxyflat(apX_flat, apY_flat, aX, aY, aX_ins, aY_ins, aT)
1543 long *apX_flat, *apY_flat;
1544 long aX , aY;
1545 long aX_ins , aY_ins;
1546 char aT;
1547 {
1548 switch (aT) {
1549 /* DEF : N (North). */
1550 case NOSYM :
1551 *apX_flat = aX_ins + aX;
1552 *apY_flat = aY_ins + aY;
1553 break;
1554
1555 /* DEF : FN (Flipped North). */
1556 case SYM_X :
1557 *apX_flat = aX_ins - aX;
1558 *apY_flat = aY_ins + aY;
1559 break;
1560
1561 /* DEF : S (Flipped South). */
1562 case SYM_Y :
1563 *apX_flat = aX_ins + aX;
1564 *apY_flat = aY_ins - aY;
1565 break;
1566
1567 /* DEF : S (South). */
1568 case SYMXY :
1569 *apX_flat = aX_ins - aX;
1570 *apY_flat = aY_ins - aY;
1571 break;
1572
1573 /* DEF : W (West). */
1574 case ROT_P :
1575 *apX_flat = aX_ins - aY;
1576 *apY_flat = aY_ins + aX;
1577 break;
1578
1579 /* DEF : E (East). */
1580 case ROT_M :
1581 *apX_flat = aX_ins + aY;
1582 *apY_flat = aY_ins - aX;
1583 break;
1584
1585 /* DEF : FP (Flipped West). */
1586 case SY_RP :
1587 *apX_flat = aX_ins + aY;
1588 *apY_flat = aY_ins + aX;
1589 break;
1590
1591 /* DEF : FE (Flipped East). */
1592 case SY_RM :
1593 *apX_flat = aX_ins - aY;
1594 *apY_flat = aY_ins - aX;
1595 break;
1596 }
1597 }
1598
1599
1600 /* ------------------------------------------------------------------
1601 * Function : "LEF2MBK_setData()".
1602 */
1603
LEF2MBK_setData()1604 static void LEF2MBK_setData()
1605 {
1606 setDataLayer (0, "ALU1", ALU1, CALU1, MBKSCALE(1));
1607 setDataLayer (1, "ALU2", ALU2, CALU2, MBKSCALE(2));
1608 setDataLayer (2, "ALU3", ALU3, CALU3, MBKSCALE(2));
1609 setDataLayer (3, "ALU4", ALU4, CALU4, MBKSCALE(2));
1610 setDataLayer (4, "ALU5", ALU5, CALU5, MBKSCALE(2));
1611 setDataLayer (5, "ALU6", ALU6, CALU6, MBKSCALE(2));
1612 setDataLayer (6, "ALU7", ALU7, CALU7, MBKSCALE(2));
1613 setDataLayer (7, "ALU8", ALU8, CALU8, MBKSCALE(2));
1614 setDataLayer (8, "ALU9", ALU9, CALU9, MBKSCALE(2));
1615
1616 setDataCut (0, "VIAP", CONT_POLY);
1617 setDataCut (1, "VIA1", CONT_VIA);
1618 setDataCut (2, "VIA2", CONT_VIA2);
1619 setDataCut (3, "VIA3", CONT_VIA3);
1620 setDataCut (4, "VIA4", CONT_VIA4);
1621 setDataCut (5, "VIA5", CONT_VIA5);
1622 setDataCut (6, "VIA6", CONT_VIA6);
1623 setDataCut (7, "VIA7", CONT_VIA7);
1624 setDataCut (8, "VIA8", CONT_VIA8);
1625
1626 addDataVIA ("CONT_VIA" , CONT_VIA , 0, 0);
1627 addDataVIA ("CONT_VIA2", CONT_VIA2, 0, 0);
1628 addDataVIA ("CONT_VIA3", CONT_VIA3, 0, 0);
1629 addDataVIA ("CONT_VIA4", CONT_VIA4, 0, 0);
1630 addDataVIA ("CONT_VIA5", CONT_VIA5, 0, 0);
1631 }
1632
1633
1634 /* ------------------------------------------------------------------
1635 * Function : "defloadlophig()".
1636 */
1637
1638 extern void defloadlophfig (apLoFig, apPhFig, aName, aMode, aVL, aFlags)
1639 lofig_list *apLoFig;
1640 phfig_list *apPhFig;
1641 char *aName;
1642 char aMode;
1643 long aVL;
1644 long aFlags;
1645 {
1646 long isRouted, iLoseg, type;
1647 void *MBKobj;
1648 struct ePow_s *plPow;
1649 struct eLoseg_s *pLoseg;
1650
1651
1652 LV_pPhFig = apPhFig;
1653 LV_pLoFig = apLoFig;
1654 LV_mode = aMode;
1655 LV_name = namealloc (aName);
1656 LV_mSig = 0L;
1657 LV_defFlags = aFlags;
1658
1659 LV_blockageName = namealloc ("_BLOCKAGE_RESERVED");
1660
1661 setVL (aVL);
1662
1663
1664 initDataTables ();
1665 LEF2MBK_setData ();
1666
1667
1668 if (!LV_pLoFig) {
1669 errMBK ("defloadlophfig");
1670 eprintf ("\n lofig is not allocated");
1671 eprintf (" while loading \"%s.%s\"\n", aName, LV_IN_PH);
1672 EXIT (1);
1673 }
1674
1675 if (LV_mode != 'A') {
1676 errMBK ("defloadlophfig");
1677 eprintf ("\n Unsupported load mode '%c'", aMode);
1678 eprintf (" while loading \"%s.%s\"\n", aName, LV_IN_PH);
1679 EXIT (1);
1680 }
1681
1682 yyin = mbkfopen (LV_name, LV_IN_PH, READ_TEXT);
1683 if (!yyin) {
1684 errMBK ("defloadlophfig");
1685 eprintf ("\n Unable to open file \"%s.%s\"\n", aName, LV_IN_PH);
1686 EXIT (1);
1687 }
1688
1689
1690 mprintf2 ("\n");
1691
1692 LV_ptLoseg = addtloseg (LV_pPhFig);
1693
1694 yylineno = 1;
1695 yydebug = 0;
1696 yyparse ();
1697
1698 destroyauthtable (LV_htPin);
1699 free (LV_tPin);
1700
1701 mprintf2 ("\n");
1702
1703
1704 if (fclose (yyin)) {
1705 warnMBK ("defloadlophfig");
1706 wprintf ("\n Unable to close file \"%s.%s\"\n", aName, LV_IN_PH);
1707 }
1708
1709
1710 delfeed (LV_pLoFig);
1711 checkLofig (LV_pLoFig);
1712
1713 if (LV_pPhFig) {
1714 if (LV_defFlags & F_DEF_NO_IOS) {
1715 __DBG( fprintf (stderr, "\n o Removing fake IO\'s.\n"); )
1716 for (iLoseg = 0; iLoseg < LV_ptLoseg->sigNB; iLoseg++) {
1717 isRouted = FALSE;
1718
1719 for (pLoseg = LV_ptLoseg->tLoseg[iLoseg];
1720 pLoseg != NULL; pLoseg = pLoseg->next) {
1721 switch (pLoseg->type) {
1722 case LOSEG_VIA:
1723 __DBG(
1724 fprintf (stderr, " - \"%s\" is routed.\n",
1725 ((struct phvia*)(pLoseg->MBKobj))->NAME);
1726 )
1727 isRouted = TRUE;
1728 break;
1729 case LOSEG_SEG:
1730 __DBG(
1731 fprintf (stderr, " - \"%s\" is routed.\n",
1732 ((struct phseg*)(pLoseg->MBKobj))->NAME);
1733 )
1734 isRouted = TRUE;
1735 break;
1736 case LOSEG_CON:
1737 case LOSEG_SEGCON:
1738 break;
1739 }
1740
1741 if (isRouted) break;
1742 }
1743
1744 /* If There is only terminal related objects : delete them. */
1745 if (!isRouted) {
1746 __DBG( fprintf (stderr, " - Removing ?\n"); )
1747 for (pLoseg = LV_ptLoseg->tLoseg[iLoseg]; pLoseg != NULL; ) {
1748 __DBG( fprintf (stderr, " - Removing loseg item.\n"); )
1749 type = pLoseg->type;
1750 MBKobj = pLoseg->MBKobj;
1751 __DBG( fprintf (stderr, " - MBKobj := %p.\n", MBKobj); )
1752
1753 pLoseg = delloseg (pLoseg);
1754
1755 switch (type) {
1756 case LOSEG_VIA:
1757 delphvia (LV_pPhFig, (struct phvia*)MBKobj);
1758 break;
1759 case LOSEG_CON:
1760 __DBG(
1761 fprintf (stderr, " - Removing MBK phcon := ");
1762 fprintf (stderr, "\"%s\".\n", ((struct phcon*)MBKobj)->NAME);
1763 )
1764
1765 delphcon (LV_pPhFig, (struct phcon*)MBKobj);
1766 break;
1767 case LOSEG_SEG:
1768 case LOSEG_SEGCON:
1769 __DBG(
1770 fprintf (stderr, " - Removing MBK phseg := ");
1771 fprintf (stderr, "\"%s\".\n", ((struct phseg*)MBKobj)->NAME);
1772 )
1773 delphseg (LV_pPhFig, (struct phseg*)MBKobj);
1774 break;
1775 }
1776 }
1777
1778 LV_ptLoseg->tLoseg[iLoseg] = NULL;
1779 }
1780 }
1781 }
1782
1783 if (!(LV_defFlags & F_DEF_NO_INTERF)) {
1784 long powFlags;
1785
1786
1787 mprintf1 (" o Copying up CALUx terminal segments.\n");
1788 copyUpCALU (LV_pLoFig, LV_pPhFig, 0);
1789
1790 mprintf1 (" o Adding power supplies terminals.\n");
1791
1792
1793 powFlags = 0L;
1794 if (LV_defFlags & F_DEF_MERGE_TERM) powFlags = F_POWER_MERGE;
1795
1796 plPow = buildPow (LV_pPhFig, ALU1, C_POWER_HORIZONTAL, "");
1797 powToCon (LV_pPhFig, ALU1, C_POWER_HORIZONTAL, plPow, powFlags);
1798
1799 plPow = buildPow (LV_pPhFig, ALU3, C_POWER_VERTICAL, "");
1800 powToCon (LV_pPhFig, ALU3, C_POWER_VERTICAL, plPow, powFlags);
1801 }
1802 }
1803 }
1804