1 // *****************************************************************************
2 // *****************************************************************************
3 // Copyright 2012 - 2017, Cadence Design Systems
4 //
5 // This file is part of the Cadence LEF/DEF Open Source
6 // Distribution, Product Version 5.8.
7 //
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied. See the License for the specific language governing
18 // permissions and limitations under the License.
19 //
20 // For updates, support, or to become part of the LEF/DEF Community,
21 // check www.openeda.org for details.
22 //
23 // $Author$
24 // $Revision$
25 // $Date$
26 // $State: $
27 // *****************************************************************************
28 // *****************************************************************************
29
30 #include <stdlib.h>
31 #include <stdio.h>
32 #include <string.h>
33 #include <time.h>
34 #ifndef WIN32
35 # include <unistd.h>
36 #endif /* not WIN32 */
37 #include "defrReader.hpp"
38 #include "defiAlias.hpp"
39
40 char defaultName[64];
41 char defaultOut[64];
42
43 // Global variables
44 FILE* fout;
45 void* userData;
46 int numObjs;
47 int isSumSet; // to keep track if within SUM
48 int isProp = 0; // for PROPERTYDEFINITIONS
49 int begOperand; // to keep track for constraint, to print - as the 1st char
50 static double curVer = 0;
51 static int setSNetWireCbk = 0;
52 static int isSessionless = 0;
53 static int ignoreRowNames = 0;
54 static int ignoreViaNames = 0;
55 static int testDebugPrint = 0; // test for ccr1488696
56
57 // TX_DIR:TRANSLATION ON
58
myLogFunction(const char * errMsg)59 void myLogFunction(const char* errMsg){
60 fprintf(fout, "ERROR: found error: %s\n", errMsg);
61 }
62
myWarningLogFunction(const char * errMsg)63 void myWarningLogFunction(const char* errMsg){
64 fprintf(fout, "WARNING: found error: %s\n", errMsg);
65 }
66
dataError()67 void dataError() {
68 fprintf(fout, "ERROR: returned user data is not correct!\n");
69 }
70
checkType(defrCallbackType_e c)71 void checkType(defrCallbackType_e c) {
72 if (c >= 0 && c <= defrDesignEndCbkType) {
73 // OK
74 } else {
75 fprintf(fout, "ERROR: callback type is out of bounds!\n");
76 }
77 }
78
79
done(defrCallbackType_e c,void *,defiUserData ud)80 int done(defrCallbackType_e c, void*, defiUserData ud) {
81 checkType(c);
82 if (ud != userData) dataError();
83 fprintf(fout, "END DESIGN\n");
84 return 0;
85 }
86
endfunc(defrCallbackType_e c,void *,defiUserData ud)87 int endfunc(defrCallbackType_e c, void*, defiUserData ud) {
88 checkType(c);
89 if (ud != userData) dataError();
90 return 0;
91 }
92
93
orientStr(int orient)94 char* orientStr(int orient) {
95 switch (orient) {
96 case 0: return ((char*)"N");
97 case 1: return ((char*)"W");
98 case 2: return ((char*)"S");
99 case 3: return ((char*)"E");
100 case 4: return ((char*)"FN");
101 case 5: return ((char*)"FW");
102 case 6: return ((char*)"FS");
103 case 7: return ((char*)"FE");
104 };
105 return ((char*)"BOGUS");
106 }
107
compMSL(defrCallbackType_e c,defiComponentMaskShiftLayer * co,defiUserData ud)108 int compMSL(defrCallbackType_e c, defiComponentMaskShiftLayer* co, defiUserData ud) {
109 int i;
110
111 checkType(c);
112 if (ud != userData) dataError();
113
114 if (co->numMaskShiftLayers()) {
115 fprintf(fout, "\nCOMPONENTMASKSHIFT ");
116
117 for (i = 0; i < co->numMaskShiftLayers(); i++) {
118 fprintf(fout, "%s ", co->maskShiftLayer(i));
119 }
120 fprintf(fout, ";\n");
121 }
122
123 return 0;
124 }
125
compf(defrCallbackType_e c,defiComponent * co,defiUserData ud)126 int compf(defrCallbackType_e c, defiComponent* co, defiUserData ud) {
127 if (testDebugPrint) {
128 co->print(fout);
129 } else {
130 int i;
131
132 checkType(c);
133 if (ud != userData) dataError();
134 // missing GENERATE, FOREIGN
135 fprintf(fout, "- %s %s ", co->id(),
136 co->name());
137 // co->changeIdAndName("idName", "modelName");
138 // fprintf(fout, "%s %s ", co->id(),
139 // co->name());
140 if (co->hasNets()) {
141 for (i = 0; i < co->numNets(); i++)
142 fprintf(fout, "%s ", co->net(i));
143 }
144 if (co->isFixed())
145 fprintf(fout, "+ FIXED %d %d %s ",
146 co->placementX(),
147 co->placementY(),
148 //orientStr(co->placementOrient()));
149 co->placementOrientStr());
150 if (co->isCover())
151 fprintf(fout, "+ COVER %d %d %s ",
152 co->placementX(),
153 co->placementY(),
154 orientStr(co->placementOrient()));
155 if (co->isPlaced())
156 fprintf(fout,"+ PLACED %d %d %s ",
157 co->placementX(),
158 co->placementY(),
159 orientStr(co->placementOrient()));
160 if (co->isUnplaced()) {
161 fprintf(fout,"+ UNPLACED ");
162 if ((co->placementX() != -1) ||
163 (co->placementY() != -1))
164 fprintf(fout,"%d %d %s ",
165 co->placementX(),
166 co->placementY(),
167 orientStr(co->placementOrient()));
168 }
169 if (co->hasSource())
170 fprintf(fout, "+ SOURCE %s ", co->source());
171 if (co->hasGenerate()) {
172 fprintf(fout, "+ GENERATE %s ", co->generateName());
173 if (co->macroName() &&
174 *(co->macroName()))
175 fprintf(fout, "%s ", co->macroName());
176 }
177 if (co->hasWeight())
178 fprintf(fout, "+ WEIGHT %d ", co->weight());
179 if (co->hasEEQ())
180 fprintf(fout, "+ EEQMASTER %s ", co->EEQ());
181 if (co->hasRegionName())
182 fprintf(fout, "+ REGION %s ", co->regionName());
183 if (co->hasRegionBounds()) {
184 int *xl, *yl, *xh, *yh;
185 int size;
186 co->regionBounds(&size, &xl, &yl, &xh, &yh);
187 for (i = 0; i < size; i++) {
188 fprintf(fout, "+ REGION %d %d %d %d \n",
189 xl[i], yl[i], xh[i], yh[i]);
190 }
191 }
192 if (co->maskShiftSize()) {
193 fprintf(fout, "+ MASKSHIFT ");
194
195 for (int i = co->maskShiftSize()-1; i >= 0; i--) {
196 fprintf(fout, "%d", co->maskShift(i));
197 }
198 fprintf(fout, "\n");
199 }
200 if (co->hasHalo()) {
201 int left, bottom, right, top;
202 (void) co->haloEdges(&left, &bottom, &right, &top);
203 fprintf(fout, "+ HALO ");
204 if (co->hasHaloSoft())
205 fprintf(fout, "SOFT ");
206 fprintf(fout, "%d %d %d %d\n", left, bottom, right, top);
207 }
208 if (co->hasRouteHalo()) {
209 fprintf(fout, "+ ROUTEHALO %d %s %s\n", co->haloDist(),
210 co->minLayer(), co->maxLayer());
211 }
212 if (co->hasForeignName()) {
213 fprintf(fout, "+ FOREIGN %s %d %d %s %d ",
214 co->foreignName(), co->foreignX(),
215 co->foreignY(), co->foreignOri(),
216 co->foreignOrient());
217 }
218 if (co->numProps()) {
219 for (i = 0; i < co->numProps(); i++) {
220 fprintf(fout, "+ PROPERTY %s %s ", co->propName(i),
221 co->propValue(i));
222 switch (co->propType(i)) {
223 case 'R': fprintf(fout, "REAL ");
224 break;
225 case 'I': fprintf(fout, "INTEGER ");
226 break;
227 case 'S': fprintf(fout, "STRING ");
228 break;
229 case 'Q': fprintf(fout, "QUOTESTRING ");
230 break;
231 case 'N': fprintf(fout, "NUMBER ");
232 break;
233 }
234 }
235 }
236 fprintf(fout, ";\n");
237 --numObjs;
238 if (numObjs <= 0)
239 fprintf(fout, "END COMPONENTS\n");
240 }
241
242 return 0;
243 }
244
245
netpath(defrCallbackType_e,defiNet *,defiUserData)246 int netpath(defrCallbackType_e, defiNet*, defiUserData) {
247 fprintf(fout, "\n");
248
249 fprintf (fout, "Callback of partial path for net\n");
250
251 return 0;
252 }
253
254
netNamef(defrCallbackType_e c,const char * netName,defiUserData ud)255 int netNamef(defrCallbackType_e c, const char* netName, defiUserData ud) {
256 checkType(c);
257 if (ud != userData) dataError();
258 fprintf(fout, "- %s ", netName);
259 return 0;
260 }
261
subnetNamef(defrCallbackType_e c,const char * subnetName,defiUserData ud)262 int subnetNamef(defrCallbackType_e c, const char* subnetName, defiUserData ud) {
263 checkType(c);
264 if (ud != userData) dataError();
265 if (curVer >= 5.6)
266 fprintf(fout, " + SUBNET CBK %s ", subnetName);
267 return 0;
268 }
269
nondefRulef(defrCallbackType_e c,const char * ruleName,defiUserData ud)270 int nondefRulef(defrCallbackType_e c, const char* ruleName, defiUserData ud) {
271 checkType(c);
272 if (ud != userData) dataError();
273 if (curVer >= 5.6)
274 fprintf(fout, " + NONDEFAULTRULE CBK %s ", ruleName);
275 return 0;
276 }
277
netf(defrCallbackType_e c,defiNet * net,defiUserData ud)278 int netf(defrCallbackType_e c, defiNet* net, defiUserData ud) {
279 // For net and special net.
280 int i, j, k, w, x, y, z, count, newLayer;
281 defiPath* p;
282 defiSubnet *s;
283 int path;
284 defiVpin *vpin;
285 // defiShield *noShield;
286 defiWire *wire;
287
288 checkType(c);
289 if (ud != userData) dataError();
290 if (c != defrNetCbkType)
291 fprintf(fout, "BOGUS NET TYPE ");
292 if (net->pinIsMustJoin(0))
293 fprintf(fout, "- MUSTJOIN ");
294 // 5/6/2004 - don't need since I have a callback for the name
295 // else
296 // fprintf(fout, "- %s ", net->name());
297
298 // net->changeNetName("newNetName");
299 // fprintf(fout, "%s ", net->name());
300 count = 0;
301 // compName & pinName
302 for (i = 0; i < net->numConnections(); i++) {
303 // set the limit of only 5 items per line
304 count++;
305 if (count >= 5) {
306 fprintf(fout, "\n");
307 count = 0;
308 }
309 fprintf(fout, "( %s %s ) ", net->instance(i),
310 net->pin(i));
311 // net->changeInstance("newInstance", i);
312 // net->changePin("newPin", i);
313 // fprintf(fout, "( %s %s ) ", net->instance(i),
314 // net->pin(i));
315 if (net->pinIsSynthesized(i))
316 fprintf(fout, "+ SYNTHESIZED ");
317 }
318
319 if (net->hasNonDefaultRule())
320 fprintf(fout, "+ NONDEFAULTRULE %s\n", net->nonDefaultRule());
321
322 for (i = 0; i < net->numVpins(); i++) {
323 vpin = net->vpin(i);
324 fprintf(fout, " + %s", vpin->name());
325 if (vpin->layer())
326 fprintf(fout, " %s", vpin->layer());
327 fprintf(fout, " %d %d %d %d", vpin->xl(), vpin->yl(), vpin->xh(),
328 vpin->yh());
329 if (vpin->status() != ' ') {
330 fprintf(fout, " %c", vpin->status());
331 fprintf(fout, " %d %d", vpin->xLoc(), vpin->yLoc());
332 if (vpin->orient() != -1)
333 fprintf(fout, " %s", orientStr(vpin->orient()));
334 }
335 fprintf(fout, "\n");
336 }
337
338 // regularWiring
339 if (net->numWires()) {
340 for (i = 0; i < net->numWires(); i++) {
341 newLayer = 0;
342 wire = net->wire(i);
343 fprintf(fout, "\n + %s ", wire->wireType());
344 count = 0;
345 for (j = 0; j < wire->numPaths(); j++) {
346 p = wire->path(j);
347 p->initTraverse();
348 while ((path = (int)p->next()) != DEFIPATH_DONE) {
349 count++;
350 // Don't want the line to be too long
351 if (count >= 5) {
352 fprintf(fout, "\n");
353 count = 0;
354 }
355 switch (path) {
356 case DEFIPATH_LAYER:
357 if (newLayer == 0) {
358 fprintf(fout, "%s ", p->getLayer());
359 newLayer = 1;
360 } else
361 fprintf(fout, "NEW %s ", p->getLayer());
362 break;
363 case DEFIPATH_MASK:
364 fprintf(fout, "MASK %d ", p->getMask());
365 break;
366 case DEFIPATH_VIAMASK:
367 fprintf(fout, "MASK %d%d%d ",
368 p->getViaTopMask(),
369 p->getViaCutMask(),
370 p->getViaBottomMask());
371 break;
372 case DEFIPATH_VIA:
373 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
374 break;
375 case DEFIPATH_VIAROTATION:
376 fprintf(fout, "%s ",
377 orientStr(p->getViaRotation()));
378 break;
379 case DEFIPATH_RECT:
380 p->getViaRect(&w, &x, &y, &z);
381 fprintf(fout, "RECT ( %d %d %d %d ) ", w, x, y, z);
382 break;
383 case DEFIPATH_VIRTUALPOINT:
384 p->getVirtualPoint(&x, &y);
385 fprintf(fout, "VIRTUAL ( %d %d ) ", x, y);
386 break;
387 case DEFIPATH_WIDTH:
388 fprintf(fout, "%d ", p->getWidth());
389 break;
390 case DEFIPATH_POINT:
391 p->getPoint(&x, &y);
392 fprintf(fout, "( %d %d ) ", x, y);
393 break;
394 case DEFIPATH_FLUSHPOINT:
395 p->getFlushPoint(&x, &y, &z);
396 fprintf(fout, "( %d %d %d ) ", x, y, z);
397 break;
398 case DEFIPATH_TAPER:
399 fprintf(fout, "TAPER ");
400 break;
401 case DEFIPATH_TAPERRULE:
402 fprintf(fout, "TAPERRULE %s ",p->getTaperRule());
403 break;
404 case DEFIPATH_STYLE:
405 fprintf(fout, "STYLE %d ",p->getStyle());
406 break;
407 }
408 }
409 }
410 fprintf(fout, "\n");
411 count = 0;
412 }
413 }
414
415 // SHIELDNET
416 if (net->numShieldNets()) {
417 for (i = 0; i < net->numShieldNets(); i++)
418 fprintf(fout, "\n + SHIELDNET %s", net->shieldNet(i));
419 }
420 /* obsolete in 5.4
421 if (net->numNoShields()) {
422 for (i = 0; i < net->numNoShields(); i++) {
423 noShield = net->noShield(i);
424 fprintf(fout, "\n + NOSHIELD ");
425 newLayer = 0;
426 for (j = 0; j < noShield->numPaths(); j++) {
427 p = noShield->path(j);
428 p->initTraverse();
429 while ((path = (int)p->next()) != DEFIPATH_DONE) {
430 count++;
431 // Don't want the line to be too long
432 if (count >= 5) {
433 fprintf(fout, "\n");
434 count = 0;
435 }
436 switch (path) {
437 case DEFIPATH_LAYER:
438 if (newLayer == 0) {
439 fprintf(fout, "%s ", p->getLayer());
440 newLayer = 1;
441 } else
442 fprintf(fout, "NEW %s ", p->getLayer());
443 break;
444 case DEFIPATH_VIA:
445 fprintf(fout, "%s ", p->getVia());
446 break;
447 case DEFIPATH_VIAROTATION:
448 fprintf(fout, "%s ",
449 orientStr(p->getViaRotation()));
450 break;
451 case DEFIPATH_WIDTH:
452 fprintf(fout, "%d ", p->getWidth());
453 break;
454 case DEFIPATH_POINT:
455 p->getPoint(&x, &y);
456 fprintf(fout, "( %d %d ) ", x, y);
457 break;
458 case DEFIPATH_FLUSHPOINT:
459 p->getFlushPoint(&x, &y, &z);
460 fprintf(fout, "( %d %d %d ) ", x, y, z);
461 break;
462 case DEFIPATH_TAPER:
463 fprintf(fout, "TAPER ");
464 break;
465 case DEFIPATH_TAPERRULE:
466 fprintf(fout, "TAPERRULE %s ",
467 p->getTaperRule());
468 break;
469 }
470 }
471 }
472 }
473 }
474 */
475
476 if (net->hasSubnets()) {
477 for (i = 0; i < net->numSubnets(); i++) {
478 s = net->subnet(i);
479 fprintf(fout, "\n");
480
481 if (s->numConnections()) {
482 if (s->pinIsMustJoin(0))
483 fprintf(fout, "- MUSTJOIN ");
484 else
485 fprintf(fout, " + SUBNET %s ", s->name());
486 for (j = 0; j < s->numConnections(); j++)
487 fprintf(fout, " ( %s %s )\n", s->instance(j),
488 s->pin(j));
489
490 // regularWiring
491 if (s->numWires()) {
492 for (k = 0; k < s->numWires(); k++) {
493 newLayer = 0;
494 wire = s->wire(k);
495 fprintf(fout, " %s ", wire->wireType());
496 count = 0;
497 for (j = 0; j < wire->numPaths(); j++) {
498 p = wire->path(j);
499 p->initTraverse();
500 while ((path = (int)p->next()) != DEFIPATH_DONE) {
501 count++;
502 // Don't want the line to be too long
503 if (count >= 5) {
504 fprintf(fout, "\n");
505 count = 0;
506 }
507 switch (path) {
508 case DEFIPATH_LAYER:
509 if (newLayer == 0) {
510 fprintf(fout, "%s ", p->getLayer());
511 newLayer = 1;
512 } else
513 fprintf(fout, "NEW %s ",
514 p->getLayer());
515 break;
516 case DEFIPATH_VIA:
517 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
518 break;
519 case DEFIPATH_VIAROTATION:
520 fprintf(fout, "%s ",
521 p->getViaRotationStr());
522 break;
523 case DEFIPATH_WIDTH:
524 fprintf(fout, "%d ", p->getWidth());
525 break;
526 case DEFIPATH_POINT:
527 p->getPoint(&x, &y);
528 fprintf(fout, "( %d %d ) ", x, y);
529 break;
530 case DEFIPATH_FLUSHPOINT:
531 p->getFlushPoint(&x, &y, &z);
532 fprintf(fout, "( %d %d %d ) ", x, y, z);
533 break;
534 case DEFIPATH_TAPER:
535 fprintf(fout, "TAPER ");
536 break;
537 case DEFIPATH_TAPERRULE:
538 fprintf(fout, "TAPERRULE %s ",
539 p->getTaperRule());
540 break;
541 case DEFIPATH_STYLE:
542 fprintf(fout, "STYLE %d ",
543 p->getStyle());
544 break;
545 }
546 }
547 }
548 }
549 }
550 }
551 }
552 }
553
554 if (net->numProps()) {
555 for (i = 0; i < net->numProps(); i++) {
556 fprintf(fout, " + PROPERTY %s ", net->propName(i));
557 switch (net->propType(i)) {
558 case 'R': fprintf(fout, "%g REAL ", net->propNumber(i));
559 break;
560 case 'I': fprintf(fout, "%g INTEGER ", net->propNumber(i));
561 break;
562 case 'S': fprintf(fout, "%s STRING ", net->propValue(i));
563 break;
564 case 'Q': fprintf(fout, "%s QUOTESTRING ", net->propValue(i));
565 break;
566 case 'N': fprintf(fout, "%g NUMBER ", net->propNumber(i));
567 break;
568 }
569 fprintf(fout, "\n");
570 }
571 }
572
573 if (net->hasWeight())
574 fprintf(fout, "+ WEIGHT %d ", net->weight());
575 if (net->hasCap())
576 fprintf(fout, "+ ESTCAP %g ", net->cap());
577 if (net->hasSource())
578 fprintf(fout, "+ SOURCE %s ", net->source());
579 if (net->hasFixedbump())
580 fprintf(fout, "+ FIXEDBUMP ");
581 if (net->hasFrequency())
582 fprintf(fout, "+ FREQUENCY %g ", net->frequency());
583 if (net->hasPattern())
584 fprintf(fout, "+ PATTERN %s ", net->pattern());
585 if (net->hasOriginal())
586 fprintf(fout, "+ ORIGINAL %s ", net->original());
587 if (net->hasUse())
588 fprintf(fout, "+ USE %s ", net->use());
589
590 fprintf (fout, ";\n");
591 --numObjs;
592 if (numObjs <= 0)
593 fprintf(fout, "END NETS\n");
594 return 0;
595 }
596
597
snetpath(defrCallbackType_e c,defiNet * ppath,defiUserData ud)598 int snetpath(defrCallbackType_e c, defiNet* ppath, defiUserData ud) {
599 int i, j, x, y, z, count, newLayer;
600 char* layerName;
601 double dist, left, right;
602 defiPath* p;
603 defiSubnet *s;
604 int path;
605 defiShield* shield;
606 defiWire* wire;
607 int numX, numY, stepX, stepY;
608
609 if (c != defrSNetPartialPathCbkType)
610 return 1;
611 if (ud != userData) dataError();
612
613 fprintf (fout, "SPECIALNET partial data\n");
614
615 fprintf(fout, "- %s ", ppath->name());
616
617 count = 0;
618 // compName & pinName
619 for (i = 0; i < ppath->numConnections(); i++) {
620 // set the limit of only 5 items print out in one line
621 count++;
622 if (count >= 5) {
623 fprintf(fout, "\n");
624 count = 0;
625 }
626 fprintf (fout, "( %s %s ) ", ppath->instance(i),
627 ppath->pin(i));
628 if (ppath->pinIsSynthesized(i))
629 fprintf(fout, "+ SYNTHESIZED ");
630 }
631
632 // specialWiring
633 // POLYGON
634 if (ppath->numPolygons()) {
635 defiPoints points;
636 for (i = 0; i < ppath->numPolygons(); i++) {
637 fprintf(fout, "\n + POLYGON %s ", ppath->polygonName(i));
638 points = ppath->getPolygon(i);
639 for (j = 0; j < points.numPoints; j++)
640 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
641 }
642 }
643 // RECT
644 if (ppath->numRectangles()) {
645 for (i = 0; i < ppath->numRectangles(); i++) {
646 fprintf(fout, "\n + RECT %s %d %d %d %d", ppath->rectName(i),
647 ppath->xl(i), ppath->yl(i),
648 ppath->xh(i), ppath->yh(i));
649 }
650 }
651
652 // COVER, FIXED, ROUTED or SHIELD
653 if (ppath->numWires()) {
654 newLayer = 0;
655 for (i = 0; i < ppath->numWires(); i++) {
656 newLayer = 0;
657 wire = ppath->wire(i);
658 fprintf(fout, "\n + %s ", wire->wireType());
659 if (strcmp (wire->wireType(), "SHIELD") == 0)
660 fprintf(fout, "%s ", wire->wireShieldNetName());
661 for (j = 0; j < wire->numPaths(); j++) {
662 p = wire->path(j);
663 p->initTraverse();
664 while ((path = (int)p->next()) != DEFIPATH_DONE) {
665 count++;
666 // Don't want the line to be too long
667 if (count >= 5) {
668 fprintf(fout, "\n");
669 count = 0;
670 }
671 switch (path) {
672 case DEFIPATH_LAYER:
673 if (newLayer == 0) {
674 fprintf(fout, "%s ", p->getLayer());
675 newLayer = 1;
676 } else
677 fprintf(fout, "NEW %s ", p->getLayer());
678 break;
679 case DEFIPATH_VIA:
680 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
681 break;
682 case DEFIPATH_VIAROTATION:
683 fprintf(fout, "%s ",
684 orientStr(p->getViaRotation()));
685 break;
686 case DEFIPATH_VIADATA:
687 p->getViaData(&numX, &numY, &stepX, &stepY);
688 fprintf(fout, "DO %d BY %d STEP %d %d ", numX, numY,
689 stepX, stepY);
690 break;
691 case DEFIPATH_WIDTH:
692 fprintf(fout, "%d ", p->getWidth());
693 break;
694 case DEFIPATH_MASK:
695 fprintf(fout, "MASK %d ", p->getMask());
696 break;
697 case DEFIPATH_VIAMASK:
698 fprintf(fout, "MASK %d%d%d ",
699 p->getViaTopMask(),
700 p->getViaCutMask(),
701 p->getViaBottomMask());
702 break;
703 case DEFIPATH_POINT:
704 p->getPoint(&x, &y);
705 fprintf(fout, "( %d %d ) ", x, y);
706 break;
707 case DEFIPATH_FLUSHPOINT:
708 p->getFlushPoint(&x, &y, &z);
709 fprintf(fout, "( %d %d %d ) ", x, y, z);
710 break;
711 case DEFIPATH_TAPER:
712 fprintf(fout, "TAPER ");
713 break;
714 case DEFIPATH_SHAPE:
715 fprintf(fout, "+ SHAPE %s ", p->getShape());
716 break;
717 case DEFIPATH_STYLE:
718 fprintf(fout, "+ STYLE %d ", p->getStyle());
719 break;
720 }
721 }
722 }
723 fprintf(fout, "\n");
724 count = 0;
725 }
726 }
727
728 if (ppath->hasSubnets()) {
729 for (i = 0; i < ppath->numSubnets(); i++) {
730 s = ppath->subnet(i);
731 if (s->numConnections()) {
732 if (s->pinIsMustJoin(0))
733 fprintf(fout, "- MUSTJOIN ");
734 else
735 fprintf(fout, "- %s ", s->name());
736 for (j = 0; j < s->numConnections(); j++) {
737 fprintf(fout, " ( %s %s )\n", s->instance(j),
738 s->pin(j));
739 }
740 }
741
742 // regularWiring
743 if (s->numWires()) {
744 for (i = 0; i < s->numWires(); i++) {
745 wire = s->wire(i);
746 fprintf(fout, " + %s ", wire->wireType());
747 for (j = 0; j < wire->numPaths(); j++) {
748 p = wire->path(j);
749 p->print(fout);
750 }
751 }
752 }
753 }
754 }
755
756 if (ppath->numProps()) {
757 for (i = 0; i < ppath->numProps(); i++) {
758 if (ppath->propIsString(i))
759 fprintf(fout, " + PROPERTY %s %s ", ppath->propName(i),
760 ppath->propValue(i));
761 if (ppath->propIsNumber(i))
762 fprintf(fout, " + PROPERTY %s %g ", ppath->propName(i),
763 ppath->propNumber(i));
764 switch (ppath->propType(i)) {
765 case 'R': fprintf(fout, "REAL ");
766 break;
767 case 'I': fprintf(fout, "INTEGER ");
768 break;
769 case 'S': fprintf(fout, "STRING ");
770 break;
771 case 'Q': fprintf(fout, "QUOTESTRING ");
772 break;
773 case 'N': fprintf(fout, "NUMBER ");
774 break;
775 }
776 fprintf(fout, "\n");
777 }
778 }
779
780 // SHIELD
781 count = 0;
782 // testing the SHIELD for 5.3, obsolete in 5.4
783 if (ppath->numShields()) {
784 for (i = 0; i < ppath->numShields(); i++) {
785 shield = ppath->shield(i);
786 fprintf(fout, "\n + SHIELD %s ", shield->shieldName());
787 newLayer = 0;
788 for (j = 0; j < shield->numPaths(); j++) {
789 p = shield->path(j);
790 p->initTraverse();
791 while ((path = (int)p->next()) != DEFIPATH_DONE) {
792 count++;
793 // Don't want the line to be too long
794 if (count >= 5) {
795 fprintf(fout, "\n");
796 count = 0;
797 }
798 switch (path) {
799 case DEFIPATH_LAYER:
800 if (newLayer == 0) {
801 fprintf(fout, "%s ", p->getLayer());
802 newLayer = 1;
803 } else
804 fprintf(fout, "NEW %s ", p->getLayer());
805 break;
806 case DEFIPATH_VIA:
807 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
808 break;
809 case DEFIPATH_VIAROTATION:
810 if (newLayer)
811 fprintf(fout, "%s ",
812 orientStr(p->getViaRotation()));
813 else
814 fprintf(fout, "Str %s ",
815 p->getViaRotationStr());
816 break;
817 case DEFIPATH_WIDTH:
818 fprintf(fout, "%d ", p->getWidth());
819 break;
820 case DEFIPATH_MASK:
821 fprintf(fout, "MASK %d ", p->getMask());
822 break;
823 case DEFIPATH_VIAMASK:
824 fprintf(fout, "MASK %d%d%d ",
825 p->getViaTopMask(),
826 p->getViaCutMask(),
827 p->getViaBottomMask());
828 break;
829 case DEFIPATH_POINT:
830 p->getPoint(&x, &y);
831 fprintf(fout, "( %d %d ) ", x, y);
832 break;
833 case DEFIPATH_FLUSHPOINT:
834 p->getFlushPoint(&x, &y, &z);
835 fprintf(fout, "( %d %d %d ) ", x, y, z);
836 break;
837 case DEFIPATH_TAPER:
838 fprintf(fout, "TAPER ");
839 break;
840 case DEFIPATH_SHAPE:
841 fprintf(fout, "+ SHAPE %s ", p->getShape());
842 break;
843 case DEFIPATH_STYLE:
844 fprintf(fout, "+ STYLE %d ", p->getStyle());
845 }
846 }
847 }
848 }
849 }
850
851 // layerName width
852 if (ppath->hasWidthRules()) {
853 for (i = 0; i < ppath->numWidthRules(); i++) {
854 ppath->widthRule(i, &layerName, &dist);
855 fprintf (fout, "\n + WIDTH %s %g ", layerName, dist);
856 }
857 }
858
859 // layerName spacing
860 if (ppath->hasSpacingRules()) {
861 for (i = 0; i < ppath->numSpacingRules(); i++) {
862 ppath->spacingRule(i, &layerName, &dist, &left, &right);
863 if (left == right)
864 fprintf (fout, "\n + SPACING %s %g ", layerName, dist);
865 else
866 fprintf (fout, "\n + SPACING %s %g RANGE %g %g ",
867 layerName, dist, left, right);
868 }
869 }
870
871 if (ppath->hasFixedbump())
872 fprintf(fout, "\n + FIXEDBUMP ");
873 if (ppath->hasFrequency())
874 fprintf(fout, "\n + FREQUENCY %g ", ppath->frequency());
875 if (ppath->hasVoltage())
876 fprintf(fout, "\n + VOLTAGE %g ", ppath->voltage());
877 if (ppath->hasWeight())
878 fprintf(fout, "\n + WEIGHT %d ", ppath->weight());
879 if (ppath->hasCap())
880 fprintf(fout, "\n + ESTCAP %g ", ppath->cap());
881 if (ppath->hasSource())
882 fprintf(fout, "\n + SOURCE %s ", ppath->source());
883 if (ppath->hasPattern())
884 fprintf(fout, "\n + PATTERN %s ", ppath->pattern());
885 if (ppath->hasOriginal())
886 fprintf(fout, "\n + ORIGINAL %s ", ppath->original());
887 if (ppath->hasUse())
888 fprintf(fout, "\n + USE %s ", ppath->use());
889
890 fprintf(fout, "\n");
891
892 return 0;
893 }
894
895
snetwire(defrCallbackType_e c,defiNet * ppath,defiUserData ud)896 int snetwire(defrCallbackType_e c, defiNet* ppath, defiUserData ud) {
897 int i, j, x, y, z, count = 0, newLayer;
898 defiPath* p;
899 int path;
900 defiWire* wire;
901 defiShield* shield;
902 int numX, numY, stepX, stepY;
903
904 if (c != defrSNetWireCbkType)
905 return 1;
906 if (ud != userData) dataError();
907
908 fprintf (fout, "SPECIALNET wire data\n");
909
910 fprintf(fout, "- %s ", ppath->name());
911
912 // POLYGON
913 if (ppath->numPolygons()) {
914 defiPoints points;
915 for (i = 0; i < ppath->numPolygons(); i++) {
916 fprintf(fout, "\n + POLYGON %s ", ppath->polygonName(i));
917
918 points = ppath->getPolygon(i);
919
920 for (j = 0; j < points.numPoints; j++) {
921 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
922 }
923 }
924 // RECT
925 }
926 if (ppath->numRectangles()) {
927 for (i = 0; i < ppath->numRectangles(); i++) {
928 fprintf(fout, "\n + RECT %s %d %d %d %d", ppath->rectName(i),
929 ppath->xl(i), ppath->yl(i),
930 ppath->xh(i), ppath->yh(i));
931 }
932 }
933 // VIA
934 if (ppath->numViaSpecs()) {
935 for (i = 0; i < ppath->numViaSpecs(); i++) {
936 fprintf(fout, "\n + VIA %s ", ppath->viaName(i)),
937 fprintf(fout, " %s", ppath->viaOrientStr(i));
938
939 defiPoints points = ppath->getViaPts(i);
940
941 for (int j = 0; j < points.numPoints; j++) {
942 fprintf(fout, " %d %d", points.x[j], points.y[j]);
943 }
944 }
945 }
946
947 // specialWiring
948 if (ppath->numWires()) {
949 newLayer = 0;
950 for (i = 0; i < ppath->numWires(); i++) {
951 newLayer = 0;
952 wire = ppath->wire(i);
953 fprintf(fout, "\n + %s ", wire->wireType());
954 if (strcmp (wire->wireType(), "SHIELD") == 0)
955 fprintf(fout, "%s ", wire->wireShieldNetName());
956 for (j = 0; j < wire->numPaths(); j++) {
957 p = wire->path(j);
958 p->initTraverse();
959 while ((path = (int)p->next()) != DEFIPATH_DONE) {
960 count++;
961 // Don't want the line to be too long
962 if (count >= 5) {
963 fprintf(fout, "\n");
964 count = 0;
965 }
966 switch (path) {
967 case DEFIPATH_LAYER:
968 if (newLayer == 0) {
969 fprintf(fout, "%s ", p->getLayer());
970 newLayer = 1;
971 } else
972 fprintf(fout, "NEW %s ", p->getLayer());
973 break;
974 case DEFIPATH_VIA:
975 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
976 break;
977 case DEFIPATH_VIAROTATION:
978 fprintf(fout, "%s ",
979 orientStr(p->getViaRotation()));
980 break;
981 case DEFIPATH_VIADATA:
982 p->getViaData(&numX, &numY, &stepX, &stepY);
983 fprintf(fout, "DO %d BY %d STEP %d %d ", numX, numY,
984 stepX, stepY);
985 break;
986 case DEFIPATH_WIDTH:
987 fprintf(fout, "%d ", p->getWidth());
988 break;
989 case DEFIPATH_MASK:
990 fprintf(fout, "MASK %d ", p->getMask());
991 break;
992 case DEFIPATH_VIAMASK:
993 fprintf(fout, "MASK %d%d%d ",
994 p->getViaTopMask(),
995 p->getViaCutMask(),
996 p->getViaBottomMask());
997 break;
998 case DEFIPATH_POINT:
999 p->getPoint(&x, &y);
1000 fprintf(fout, "( %d %d ) ", x, y);
1001 break;
1002 case DEFIPATH_FLUSHPOINT:
1003 p->getFlushPoint(&x, &y, &z);
1004 fprintf(fout, "( %d %d %d ) ", x, y, z);
1005 break;
1006 case DEFIPATH_TAPER:
1007 fprintf(fout, "TAPER ");
1008 break;
1009 case DEFIPATH_SHAPE:
1010 fprintf(fout, "+ SHAPE %s ", p->getShape());
1011 break;
1012 case DEFIPATH_STYLE:
1013 fprintf(fout, "+ STYLE %d ", p->getStyle());
1014 break;
1015 }
1016 }
1017 }
1018 fprintf(fout, "\n");
1019 count = 0;
1020 }
1021 } else if (ppath->numShields()) {
1022 for (i = 0; i < ppath->numShields(); i++) {
1023 shield = ppath->shield(i);
1024 fprintf(fout, "\n + SHIELD %s ", shield->shieldName());
1025 newLayer = 0;
1026 for (j = 0; j < shield->numPaths(); j++) {
1027 p = shield->path(j);
1028 p->initTraverse();
1029 while ((path = (int)p->next()) != DEFIPATH_DONE) {
1030 count++;
1031 // Don't want the line to be too long
1032 if (count >= 5) {
1033 fprintf(fout, "\n");
1034 count = 0;
1035 }
1036 switch (path) {
1037 case DEFIPATH_LAYER:
1038 if (newLayer == 0) {
1039 fprintf(fout, "%s ", p->getLayer());
1040 newLayer = 1;
1041 } else
1042 fprintf(fout, "NEW %s ", p->getLayer());
1043 break;
1044 case DEFIPATH_VIA:
1045 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
1046 break;
1047 case DEFIPATH_VIAROTATION:
1048 fprintf(fout, "%s ",
1049 orientStr(p->getViaRotation()));
1050 break;
1051 case DEFIPATH_WIDTH:
1052 fprintf(fout, "%d ", p->getWidth());
1053 break;
1054 case DEFIPATH_MASK:
1055 fprintf(fout, "MASK %d ", p->getMask());
1056 break;
1057 case DEFIPATH_VIAMASK:
1058 fprintf(fout, "MASK %d%d%d ",
1059 p->getViaTopMask(),
1060 p->getViaCutMask(),
1061 p->getViaBottomMask());
1062 break;
1063 case DEFIPATH_POINT:
1064 p->getPoint(&x, &y);
1065 fprintf(fout, "( %d %d ) ", x, y);
1066 break;
1067 case DEFIPATH_FLUSHPOINT:
1068 p->getFlushPoint(&x, &y, &z);
1069 fprintf(fout, "( %d %d %d ) ", x, y, z);
1070 break;
1071 case DEFIPATH_TAPER:
1072 fprintf(fout, "TAPER ");
1073 break;
1074 case DEFIPATH_SHAPE:
1075 fprintf(fout, "+ SHAPE %s ", p->getShape());
1076 break;
1077 case DEFIPATH_STYLE:
1078 fprintf(fout, "+ STYLE %d ", p->getStyle());
1079 break;
1080 }
1081 }
1082 }
1083 }
1084 }
1085
1086 fprintf(fout, "\n");
1087
1088 return 0;
1089 }
1090
snetf(defrCallbackType_e c,defiNet * net,defiUserData ud)1091 int snetf(defrCallbackType_e c, defiNet* net, defiUserData ud) {
1092 // For net and special net.
1093 int i, j, x, y, z, count, newLayer;
1094 char* layerName;
1095 double dist, left, right;
1096 defiPath* p;
1097 defiSubnet *s;
1098 int path;
1099 defiShield* shield;
1100 defiWire* wire;
1101 int numX, numY, stepX, stepY;
1102
1103 checkType(c);
1104 if (ud != userData) dataError();
1105 if (c != defrSNetCbkType)
1106 fprintf(fout, "BOGUS NET TYPE ");
1107
1108 // 5/6/2004 - don't need since I have a callback for the name
1109 // fprintf(fout, "- %s ", net->name());
1110
1111 count = 0;
1112 // compName & pinName
1113 for (i = 0; i < net->numConnections(); i++) {
1114 // set the limit of only 5 items print out in one line
1115 count++;
1116 if (count >= 5) {
1117 fprintf(fout, "\n");
1118 count = 0;
1119 }
1120 fprintf (fout, "( %s %s ) ", net->instance(i),
1121 net->pin(i));
1122 if (net->pinIsSynthesized(i))
1123 fprintf(fout, "+ SYNTHESIZED ");
1124 }
1125
1126 // specialWiring
1127 if (net->numWires()) {
1128 newLayer = 0;
1129 for (i = 0; i < net->numWires(); i++) {
1130 newLayer = 0;
1131 wire = net->wire(i);
1132 fprintf(fout, "\n + %s ", wire->wireType());
1133 if (strcmp (wire->wireType(), "SHIELD") == 0)
1134 fprintf(fout, "%s ", wire->wireShieldNetName());
1135 for (j = 0; j < wire->numPaths(); j++) {
1136 p = wire->path(j);
1137 p->initTraverse();
1138 if (testDebugPrint) {
1139 p->print(fout);
1140 } else {
1141 while ((path = (int)p->next()) != DEFIPATH_DONE) {
1142 count++;
1143 // Don't want the line to be too long
1144 if (count >= 5) {
1145 fprintf(fout, "\n");
1146 count = 0;
1147 }
1148 switch (path) {
1149 case DEFIPATH_LAYER:
1150 if (newLayer == 0) {
1151 fprintf(fout, "%s ", p->getLayer());
1152 newLayer = 1;
1153 } else
1154 fprintf(fout, "NEW %s ", p->getLayer());
1155 break;
1156 case DEFIPATH_VIA:
1157 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
1158 break;
1159 case DEFIPATH_VIAROTATION:
1160 fprintf(fout, "%s ",
1161 orientStr(p->getViaRotation()));
1162 break;
1163 case DEFIPATH_VIADATA:
1164 p->getViaData(&numX, &numY, &stepX, &stepY);
1165 fprintf(fout, "DO %d BY %d STEP %d %d ", numX, numY,
1166 stepX, stepY);
1167 break;
1168 case DEFIPATH_WIDTH:
1169 fprintf(fout, "%d ", p->getWidth());
1170 break;
1171 case DEFIPATH_MASK:
1172 fprintf(fout, "MASK %d ", p->getMask());
1173 break;
1174 case DEFIPATH_VIAMASK:
1175 fprintf(fout, "MASK %d%d%d ",
1176 p->getViaTopMask(),
1177 p->getViaCutMask(),
1178 p->getViaBottomMask());
1179 break;
1180 case DEFIPATH_POINT:
1181 p->getPoint(&x, &y);
1182 fprintf(fout, "( %d %d ) ", x, y);
1183 break;
1184 case DEFIPATH_FLUSHPOINT:
1185 p->getFlushPoint(&x, &y, &z);
1186 fprintf(fout, "( %d %d %d ) ", x, y, z);
1187 break;
1188 case DEFIPATH_TAPER:
1189 fprintf(fout, "TAPER ");
1190 break;
1191 case DEFIPATH_SHAPE:
1192 fprintf(fout, "+ SHAPE %s ", p->getShape());
1193 break;
1194 case DEFIPATH_STYLE:
1195 fprintf(fout, "+ STYLE %d ", p->getStyle());
1196 break;
1197 }
1198 }
1199 }
1200 }
1201 fprintf(fout, "\n");
1202 count = 0;
1203 }
1204 }
1205
1206 // POLYGON
1207 if (net->numPolygons()) {
1208 defiPoints points;
1209
1210 for (i = 0; i < net->numPolygons(); i++) {
1211 if (curVer >= 5.8 ) {
1212 if (strcmp(net->polyRouteStatus(i), "") != 0) {
1213 fprintf(fout, "\n + %s ", net->polyRouteStatus(i));
1214 if (strcmp(net->polyRouteStatus(i), "SHIELD") == 0) {
1215 fprintf(fout, "\n + %s ", net->polyRouteStatusShieldName(i));
1216 }
1217 }
1218 if (strcmp(net->polyShapeType(i), "") != 0) {
1219 fprintf(fout, "\n + SHAPE %s ", net->polyShapeType(i));
1220 }
1221 }
1222 if (net->polyMask(i)) {
1223 fprintf(fout, "\n + MASK %d + POLYGON % s ", net->polyMask(i),
1224 net->polygonName(i));
1225 } else {
1226 fprintf(fout, "\n + POLYGON %s ", net->polygonName(i));
1227 }
1228 points = net->getPolygon(i);
1229 for (j = 0; j < points.numPoints; j++)
1230 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
1231 }
1232 }
1233 // RECT
1234 if (net->numRectangles()) {
1235
1236 for (i = 0; i < net->numRectangles(); i++) {
1237 if (curVer >= 5.8 ) {
1238 if (strcmp(net->rectRouteStatus(i), "") != 0) {
1239 fprintf(fout, "\n + %s ", net->rectRouteStatus(i));
1240 if (strcmp(net->rectRouteStatus(i), "SHIELD") == 0) {
1241 fprintf(fout, "\n + %s ", net->rectRouteStatusShieldName(i));
1242 }
1243 }
1244 if (strcmp(net->rectShapeType(i), "") != 0) {
1245 fprintf(fout, "\n + SHAPE %s ", net->rectShapeType(i));
1246 }
1247 }
1248 if (net->rectMask(i)) {
1249 fprintf(fout, "\n + MASK %d + RECT %s %d %d %d %d",
1250 net->rectMask(i), net->rectName(i),
1251 net->xl(i), net->yl(i), net->xh(i),
1252 net->yh(i));
1253 } else {
1254 fprintf(fout, "\n + RECT %s %d %d %d %d",
1255 net->rectName(i),
1256 net->xl(i),
1257 net->yl(i),
1258 net->xh(i),
1259 net->yh(i));
1260 }
1261 }
1262 }
1263 // VIA
1264 if (curVer >= 5.8 && net->numViaSpecs()) {
1265 for (i = 0; i < net->numViaSpecs(); i++) {
1266 if (strcmp(net->viaRouteStatus(i), "") != 0) {
1267 fprintf(fout, "\n + %s ", net->viaRouteStatus(i));
1268 if (strcmp(net->viaRouteStatus(i), "SHIELD") == 0) {
1269 fprintf(fout, "\n + %s ", net->viaRouteStatusShieldName(i));
1270 }
1271 }
1272 if (strcmp(net->viaShapeType(i), "") != 0) {
1273 fprintf(fout, "\n + SHAPE %s ", net->viaShapeType(i));
1274 }
1275 if (net->topMaskNum(i) || net->cutMaskNum(i) || net->bottomMaskNum(i)) {
1276 fprintf(fout, "\n + MASK %d%d%d + VIA %s ", net->topMaskNum(i),
1277 net->cutMaskNum(i),
1278 net->bottomMaskNum(i),
1279 net->viaName(i));
1280 } else {
1281 fprintf(fout, "\n + VIA %s ", net->viaName(i));
1282 }
1283 fprintf(fout, " %s", net->viaOrientStr(i));
1284
1285 defiPoints points = net->getViaPts(i);
1286
1287 for (int j = 0; j < points.numPoints; j++) {
1288 fprintf(fout, " %d %d", points.x[j], points.y[j]);
1289 }
1290 fprintf(fout, ";\n");
1291
1292 }
1293 }
1294
1295 if (net->hasSubnets()) {
1296 for (i = 0; i < net->numSubnets(); i++) {
1297 s = net->subnet(i);
1298 if (s->numConnections()) {
1299 if (s->pinIsMustJoin(0))
1300 fprintf(fout, "- MUSTJOIN ");
1301 else
1302 fprintf(fout, "- %s ", s->name());
1303 for (j = 0; j < s->numConnections(); j++) {
1304 fprintf(fout, " ( %s %s )\n", s->instance(j),
1305 s->pin(j));
1306 }
1307 }
1308
1309 // regularWiring
1310 if (s->numWires()) {
1311 for (i = 0; i < s->numWires(); i++) {
1312 wire = s->wire(i);
1313 fprintf(fout, " + %s ", wire->wireType());
1314 for (j = 0; j < wire->numPaths(); j++) {
1315 p = wire->path(j);
1316 p->print(fout);
1317 }
1318 }
1319 }
1320 }
1321 }
1322
1323 if (net->numProps()) {
1324 for (i = 0; i < net->numProps(); i++) {
1325 if (net->propIsString(i))
1326 fprintf(fout, " + PROPERTY %s %s ", net->propName(i),
1327 net->propValue(i));
1328 if (net->propIsNumber(i))
1329 fprintf(fout, " + PROPERTY %s %g ", net->propName(i),
1330 net->propNumber(i));
1331 switch (net->propType(i)) {
1332 case 'R': fprintf(fout, "REAL ");
1333 break;
1334 case 'I': fprintf(fout, "INTEGER ");
1335 break;
1336 case 'S': fprintf(fout, "STRING ");
1337 break;
1338 case 'Q': fprintf(fout, "QUOTESTRING ");
1339 break;
1340 case 'N': fprintf(fout, "NUMBER ");
1341 break;
1342 }
1343 fprintf(fout, "\n");
1344 }
1345 }
1346
1347 // SHIELD
1348 count = 0;
1349 // testing the SHIELD for 5.3, obsolete in 5.4
1350 if (net->numShields()) {
1351 for (i = 0; i < net->numShields(); i++) {
1352 shield = net->shield(i);
1353 fprintf(fout, "\n + SHIELD %s ", shield->shieldName());
1354 newLayer = 0;
1355 for (j = 0; j < shield->numPaths(); j++) {
1356 p = shield->path(j);
1357 p->initTraverse();
1358 while ((path = (int)p->next()) != DEFIPATH_DONE) {
1359 count++;
1360 // Don't want the line to be too long
1361 if (count >= 5) {
1362 fprintf(fout, "\n");
1363 count = 0;
1364 }
1365 switch (path) {
1366 case DEFIPATH_LAYER:
1367 if (newLayer == 0) {
1368 fprintf(fout, "%s ", p->getLayer());
1369 newLayer = 1;
1370 } else
1371 fprintf(fout, "NEW %s ", p->getLayer());
1372 break;
1373 case DEFIPATH_VIA:
1374 fprintf(fout, "%s ", ignoreViaNames ? "XXX" : p->getVia());
1375 break;
1376 case DEFIPATH_VIAROTATION:
1377 fprintf(fout, "%s ",
1378 orientStr(p->getViaRotation()));
1379 break;
1380 case DEFIPATH_WIDTH:
1381 fprintf(fout, "%d ", p->getWidth());
1382 break;
1383 case DEFIPATH_MASK:
1384 fprintf(fout, "MASK %d ", p->getMask());
1385 break;
1386 case DEFIPATH_VIAMASK:
1387 fprintf(fout, "MASK %d%d%d ",
1388 p->getViaTopMask(),
1389 p->getViaCutMask(),
1390 p->getViaBottomMask());
1391 break;
1392 case DEFIPATH_POINT:
1393 p->getPoint(&x, &y);
1394 fprintf(fout, "( %d %d ) ", x, y);
1395 break;
1396 case DEFIPATH_FLUSHPOINT:
1397 p->getFlushPoint(&x, &y, &z);
1398 fprintf(fout, "( %d %d %d ) ", x, y, z);
1399 break;
1400 case DEFIPATH_TAPER:
1401 fprintf(fout, "TAPER ");
1402 break;
1403 case DEFIPATH_SHAPE:
1404 fprintf(fout, "+ SHAPE %s ", p->getShape());
1405 break;
1406 case DEFIPATH_STYLE:
1407 fprintf(fout, "+ STYLE %d ", p->getStyle());
1408 break;
1409 }
1410 }
1411 }
1412 }
1413 }
1414
1415 // layerName width
1416 if (net->hasWidthRules()) {
1417 for (i = 0; i < net->numWidthRules(); i++) {
1418 net->widthRule(i, &layerName, &dist);
1419 fprintf (fout, "\n + WIDTH %s %g ", layerName, dist);
1420 }
1421 }
1422
1423 // layerName spacing
1424 if (net->hasSpacingRules()) {
1425 for (i = 0; i < net->numSpacingRules(); i++) {
1426 net->spacingRule(i, &layerName, &dist, &left, &right);
1427 if (left == right)
1428 fprintf (fout, "\n + SPACING %s %g ", layerName, dist);
1429 else
1430 fprintf (fout, "\n + SPACING %s %g RANGE %g %g ",
1431 layerName, dist, left, right);
1432 }
1433 }
1434
1435 if (net->hasFixedbump())
1436 fprintf(fout, "\n + FIXEDBUMP ");
1437 if (net->hasFrequency())
1438 fprintf(fout, "\n + FREQUENCY %g ", net->frequency());
1439 if (net->hasVoltage())
1440 fprintf(fout, "\n + VOLTAGE %g ", net->voltage());
1441 if (net->hasWeight())
1442 fprintf(fout, "\n + WEIGHT %d ", net->weight());
1443 if (net->hasCap())
1444 fprintf(fout, "\n + ESTCAP %g ", net->cap());
1445 if (net->hasSource())
1446 fprintf(fout, "\n + SOURCE %s ", net->source());
1447 if (net->hasPattern())
1448 fprintf(fout, "\n + PATTERN %s ", net->pattern());
1449 if (net->hasOriginal())
1450 fprintf(fout, "\n + ORIGINAL %s ", net->original());
1451 if (net->hasUse())
1452 fprintf(fout, "\n + USE %s ", net->use());
1453
1454 fprintf (fout, ";\n");
1455 --numObjs;
1456 if (numObjs <= 0)
1457 fprintf(fout, "END SPECIALNETS\n");
1458 return 0;
1459 }
1460
1461
ndr(defrCallbackType_e c,defiNonDefault * nd,defiUserData ud)1462 int ndr(defrCallbackType_e c, defiNonDefault* nd, defiUserData ud) {
1463 // For nondefaultrule
1464 int i;
1465
1466 checkType(c);
1467 if (ud != userData) dataError();
1468 if (c != defrNonDefaultCbkType)
1469 fprintf(fout, "BOGUS NONDEFAULTRULE TYPE ");
1470 fprintf(fout, "- %s\n", nd->name());
1471 if (nd->hasHardspacing())
1472 fprintf(fout, " + HARDSPACING\n");
1473 for (i = 0; i < nd->numLayers(); i++) {
1474 fprintf(fout, " + LAYER %s", nd->layerName(i));
1475 fprintf(fout, " WIDTH %d", nd->layerWidthVal(i));
1476 if (nd->hasLayerDiagWidth(i))
1477 fprintf(fout, " DIAGWIDTH %d",
1478 nd->layerDiagWidthVal(i));
1479 if (nd->hasLayerSpacing(i))
1480 fprintf(fout, " SPACING %d", nd->layerSpacingVal(i));
1481 if (nd->hasLayerWireExt(i))
1482 fprintf(fout, " WIREEXT %d", nd->layerWireExtVal(i));
1483 fprintf(fout, "\n");
1484 }
1485 for (i = 0; i < nd->numVias(); i++)
1486 fprintf(fout, " + VIA %s\n", nd->viaName(i));
1487 for (i = 0; i < nd->numViaRules(); i++)
1488 fprintf(fout, " + VIARULE %s\n", ignoreViaNames ? "XXX" : nd->viaRuleName(i));
1489 for (i = 0; i < nd->numMinCuts(); i++)
1490 fprintf(fout, " + MINCUTS %s %d\n", nd->cutLayerName(i),
1491 nd->numCuts(i));
1492 for (i = 0; i < nd->numProps(); i++) {
1493 fprintf(fout, " + PROPERTY %s %s ", nd->propName(i),
1494 nd->propValue(i));
1495 switch (nd->propType(i)) {
1496 case 'R': fprintf(fout, "REAL\n");
1497 break;
1498 case 'I': fprintf(fout, "INTEGER\n");
1499 break;
1500 case 'S': fprintf(fout, "STRING\n");
1501 break;
1502 case 'Q': fprintf(fout, "QUOTESTRING\n");
1503 break;
1504 case 'N': fprintf(fout, "NUMBER\n");
1505 break;
1506 }
1507 }
1508 --numObjs;
1509 if (numObjs <= 0)
1510 fprintf(fout, "END NONDEFAULTRULES\n");
1511 return 0;
1512 }
1513
tname(defrCallbackType_e c,const char * string,defiUserData ud)1514 int tname(defrCallbackType_e c, const char* string, defiUserData ud) {
1515 checkType(c);
1516 if (ud != userData) dataError();
1517 fprintf(fout, "TECHNOLOGY %s ;\n", string);
1518 return 0;
1519 }
1520
dname(defrCallbackType_e c,const char * string,defiUserData ud)1521 int dname(defrCallbackType_e c, const char* string, defiUserData ud) {
1522 checkType(c);
1523 if (ud != userData) dataError();
1524 fprintf(fout, "DESIGN %s ;\n", string);
1525
1526 return 0;
1527 }
1528
1529
address(const char * in)1530 char* address(const char* in) {
1531 return ((char*)in);
1532 }
1533
cs(defrCallbackType_e c,int num,defiUserData ud)1534 int cs(defrCallbackType_e c, int num, defiUserData ud) {
1535 char* name;
1536
1537 checkType(c);
1538
1539 if (ud != userData) dataError();
1540
1541 switch (c) {
1542 case defrComponentStartCbkType : name = address("COMPONENTS"); break;
1543 case defrNetStartCbkType : name = address("NETS"); break;
1544 case defrStartPinsCbkType : name = address("PINS"); break;
1545 case defrViaStartCbkType : name = address("VIAS"); break;
1546 case defrRegionStartCbkType : name = address("REGIONS"); break;
1547 case defrSNetStartCbkType : name = address("SPECIALNETS"); break;
1548 case defrGroupsStartCbkType : name = address("GROUPS"); break;
1549 case defrScanchainsStartCbkType : name = address("SCANCHAINS"); break;
1550 case defrIOTimingsStartCbkType : name = address("IOTIMINGS"); break;
1551 case defrFPCStartCbkType : name = address("FLOORPLANCONSTRAINTS"); break;
1552 case defrTimingDisablesStartCbkType : name = address("TIMING DISABLES"); break;
1553 case defrPartitionsStartCbkType : name = address("PARTITIONS"); break;
1554 case defrPinPropStartCbkType : name = address("PINPROPERTIES"); break;
1555 case defrBlockageStartCbkType : name = address("BLOCKAGES"); break;
1556 case defrSlotStartCbkType : name = address("SLOTS"); break;
1557 case defrFillStartCbkType : name = address("FILLS"); break;
1558 case defrNonDefaultStartCbkType : name = address("NONDEFAULTRULES"); break;
1559 case defrStylesStartCbkType : name = address("STYLES"); break;
1560 default : name = address("BOGUS"); return 1;
1561 }
1562 fprintf(fout, "\n%s %d ;\n", name, num);
1563 numObjs = num;
1564 return 0;
1565 }
1566
constraintst(defrCallbackType_e c,int num,defiUserData ud)1567 int constraintst(defrCallbackType_e c, int num, defiUserData ud) {
1568 // Handles both constraints and assertions
1569 checkType(c);
1570 if (ud != userData) dataError();
1571 if (c == defrConstraintsStartCbkType)
1572 fprintf(fout, "\nCONSTRAINTS %d ;\n\n", num);
1573 else
1574 fprintf(fout, "\nASSERTIONS %d ;\n\n", num);
1575 numObjs = num;
1576 return 0;
1577 }
1578
operand(defrCallbackType_e c,defiAssertion * a,int ind)1579 void operand(defrCallbackType_e c, defiAssertion* a, int ind) {
1580 int i, first = 1;
1581 char* netName;
1582 char* fromInst, * fromPin, * toInst, * toPin;
1583
1584 if (a->isSum()) {
1585 // Sum in operand, recursively call operand
1586 fprintf(fout, "- SUM ( ");
1587 a->unsetSum();
1588 isSumSet = 1;
1589 begOperand = 0;
1590 operand (c, a, ind);
1591 fprintf(fout, ") ");
1592 } else {
1593 // operand
1594 if (ind >= a->numItems()) {
1595 fprintf(fout, "ERROR: when writing out SUM in Constraints.\n");
1596 return;
1597 }
1598 if (begOperand) {
1599 fprintf(fout, "- ");
1600 begOperand = 0;
1601 }
1602 for (i = ind; i < a->numItems(); i++) {
1603 if (a->isNet(i)) {
1604 a->net(i, &netName);
1605 if (!first)
1606 fprintf(fout, ", "); // print , as separator
1607 fprintf(fout, "NET %s ", netName);
1608 } else if (a->isPath(i)) {
1609 a->path(i, &fromInst, &fromPin, &toInst,
1610 &toPin);
1611 if (!first)
1612 fprintf(fout, ", ");
1613 fprintf(fout, "PATH %s %s %s %s ", fromInst, fromPin, toInst,
1614 toPin);
1615 } else if (isSumSet) {
1616 // SUM within SUM, reset the flag
1617 a->setSum();
1618 operand(c, a, i);
1619 }
1620 first = 0;
1621 }
1622
1623 }
1624 }
1625
constraint(defrCallbackType_e c,defiAssertion * a,defiUserData ud)1626 int constraint(defrCallbackType_e c, defiAssertion* a, defiUserData ud) {
1627 // Handles both constraints and assertions
1628
1629 checkType(c);
1630 if (ud != userData) dataError();
1631 if (a->isWiredlogic())
1632 // Wirelogic
1633 fprintf(fout, "- WIREDLOGIC %s + MAXDIST %g ;\n",
1634 // Wiredlogic dist is also store in fallMax
1635 // a->netName(), a->distance());
1636 a->netName(), a->fallMax());
1637 else {
1638 // Call the operand function
1639 isSumSet = 0; // reset the global variable
1640 begOperand = 1;
1641 operand (c, a, 0);
1642 // Get the Rise and Fall
1643 if (a->hasRiseMax())
1644 fprintf(fout, "+ RISEMAX %g ", a->riseMax());
1645 if (a->hasFallMax())
1646 fprintf(fout, "+ FALLMAX %g ", a->fallMax());
1647 if (a->hasRiseMin())
1648 fprintf(fout, "+ RISEMIN %g ", a->riseMin());
1649 if (a->hasFallMin())
1650 fprintf(fout, "+ FALLMIN %g ", a->fallMin());
1651 fprintf(fout, ";\n");
1652 }
1653 --numObjs;
1654 if (numObjs <= 0) {
1655 if (c == defrConstraintCbkType)
1656 fprintf(fout, "END CONSTRAINTS\n");
1657 else
1658 fprintf(fout, "END ASSERTIONS\n");
1659 }
1660 return 0;
1661 }
1662
1663
propstart(defrCallbackType_e c,void *,defiUserData)1664 int propstart(defrCallbackType_e c, void*, defiUserData) {
1665 checkType(c);
1666 fprintf(fout, "\nPROPERTYDEFINITIONS\n");
1667 isProp = 1;
1668
1669 return 0;
1670 }
1671
1672
prop(defrCallbackType_e c,defiProp * p,defiUserData ud)1673 int prop(defrCallbackType_e c, defiProp* p, defiUserData ud) {
1674 checkType(c);
1675 if (ud != userData) dataError();
1676 if (strcmp(p->propType(), "design") == 0)
1677 fprintf(fout, "DESIGN %s ", p->propName());
1678 else if (strcmp(p->propType(), "net") == 0)
1679 fprintf(fout, "NET %s ", p->propName());
1680 else if (strcmp(p->propType(), "component") == 0)
1681 fprintf(fout, "COMPONENT %s ", p->propName());
1682 else if (strcmp(p->propType(), "specialnet") == 0)
1683 fprintf(fout, "SPECIALNET %s ", p->propName());
1684 else if (strcmp(p->propType(), "group") == 0)
1685 fprintf(fout, "GROUP %s ", p->propName());
1686 else if (strcmp(p->propType(), "row") == 0)
1687 fprintf(fout, "ROW %s ", p->propName());
1688 else if (strcmp(p->propType(), "componentpin") == 0)
1689 fprintf(fout, "COMPONENTPIN %s ", p->propName());
1690 else if (strcmp(p->propType(), "region") == 0)
1691 fprintf(fout, "REGION %s ", p->propName());
1692 else if (strcmp(p->propType(), "nondefaultrule") == 0)
1693 fprintf(fout, "NONDEFAULTRULE %s ", p->propName());
1694 if (p->dataType() == 'I')
1695 fprintf(fout, "INTEGER ");
1696 if (p->dataType() == 'R')
1697 fprintf(fout, "REAL ");
1698 if (p->dataType() == 'S')
1699 fprintf(fout, "STRING ");
1700 if (p->dataType() == 'Q')
1701 fprintf(fout, "STRING ");
1702 if (p->hasRange()) {
1703 fprintf(fout, "RANGE %g %g ", p->left(),
1704 p->right());
1705 }
1706 if (p->hasNumber())
1707 fprintf(fout, "%g ", p->number());
1708 if (p->hasString())
1709 fprintf(fout, "\"%s\" ", p->string());
1710 fprintf(fout, ";\n");
1711
1712 return 0;
1713 }
1714
1715
propend(defrCallbackType_e c,void *,defiUserData)1716 int propend(defrCallbackType_e c, void*, defiUserData) {
1717 checkType(c);
1718 if (isProp) {
1719 fprintf(fout, "END PROPERTYDEFINITIONS\n\n");
1720 isProp = 0;
1721 }
1722
1723 return 0;
1724 }
1725
1726
hist(defrCallbackType_e c,const char * h,defiUserData ud)1727 int hist(defrCallbackType_e c, const char* h, defiUserData ud) {
1728 checkType(c);
1729 defrSetCaseSensitivity(0);
1730 if (ud != userData) dataError();
1731 fprintf(fout, "HISTORY %s ;\n", h);
1732 defrSetCaseSensitivity(1);
1733 return 0;
1734 }
1735
1736
an(defrCallbackType_e c,const char * h,defiUserData ud)1737 int an(defrCallbackType_e c, const char* h, defiUserData ud) {
1738 checkType(c);
1739 if (ud != userData) dataError();
1740 fprintf(fout, "ARRAY %s ;\n", h);
1741 return 0;
1742 }
1743
1744
fn(defrCallbackType_e c,const char * h,defiUserData ud)1745 int fn(defrCallbackType_e c, const char* h, defiUserData ud) {
1746 checkType(c);
1747 if (ud != userData) dataError();
1748 fprintf(fout, "FLOORPLAN %s ;\n", h);
1749 return 0;
1750 }
1751
1752
bbn(defrCallbackType_e c,const char * h,defiUserData ud)1753 int bbn(defrCallbackType_e c, const char* h, defiUserData ud) {
1754 checkType(c);
1755 if (ud != userData) dataError();
1756 fprintf(fout, "BUSBITCHARS \"%s\" ;\n", h);
1757 return 0;
1758 }
1759
1760
vers(defrCallbackType_e c,double d,defiUserData ud)1761 int vers(defrCallbackType_e c, double d, defiUserData ud) {
1762 checkType(c);
1763 if (ud != userData)
1764 dataError();
1765 fprintf(fout, "VERSION %g ;\n", d);
1766 curVer = d;
1767
1768 fprintf(fout, "ALIAS alias1 aliasValue1 1 ;\n");
1769 fprintf(fout, "ALIAS alias2 aliasValue2 0 ;\n");
1770
1771 return 0;
1772 }
1773
1774
versStr(defrCallbackType_e c,const char * versionName,defiUserData ud)1775 int versStr(defrCallbackType_e c, const char* versionName, defiUserData ud) {
1776 checkType(c);
1777 if (ud != userData) dataError();
1778 fprintf(fout, "VERSION %s ;\n", versionName);
1779 return 0;
1780 }
1781
1782
units(defrCallbackType_e c,double d,defiUserData ud)1783 int units(defrCallbackType_e c, double d, defiUserData ud) {
1784 checkType(c);
1785 if (ud != userData) dataError();
1786 fprintf(fout, "UNITS DISTANCE MICRONS %g ;\n", d);
1787 return 0;
1788 }
1789
1790
casesens(defrCallbackType_e c,int d,defiUserData ud)1791 int casesens(defrCallbackType_e c, int d, defiUserData ud) {
1792 checkType(c);
1793 if (ud != userData) dataError();
1794 if (d == 1)
1795 fprintf(fout, "NAMESCASESENSITIVE ON ;\n", d);
1796 else
1797 fprintf(fout, "NAMESCASESENSITIVE OFF ;\n", d);
1798 return 0;
1799 }
1800
1801
cls(defrCallbackType_e c,void * cl,defiUserData ud)1802 int cls(defrCallbackType_e c, void* cl, defiUserData ud) {
1803 defiSite* site; // Site and Canplace and CannotOccupy
1804 defiBox* box; // DieArea and
1805 defiPinCap* pc;
1806 defiPin* pin;
1807 int i, j, k;
1808 defiRow* row;
1809 defiTrack* track;
1810 defiGcellGrid* gcg;
1811 defiVia* via;
1812 defiRegion* re;
1813 defiGroup* group;
1814 defiComponentMaskShiftLayer* maskShiftLayer = NULL;
1815 defiScanchain* sc;
1816 defiIOTiming* iot;
1817 defiFPC* fpc;
1818 defiTimingDisable* td;
1819 defiPartition* part;
1820 defiPinProp* pprop;
1821 defiBlockage* block;
1822 defiSlot* slots;
1823 defiFill* fills;
1824 defiStyles* styles;
1825 int xl, yl, xh, yh;
1826 char *name, *a1, *b1;
1827 char **inst, **inPin, **outPin;
1828 int *bits;
1829 int size;
1830 int corner, typ;
1831 const char *itemT;
1832 char dir;
1833 defiPinAntennaModel* aModel;
1834 defiPoints points;
1835
1836 checkType(c);
1837 if (ud != userData) dataError();
1838 switch (c) {
1839
1840 case defrSiteCbkType :
1841 site = (defiSite*)cl;
1842 fprintf(fout, "SITE %s %g %g %s ", site->name(),
1843 site->x_orig(), site->y_orig(),
1844 orientStr(site->orient()));
1845 fprintf(fout, "DO %g BY %g STEP %g %g ;\n",
1846 site->x_num(), site->y_num(),
1847 site->x_step(), site->y_step());
1848 break;
1849 case defrCanplaceCbkType :
1850 site = (defiSite*)cl;
1851 fprintf(fout, "CANPLACE %s %g %g %s ", site->name(),
1852 site->x_orig(), site->y_orig(),
1853 orientStr(site->orient()));
1854 fprintf(fout, "DO %g BY %g STEP %g %g ;\n",
1855 site->x_num(), site->y_num(),
1856 site->x_step(), site->y_step());
1857 break;
1858 case defrCannotOccupyCbkType :
1859 site = (defiSite*)cl;
1860 fprintf(fout, "CANNOTOCCUPY %s %g %g %s ",
1861 site->name(), site->x_orig(),
1862 site->y_orig(), orientStr(site->orient()));
1863 fprintf(fout, "DO %g BY %g STEP %g %g ;\n",
1864 site->x_num(), site->y_num(),
1865 site->x_step(), site->y_step());
1866 break;
1867 case defrDieAreaCbkType :
1868 box = (defiBox*)cl;
1869 fprintf(fout, "DIEAREA %d %d %d %d ;\n",
1870 box->xl(), box->yl(), box->xh(),
1871 box->yh());
1872 fprintf(fout, "DIEAREA ");
1873 points = box->getPoint();
1874 for (i = 0; i < points.numPoints; i++)
1875 fprintf(fout, "%d %d ", points.x[i], points.y[i]);
1876 fprintf(fout, ";\n");
1877 break;
1878 case defrPinCapCbkType :
1879 pc = (defiPinCap*)cl;
1880 if (testDebugPrint) {
1881 pc->print(fout);
1882 } else {
1883 fprintf(fout, "MINPINS %d WIRECAP %g ;\n",
1884 pc->pin(), pc->cap());
1885 --numObjs;
1886 if (numObjs <= 0)
1887 fprintf(fout, "END DEFAULTCAP\n");
1888 }
1889 break;
1890 case defrPinCbkType :
1891 pin = (defiPin*)cl;
1892 if (testDebugPrint) {
1893 pin->print(fout);
1894 } else {
1895 fprintf(fout, "- %s + NET %s ", pin->pinName(),
1896 pin->netName());
1897 // pin->changePinName("pinName");
1898 // fprintf(fout, "%s ", pin->pinName());
1899 if (pin->hasDirection())
1900 fprintf(fout, "+ DIRECTION %s ", pin->direction());
1901 if (pin->hasUse())
1902 fprintf(fout, "+ USE %s ", pin->use());
1903 if (pin->hasNetExpr())
1904 fprintf(fout, "+ NETEXPR \"%s\" ", pin->netExpr());
1905 if (pin->hasSupplySensitivity())
1906 fprintf(fout, "+ SUPPLYSENSITIVITY %s ",
1907 pin->supplySensitivity());
1908 if (pin->hasGroundSensitivity())
1909 fprintf(fout, "+ GROUNDSENSITIVITY %s ",
1910 pin->groundSensitivity());
1911 if (pin->hasLayer()) {
1912 defiPoints points;
1913 for (i = 0; i < pin->numLayer(); i++) {
1914 fprintf(fout, "\n + LAYER %s ", pin->layer(i));
1915 if (pin->layerMask(i))
1916 fprintf(fout, "MASK %d ",
1917 pin->layerMask(i));
1918 if (pin->hasLayerSpacing(i))
1919 fprintf(fout, "SPACING %d ",
1920 pin->layerSpacing(i));
1921 if (pin->hasLayerDesignRuleWidth(i))
1922 fprintf(fout, "DESIGNRULEWIDTH %d ",
1923 pin->layerDesignRuleWidth(i));
1924 pin->bounds(i, &xl, &yl, &xh, &yh);
1925 fprintf(fout, "%d %d %d %d ", xl, yl, xh, yh);
1926 }
1927 for (i = 0; i < pin->numPolygons(); i++) {
1928 fprintf(fout, "\n + POLYGON %s ",
1929 pin->polygonName(i));
1930 if (pin->polygonMask(i))
1931 fprintf(fout, "MASK %d ",
1932 pin->polygonMask(i));
1933 if (pin->hasPolygonSpacing(i))
1934 fprintf(fout, "SPACING %d ",
1935 pin->polygonSpacing(i));
1936 if (pin->hasPolygonDesignRuleWidth(i))
1937 fprintf(fout, "DESIGNRULEWIDTH %d ",
1938 pin->polygonDesignRuleWidth(i));
1939 points = pin->getPolygon(i);
1940 for (j = 0; j < points.numPoints; j++)
1941 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
1942 }
1943 for (i = 0; i < pin->numVias(); i++) {
1944 if (pin->viaTopMask(i) || pin->viaCutMask(i) || pin->viaBottomMask(i)) {
1945 fprintf(fout, "\n + VIA %s MASK %d%d%d %d %d ",
1946 pin->viaName(i),
1947 pin->viaTopMask(i),
1948 pin->viaCutMask(i),
1949 pin->viaBottomMask(i),
1950 pin->viaPtX(i),
1951 pin->viaPtY(i));
1952 } else {
1953 fprintf(fout, "\n + VIA %s %d %d ", pin->viaName(i),
1954 pin->viaPtX(i), pin->viaPtY(i));
1955 }
1956 }
1957 }
1958 if (pin->hasPort()) {
1959 defiPoints points;
1960 defiPinPort* port;
1961 for (j = 0; j < pin->numPorts(); j++) {
1962 port = pin->pinPort(j);
1963 fprintf(fout, "\n + PORT");
1964 for (i = 0; i < port->numLayer(); i++) {
1965 fprintf(fout, "\n + LAYER %s ",
1966 port->layer(i));
1967 if (port->layerMask(i))
1968 fprintf(fout, "MASK %d ",
1969 port->layerMask(i));
1970 if (port->hasLayerSpacing(i))
1971 fprintf(fout, "SPACING %d ",
1972 port->layerSpacing(i));
1973 if (port->hasLayerDesignRuleWidth(i))
1974 fprintf(fout, "DESIGNRULEWIDTH %d ",
1975 port->layerDesignRuleWidth(i));
1976 port->bounds(i, &xl, &yl, &xh, &yh);
1977 fprintf(fout, "%d %d %d %d ", xl, yl, xh, yh);
1978 }
1979 for (i = 0; i < port->numPolygons(); i++) {
1980 fprintf(fout, "\n + POLYGON %s ",
1981 port->polygonName(i));
1982 if (port->polygonMask(i))
1983 fprintf(fout, "MASK %d ",
1984 port->polygonMask(i));
1985 if (port->hasPolygonSpacing(i))
1986 fprintf(fout, "SPACING %d ",
1987 port->polygonSpacing(i));
1988 if (port->hasPolygonDesignRuleWidth(i))
1989 fprintf(fout, "DESIGNRULEWIDTH %d ",
1990 port->polygonDesignRuleWidth(i));
1991 points = port->getPolygon(i);
1992 for (k = 0; k < points.numPoints; k++)
1993 fprintf(fout, "( %d %d ) ", points.x[k], points.y[k]);
1994 }
1995 for (i = 0; i < port->numVias(); i++) {
1996 if (port->viaTopMask(i) || port->viaCutMask(i)
1997 || port->viaBottomMask(i)) {
1998 fprintf(fout, "\n + VIA %s MASK %d%d%d ( %d %d ) ",
1999 port->viaName(i),
2000 port->viaTopMask(i),
2001 port->viaCutMask(i),
2002 port->viaBottomMask(i),
2003 port->viaPtX(i),
2004 port->viaPtY(i));
2005 } else {
2006 fprintf(fout, "\n + VIA %s ( %d %d ) ",
2007 port->viaName(i),
2008 port->viaPtX(i),
2009 port->viaPtY(i));
2010 }
2011 }
2012 if (port->hasPlacement()) {
2013 if (port->isPlaced()) {
2014 fprintf(fout, "\n + PLACED ");
2015 fprintf(fout, "( %d %d ) %s ",
2016 port->placementX(),
2017 port->placementY(),
2018 orientStr(port->orient()));
2019 }
2020 if (port->isCover()) {
2021 fprintf(fout, "\n + COVER ");
2022 fprintf(fout, "( %d %d ) %s ",
2023 port->placementX(),
2024 port->placementY(),
2025 orientStr(port->orient()));
2026 }
2027 if (port->isFixed()) {
2028 fprintf(fout, "\n + FIXED ");
2029 fprintf(fout, "( %d %d ) %s ",
2030 port->placementX(),
2031 port->placementY(),
2032 orientStr(port->orient()));
2033 }
2034 }
2035 }
2036 }
2037 if (pin->hasPlacement()) {
2038 if (pin->isPlaced()) {
2039 fprintf(fout, "+ PLACED ");
2040 fprintf(fout, "( %d %d ) %s ", pin->placementX(),
2041 pin->placementY(),
2042 orientStr(pin->orient()));
2043 }
2044 if (pin->isCover()) {
2045 fprintf(fout, "+ COVER ");
2046 fprintf(fout, "( %d %d ) %s ", pin->placementX(),
2047 pin->placementY(),
2048 orientStr(pin->orient()));
2049 }
2050 if (pin->isFixed()) {
2051 fprintf(fout, "+ FIXED ");
2052 fprintf(fout, "( %d %d ) %s ", pin->placementX(),
2053 pin->placementY(),
2054 orientStr(pin->orient()));
2055 }
2056 if (pin->isUnplaced())
2057 fprintf(fout, "+ UNPLACED ");
2058 }
2059 if (pin->hasSpecial()) {
2060 fprintf(fout, "+ SPECIAL ");
2061 }
2062 if (pin->hasAPinPartialMetalArea()) {
2063 for (i = 0; i < pin->numAPinPartialMetalArea(); i++) {
2064 fprintf(fout, "ANTENNAPINPARTIALMETALAREA %d",
2065 pin->APinPartialMetalArea(i));
2066 if (*(pin->APinPartialMetalAreaLayer(i)))
2067 fprintf(fout, " LAYER %s",
2068 pin->APinPartialMetalAreaLayer(i));
2069 fprintf(fout, "\n");
2070 }
2071 }
2072 if (pin->hasAPinPartialMetalSideArea()) {
2073 for (i = 0; i < pin->numAPinPartialMetalSideArea(); i++) {
2074 fprintf(fout, "ANTENNAPINPARTIALMETALSIDEAREA %d",
2075 pin->APinPartialMetalSideArea(i));
2076 if (*(pin->APinPartialMetalSideAreaLayer(i)))
2077 fprintf(fout, " LAYER %s",
2078 pin->APinPartialMetalSideAreaLayer(i));
2079 fprintf(fout, "\n");
2080 }
2081 }
2082 if (pin->hasAPinDiffArea()) {
2083 for (i = 0; i < pin->numAPinDiffArea(); i++) {
2084 fprintf(fout, "ANTENNAPINDIFFAREA %d", pin->APinDiffArea(i));
2085 if (*(pin->APinDiffAreaLayer(i)))
2086 fprintf(fout, " LAYER %s", pin->APinDiffAreaLayer(i));
2087 fprintf(fout, "\n");
2088 }
2089 }
2090 if (pin->hasAPinPartialCutArea()) {
2091 for (i = 0; i < pin->numAPinPartialCutArea(); i++) {
2092 fprintf(fout, "ANTENNAPINPARTIALCUTAREA %d",
2093 pin->APinPartialCutArea(i));
2094 if (*(pin->APinPartialCutAreaLayer(i)))
2095 fprintf(fout, " LAYER %s", pin->APinPartialCutAreaLayer(i));
2096 fprintf(fout, "\n");
2097 }
2098 }
2099
2100 for (j = 0; j < pin->numAntennaModel(); j++) {
2101 aModel = pin->antennaModel(j);
2102
2103 fprintf(fout, "ANTENNAMODEL %s\n",
2104 aModel->antennaOxide());
2105
2106 if (aModel->hasAPinGateArea()) {
2107 for (i = 0; i < aModel->numAPinGateArea();
2108 i++) {
2109 fprintf(fout, "ANTENNAPINGATEAREA %d",
2110 aModel->APinGateArea(i));
2111 if (aModel->hasAPinGateAreaLayer(i))
2112 fprintf(fout, " LAYER %s", aModel->APinGateAreaLayer(i));
2113 fprintf(fout, "\n");
2114 }
2115 }
2116 if (aModel->hasAPinMaxAreaCar()) {
2117 for (i = 0;
2118 i < aModel->numAPinMaxAreaCar(); i++) {
2119 fprintf(fout, "ANTENNAPINMAXAREACAR %d",
2120 aModel->APinMaxAreaCar(i));
2121 if (aModel->hasAPinMaxAreaCarLayer(i))
2122 fprintf(fout,
2123 " LAYER %s", aModel->APinMaxAreaCarLayer(i));
2124 fprintf(fout, "\n");
2125 }
2126 }
2127 if (aModel->hasAPinMaxSideAreaCar()) {
2128 for (i = 0;
2129 i < aModel->numAPinMaxSideAreaCar();
2130 i++) {
2131 fprintf(fout, "ANTENNAPINMAXSIDEAREACAR %d",
2132 aModel->APinMaxSideAreaCar(i));
2133 if (aModel->hasAPinMaxSideAreaCarLayer(i))
2134 fprintf(fout,
2135 " LAYER %s", aModel->APinMaxSideAreaCarLayer(i));
2136 fprintf(fout, "\n");
2137 }
2138 }
2139 if (aModel->hasAPinMaxCutCar()) {
2140 for (i = 0; i < aModel->numAPinMaxCutCar();
2141 i++) {
2142 fprintf(fout, "ANTENNAPINMAXCUTCAR %d",
2143 aModel->APinMaxCutCar(i));
2144 if (aModel->hasAPinMaxCutCarLayer(i))
2145 fprintf(fout, " LAYER %s",
2146 aModel->APinMaxCutCarLayer(i));
2147 fprintf(fout, "\n");
2148 }
2149 }
2150 }
2151 fprintf(fout, ";\n");
2152 --numObjs;
2153 if (numObjs <= 0)
2154 fprintf(fout, "END PINS\n");
2155 }
2156 break;
2157 case defrDefaultCapCbkType :
2158 i = (long)cl;
2159 fprintf(fout, "DEFAULTCAP %d\n", i);
2160 numObjs = i;
2161 break;
2162 case defrRowCbkType :
2163 row = (defiRow*)cl;
2164 fprintf(fout, "ROW %s %s %g %g %s ", ignoreRowNames ? "XXX" : row->name(),
2165 row->macro(), row->x(), row->y(),
2166 orientStr(row->orient()));
2167 if (row->hasDo()) {
2168 fprintf(fout, "DO %g BY %g ",
2169 row->xNum(), row->yNum());
2170 if (row->hasDoStep())
2171 fprintf(fout, "STEP %g %g ;\n",
2172 row->xStep(), row->yStep());
2173 else
2174 fprintf(fout, ";\n");
2175 } else
2176 fprintf(fout, ";\n");
2177 if (row->numProps() > 0) {
2178 for (i = 0; i < row->numProps(); i++) {
2179 fprintf(fout, " + PROPERTY %s %s ",
2180 row->propName(i),
2181 row->propValue(i));
2182 switch (row->propType(i)) {
2183 case 'R': fprintf(fout, "REAL ");
2184 break;
2185 case 'I': fprintf(fout, "INTEGER ");
2186 break;
2187 case 'S': fprintf(fout, "STRING ");
2188 break;
2189 case 'Q': fprintf(fout, "QUOTESTRING ");
2190 break;
2191 case 'N': fprintf(fout, "NUMBER ");
2192 break;
2193 }
2194 }
2195 fprintf(fout, ";\n");
2196 }
2197 break;
2198 case defrTrackCbkType :
2199 track = (defiTrack*)cl;
2200 if (track->firstTrackMask()) {
2201 if (track->sameMask()) {
2202 fprintf(fout, "TRACKS %s %g DO %g STEP %g MASK %d SAMEMASK LAYER ",
2203 track->macro(), track->x(),
2204 track->xNum(), track->xStep(),
2205 track->firstTrackMask());
2206 } else {
2207 fprintf(fout, "TRACKS %s %g DO %g STEP %g MASK %d LAYER ",
2208 track->macro(), track->x(),
2209 track->xNum(), track->xStep(),
2210 track->firstTrackMask());
2211 }
2212 } else {
2213 fprintf(fout, "TRACKS %s %g DO %g STEP %g LAYER ",
2214 track->macro(), track->x(),
2215 track->xNum(), track->xStep());
2216 }
2217 for (i = 0; i < track->numLayers(); i++)
2218 fprintf(fout, "%s ", track->layer(i));
2219 fprintf(fout, ";\n");
2220 break;
2221 case defrGcellGridCbkType :
2222 gcg = (defiGcellGrid*)cl;
2223 fprintf(fout, "GCELLGRID %s %d DO %d STEP %g ;\n",
2224 gcg->macro(), gcg->x(),
2225 gcg->xNum(), gcg->xStep());
2226 break;
2227 case defrViaCbkType :
2228 via = (defiVia*)cl;
2229 if (testDebugPrint) {
2230 via->print(fout);
2231 } else {
2232 fprintf(fout, "- %s ", via->name());
2233 if (via->hasPattern())
2234 fprintf(fout, "+ PATTERNNAME %s ", via->pattern());
2235 for (i = 0; i < via->numLayers(); i++) {
2236 via->layer(i, &name, &xl, &yl, &xh, &yh);
2237 int rectMask = via->rectMask(i);
2238
2239 if (rectMask) {
2240 fprintf(fout, "+ RECT %s + MASK %d %d %d %d %d \n",
2241 name, rectMask, xl, yl, xh, yh);
2242 } else {
2243 fprintf(fout, "+ RECT %s %d %d %d %d \n",
2244 name, xl, yl, xh, yh);
2245 }
2246 }
2247 // POLYGON
2248 if (via->numPolygons()) {
2249 defiPoints points;
2250 for (i = 0; i < via->numPolygons(); i++) {
2251 int polyMask = via->polyMask(i);
2252
2253 if (polyMask) {
2254 fprintf(fout, "\n + POLYGON %s + MASK %d ",
2255 via->polygonName(i), polyMask);
2256 } else {
2257 fprintf(fout, "\n + POLYGON %s ", via->polygonName(i));
2258 }
2259 points = via->getPolygon(i);
2260 for (j = 0; j < points.numPoints; j++)
2261 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
2262 }
2263 }
2264 fprintf(fout, " ;\n");
2265 if (via->hasViaRule()) {
2266 char *vrn, *bl, *cl, *tl;
2267 int xs, ys, xcs, ycs, xbe, ybe, xte, yte;
2268 int cr, cc, xo, yo, xbo, ybo, xto, yto;
2269 (void)via->viaRule(&vrn, &xs, &ys, &bl, &cl, &tl, &xcs,
2270 &ycs, &xbe, &ybe, &xte, &yte);
2271 fprintf(fout, "+ VIARULE '%s'\n", ignoreViaNames ? "XXX" : vrn);
2272 fprintf(fout, " + CUTSIZE %d %d\n", xs, ys);
2273 fprintf(fout, " + LAYERS %s %s %s\n", bl, cl, tl);
2274 fprintf(fout, " + CUTSPACING %d %d\n", xcs, ycs);
2275 fprintf(fout, " + ENCLOSURE %d %d %d %d\n", xbe, ybe, xte, yte);
2276 if (via->hasRowCol()) {
2277 (void)via->rowCol(&cr, &cc);
2278 fprintf(fout, " + ROWCOL %d %d\n", cr, cc);
2279 }
2280 if (via->hasOrigin()) {
2281 (void)via->origin(&xo, &yo);
2282 fprintf(fout, " + ORIGIN %d %d\n", xo, yo);
2283 }
2284 if (via->hasOffset()) {
2285 (void)via->offset(&xbo, &ybo, &xto, &yto);
2286 fprintf(fout, " + OFFSET %d %d %d %d\n", xbo, ybo, xto, yto);
2287 }
2288 if (via->hasCutPattern())
2289 fprintf(fout, " + PATTERN '%s'\n", via->cutPattern());
2290 }
2291 --numObjs;
2292 if (numObjs <= 0)
2293 fprintf(fout, "END VIAS\n");
2294 }
2295 break;
2296 case defrRegionCbkType :
2297 re = (defiRegion*)cl;
2298 fprintf(fout, "- %s ", re->name());
2299 for (i = 0; i < re->numRectangles(); i++)
2300 fprintf(fout, "%d %d %d %d \n", re->xl(i),
2301 re->yl(i), re->xh(i),
2302 re->yh(i));
2303 if (re->hasType())
2304 fprintf(fout, "+ TYPE %s\n", re->type());
2305 if (re->numProps()) {
2306 for (i = 0; i < re->numProps(); i++) {
2307 fprintf(fout, "+ PROPERTY %s %s ", re->propName(i),
2308 re->propValue(i));
2309 switch (re->propType(i)) {
2310 case 'R': fprintf(fout, "REAL ");
2311 break;
2312 case 'I': fprintf(fout, "INTEGER ");
2313 break;
2314 case 'S': fprintf(fout, "STRING ");
2315 break;
2316 case 'Q': fprintf(fout, "QUOTESTRING ");
2317 break;
2318 case 'N': fprintf(fout, "NUMBER ");
2319 break;
2320 }
2321 }
2322 }
2323 fprintf(fout, ";\n");
2324 --numObjs;
2325 if (numObjs <= 0) {
2326 fprintf(fout, "END REGIONS\n");
2327 }
2328 break;
2329 case defrGroupNameCbkType :
2330 if ((char*)cl) {
2331 fprintf(fout, "- %s", (char*)cl);
2332 }
2333 break;
2334 case defrGroupMemberCbkType :
2335 if ((char*)cl) {
2336 fprintf(fout, " %s", (char*)cl);
2337 }
2338 break;
2339 case defrComponentMaskShiftLayerCbkType :
2340 fprintf(fout, "COMPONENTMASKSHIFT ");
2341
2342 for (i = 0; i < maskShiftLayer->numMaskShiftLayers(); i++) {
2343 fprintf(fout, "%s ", maskShiftLayer->maskShiftLayer(i));
2344 }
2345 fprintf(fout, ";\n");
2346 break;
2347 case defrGroupCbkType :
2348 group = (defiGroup*)cl;
2349 if (group->hasMaxX() | group->hasMaxY()
2350 | group->hasPerim()) {
2351 fprintf(fout, "\n + SOFT ");
2352 if (group->hasPerim())
2353 fprintf(fout, "MAXHALFPERIMETER %d ",
2354 group->perim());
2355 if (group->hasMaxX())
2356 fprintf(fout, "MAXX %d ", group->maxX());
2357 if (group->hasMaxY())
2358 fprintf(fout, "MAXY %d ", group->maxY());
2359 }
2360 if (group->hasRegionName())
2361 fprintf(fout, "\n + REGION %s ", group->regionName());
2362 if (group->hasRegionBox()) {
2363 int *gxl, *gyl, *gxh, *gyh;
2364 int size;
2365 group->regionRects(&size, &gxl, &gyl, &gxh, &gyh);
2366 for (i = 0; i < size; i++)
2367 fprintf(fout, "REGION %d %d %d %d ", gxl[i], gyl[i],
2368 gxh[i], gyh[i]);
2369 }
2370 if (group->numProps()) {
2371 for (i = 0; i < group->numProps(); i++) {
2372 fprintf(fout, "\n + PROPERTY %s %s ",
2373 group->propName(i),
2374 group->propValue(i));
2375 switch (group->propType(i)) {
2376 case 'R': fprintf(fout, "REAL ");
2377 break;
2378 case 'I': fprintf(fout, "INTEGER ");
2379 break;
2380 case 'S': fprintf(fout, "STRING ");
2381 break;
2382 case 'Q': fprintf(fout, "QUOTESTRING ");
2383 break;
2384 case 'N': fprintf(fout, "NUMBER ");
2385 break;
2386 }
2387 }
2388 }
2389 fprintf(fout, " ;\n");
2390 --numObjs;
2391 if (numObjs <= 0)
2392 fprintf(fout, "END GROUPS\n");
2393 break;
2394 case defrScanchainCbkType :
2395 sc = (defiScanchain*)cl;
2396 fprintf(fout, "- %s\n", sc->name());
2397 if (sc->hasStart()) {
2398 sc->start(&a1, &b1);
2399 fprintf(fout, " + START %s %s\n", a1, b1);
2400 }
2401 if (sc->hasStop()) {
2402 sc->stop(&a1, &b1);
2403 fprintf(fout, " + STOP %s %s\n", a1, b1);
2404 }
2405 if (sc->hasCommonInPin() ||
2406 sc->hasCommonOutPin()) {
2407 fprintf(fout, " + COMMONSCANPINS ");
2408 if (sc->hasCommonInPin())
2409 fprintf(fout, " ( IN %s ) ", sc->commonInPin());
2410 if (sc->hasCommonOutPin())
2411 fprintf(fout, " ( OUT %s ) ",sc->commonOutPin());
2412 fprintf(fout, "\n");
2413 }
2414 if (sc->hasFloating()) {
2415 sc->floating(&size, &inst, &inPin, &outPin, &bits);
2416 if (size > 0)
2417 fprintf(fout, " + FLOATING\n");
2418 for (i = 0; i < size; i++) {
2419 fprintf(fout, " %s ", inst[i]);
2420 if (inPin[i])
2421 fprintf(fout, "( IN %s ) ", inPin[i]);
2422 if (outPin[i])
2423 fprintf(fout, "( OUT %s ) ", outPin[i]);
2424 if (bits[i] != -1)
2425 fprintf(fout, "( BITS %d ) ", bits[i]);
2426 fprintf(fout, "\n");
2427 }
2428 }
2429
2430 if (sc->hasOrdered()) {
2431 for (i = 0; i < sc->numOrderedLists(); i++) {
2432 sc->ordered(i, &size, &inst, &inPin, &outPin,
2433 &bits);
2434 if (size > 0)
2435 fprintf(fout, " + ORDERED\n");
2436 for (j = 0; j < size; j++) {
2437 fprintf(fout, " %s ", inst[j]);
2438 if (inPin[j])
2439 fprintf(fout, "( IN %s ) ", inPin[j]);
2440 if (outPin[j])
2441 fprintf(fout, "( OUT %s ) ", outPin[j]);
2442 if (bits[j] != -1)
2443 fprintf(fout, "( BITS %d ) ", bits[j]);
2444 fprintf(fout, "\n");
2445 }
2446 }
2447 }
2448
2449 if (sc->hasPartition()) {
2450 fprintf(fout, " + PARTITION %s ",
2451 sc->partitionName());
2452 if (sc->hasPartitionMaxBits())
2453 fprintf(fout, "MAXBITS %d ",
2454 sc->partitionMaxBits());
2455 }
2456 fprintf(fout, ";\n");
2457 --numObjs;
2458 if (numObjs <= 0)
2459 fprintf(fout, "END SCANCHAINS\n");
2460 break;
2461 case defrIOTimingCbkType :
2462 iot = (defiIOTiming*)cl;
2463 fprintf(fout, "- ( %s %s )\n", iot->inst(),
2464 iot->pin());
2465 if (iot->hasSlewRise())
2466 fprintf(fout, " + RISE SLEWRATE %g %g\n",
2467 iot->slewRiseMin(),
2468 iot->slewRiseMax());
2469 if (iot->hasSlewFall())
2470 fprintf(fout, " + FALL SLEWRATE %g %g\n",
2471 iot->slewFallMin(),
2472 iot->slewFallMax());
2473 if (iot->hasVariableRise())
2474 fprintf(fout, " + RISE VARIABLE %g %g\n",
2475 iot->variableRiseMin(),
2476 iot->variableRiseMax());
2477 if (iot->hasVariableFall())
2478 fprintf(fout, " + FALL VARIABLE %g %g\n",
2479 iot->variableFallMin(),
2480 iot->variableFallMax());
2481 if (iot->hasCapacitance())
2482 fprintf(fout, " + CAPACITANCE %g\n",
2483 iot->capacitance());
2484 if (iot->hasDriveCell()) {
2485 fprintf(fout, " + DRIVECELL %s ",
2486 iot->driveCell());
2487 if (iot->hasFrom())
2488 fprintf(fout, " FROMPIN %s ",
2489 iot->from());
2490 if (iot->hasTo())
2491 fprintf(fout, " TOPIN %s ",
2492 iot->to());
2493 if (iot->hasParallel())
2494 fprintf(fout, "PARALLEL %g",
2495 iot->parallel());
2496 fprintf(fout, "\n");
2497 }
2498 fprintf(fout, ";\n");
2499 --numObjs;
2500 if (numObjs <= 0)
2501 fprintf(fout, "END IOTIMINGS\n");
2502 break;
2503 case defrFPCCbkType :
2504 fpc = (defiFPC*)cl;
2505 fprintf(fout, "- %s ", fpc->name());
2506 if (fpc->isVertical())
2507 fprintf(fout, "VERTICAL ");
2508 if (fpc->isHorizontal())
2509 fprintf(fout, "HORIZONTAL ");
2510 if (fpc->hasAlign())
2511 fprintf(fout, "ALIGN ");
2512 if (fpc->hasMax())
2513 fprintf(fout, "%g ", fpc->alignMax());
2514 if (fpc->hasMin())
2515 fprintf(fout, "%g ", fpc->alignMin());
2516 if (fpc->hasEqual())
2517 fprintf(fout, "%g ", fpc->equal());
2518 for (i = 0; i < fpc->numParts(); i++) {
2519 fpc->getPart(i, &corner, &typ, &name);
2520 if (corner == 'B')
2521 fprintf(fout, "BOTTOMLEFT ");
2522 else
2523 fprintf(fout, "TOPRIGHT ");
2524 if (typ == 'R')
2525 fprintf(fout, "ROWS %s ", name);
2526 else
2527 fprintf(fout, "COMPS %s ", name);
2528 }
2529 fprintf(fout, ";\n");
2530 --numObjs;
2531 if (numObjs <= 0)
2532 fprintf(fout, "END FLOORPLANCONSTRAINTS\n");
2533 break;
2534 case defrTimingDisableCbkType :
2535 td = (defiTimingDisable*)cl;
2536 if (td->hasFromTo())
2537 fprintf(fout, "- FROMPIN %s %s ",
2538 td->fromInst(),
2539 td->fromPin(),
2540 td->toInst(),
2541 td->toPin());
2542 if (td->hasThru())
2543 fprintf(fout, "- THRUPIN %s %s ",
2544 td->thruInst(),
2545 td->thruPin());
2546 if (td->hasMacroFromTo())
2547 fprintf(fout, "- MACRO %s FROMPIN %s %s ",
2548 td->macroName(),
2549 td->fromPin(),
2550 td->toPin());
2551 if (td->hasMacroThru())
2552 fprintf(fout, "- MACRO %s THRUPIN %s %s ",
2553 td->macroName(),
2554 td->fromPin());
2555 fprintf(fout, ";\n");
2556 break;
2557 case defrPartitionCbkType :
2558 part = (defiPartition*)cl;
2559 fprintf(fout, "- %s ", part->name());
2560 if (part->isSetupRise() |
2561 part->isSetupFall() |
2562 part->isHoldRise() |
2563 part->isHoldFall()) {
2564 // has turnoff
2565 fprintf(fout, "TURNOFF ");
2566 if (part->isSetupRise())
2567 fprintf(fout, "SETUPRISE ");
2568 if (part->isSetupFall())
2569 fprintf(fout, "SETUPFALL ");
2570 if (part->isHoldRise())
2571 fprintf(fout, "HOLDRISE ");
2572 if (part->isHoldFall())
2573 fprintf(fout, "HOLDFALL ");
2574 }
2575 itemT = part->itemType();
2576 dir = part->direction();
2577 if (strcmp(itemT, "CLOCK") == 0) {
2578 if (dir == 'T') // toclockpin
2579 fprintf(fout, "+ TOCLOCKPIN %s %s ",
2580 part->instName(),
2581 part->pinName());
2582 if (dir == 'F') // fromclockpin
2583 fprintf(fout, "+ FROMCLOCKPIN %s %s ",
2584 part->instName(),
2585 part->pinName());
2586 if (part->hasMin())
2587 fprintf(fout, "MIN %g %g ",
2588 part->partitionMin(),
2589 part->partitionMax());
2590 if (part->hasMax())
2591 fprintf(fout, "MAX %g %g ",
2592 part->partitionMin(),
2593 part->partitionMax());
2594 fprintf(fout, "PINS ");
2595 for (i = 0; i < part->numPins(); i++)
2596 fprintf(fout, "%s ", part->pin(i));
2597 } else if (strcmp(itemT, "IO") == 0) {
2598 if (dir == 'T') // toiopin
2599 fprintf(fout, "+ TOIOPIN %s %s ",
2600 part->instName(),
2601 part->pinName());
2602 if (dir == 'F') // fromiopin
2603 fprintf(fout, "+ FROMIOPIN %s %s ",
2604 part->instName(),
2605 part->pinName());
2606 } else if (strcmp(itemT, "COMP") == 0) {
2607 if (dir == 'T') // tocomppin
2608 fprintf(fout, "+ TOCOMPPIN %s %s ",
2609 part->instName(),
2610 part->pinName());
2611 if (dir == 'F') // fromcomppin
2612 fprintf(fout, "+ FROMCOMPPIN %s %s ",
2613 part->instName(),
2614 part->pinName());
2615 }
2616 fprintf(fout, ";\n");
2617 --numObjs;
2618 if (numObjs <= 0)
2619 fprintf(fout, "END PARTITIONS\n");
2620 break;
2621
2622 case defrPinPropCbkType :
2623 pprop = (defiPinProp*)cl;
2624 if (pprop->isPin())
2625 fprintf(fout, "- PIN %s ", pprop->pinName());
2626 else
2627 fprintf(fout, "- %s %s ",
2628 pprop->instName(),
2629 pprop->pinName());
2630 fprintf(fout, ";\n");
2631 if (pprop->numProps() > 0) {
2632 for (i = 0; i < pprop->numProps(); i++) {
2633 fprintf(fout, " + PROPERTY %s %s ",
2634 pprop->propName(i),
2635 pprop->propValue(i));
2636 switch (pprop->propType(i)) {
2637 case 'R': fprintf(fout, "REAL ");
2638 break;
2639 case 'I': fprintf(fout, "INTEGER ");
2640 break;
2641 case 'S': fprintf(fout, "STRING ");
2642 break;
2643 case 'Q': fprintf(fout, "QUOTESTRING ");
2644 break;
2645 case 'N': fprintf(fout, "NUMBER ");
2646 break;
2647 }
2648 }
2649 fprintf(fout, ";\n");
2650 }
2651 --numObjs;
2652 if (numObjs <= 0)
2653 fprintf(fout, "END PINPROPERTIES\n");
2654 break;
2655 case defrBlockageCbkType :
2656 block = (defiBlockage*)cl;
2657 if (testDebugPrint) {
2658 block->print(fout);
2659 } else {
2660 if (block->hasLayer()) {
2661 fprintf(fout, "- LAYER %s\n", block->layerName());
2662 if (block->hasComponent())
2663 fprintf(fout, " + COMPONENT %s\n",
2664 block->layerComponentName());
2665 if (block->hasSlots())
2666 fprintf(fout, " + SLOTS\n");
2667 if (block->hasFills())
2668 fprintf(fout, " + FILLS\n");
2669 if (block->hasPushdown())
2670 fprintf(fout, " + PUSHDOWN\n");
2671 if (block->hasExceptpgnet())
2672 fprintf(fout, " + EXCEPTPGNET\n");
2673 if (block->hasMask())
2674 fprintf(fout, " + MASK %d\n", block->mask());
2675 if (block->hasSpacing())
2676 fprintf(fout, " + SPACING %d\n",
2677 block->minSpacing());
2678 if (block->hasDesignRuleWidth())
2679 fprintf(fout, " + DESIGNRULEWIDTH %d\n",
2680 block->designRuleWidth());
2681 }
2682 else if (block->hasPlacement()) {
2683 fprintf(fout, "- PLACEMENT\n");
2684 if (block->hasSoft())
2685 fprintf(fout, " + SOFT\n");
2686 if (block->hasPartial())
2687 fprintf(fout, " + PARTIAL %g\n",
2688 block->placementMaxDensity());
2689 if (block->hasComponent())
2690 fprintf(fout, " + COMPONENT %s\n",
2691 block->placementComponentName());
2692 if (block->hasPushdown())
2693 fprintf(fout, " + PUSHDOWN\n");
2694 }
2695
2696 for (i = 0; i < block->numRectangles(); i++) {
2697 fprintf(fout, " RECT %d %d %d %d\n",
2698 block->xl(i), block->yl(i),
2699 block->xh(i), block->yh(i));
2700 }
2701
2702 for (i = 0; i < block->numPolygons(); i++) {
2703 fprintf(fout, " POLYGON ");
2704 points = block->getPolygon(i);
2705 for (j = 0; j < points.numPoints; j++)
2706 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
2707 fprintf(fout, "\n");
2708 }
2709 fprintf(fout, ";\n");
2710 --numObjs;
2711 if (numObjs <= 0)
2712 fprintf(fout, "END BLOCKAGES\n");
2713 }
2714 break;
2715 case defrSlotCbkType :
2716 slots = (defiSlot*)cl;
2717 if (slots->hasLayer())
2718 fprintf(fout, "- LAYER %s\n", slots->layerName());
2719
2720 for (i = 0; i < slots->numRectangles(); i++) {
2721 fprintf(fout, " RECT %d %d %d %d\n",
2722 slots->xl(i), slots->yl(i),
2723 slots->xh(i), slots->yh(i));
2724 }
2725 for (i = 0; i < slots->numPolygons(); i++) {
2726 fprintf(fout, " POLYGON ");
2727 points = slots->getPolygon(i);
2728 for (j = 0; j < points.numPoints; j++)
2729 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
2730 fprintf(fout, ";\n");
2731 }
2732 fprintf(fout, ";\n");
2733 --numObjs;
2734 if (numObjs <= 0)
2735 fprintf(fout, "END SLOTS\n");
2736 break;
2737 case defrFillCbkType :
2738 fills = (defiFill*)cl;
2739 if (testDebugPrint) {
2740 fills->print(fout);
2741 } else {
2742 if (fills->hasLayer()) {
2743 fprintf(fout, "- LAYER %s", fills->layerName());
2744 if (fills->layerMask()) {
2745 fprintf(fout, " + MASK %d", fills->layerMask());
2746 }
2747 if (fills->hasLayerOpc())
2748 fprintf(fout, " + OPC");
2749 fprintf(fout, "\n");
2750
2751 for (i = 0; i < fills->numRectangles(); i++) {
2752 fprintf(fout, " RECT %d %d %d %d\n",
2753 fills->xl(i), fills->yl(i),
2754 fills->xh(i), fills->yh(i));
2755 }
2756 for (i = 0; i < fills->numPolygons(); i++) {
2757 fprintf(fout, " POLYGON ");
2758 points = fills->getPolygon(i);
2759 for (j = 0; j < points.numPoints; j++)
2760 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
2761 fprintf(fout, ";\n");
2762 }
2763 fprintf(fout, ";\n");
2764 }
2765 --numObjs;
2766 if (fills->hasVia()) {
2767 fprintf(fout, "- VIA %s", fills->viaName());
2768 if (fills->viaTopMask() || fills->viaCutMask()
2769 || fills->viaBottomMask()) {
2770 fprintf(fout, " + MASK %d%d%d",
2771 fills->viaTopMask(),
2772 fills->viaCutMask(),
2773 fills->viaBottomMask());
2774 }
2775 if (fills->hasViaOpc())
2776 fprintf(fout, " + OPC");
2777 fprintf(fout, "\n");
2778
2779 for (i = 0; i < fills->numViaPts(); i++) {
2780 points = fills->getViaPts(i);
2781 for (j = 0; j < points.numPoints; j++)
2782 fprintf(fout, " %d %d", points.x[j], points.y[j]);
2783 fprintf(fout, ";\n");
2784 }
2785 fprintf(fout, ";\n");
2786 }
2787 if (numObjs <= 0)
2788 fprintf(fout, "END FILLS\n");
2789 }
2790 break;
2791 case defrStylesCbkType :
2792 // defiPoints points;
2793 styles = (defiStyles*)cl;
2794 fprintf(fout, "- STYLE %d ", styles->style());
2795 points = styles->getPolygon();
2796 for (j = 0; j < points.numPoints; j++)
2797 fprintf(fout, "%d %d ", points.x[j], points.y[j]);
2798 fprintf(fout, ";\n");
2799 --numObjs;
2800 if (numObjs <= 0)
2801 fprintf(fout, "END STYLES\n");
2802 break;
2803
2804 default: fprintf(fout, "BOGUS callback to cls.\n"); return 1;
2805 }
2806 return 0;
2807 }
2808
2809
dn(defrCallbackType_e c,const char * h,defiUserData ud)2810 int dn(defrCallbackType_e c, const char* h, defiUserData ud) {
2811 checkType(c);
2812 if (ud != userData) dataError();
2813 fprintf(fout, "DIVIDERCHAR \"%s\" ;\n",h);
2814 return 0;
2815 }
2816
2817
ext(defrCallbackType_e t,const char * c,defiUserData ud)2818 int ext(defrCallbackType_e t, const char* c, defiUserData ud) {
2819 char* name;
2820
2821 checkType(t);
2822 if (ud != userData) dataError();
2823
2824 switch (t) {
2825 case defrNetExtCbkType : name = address("net"); break;
2826 case defrComponentExtCbkType : name = address("component"); break;
2827 case defrPinExtCbkType : name = address("pin"); break;
2828 case defrViaExtCbkType : name = address("via"); break;
2829 case defrNetConnectionExtCbkType : name = address("net connection"); break;
2830 case defrGroupExtCbkType : name = address("group"); break;
2831 case defrScanChainExtCbkType : name = address("scanchain"); break;
2832 case defrIoTimingsExtCbkType : name = address("io timing"); break;
2833 case defrPartitionsExtCbkType : name = address("partition"); break;
2834 default: name = address("BOGUS"); return 1;
2835 }
2836 fprintf(fout, " %s extension %s\n", name, c);
2837 return 0;
2838 }
2839
extension(defrCallbackType_e c,const char * extsn,defiUserData ud)2840 int extension(defrCallbackType_e c, const char* extsn, defiUserData ud) {
2841 checkType(c);
2842 if (ud != userData) dataError();
2843 fprintf(fout, "BEGINEXT %s\n", extsn);
2844 return 0;
2845 }
2846
mallocCB(size_t size)2847 void* mallocCB(size_t size) {
2848 return malloc(size);
2849 }
2850
reallocCB(void * name,size_t size)2851 void* reallocCB(void* name, size_t size) {
2852 return realloc(name, size);
2853 }
2854
freeCB(void * name)2855 void freeCB(void* name) {
2856 free(name);
2857 return;
2858 }
2859
2860
2861 BEGIN_LEFDEF_PARSER_NAMESPACE
2862 extern long long nlines;
2863 END_LEFDEF_PARSER_NAMESPACE
2864 static int ccr1131444 = 0;
2865
lineNumberCB(long long lineNo)2866 void lineNumberCB(long long lineNo) {
2867
2868 // The CCR 1131444 tests ability of the DEF parser to count
2869 // input line numbers out of 32-bit int range. On the first callback
2870 // call 10G lines will be added to line counter. It should be
2871 // reflected in output.
2872 if (ccr1131444) {
2873 lineNo += 10000000000LL;
2874 defrSetNLines(lineNo);
2875 ccr1131444 = 0;
2876 }
2877
2878 fprintf(fout, "Parsed %lld number of lines!!\n", lineNo);
2879 }
2880
unUsedCB(defrCallbackType_e,void *,defiUserData)2881 int unUsedCB(defrCallbackType_e, void*, defiUserData) {
2882 fprintf(fout, "This callback is not used.\n");
2883 return 0;
2884 }
2885
printWarning(const char * str)2886 void printWarning(const char *str)
2887 {
2888 fprintf(stderr, "%s\n", str);
2889 }
2890
main(int argc,char ** argv)2891 int main(int argc, char** argv) {
2892 int num = 99;
2893 char* inFile[6];
2894 char* outFile;
2895 FILE* f;
2896 int res;
2897 int noCalls = 0;
2898 // long start_mem;
2899 int retStr = 0;
2900 int numInFile = 0;
2901 int fileCt = 0;
2902 int test1 = 0;
2903 int test2 = 0;
2904 int noNetCb = 0;
2905 int ccr749853 = 0;
2906 int line_num_print_interval = 50;
2907
2908 #ifdef WIN32
2909 // Enable two-digit exponent format
2910 _set_output_format(_TWO_DIGIT_EXPONENT);
2911 #endif
2912
2913 // start_mem = (long)sbrk(0);
2914
2915 strcpy(defaultName, "def.in");
2916 strcpy(defaultOut, "list");
2917 inFile[0] = defaultName;
2918 outFile = defaultOut;
2919 fout = stdout;
2920 userData = (void*) 0x01020304;
2921 argc--;
2922 argv++;
2923
2924 if (argc == 0) {
2925 fprintf(stderr, "Type 'defrw --help' for the help.\n");
2926 return 2;
2927 }
2928
2929 while (argc--) {
2930 if (strcmp(*argv, "-d") == 0) {
2931 argv++;
2932 argc--;
2933 sscanf(*argv, "%d", &num);
2934 defiSetDebug(num, 1);
2935 } else if (strcmp(*argv, "-nc") == 0) {
2936 noCalls = 1;
2937 } else if (strcmp(*argv, "-o") == 0) {
2938 argv++;
2939 argc--;
2940 outFile = *argv;
2941 if ((fout = fopen(outFile, "w")) == 0) {
2942 fprintf(stderr, "ERROR: could not open output file\n");
2943 return 2;
2944 }
2945 } else if (strcmp(*argv, "-verStr") == 0) {
2946 /* New to set the version callback routine to return a string */
2947 /* instead of double. */
2948 retStr = 1;
2949 } else if (strcmp(*argv, "-i") == 0) {
2950 argv++;
2951 argc--;
2952 line_num_print_interval = atoi(*argv);
2953 } else if (strcmp(*argv, "-test1") == 0) {
2954 test1 = 1;
2955 } else if (strcmp(*argv, "-test2") == 0) {
2956 test2 = 1;
2957 } else if (strcmp(*argv, "-noNet") == 0) {
2958 noNetCb = 1;
2959 } else if (strcmp(*argv, "-ccr749853") == 0) {
2960 ccr749853 = 1;
2961 } else if (strcmp(*argv, "-ccr1131444") == 0) {
2962 ccr1131444 = 1;
2963 } else if (strcmp(*argv, "-testDebugPrint") == 0) {
2964 testDebugPrint = 1;
2965 } else if (strcmp(*argv, "-sessionless") == 0) {
2966 isSessionless = 1;
2967 } else if (strcmp(*argv, "-ignoreRowNames") == 0) {
2968 ignoreRowNames = 1;
2969 } else if (strcmp(*argv, "-ignoreViaNames") == 0) {
2970 ignoreViaNames = 1;
2971 } else if (argv[0][0] != '-') {
2972 if (numInFile >= 6) {
2973 fprintf(stderr, "ERROR: too many input files, max = 6.\n");
2974 return 2;
2975 }
2976 inFile[numInFile++] = *argv;
2977 } else if ((strcmp(*argv, "-h") == 0) || (strcmp(*argv, "--help") == 0)) {
2978 fprintf(stderr, "Usage: defrw (<option>|<file>)* \n");
2979 fprintf(stderr, "Files:\n");
2980 fprintf(stderr, "\tupto 6 DEF files many be supplied.\n");
2981 fprintf(stderr, "\tif <defFileName> is set to 'STDIN' - takes data from stdin.\n");
2982 fprintf(stderr, "Options:\n");
2983 fprintf(stderr, "\t-i <num_lines> -- sets processing msg interval (default: 50 lines).\n");
2984 fprintf(stderr, "\t-nc -- no functional callbacks will be called.\n");
2985 fprintf(stderr, "\t-o <out_file> -- write output to the file.\n");
2986 fprintf(stderr, "\t-ignoreRowNames -- don't output row names.\n");
2987 fprintf(stderr, "\t-ignoreViaNames -- don't output via names.\n");
2988 return 2;
2989 } else if (strcmp(*argv, "-setSNetWireCbk") == 0) {
2990 setSNetWireCbk = 1;
2991 } else {
2992 fprintf(stderr, "ERROR: Illegal command line option: '%s'\n", *argv);
2993 return 2;
2994 }
2995
2996 argv++;
2997 }
2998
2999 //defrSetLogFunction(myLogFunction);
3000 //defrSetWarningLogFunction(myWarningLogFunction);
3001
3002 if (isSessionless) {
3003 defrInitSession(0);
3004 defrSetLongLineNumberFunction(lineNumberCB);
3005 defrSetDeltaNumberLines(line_num_print_interval);
3006 }
3007
3008 defrInitSession(isSessionless ? 0 : 1);
3009
3010 if (noCalls == 0) {
3011
3012 defrSetWarningLogFunction(printWarning);
3013
3014
3015 defrSetUserData((void*)3);
3016 defrSetDesignCbk(dname);
3017 defrSetTechnologyCbk(tname);
3018 defrSetExtensionCbk(extension);
3019 defrSetDesignEndCbk(done);
3020 defrSetPropDefStartCbk(propstart);
3021 defrSetPropCbk(prop);
3022 defrSetPropDefEndCbk(propend);
3023 /* Test for CCR 766289*/
3024 if (!noNetCb)
3025 defrSetNetCbk(netf);
3026 defrSetNetNameCbk(netNamef);
3027 defrSetNetNonDefaultRuleCbk(nondefRulef);
3028 defrSetNetSubnetNameCbk(subnetNamef);
3029 defrSetNetPartialPathCbk(netpath);
3030 defrSetSNetCbk(snetf);
3031 defrSetSNetPartialPathCbk(snetpath);
3032 if (setSNetWireCbk)
3033 defrSetSNetWireCbk(snetwire);
3034 defrSetComponentMaskShiftLayerCbk(compMSL);
3035 defrSetComponentCbk(compf);
3036 defrSetAddPathToNet();
3037 defrSetHistoryCbk(hist);
3038 defrSetConstraintCbk(constraint);
3039 defrSetAssertionCbk(constraint);
3040 defrSetArrayNameCbk(an);
3041 defrSetFloorPlanNameCbk(fn);
3042 defrSetDividerCbk(dn);
3043 defrSetBusBitCbk(bbn);
3044 defrSetNonDefaultCbk(ndr);
3045
3046 defrSetAssertionsStartCbk(constraintst);
3047 defrSetConstraintsStartCbk(constraintst);
3048 defrSetComponentStartCbk(cs);
3049 defrSetPinPropStartCbk(cs);
3050 defrSetNetStartCbk(cs);
3051 defrSetStartPinsCbk(cs);
3052 defrSetViaStartCbk(cs);
3053 defrSetRegionStartCbk(cs);
3054 defrSetSNetStartCbk(cs);
3055 defrSetGroupsStartCbk(cs);
3056 defrSetScanchainsStartCbk(cs);
3057 defrSetIOTimingsStartCbk(cs);
3058 defrSetFPCStartCbk(cs);
3059 defrSetTimingDisablesStartCbk(cs);
3060 defrSetPartitionsStartCbk(cs);
3061 defrSetBlockageStartCbk(cs);
3062 defrSetSlotStartCbk(cs);
3063 defrSetFillStartCbk(cs);
3064 defrSetNonDefaultStartCbk(cs);
3065 defrSetStylesStartCbk(cs);
3066
3067 // All of the extensions point to the same function.
3068 defrSetNetExtCbk(ext);
3069 defrSetComponentExtCbk(ext);
3070 defrSetPinExtCbk(ext);
3071 defrSetViaExtCbk(ext);
3072 defrSetNetConnectionExtCbk(ext);
3073 defrSetGroupExtCbk(ext);
3074 defrSetScanChainExtCbk(ext);
3075 defrSetIoTimingsExtCbk(ext);
3076 defrSetPartitionsExtCbk(ext);
3077
3078 defrSetUnitsCbk(units);
3079 if (!retStr)
3080 defrSetVersionCbk(vers);
3081 else
3082 defrSetVersionStrCbk(versStr);
3083 defrSetCaseSensitiveCbk(casesens);
3084
3085 // The following calls are an example of using one function "cls"
3086 // to be the callback for many DIFFERENT types of constructs.
3087 // We have to cast the function type to meet the requirements
3088 // of each different set function.
3089 defrSetSiteCbk((defrSiteCbkFnType)cls);
3090 defrSetCanplaceCbk((defrSiteCbkFnType)cls);
3091 defrSetCannotOccupyCbk((defrSiteCbkFnType)cls);
3092 defrSetDieAreaCbk((defrBoxCbkFnType)cls);
3093 defrSetPinCapCbk((defrPinCapCbkFnType)cls);
3094 defrSetPinCbk((defrPinCbkFnType)cls);
3095 defrSetPinPropCbk((defrPinPropCbkFnType)cls);
3096 defrSetDefaultCapCbk((defrIntegerCbkFnType)cls);
3097 defrSetRowCbk((defrRowCbkFnType)cls);
3098 defrSetTrackCbk((defrTrackCbkFnType)cls);
3099 defrSetGcellGridCbk((defrGcellGridCbkFnType)cls);
3100 defrSetViaCbk((defrViaCbkFnType)cls);
3101 defrSetRegionCbk((defrRegionCbkFnType)cls);
3102 defrSetGroupNameCbk((defrStringCbkFnType)cls);
3103 defrSetGroupMemberCbk((defrStringCbkFnType)cls);
3104 defrSetGroupCbk((defrGroupCbkFnType)cls);
3105 defrSetScanchainCbk((defrScanchainCbkFnType)cls);
3106 defrSetIOTimingCbk((defrIOTimingCbkFnType)cls);
3107 defrSetFPCCbk((defrFPCCbkFnType)cls);
3108 defrSetTimingDisableCbk((defrTimingDisableCbkFnType)cls);
3109 defrSetPartitionCbk((defrPartitionCbkFnType)cls);
3110 defrSetBlockageCbk((defrBlockageCbkFnType)cls);
3111 defrSetSlotCbk((defrSlotCbkFnType)cls);
3112 defrSetFillCbk((defrFillCbkFnType)cls);
3113 defrSetStylesCbk((defrStylesCbkFnType)cls);
3114
3115 defrSetAssertionsEndCbk(endfunc);
3116 defrSetComponentEndCbk(endfunc);
3117 defrSetConstraintsEndCbk(endfunc);
3118 defrSetNetEndCbk(endfunc);
3119 defrSetFPCEndCbk(endfunc);
3120 defrSetFPCEndCbk(endfunc);
3121 defrSetGroupsEndCbk(endfunc);
3122 defrSetIOTimingsEndCbk(endfunc);
3123 defrSetNetEndCbk(endfunc);
3124 defrSetPartitionsEndCbk(endfunc);
3125 defrSetRegionEndCbk(endfunc);
3126 defrSetSNetEndCbk(endfunc);
3127 defrSetScanchainsEndCbk(endfunc);
3128 defrSetPinEndCbk(endfunc);
3129 defrSetTimingDisablesEndCbk(endfunc);
3130 defrSetViaEndCbk(endfunc);
3131 defrSetPinPropEndCbk(endfunc);
3132 defrSetBlockageEndCbk(endfunc);
3133 defrSetSlotEndCbk(endfunc);
3134 defrSetFillEndCbk(endfunc);
3135 defrSetNonDefaultEndCbk(endfunc);
3136 defrSetStylesEndCbk(endfunc);
3137
3138 defrSetMallocFunction(mallocCB);
3139 defrSetReallocFunction(reallocCB);
3140 defrSetFreeFunction(freeCB);
3141
3142 //defrSetRegisterUnusedCallbacks();
3143
3144 // Testing to set the number of warnings
3145 defrSetAssertionWarnings(3);
3146 defrSetBlockageWarnings(3);
3147 defrSetCaseSensitiveWarnings(3);
3148 defrSetComponentWarnings(3);
3149 defrSetConstraintWarnings(0);
3150 defrSetDefaultCapWarnings(3);
3151 defrSetGcellGridWarnings(3);
3152 defrSetIOTimingWarnings(3);
3153 defrSetNetWarnings(3);
3154 defrSetNonDefaultWarnings(3);
3155 defrSetPinExtWarnings(3);
3156 defrSetPinWarnings(3);
3157 defrSetRegionWarnings(3);
3158 defrSetRowWarnings(3);
3159 defrSetScanchainWarnings(3);
3160 defrSetSNetWarnings(3);
3161 defrSetStylesWarnings(3);
3162 defrSetTrackWarnings(3);
3163 defrSetUnitsWarnings(3);
3164 defrSetVersionWarnings(3);
3165 defrSetViaWarnings(3);
3166 }
3167
3168 if (! isSessionless) {
3169 defrSetLongLineNumberFunction(lineNumberCB);
3170 defrSetDeltaNumberLines(line_num_print_interval);
3171 }
3172
3173 (void) defrSetOpenLogFileAppend();
3174
3175 if (ccr749853) {
3176 defrSetTotalMsgLimit (5);
3177 defrSetLimitPerMsg (6008, 2);
3178
3179 }
3180
3181 if (test1) { // for special tests
3182 for (fileCt = 0; fileCt < numInFile; fileCt++) {
3183 if ((f = fopen(inFile[fileCt],"r")) == 0) {
3184 fprintf(stderr,"Couldn't open input file '%s'\n", inFile[fileCt]);
3185 return(2);
3186 }
3187 // Set case sensitive to 0 to start with, in History & PropertyDefinition
3188 // reset it to 1.
3189 res = defrRead(f, inFile[fileCt], userData, 1);
3190
3191 if (res)
3192 fprintf(stderr, "Reader returns bad status.\n", inFile[fileCt]);
3193
3194 (void)defrPrintUnusedCallbacks(fout);
3195 (void)defrReleaseNResetMemory();
3196 (void)defrUnsetNonDefaultCbk();
3197 (void)defrUnsetNonDefaultStartCbk();
3198 (void)defrUnsetNonDefaultEndCbk();
3199 }
3200 }
3201 else if (test2) { // for special tests
3202 // this test is design to test the 3 APIs, defrDisableParserMsgs,
3203 // defrEnableParserMsgs & defrEnableAllMsgs
3204 // It uses the file ccr523879.def. This file will parser 3 times
3205 // 1st it will have defrDisableParserMsgs set to both 7010 & 7016
3206 // 2nd will enable 7016 by calling defrEnableParserMsgs
3207 // 3rd enable all msgs by call defrEnableAllMsgs
3208
3209 int nMsgs = 2;
3210 int dMsgs[2];
3211
3212 for (fileCt = 0; fileCt < numInFile; fileCt++) {
3213 if (fileCt == 0) {
3214 dMsgs[0] = 7010;
3215 dMsgs[1] = 7016;
3216 defrDisableParserMsgs (2, (int*)dMsgs);
3217 } else if (fileCt == 1) {
3218 dMsgs[0] = 7016;
3219 defrEnableParserMsgs (1, (int*)dMsgs);
3220 } else
3221 defrEnableAllMsgs();
3222
3223 if ((f = fopen(inFile[fileCt],"r")) == 0) {
3224 fprintf(stderr,"Couldn't open input file '%s'\n", inFile[fileCt]);
3225 return(2);
3226 }
3227
3228 res = defrRead(f, inFile[fileCt], userData, 1);
3229
3230 if (res)
3231 fprintf(stderr, "Reader returns bad status.\n", inFile[fileCt]);
3232
3233 (void)defrPrintUnusedCallbacks(fout);
3234 (void)defrReleaseNResetMemory();
3235 (void)defrUnsetNonDefaultCbk();
3236 (void)defrUnsetNonDefaultStartCbk();
3237 (void)defrUnsetNonDefaultEndCbk();
3238 }
3239 } else {
3240 for (fileCt = 0; fileCt < numInFile; fileCt++) {
3241 if (strcmp(inFile[fileCt], "STDIN") == 0) {
3242 f = stdin;
3243 } else if ((f = fopen(inFile[fileCt],"r")) == 0) {
3244 fprintf(stderr,"Couldn't open input file '%s'\n", inFile[fileCt]);
3245 return(2);
3246 }
3247 // Set case sensitive to 0 to start with, in History & PropertyDefinition
3248 // reset it to 1.
3249
3250 res = defrRead(f, inFile[fileCt], userData, 1);
3251
3252 if (res)
3253 fprintf(stderr, "Reader returns bad status.\n", inFile[fileCt]);
3254
3255 // Testing the aliases API.
3256 defrAddAlias ("alias1", "aliasValue1", 1);
3257
3258 defiAlias_itr aliasStore;
3259 const char *alias1Value = NULL;
3260
3261 while (aliasStore.Next()) {
3262 if (strcmp(aliasStore.Key(), "alias1") == 0) {
3263 alias1Value = aliasStore.Data();
3264 }
3265 }
3266
3267 if (!alias1Value || strcmp(alias1Value, "aliasValue1")) {
3268 fprintf(stderr, "ERROR: Aliases don't work\n");
3269 }
3270
3271 (void)defrPrintUnusedCallbacks(fout);
3272 (void)defrReleaseNResetMemory();
3273 }
3274 (void)defrUnsetCallbacks();
3275 (void)defrSetUnusedCallbacks(unUsedCB);
3276 }
3277
3278 // Unset all the callbacks
3279 defrUnsetArrayNameCbk ();
3280 defrUnsetAssertionCbk ();
3281 defrUnsetAssertionsStartCbk ();
3282 defrUnsetAssertionsEndCbk ();
3283 defrUnsetBlockageCbk ();
3284 defrUnsetBlockageStartCbk ();
3285 defrUnsetBlockageEndCbk ();
3286 defrUnsetBusBitCbk ();
3287 defrUnsetCannotOccupyCbk ();
3288 defrUnsetCanplaceCbk ();
3289 defrUnsetCaseSensitiveCbk ();
3290 defrUnsetComponentCbk ();
3291 defrUnsetComponentExtCbk ();
3292 defrUnsetComponentStartCbk ();
3293 defrUnsetComponentEndCbk ();
3294 defrUnsetConstraintCbk ();
3295 defrUnsetConstraintsStartCbk ();
3296 defrUnsetConstraintsEndCbk ();
3297 defrUnsetDefaultCapCbk ();
3298 defrUnsetDesignCbk ();
3299 defrUnsetDesignEndCbk ();
3300 defrUnsetDieAreaCbk ();
3301 defrUnsetDividerCbk ();
3302 defrUnsetExtensionCbk ();
3303 defrUnsetFillCbk ();
3304 defrUnsetFillStartCbk ();
3305 defrUnsetFillEndCbk ();
3306 defrUnsetFPCCbk ();
3307 defrUnsetFPCStartCbk ();
3308 defrUnsetFPCEndCbk ();
3309 defrUnsetFloorPlanNameCbk ();
3310 defrUnsetGcellGridCbk ();
3311 defrUnsetGroupCbk ();
3312 defrUnsetGroupExtCbk ();
3313 defrUnsetGroupMemberCbk ();
3314 defrUnsetComponentMaskShiftLayerCbk ();
3315 defrUnsetGroupNameCbk ();
3316 defrUnsetGroupsStartCbk ();
3317 defrUnsetGroupsEndCbk ();
3318 defrUnsetHistoryCbk ();
3319 defrUnsetIOTimingCbk ();
3320 defrUnsetIOTimingsStartCbk ();
3321 defrUnsetIOTimingsEndCbk ();
3322 defrUnsetIOTimingsExtCbk ();
3323 defrUnsetNetCbk ();
3324 defrUnsetNetNameCbk ();
3325 defrUnsetNetNonDefaultRuleCbk ();
3326 defrUnsetNetConnectionExtCbk ();
3327 defrUnsetNetExtCbk ();
3328 defrUnsetNetPartialPathCbk ();
3329 defrUnsetNetSubnetNameCbk ();
3330 defrUnsetNetStartCbk ();
3331 defrUnsetNetEndCbk ();
3332 defrUnsetNonDefaultCbk ();
3333 defrUnsetNonDefaultStartCbk ();
3334 defrUnsetNonDefaultEndCbk ();
3335 defrUnsetPartitionCbk ();
3336 defrUnsetPartitionsExtCbk ();
3337 defrUnsetPartitionsStartCbk ();
3338 defrUnsetPartitionsEndCbk ();
3339 defrUnsetPathCbk ();
3340 defrUnsetPinCapCbk ();
3341 defrUnsetPinCbk ();
3342 defrUnsetPinEndCbk ();
3343 defrUnsetPinExtCbk ();
3344 defrUnsetPinPropCbk ();
3345 defrUnsetPinPropStartCbk ();
3346 defrUnsetPinPropEndCbk ();
3347 defrUnsetPropCbk ();
3348 defrUnsetPropDefEndCbk ();
3349 defrUnsetPropDefStartCbk ();
3350 defrUnsetRegionCbk ();
3351 defrUnsetRegionStartCbk ();
3352 defrUnsetRegionEndCbk ();
3353 defrUnsetRowCbk ();
3354 defrUnsetScanChainExtCbk ();
3355 defrUnsetScanchainCbk ();
3356 defrUnsetScanchainsStartCbk ();
3357 defrUnsetScanchainsEndCbk ();
3358 defrUnsetSiteCbk ();
3359 defrUnsetSlotCbk ();
3360 defrUnsetSlotStartCbk ();
3361 defrUnsetSlotEndCbk ();
3362 defrUnsetSNetWireCbk ();
3363 defrUnsetSNetCbk ();
3364 defrUnsetSNetStartCbk ();
3365 defrUnsetSNetEndCbk ();
3366 defrUnsetSNetPartialPathCbk ();
3367 defrUnsetStartPinsCbk ();
3368 defrUnsetStylesCbk ();
3369 defrUnsetStylesStartCbk ();
3370 defrUnsetStylesEndCbk ();
3371 defrUnsetTechnologyCbk ();
3372 defrUnsetTimingDisableCbk ();
3373 defrUnsetTimingDisablesStartCbk ();
3374 defrUnsetTimingDisablesEndCbk ();
3375 defrUnsetTrackCbk ();
3376 defrUnsetUnitsCbk ();
3377 defrUnsetVersionCbk ();
3378 defrUnsetVersionStrCbk ();
3379 defrUnsetViaCbk ();
3380 defrUnsetViaExtCbk ();
3381 defrUnsetViaStartCbk ();
3382 defrUnsetViaEndCbk ();
3383
3384 fclose(fout);
3385
3386 // Release allocated singleton data.
3387 defrClear();
3388
3389 return res;
3390 }
3391
3392