1 // *****************************************************************************
2 // *****************************************************************************
3 // Copyright 2013-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: icftcm $
24 // $Revision: #2 $
25 // $Date: 2017/06/19 $
26 // $State: $
27 // *****************************************************************************
28 // *****************************************************************************
29
30 #include <string.h>
31 #include <stdlib.h>
32 #include "defiNet.hpp"
33 #include "defiPath.hpp"
34 #include "defiDebug.hpp"
35 #include "lex.h"
36 #include "defiUtil.hpp"
37
38 BEGIN_LEFDEF_PARSER_NAMESPACE
39
40 #define maxLimit 65536
41
42 ////////////////////////////////////////////////////
43 ////////////////////////////////////////////////////
44 //
45 // defiWire
46 //
47 ////////////////////////////////////////////////////
48 ////////////////////////////////////////////////////
49
50
defiWire(defrData * data)51 defiWire::defiWire(defrData *data)
52 : defData(data)
53 {
54 wireShieldName_ = 0;
55 type_ = 0;
56 numPaths_ = 0;
57 pathsAllocated_ = 0;
58 paths_ = 0;
59 }
60
61
Init(const char * type,const char * wireShieldName)62 void defiWire::Init(const char* type, const char* wireShieldName) {
63 int len = strlen(type) + 1;
64 type_ = (char*)malloc(len);
65 strcpy(type_, defData->DEFCASE(type));
66 if (wireShieldName) {
67 wireShieldName_ = (char*)malloc(strlen(wireShieldName)+1);
68 strcpy(wireShieldName_, wireShieldName);
69 } else
70 wireShieldName_ = 0;
71 numPaths_ = 0;
72 pathsAllocated_ = 0;
73 paths_ = 0;
74 }
75
76
Destroy()77 void defiWire::Destroy() {
78 clear();
79 }
80
~defiWire()81 defiWire::~defiWire() {
82 Destroy();
83 }
84
DEF_COPY_CONSTRUCTOR_C(defiWire)85 DEF_COPY_CONSTRUCTOR_C( defiWire ) {
86 type_ = 0;
87 wireShieldName_ = 0;
88
89 // defData = NULL;
90 DEF_COPY_FUNC ( defData );
91 DEF_MALLOC_FUNC( type_, char, sizeof(char) * (strlen(prev.type_) +1));
92 DEF_MALLOC_FUNC( wireShieldName_, char, sizeof(char) * (strlen(prev.wireShieldName_) +1));
93 DEF_COPY_FUNC( numPaths_ );
94 DEF_COPY_FUNC( pathsAllocated_ );
95
96 // DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
97 if( prev.paths_ ) {
98 paths_ = new defiPath*[numPaths_];
99
100 for(int i=0; i<numPaths_; i++) {
101 if( prev.paths_[i] ) {
102 // paths_[i] = new defiPath(defData);
103 paths_[i] = new defiPath(*prev.paths_[i]);
104 // paths_[i] = prev.paths_[i];
105 }
106 else {
107 paths_[i] = 0;
108 }
109 }
110 }
111 else {
112 paths_ = 0;
113 }
114 }
115
DEF_ASSIGN_OPERATOR_C(defiWire)116 DEF_ASSIGN_OPERATOR_C( defiWire ) {
117 CHECK_SELF_ASSIGN
118 type_ = 0;
119 wireShieldName_ = 0;
120
121 // defData = NULL;
122 DEF_COPY_FUNC( defData );
123 DEF_MALLOC_FUNC( type_, char, sizeof(char) * (strlen(prev.type_) +1));
124 DEF_MALLOC_FUNC( wireShieldName_, char, sizeof(char) * (strlen(prev.wireShieldName_) +1));
125 DEF_COPY_FUNC( numPaths_ );
126 DEF_COPY_FUNC( pathsAllocated_ );
127
128 // DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
129
130 if( prev.paths_ ) {
131 paths_ = new defiPath*[numPaths_];
132
133 for(int i=0; i<numPaths_; i++) {
134 if( prev.paths_[i] ) {
135 // paths_[i] = new defiPath(defData);
136 paths_[i] = new defiPath(*prev.paths_[i]);
137 // paths_[i] = prev.paths_[i];
138 }
139 else {
140 paths_[i] = 0;
141 }
142 }
143 }
144 else {
145 paths_ = 0;
146 }
147
148 return *this;
149 }
150
151
152
addPath(defiPath * p,int reset,int netOsnet,int * needCbk)153 void defiWire::addPath(defiPath* p, int reset, int netOsnet, int *needCbk) {
154 int i;
155 size_t incNumber;
156
157 if (reset) {
158 for (i = 0; i < numPaths_; i++) {
159 delete paths_[i];
160 }
161 numPaths_ = 0;
162 }
163 if (numPaths_ >= pathsAllocated_) {
164 // 6/17/2003 - don't want to allocate too large memory just in case
165 // a net has many wires with only 1 or 2 paths
166
167 if (pathsAllocated_ <= maxLimit) {
168 incNumber = pathsAllocated_*2;
169 if (incNumber > maxLimit) {
170 incNumber = pathsAllocated_ + maxLimit;
171 }
172 } else {
173 incNumber = pathsAllocated_ + maxLimit;
174 }
175
176 switch (netOsnet) {
177 case 2:
178 bumpPaths(
179 pathsAllocated_ ? incNumber : 1000);
180 break;
181 default:
182 bumpPaths(
183 pathsAllocated_ ? incNumber : 8);
184 break;
185 }
186 }
187
188 paths_[numPaths_++] = new defiPath(p);
189
190 if (numPaths_ == pathsAllocated_)
191 *needCbk = 1; // pre-warn the parser it needs to realloc next time
192 }
193
194
clear()195 void defiWire::clear() {
196 int i;
197
198 if (type_) {
199 free(type_);
200 type_ = 0;
201 }
202
203 if (wireShieldName_) {
204 free(wireShieldName_);
205 wireShieldName_ = 0;
206 }
207
208 if (paths_) {
209 for (i = 0; i < numPaths_; i++) {
210 delete paths_[i];
211 }
212
213 delete [] paths_;
214 paths_ = 0;
215 numPaths_ = 0;
216 pathsAllocated_ = 0;
217 }
218 }
219
220
bumpPaths(long long size)221 void defiWire::bumpPaths(long long size) {
222 long long i;
223 defiPath** newPaths = new defiPath*[size];
224
225 for (i = 0; i < numPaths_; i++)
226 newPaths[i] = paths_[i];
227
228 pathsAllocated_ = size;
229 delete [] paths_;
230 paths_ = newPaths;
231 }
232
233
numPaths() const234 int defiWire::numPaths() const {
235 return numPaths_;
236 }
237
238
wireType() const239 const char* defiWire::wireType() const {
240 return type_;
241 }
242
wireShieldNetName() const243 const char* defiWire::wireShieldNetName() const {
244 return wireShieldName_;
245 }
246
path(int index)247 defiPath* defiWire::path(int index) {
248 if (index >= 0 && index < numPaths_)
249 return paths_[index];
250 return 0;
251 }
252
253
path(int index) const254 const defiPath* defiWire::path(int index) const {
255 if (index >= 0 && index < numPaths_)
256 return paths_[index];
257 return 0;
258 }
259
260 ////////////////////////////////////////////////////
261 ////////////////////////////////////////////////////
262 //
263 // defiSubnet
264 //
265 ////////////////////////////////////////////////////
266 ////////////////////////////////////////////////////
267
268
defiSubnet(defrData * data)269 defiSubnet::defiSubnet(defrData *data)
270 : defData(data)
271 {
272 Init();
273 }
274
275
Init()276 void defiSubnet::Init() {
277 name_ = 0;
278 bumpName(16);
279
280 instances_ = 0;
281 pins_ = 0;
282 musts_ = 0;
283 synthesized_ = 0;
284 numPins_ = 0;
285 bumpPins(16);
286
287 // WMD -- this will be removed by the next release
288 paths_ = 0;
289 numPaths_ = 0;
290 pathsAllocated_ = 0;
291
292 numWires_ = 0;
293 wiresAllocated_ = 0;
294 wires_ = 0;
295 nonDefaultRule_ = 0;
296
297 clear();
298 }
299
300
DEF_COPY_CONSTRUCTOR_C(defiSubnet)301 DEF_COPY_CONSTRUCTOR_C( defiSubnet ) {
302 defData = NULL;
303 this->Init();
304
305 DEF_COPY_FUNC( nameSize_ );
306 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
307 DEF_COPY_FUNC( pinsAllocated_ );
308 DEF_COPY_FUNC( numPins_ );
309
310 DEF_MALLOC_FUNC_FOR_2D_STR( instances_, numPins_ );
311 DEF_MALLOC_FUNC_FOR_2D_STR( pins_, numPins_ );
312
313 DEF_MALLOC_FUNC( synthesized_, char, sizeof(char) * numPins_ );
314 DEF_MALLOC_FUNC( musts_, char, sizeof(char) * numPins_ );
315 DEF_COPY_FUNC( isFixed_ );
316 DEF_COPY_FUNC( isRouted_ );
317 DEF_COPY_FUNC( isCover_ );
318 DEF_COPY_FUNC( numPaths_ );
319 DEF_COPY_FUNC( pathsAllocated_ );
320 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
321
322 DEF_COPY_FUNC( numWires_ );
323 DEF_COPY_FUNC( wiresAllocated_ );
324 DEF_MALLOC_FUNC_FOR_2D( wires_, defiWire, numWires_, 1 );
325 DEF_MALLOC_FUNC( nonDefaultRule_, char, sizeof(char) * (strlen(prev.nonDefaultRule_) +1));
326
327 }
328
329
DEF_ASSIGN_OPERATOR_C(defiSubnet)330 DEF_ASSIGN_OPERATOR_C( defiSubnet ) {
331 CHECK_SELF_ASSIGN
332 defData = NULL;
333 this->Init();
334
335 DEF_COPY_FUNC( nameSize_ );
336 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
337 DEF_COPY_FUNC( pinsAllocated_ );
338 DEF_COPY_FUNC( numPins_ );
339
340 DEF_MALLOC_FUNC_FOR_2D_STR( instances_, numPins_ );
341 DEF_MALLOC_FUNC_FOR_2D_STR( pins_, numPins_ );
342
343 DEF_MALLOC_FUNC( synthesized_, char, sizeof(char) * (strlen(prev.synthesized_) +1));
344 DEF_MALLOC_FUNC( musts_, char, sizeof(char) * (strlen(prev.musts_) +1));
345 DEF_COPY_FUNC( isFixed_ );
346 DEF_COPY_FUNC( isRouted_ );
347 DEF_COPY_FUNC( isCover_ );
348 DEF_COPY_FUNC( numPaths_ );
349 DEF_COPY_FUNC( pathsAllocated_ );
350 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
351
352 DEF_COPY_FUNC( numWires_ );
353 DEF_COPY_FUNC( wiresAllocated_ );
354 DEF_MALLOC_FUNC_FOR_2D( wires_, defiWire, numWires_, 1 );
355 DEF_MALLOC_FUNC( nonDefaultRule_, char, sizeof(char) * (strlen(prev.nonDefaultRule_) +1));
356 return *this;
357 }
358
Destroy()359 void defiSubnet::Destroy() {
360 clear();
361 free(name_);
362 free((char*)(instances_));
363 free((char*)(pins_));
364 free(musts_);
365 free(synthesized_);
366
367 }
368
369
~defiSubnet()370 defiSubnet::~defiSubnet() {
371 Destroy();
372 }
373
374
setName(const char * name)375 void defiSubnet::setName(const char* name) {
376 int len = strlen(name) + 1;
377 if (len > nameSize_) bumpName(len);
378 strcpy(name_, defData->DEFCASE(name));
379 }
380
381
setNonDefault(const char * name)382 void defiSubnet::setNonDefault(const char* name) {
383 int len = strlen(name) + 1;
384 nonDefaultRule_ = (char*)malloc(len);
385 strcpy(nonDefaultRule_, defData->DEFCASE(name));
386 }
387
388
addMustPin(const char * instance,const char * pin,int syn)389 void defiSubnet::addMustPin(const char* instance, const char* pin, int syn) {
390 addPin(instance, pin, syn);
391 musts_[numPins_ - 1] = 1;
392 }
393
394
addPin(const char * instance,const char * pin,int syn)395 void defiSubnet::addPin(const char* instance, const char* pin, int syn) {
396 int len;
397
398 if (numPins_ == pinsAllocated_)
399 bumpPins(pinsAllocated_ * 2);
400
401 len = strlen(instance)+ 1;
402 instances_[numPins_] = (char*)malloc(len);
403 strcpy(instances_[numPins_], defData->DEFCASE(instance));
404
405 len = strlen(pin)+ 1;
406 pins_[numPins_] = (char*)malloc(len);
407 strcpy(pins_[numPins_], defData->DEFCASE(pin));
408
409 musts_[numPins_] = 0;
410 // fflush(stdout);
411 // printf("numPin : %d, innerSynCont : %d\n", numPins_, syn);
412 synthesized_[numPins_] = syn;
413
414 (numPins_)++;
415 }
416
417 // WMD -- this will be removed by the next release
setType(const char * typ)418 void defiSubnet::setType(const char* typ) {
419 if (*typ == 'F') {
420 isFixed_ = 1;
421 } else if (*typ == 'C') {
422 isCover_ = 1;
423 } else if (*typ == 'R') {
424 isRouted_ = 1;
425 } else {
426 // Silently do nothing with bad input.
427 }
428
429 }
430
431 // WMD -- this will be removed by the next release
addPath(defiPath * p,int reset,int netOsnet,int * needCbk)432 void defiSubnet::addPath(defiPath* p, int reset, int netOsnet, int *needCbk) {
433 int i;
434 size_t incNumber;
435
436 if (reset) {
437 for (i = 0; i < numPaths_; i++) {
438 delete paths_[i];
439 }
440 numPaths_ = 0;
441 }
442
443 if (numPaths_ >= pathsAllocated_) {
444 // 6/17/2003 - don't want to allocate too large memory just in case
445 // a net has many wires with only 1 or 2 paths
446 if (pathsAllocated_ <= maxLimit) {
447 incNumber = pathsAllocated_*2;
448 if (incNumber > maxLimit) {
449 incNumber = pathsAllocated_ + maxLimit;
450 }
451 } else {
452 incNumber = pathsAllocated_ + maxLimit;
453 }
454
455 switch (netOsnet) {
456 case 2:
457 bumpPaths(
458 pathsAllocated_ ? incNumber : 1000);
459 break;
460 default:
461 bumpPaths(
462 pathsAllocated_ ? incNumber : 8);
463 break;
464 }
465 }
466
467 paths_[numPaths_++] = new defiPath(p);
468
469 if (numPaths_ == pathsAllocated_)
470 *needCbk = 1; // pre-warn the parser it needs to realloc next time
471 }
472
473
addWire(const char * type)474 void defiSubnet::addWire(const char* type) {
475 defiWire* wire;
476 if (numWires_ == wiresAllocated_) {
477 defiWire** array;
478 int i;
479 wiresAllocated_ = wiresAllocated_ ?
480 wiresAllocated_ * 2 : 2 ;
481 array = (defiWire**)malloc(sizeof(defiWire*)*wiresAllocated_);
482 for (i = 0; i < numWires_; i++) {
483 array[i] = wires_[i];
484 }
485 if (wires_)
486 free((char*)(wires_));
487 wires_ = array;
488 }
489 wire = wires_[numWires_] = new defiWire(defData);
490 // wire = wires_[numWires_] = (defiWire*)malloc(sizeof(defiWire));
491 // wire->defData = defData;
492 numWires_ += 1;
493 wire->Init(type, NULL);
494 }
495
496
addWirePath(defiPath * p,int reset,int netOsnet,int * needCbk)497 void defiSubnet::addWirePath(defiPath* p, int reset, int netOsnet, int *needCbk) {
498 if (numWires_ > 0)
499 wires_[numWires_-1]->addPath(p, reset, netOsnet,
500 needCbk);
501 else
502 // Something screw up, can't be both be zero.
503 defiError(0, 6080, "ERROR (DEFPARS-6080): An internal error has occurred. The index number for the SUBNET wires array is less then or equal to 0.\nContact Cadence Customer Support with this error information.", defData);
504 }
505
name() const506 const char* defiSubnet::name() const {
507 return name_;
508 }
509
510
hasNonDefaultRule() const511 int defiSubnet::hasNonDefaultRule() const {
512 return nonDefaultRule_ ? 1 : 0;
513 }
514
515
nonDefaultRule() const516 const char* defiSubnet::nonDefaultRule() const {
517 return nonDefaultRule_;
518 }
519
520
numConnections() const521 int defiSubnet::numConnections() const {
522 return numPins_;
523 }
524
525
instance(int index) const526 const char* defiSubnet::instance(int index) const {
527 if (index >= 0 && index < numPins_)
528 return instances_[index];
529 return 0;
530 }
531
532
pin(int index) const533 const char* defiSubnet::pin(int index) const {
534 if (index >= 0 && index < numPins_)
535 return pins_[index];
536 return 0;
537 }
538
539
pinIsMustJoin(int index) const540 int defiSubnet::pinIsMustJoin(int index) const {
541 if (index >= 0 && index < numPins_)
542 return (int)(musts_[index]);
543 return 0;
544 }
545
546
pinIsSynthesized(int index) const547 int defiSubnet::pinIsSynthesized(int index) const {
548 if (index >= 0 && index < numPins_)
549 return (int)(synthesized_[index]);
550 return 0;
551 }
552
553 // WMD -- this will be removed by the next release
isFixed() const554 int defiSubnet::isFixed() const {
555 return (int)(isFixed_);
556 }
557
558
559 // WMD -- this will be removed by the next release
isRouted() const560 int defiSubnet::isRouted() const {
561 return (int)(isRouted_);
562 }
563
564
565 // WMD -- this will be removed by the next release
isCover() const566 int defiSubnet::isCover() const {
567 return (int)(isCover_);
568 }
569
570
bumpName(long long size)571 void defiSubnet::bumpName(long long size) {
572 if (name_) free(name_);
573 name_ = (char*)malloc(size);
574 nameSize_ = size;
575 name_[0] = '\0';
576 }
577
578
bumpPins(long long size)579 void defiSubnet::bumpPins(long long size) {
580 char** newInstances = (char**)malloc(sizeof(char*)*size);
581 char** newPins = (char**)malloc(sizeof(char*)*size);
582 char* newMusts = (char*)malloc(size);
583 char* newSyn = (char*)malloc(size);
584 long long i;
585
586 if (instances_) {
587 for (i = 0; i < pinsAllocated_; i++) {
588 newInstances[i] = instances_[i];
589 newPins[i] = pins_[i];
590 newMusts[i] = musts_[i];
591 newSyn[i] = synthesized_[i];
592 }
593 free((char*)(instances_));
594 free((char*)(pins_));
595 free(musts_);
596 free(synthesized_);
597 }
598
599 instances_ = newInstances;
600 pins_ = newPins;
601 musts_ = newMusts;
602 synthesized_ = newSyn;
603 pinsAllocated_ = size;
604 }
605
606
clear()607 void defiSubnet::clear() {
608 int i;
609
610 // WMD -- this will be removed by the next release
611 isFixed_ = 0;
612 isRouted_ = 0;
613 isCover_ = 0;
614 name_[0] = '\0';
615
616 for (i = 0; i < numPins_; i++) {
617 free(instances_[i]);
618 free(pins_[i]);
619 instances_[i] = 0;
620 pins_[i] = 0;
621 musts_[i] = 0;
622 synthesized_[i] = 0;
623 }
624 numPins_ = 0;
625
626 // WMD -- this will be removed by the next release
627 if (paths_) {
628 for (i = 0; i < numPaths_; i++) {
629 delete paths_[i];
630 }
631 delete [] paths_;
632 paths_ = 0;
633 numPaths_ = 0;
634 pathsAllocated_ = 0;
635 }
636
637 if (nonDefaultRule_) {
638 free(nonDefaultRule_);
639 nonDefaultRule_ = 0;
640 }
641
642 if (numWires_) {
643 for (i = 0; i < numWires_; i++) {
644 delete wires_[i];
645 wires_[i] = 0;
646 }
647 free((char*)(wires_));
648 wires_ = 0;
649 numWires_ = 0;
650 wiresAllocated_ = 0;
651 }
652 }
653
654
print(FILE * f) const655 void defiSubnet::print(FILE* f) const {
656 int i, j;
657 const defiPath* p;
658 const defiWire* w;
659
660 fprintf(f, " subnet '%s'", name_);
661 fprintf(f, "\n");
662
663 if (hasNonDefaultRule())
664 fprintf(f, " nondefault rule %s\n",
665 nonDefaultRule());
666
667 if (numConnections()) {
668 fprintf(f, " Pins:\n");
669 for (i = 0; i < numConnections(); i++) {
670 fprintf(f, " '%s' '%s'%s%s\n",
671 instance(i),
672 pin(i),
673 pinIsMustJoin(i) ? " MUSTJOIN" : "",
674 pinIsSynthesized(i) ? " SYNTHESIZED" : "");
675 }
676 }
677
678 if (numWires()) {
679 fprintf(f, " Paths:\n");
680 for (i = 0; i < numWires(); i++) {
681 w = wire(i);
682 for (j = 0; j < w->numPaths(); j++) {
683 p = w->path(j);
684 p->print(f);
685 }
686 }
687 }
688 }
689
numWires() const690 int defiSubnet::numWires() const {
691 return numWires_;
692 }
693
694
wire(int index)695 defiWire* defiSubnet::wire(int index) {
696 if (index >= 0 && index < numWires_)
697 return wires_[index];
698 return 0;
699 }
700
701
wire(int index) const702 const defiWire* defiSubnet::wire(int index) const {
703 if (index >= 0 && index < numWires_)
704 return wires_[index];
705 return 0;
706 }
707
708
709 // WMD -- this will be removed after the next release
path(int index)710 defiPath* defiSubnet::path(int index) {
711 if (index >= 0 && index < numPaths_)
712 return paths_[index];
713 return 0;
714 }
715
716 // WMD -- this will be removed after the next release
path(int index) const717 const defiPath* defiSubnet::path(int index) const {
718 if (index >= 0 && index < numPaths_)
719 return paths_[index];
720 return 0;
721 }
722
723 // WMD -- this will be removed after the next release
numPaths() const724 int defiSubnet::numPaths() const {
725 return numPaths_;
726 }
727
728 // WMD -- this will be removed after the next release
bumpPaths(long long size)729 void defiSubnet::bumpPaths(long long size) {
730 long long i;
731 defiPath** newPaths = new defiPath*[size];
732
733 for (i = 0; i < numPaths_; i++)
734 newPaths[i] = paths_[i];
735
736 pathsAllocated_ = size;
737
738 delete [] paths_;
739 paths_ = newPaths;
740 }
741
742
743 ////////////////////////////////////////////////////
744 ////////////////////////////////////////////////////
745 //
746 // defiVpin
747 //
748 ////////////////////////////////////////////////////
749 ////////////////////////////////////////////////////
750
751
defiVpin(defrData * data)752 defiVpin::defiVpin(defrData *data)
753 : defData(data)
754 {
755 }
756
757
Init(const char * name)758 void defiVpin::Init(const char* name) {
759 int len = strlen(name) + 1;
760 name_ = (char*)malloc(len);
761 strcpy(name_, defData->DEFCASE(name));
762 orient_ = -1;
763 status_ = ' ';
764 layer_ = 0;
765 }
766
767
~defiVpin()768 defiVpin::~defiVpin() {
769 Destroy();
770 }
771
DEF_COPY_CONSTRUCTOR_C(defiVpin)772 DEF_COPY_CONSTRUCTOR_C( defiVpin ) {
773 defData = NULL;
774
775 DEF_COPY_FUNC( xl_ );
776 DEF_COPY_FUNC( yl_ );
777 DEF_COPY_FUNC( xh_ );
778 DEF_COPY_FUNC( yh_ );
779 DEF_COPY_FUNC( orient_ );
780 DEF_COPY_FUNC( status_ );
781 DEF_COPY_FUNC( xLoc_ );
782 DEF_COPY_FUNC( yLoc_ );
783 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
784 DEF_MALLOC_FUNC( layer_, char, sizeof(char) * (strlen(prev.layer_) +1));
785 }
786
DEF_ASSIGN_OPERATOR_C(defiVpin)787 DEF_ASSIGN_OPERATOR_C( defiVpin ) {
788 CHECK_SELF_ASSIGN
789 defData = NULL;
790
791 DEF_COPY_FUNC( xl_ );
792 DEF_COPY_FUNC( yl_ );
793 DEF_COPY_FUNC( xh_ );
794 DEF_COPY_FUNC( yh_ );
795 DEF_COPY_FUNC( orient_ );
796 DEF_COPY_FUNC( status_ );
797 DEF_COPY_FUNC( xLoc_ );
798 DEF_COPY_FUNC( yLoc_ );
799 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
800 DEF_MALLOC_FUNC( layer_, char, sizeof(char) * (strlen(prev.layer_) +1));
801 return *this;
802 }
803
Destroy()804 void defiVpin::Destroy() {
805 free(name_);
806 if (layer_) free(layer_);
807 }
808
809
setBounds(int xl,int yl,int xh,int yh)810 void defiVpin::setBounds(int xl, int yl, int xh, int yh) {
811 xl_ = xl;
812 yl_ = yl;
813 xh_ = xh;
814 yh_ = yh;
815 }
816
817
setLayer(const char * lay)818 void defiVpin::setLayer(const char* lay) {
819 int len = strlen(lay)+1;
820 layer_ = (char*)malloc(len);
821 strcpy(layer_, lay);
822 }
823
824
setOrient(int orient)825 void defiVpin::setOrient(int orient) {
826 orient_ = orient;
827 }
828
829
setLoc(int x,int y)830 void defiVpin::setLoc(int x, int y) {
831 xLoc_ = x;
832 yLoc_ = y;
833 }
834
835
setStatus(char st)836 void defiVpin::setStatus(char st) {
837 status_ = st;
838 }
839
840
xl() const841 int defiVpin::xl() const {
842 return xl_;
843 }
844
845
yl() const846 int defiVpin::yl() const {
847 return yl_;
848 }
849
850
xh() const851 int defiVpin::xh() const {
852 return xh_;
853 }
854
855
yh() const856 int defiVpin::yh() const {
857 return yh_;
858 }
859
860
status() const861 char defiVpin::status() const {
862 return status_;
863 }
864
865
orient() const866 int defiVpin::orient() const {
867 return orient_;
868 }
869
870
orientStr() const871 const char* defiVpin::orientStr() const {
872 return (defiOrientStr(orient_));
873 }
874
875
xLoc() const876 int defiVpin::xLoc() const {
877 return xLoc_;
878 }
879
880
yLoc() const881 int defiVpin::yLoc() const {
882 return yLoc_;
883 }
884
885
name() const886 const char* defiVpin::name() const {
887 return name_;
888 }
889
890
layer() const891 const char* defiVpin::layer() const {
892 return layer_;
893 }
894
895
896
897 ////////////////////////////////////////////////////
898 ////////////////////////////////////////////////////
899 //
900 // defiShield
901 //
902 ////////////////////////////////////////////////////
903 ////////////////////////////////////////////////////
904
905
defiShield(defrData * data)906 defiShield::defiShield(defrData *data)
907 : defData(data)
908 {
909 }
910
911
Init(const char * name)912 void defiShield::Init(const char* name) {
913 int len = strlen(name) + 1;
914 name_ = (char*)malloc(len);
915 strcpy(name_, defData->DEFCASE(name));
916 numPaths_ = 0;
917 pathsAllocated_ = 0;
918 paths_ = NULL;
919 }
920
DEF_COPY_CONSTRUCTOR_C(defiShield)921 DEF_COPY_CONSTRUCTOR_C( defiShield ) {
922 defData = NULL;
923
924 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
925 DEF_COPY_FUNC( numPaths_ );
926 DEF_COPY_FUNC( pathsAllocated_ );
927 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
928
929 }
930
DEF_ASSIGN_OPERATOR_C(defiShield)931 DEF_ASSIGN_OPERATOR_C( defiShield ) {
932 CHECK_SELF_ASSIGN
933 defData = NULL;
934
935 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
936 DEF_COPY_FUNC( numPaths_ );
937 DEF_COPY_FUNC( pathsAllocated_ );
938 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1 );
939 return *this;
940 }
941
Destroy()942 void defiShield::Destroy() {
943 clear();
944 }
945
946
~defiShield()947 defiShield::~defiShield() {
948 Destroy();
949 }
950
951
addPath(defiPath * p,int reset,int netOsnet,int * needCbk)952 void defiShield::addPath(defiPath* p, int reset, int netOsnet, int *needCbk) {
953 int i;
954 size_t incNumber;
955
956 if (reset) {
957 for (i = 0; i < numPaths_; i++) {
958 delete paths_[i];
959 }
960 numPaths_ = 0;
961 }
962 if (numPaths_ >= pathsAllocated_) {
963 // 6/17/2003 - don't want to allocate too large memory just in case
964 // a net has many wires with only 1 or 2 paths
965
966 if (pathsAllocated_ <= maxLimit) {
967 incNumber = pathsAllocated_*2;
968 if (incNumber > maxLimit) {
969 incNumber = pathsAllocated_ + maxLimit;
970 }
971 } else {
972 incNumber = pathsAllocated_ + maxLimit;
973 }
974
975 switch (netOsnet) {
976 case 2:
977 bumpPaths(
978 pathsAllocated_ ? incNumber : 1000);
979 break;
980 default:
981 bumpPaths(
982 pathsAllocated_ ? incNumber : 8);
983 break;
984 }
985 }
986 paths_[numPaths_++] = new defiPath(p);
987 if (numPaths_ == pathsAllocated_)
988 *needCbk = 1; // pre-warn the parser it needs to realloc next time
989 }
990
991
clear()992 void defiShield::clear() {
993 int i;
994
995 if (name_) {
996 free(name_);
997 name_ = 0;
998 }
999
1000 if (paths_) {
1001 for (i = 0; i < numPaths_; i++) {
1002 delete paths_[i];
1003 }
1004
1005 delete [] paths_;
1006
1007 paths_ = 0;
1008 numPaths_ = 0;
1009 pathsAllocated_ = 0;
1010 }
1011 }
1012
1013
bumpPaths(long long size)1014 void defiShield::bumpPaths(long long size) {
1015 long long i;
1016
1017 defiPath** newPaths = new defiPath*[size];
1018
1019 for (i = 0; i < numPaths_; i++)
1020 newPaths[i] = paths_[i];
1021
1022 pathsAllocated_ = size;
1023
1024 delete [] paths_;
1025
1026 paths_ = newPaths;
1027 }
1028
1029
numPaths() const1030 int defiShield::numPaths() const {
1031 return numPaths_;
1032 }
1033
1034
shieldName() const1035 const char* defiShield::shieldName() const {
1036 return name_;
1037 }
1038
path(int index)1039 defiPath* defiShield::path(int index) {
1040 if (index >= 0 && index < numPaths_)
1041 return paths_[index];
1042 return 0;
1043 }
1044
path(int index) const1045 const defiPath* defiShield::path(int index) const {
1046 if (index >= 0 && index < numPaths_)
1047 return paths_[index];
1048 return 0;
1049 }
1050
1051
1052
1053
1054 ////////////////////////////////////////////////////
1055 ////////////////////////////////////////////////////
1056 //
1057 // defiNet
1058 //
1059 ////////////////////////////////////////////////////
1060 ////////////////////////////////////////////////////
1061
1062
defiNet(defrData * data)1063 defiNet::defiNet(defrData *data)
1064 : defData(data)
1065 {
1066 Init();
1067 }
1068
1069
Init()1070 void defiNet::Init() {
1071 name_ = 0;
1072 instances_ = 0;
1073 numPins_ = 0;
1074 numProps_ = 0;
1075 propNames_ = 0;
1076 subnets_ = 0;
1077 source_ = 0;
1078 pattern_ = 0;
1079 style_ = 0;
1080 shieldNet_ = 0;
1081 original_ = 0;
1082 use_ = 0;
1083 nonDefaultRule_ = 0;
1084 numWires_ = 0;
1085 wiresAllocated_ = 0;
1086 wires_= 0;
1087
1088 numWidths_ = 0;
1089 widthsAllocated_ = 0;
1090 wlayers_ = 0;
1091 wdist_ = 0;
1092
1093 numSpacing_ = 0;
1094 spacingAllocated_ = 0;
1095 slayers_ = 0;
1096 sdist_ = 0;
1097 sleft_ = 0;
1098 sright_ = 0;
1099
1100 vpins_ = 0;
1101 numVpins_ = 0;
1102 vpinsAllocated_ = 0;
1103
1104 shields_ = 0;
1105 numShields_ = 0;
1106 numNoShields_ = 0;
1107 shieldsAllocated_ = 0;
1108 numShieldNet_ = 0;
1109 shieldNetsAllocated_ = 0;
1110
1111 bumpProps(2);
1112 bumpName(16);
1113 bumpPins(16);
1114 bumpSubnets(2);
1115
1116 rectNames_ = 0;
1117 rectRouteStatus_ = 0;
1118 rectRouteStatusShieldNames_=0;
1119 rectShapeTypes_ = 0;
1120 rectMasks_ = 0;
1121 polygonNames_ = 0;
1122 polyRouteStatus_ = 0;
1123 polyShapeTypes_ = 0;
1124 polyRouteStatusShieldNames_ = 0;
1125 numPolys_ = 0;
1126 polysAllocated_ = 0;
1127 polygons_ = 0;
1128 polyMasks_ = 0;
1129
1130 numSubnets_ = 0;
1131 paths_ = 0;
1132 numPaths_ = 0;
1133
1134 numPts_ = 0;
1135 viaNames_ = 0;
1136 viaPts_ = 0;
1137 ptsAllocated_=0;
1138 viaMasks_ = 0;
1139 viaOrients_ = 0;
1140 viaRouteStatus_ = 0;
1141 viaShapeTypes_ = 0;
1142 viaRouteStatusShieldNames_ = 0;
1143
1144 // propTypes_ = 0;
1145
1146 // synthesized_ = 0;
1147 // musts_ = 0;
1148
1149 // pins_ = 0;
1150 clear();
1151 }
1152
DEF_COPY_CONSTRUCTOR_C(defiNet)1153 DEF_COPY_CONSTRUCTOR_C( defiNet ){
1154 DEF_COPY_FUNC(defData) ;
1155 this->Init();
1156
1157 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
1158 DEF_COPY_FUNC( nameSize_ );
1159
1160 DEF_COPY_FUNC( numPins_ );
1161 DEF_COPY_FUNC( pinsAllocated_ );
1162 DEF_MALLOC_FUNC_FOR_2D_STR( instances_, numPins_);
1163 DEF_MALLOC_FUNC_FOR_2D_STR( pins_, numPins_);
1164
1165 DEF_MALLOC_FUNC( musts_, char, sizeof(char) * numPins_);
1166 DEF_MALLOC_FUNC( synthesized_, char, sizeof(char) * numPins_);
1167 DEF_COPY_FUNC( weight_ );
1168 DEF_COPY_FUNC( hasWeight_ );
1169 DEF_COPY_FUNC( isFixed_ );
1170 DEF_COPY_FUNC( isRouted_ );
1171 DEF_COPY_FUNC( isCover_ );
1172 DEF_COPY_FUNC( hasCap_ );
1173 DEF_COPY_FUNC( hasFrequency_ );
1174 DEF_COPY_FUNC( hasVoltage_ );
1175 DEF_COPY_FUNC( numProps_ );
1176 DEF_MALLOC_FUNC_FOR_2D_STR( propNames_, numProps_ );
1177 DEF_MALLOC_FUNC_FOR_2D_STR( propValues_, numProps_ );
1178
1179 DEF_MALLOC_FUNC( propDValues_, double, sizeof(double) * numProps_);
1180 DEF_MALLOC_FUNC( propTypes_, char, sizeof(char) * numProps_ );
1181 DEF_COPY_FUNC( propsAllocated_ );
1182 DEF_COPY_FUNC( numSubnets_ );
1183 DEF_MALLOC_FUNC_FOR_2D( subnets_, defiSubnet, numSubnets_, 1);
1184
1185 DEF_COPY_FUNC( subnetsAllocated_ );
1186 DEF_COPY_FUNC( cap_ );
1187 DEF_MALLOC_FUNC( source_, char, sizeof(char) * (strlen(prev.source_) +1));
1188 DEF_COPY_FUNC( fixedbump_ );
1189 DEF_COPY_FUNC( frequency_ );
1190 DEF_MALLOC_FUNC( pattern_, char, sizeof(char) * (strlen(prev.pattern_) +1));
1191 DEF_MALLOC_FUNC( original_, char, sizeof(char) * (strlen(prev.original_) +1));
1192 DEF_MALLOC_FUNC( use_, char, sizeof(char) * (strlen(prev.use_) +1));
1193 DEF_MALLOC_FUNC( nonDefaultRule_, char, sizeof(char) * (strlen(prev.nonDefaultRule_) +1));
1194 DEF_COPY_FUNC( style_ );
1195
1196 DEF_COPY_FUNC( numPaths_ );
1197 DEF_COPY_FUNC( pathsAllocated_ );
1198 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1);
1199
1200 DEF_COPY_FUNC( voltage_ );
1201 DEF_COPY_FUNC( numWires_ );
1202 DEF_COPY_FUNC( wiresAllocated_ );
1203 // DEF_MALLOC_FUNC_FOR_2D( wires_, defiWire, numWires_, 1 );
1204
1205 // wire_ : outer array : malloc/free
1206 // inner array : new/delete
1207 if( prev.wires_) {
1208 wires_ = (defiWire**) malloc( sizeof(defiWire*)*numWires_ );
1209
1210 for(int i=0; i<numWires_; i++) {
1211 if( prev.wires_[i] ) {
1212 // wires_[i] = new defiWire(defData);
1213 wires_[i] = new defiWire(* prev.wires_[i]);
1214 }
1215 else {
1216 wires_[i] = 0;
1217 }
1218 }
1219 }
1220 else {
1221 wires_ = 0;
1222 }
1223
1224 DEF_COPY_FUNC( widthsAllocated_ );
1225 DEF_COPY_FUNC( numWidths_ );
1226 DEF_MALLOC_FUNC_FOR_2D_STR( wlayers_, numWidths_ );
1227 DEF_MALLOC_FUNC( wdist_, double, sizeof(double) * numWidths_ );
1228
1229 DEF_COPY_FUNC( spacingAllocated_ );
1230 DEF_COPY_FUNC( numSpacing_ );
1231 DEF_MALLOC_FUNC_FOR_2D_STR( slayers_, numSpacing_ );
1232 DEF_MALLOC_FUNC( sdist_, double, sizeof(double) * numSpacing_);
1233 DEF_MALLOC_FUNC( sleft_, double, sizeof(double) * numSpacing_);
1234 DEF_MALLOC_FUNC( sright_, double, sizeof(double) * numSpacing_);
1235 DEF_COPY_FUNC( xTalk_ );
1236 DEF_COPY_FUNC( numVpins_ );
1237 DEF_COPY_FUNC( vpinsAllocated_ );
1238 DEF_MALLOC_FUNC_FOR_2D( vpins_, defiVpin, numVpins_, 1);
1239
1240 DEF_COPY_FUNC( numShields_ );
1241 DEF_COPY_FUNC( shieldsAllocated_ );
1242 DEF_MALLOC_FUNC_FOR_2D( shields_, defiShield, numShields_, 1);
1243
1244 DEF_COPY_FUNC( numNoShields_ );
1245
1246 DEF_COPY_FUNC( numShieldNet_ );
1247 DEF_COPY_FUNC( shieldNetsAllocated_ );
1248 DEF_MALLOC_FUNC_FOR_2D_STR( shieldNet_, numShieldNet_ );
1249
1250 DEF_COPY_FUNC( numPolys_ );
1251 DEF_COPY_FUNC( polysAllocated_ );
1252 DEF_MALLOC_FUNC_FOR_2D_STR( polygonNames_, numPolys_ );
1253 DEF_MALLOC_FUNC_FOR_2D_POINT( polygons_, numPolys_);
1254
1255 DEF_MALLOC_FUNC( polyMasks_, int, sizeof(int) * numPolys_ );
1256 DEF_MALLOC_FUNC_FOR_2D_STR( polyRouteStatus_, numPolys_ );
1257 DEF_MALLOC_FUNC_FOR_2D_STR( polyShapeTypes_, numPolys_ );
1258 DEF_MALLOC_FUNC_FOR_2D_STR( polyRouteStatusShieldNames_, numPolys_ );
1259
1260 DEF_COPY_FUNC( numRects_ );
1261 DEF_COPY_FUNC( rectsAllocated_ );
1262 DEF_MALLOC_FUNC_FOR_2D_STR( rectNames_, numRects_ );
1263
1264 DEF_MALLOC_FUNC( xl_, int, sizeof(int) * numRects_ );
1265 DEF_MALLOC_FUNC( yl_, int, sizeof(int) * numRects_ );
1266 DEF_MALLOC_FUNC( xh_, int, sizeof(int) * numRects_ );
1267 DEF_MALLOC_FUNC( yh_, int, sizeof(int) * numRects_ );
1268 DEF_MALLOC_FUNC( rectMasks_, int, sizeof(int) * numRects_ );
1269 DEF_MALLOC_FUNC_FOR_2D_STR( rectRouteStatus_, numRects_ );
1270 DEF_MALLOC_FUNC_FOR_2D_STR( rectRouteStatusShieldNames_, numRects_ );
1271 DEF_MALLOC_FUNC_FOR_2D_STR( rectShapeTypes_, numRects_ );
1272
1273 DEF_COPY_FUNC( numPts_ );
1274 DEF_COPY_FUNC( ptsAllocated_ );
1275
1276 DEF_MALLOC_FUNC_FOR_2D_POINT( viaPts_, numPts_ );
1277 DEF_MALLOC_FUNC_FOR_2D_STR( viaNames_, numPts_ );
1278
1279 DEF_MALLOC_FUNC( viaOrients_, int, sizeof(int) * numPts_ );
1280 DEF_MALLOC_FUNC( viaMasks_, int, sizeof(int) * numPts_ );
1281 DEF_MALLOC_FUNC_FOR_2D_STR( viaRouteStatus_, numPts_ );
1282 DEF_MALLOC_FUNC_FOR_2D_STR( viaRouteStatusShieldNames_, numPts_ );
1283 DEF_MALLOC_FUNC_FOR_2D_STR( viaShapeTypes_, numPts_ );
1284
1285 }
1286
1287
DEF_ASSIGN_OPERATOR_C(defiNet)1288 DEF_ASSIGN_OPERATOR_C( defiNet ) {
1289 CHECK_SELF_ASSIGN
1290 DEF_COPY_FUNC(defData) ;
1291 this->Init();
1292
1293 DEF_MALLOC_FUNC( name_, char, sizeof(char) * (strlen(prev.name_) +1));
1294 DEF_COPY_FUNC( nameSize_ );
1295
1296 DEF_COPY_FUNC( numPins_ );
1297 DEF_COPY_FUNC( pinsAllocated_ );
1298 DEF_MALLOC_FUNC_FOR_2D_STR( instances_, numPins_);
1299 DEF_MALLOC_FUNC_FOR_2D_STR( pins_, numPins_);
1300
1301 DEF_MALLOC_FUNC( musts_, char, sizeof(char) * numPins_);
1302 DEF_MALLOC_FUNC( synthesized_, char, sizeof(char) * numPins_);
1303 DEF_COPY_FUNC( weight_ );
1304 DEF_COPY_FUNC( hasWeight_ );
1305 DEF_COPY_FUNC( isFixed_ );
1306 DEF_COPY_FUNC( isRouted_ );
1307 DEF_COPY_FUNC( isCover_ );
1308 DEF_COPY_FUNC( hasCap_ );
1309 DEF_COPY_FUNC( hasFrequency_ );
1310 DEF_COPY_FUNC( hasVoltage_ );
1311 DEF_COPY_FUNC( numProps_ );
1312 DEF_MALLOC_FUNC_FOR_2D_STR( propNames_, numProps_ );
1313 DEF_MALLOC_FUNC_FOR_2D_STR( propValues_, numProps_ );
1314
1315 DEF_MALLOC_FUNC( propDValues_, double, sizeof(double) * numProps_);
1316 DEF_MALLOC_FUNC( propTypes_, char, sizeof(char) * numProps_ );
1317 DEF_COPY_FUNC( propsAllocated_ );
1318 DEF_COPY_FUNC( numSubnets_ );
1319 DEF_MALLOC_FUNC_FOR_2D( subnets_, defiSubnet, numSubnets_, 1);
1320
1321 DEF_COPY_FUNC( subnetsAllocated_ );
1322 DEF_COPY_FUNC( cap_ );
1323 DEF_MALLOC_FUNC( source_, char, sizeof(char) * (strlen(prev.source_) +1));
1324 DEF_COPY_FUNC( fixedbump_ );
1325 DEF_COPY_FUNC( frequency_ );
1326 DEF_MALLOC_FUNC( pattern_, char, sizeof(char) * (strlen(prev.pattern_) +1));
1327 DEF_MALLOC_FUNC( original_, char, sizeof(char) * (strlen(prev.original_) +1));
1328 DEF_MALLOC_FUNC( use_, char, sizeof(char) * (strlen(prev.use_) +1));
1329 DEF_MALLOC_FUNC( nonDefaultRule_, char, sizeof(char) * (strlen(prev.nonDefaultRule_) +1));
1330 DEF_COPY_FUNC( style_ );
1331
1332 DEF_COPY_FUNC( numPaths_ );
1333 DEF_COPY_FUNC( pathsAllocated_ );
1334 DEF_MALLOC_FUNC_FOR_2D( paths_, defiPath, numPaths_, 1);
1335
1336 DEF_COPY_FUNC( voltage_ );
1337 DEF_COPY_FUNC( numWires_ );
1338 DEF_COPY_FUNC( wiresAllocated_ );
1339 // DEF_MALLOC_FUNC_FOR_2D( wires_, defiWire, numWires_, 1 );
1340
1341 // wire_ : outer array : malloc/free
1342 // inner array : new/delete
1343 if( prev.wires_) {
1344 wires_ = (defiWire**) malloc( sizeof(defiWire*)*numWires_ );
1345
1346 for(int i=0; i<numWires_; i++) {
1347 if( prev.wires_[i] ) {
1348 // wires_[i] = new defiWire(defData);
1349 wires_[i] = new defiWire(*prev.wires_[i]);
1350 }
1351 else {
1352 wires_[i] = 0;
1353 }
1354 }
1355 }
1356 else {
1357 wires_ = 0;
1358 }
1359
1360 DEF_COPY_FUNC( widthsAllocated_ );
1361 DEF_COPY_FUNC( numWidths_ );
1362 DEF_MALLOC_FUNC_FOR_2D_STR( wlayers_, numWidths_ );
1363 DEF_MALLOC_FUNC( wdist_, double, sizeof(double) * numWidths_ );
1364
1365 DEF_COPY_FUNC( spacingAllocated_ );
1366 DEF_COPY_FUNC( numSpacing_ );
1367 DEF_MALLOC_FUNC_FOR_2D_STR( slayers_, numSpacing_ );
1368 DEF_MALLOC_FUNC( sdist_, double, sizeof(double) * numSpacing_);
1369 DEF_MALLOC_FUNC( sleft_, double, sizeof(double) * numSpacing_);
1370 DEF_MALLOC_FUNC( sright_, double, sizeof(double) * numSpacing_);
1371 DEF_COPY_FUNC( xTalk_ );
1372 DEF_COPY_FUNC( numVpins_ );
1373 DEF_COPY_FUNC( vpinsAllocated_ );
1374 DEF_MALLOC_FUNC_FOR_2D( vpins_, defiVpin, numVpins_, 1);
1375
1376 DEF_COPY_FUNC( numShields_ );
1377 DEF_COPY_FUNC( shieldsAllocated_ );
1378 DEF_MALLOC_FUNC_FOR_2D( shields_, defiShield, numShields_, 1);
1379
1380 DEF_COPY_FUNC( numNoShields_ );
1381
1382 DEF_COPY_FUNC( numShieldNet_ );
1383 DEF_COPY_FUNC( shieldNetsAllocated_ );
1384 DEF_MALLOC_FUNC_FOR_2D_STR( shieldNet_, numShieldNet_ );
1385
1386 DEF_COPY_FUNC( numPolys_ );
1387 DEF_COPY_FUNC( polysAllocated_ );
1388 DEF_MALLOC_FUNC_FOR_2D_STR( polygonNames_, numPolys_ );
1389 DEF_MALLOC_FUNC_FOR_2D_POINT( polygons_, numPolys_);
1390
1391 DEF_MALLOC_FUNC( polyMasks_, int, sizeof(int) * numPolys_ );
1392 DEF_MALLOC_FUNC_FOR_2D_STR( polyRouteStatus_, numPolys_ );
1393 DEF_MALLOC_FUNC_FOR_2D_STR( polyShapeTypes_, numPolys_ );
1394 DEF_MALLOC_FUNC_FOR_2D_STR( polyRouteStatusShieldNames_, numPolys_ );
1395
1396 DEF_COPY_FUNC( numRects_ );
1397 DEF_COPY_FUNC( rectsAllocated_ );
1398 DEF_MALLOC_FUNC_FOR_2D_STR( rectNames_, numRects_ );
1399
1400 DEF_MALLOC_FUNC( xl_, int, sizeof(int) * numRects_ );
1401 DEF_MALLOC_FUNC( yl_, int, sizeof(int) * numRects_ );
1402 DEF_MALLOC_FUNC( xh_, int, sizeof(int) * numRects_ );
1403 DEF_MALLOC_FUNC( yh_, int, sizeof(int) * numRects_ );
1404 DEF_MALLOC_FUNC( rectMasks_, int, sizeof(int) * numRects_ );
1405 DEF_MALLOC_FUNC_FOR_2D_STR( rectRouteStatus_, numRects_ );
1406 DEF_MALLOC_FUNC_FOR_2D_STR( rectRouteStatusShieldNames_, numRects_ );
1407 DEF_MALLOC_FUNC_FOR_2D_STR( rectShapeTypes_, numRects_ );
1408
1409 DEF_COPY_FUNC( numPts_ );
1410 DEF_COPY_FUNC( ptsAllocated_ );
1411
1412 DEF_MALLOC_FUNC_FOR_2D_POINT( viaPts_, numPts_ );
1413 DEF_MALLOC_FUNC_FOR_2D_STR( viaNames_, numPts_ );
1414
1415 DEF_MALLOC_FUNC( viaOrients_, int, sizeof(int) * numPts_ );
1416 DEF_MALLOC_FUNC( viaMasks_, int, sizeof(int) * numPts_ );
1417 DEF_MALLOC_FUNC_FOR_2D_STR( viaRouteStatus_, numPts_ );
1418 DEF_MALLOC_FUNC_FOR_2D_STR( viaRouteStatusShieldNames_, numPts_ );
1419 DEF_MALLOC_FUNC_FOR_2D_STR( viaShapeTypes_, numPts_ );
1420 return *this;
1421 }
1422
Destroy()1423 void defiNet::Destroy() {
1424 clear();
1425 free(name_);
1426 free((char*)(instances_));
1427 free((char*)(pins_));
1428 free(musts_);
1429 free(synthesized_);
1430 free((char*)(propNames_));
1431 free((char*)(propValues_));
1432 free((char*)(propDValues_));
1433 free((char*)(propTypes_));
1434 free((char*)(subnets_));
1435 if (source_) free(source_);
1436 if (pattern_) free(pattern_);
1437 if (shieldNet_) free(shieldNet_);
1438 if (original_) free(original_);
1439 if (use_) free(use_);
1440 if (nonDefaultRule_) free(nonDefaultRule_);
1441 if (wlayers_) free((char*)(wlayers_));
1442 if (slayers_) free((char*)(slayers_));
1443 if (sdist_) free((char*)(sdist_));
1444 if (wdist_) free((char*)(wdist_));
1445 if (sleft_) free((char*)(sleft_));
1446 if (sright_) free((char*)(sright_));
1447 }
1448
1449
~defiNet()1450 defiNet::~defiNet() {
1451 Destroy();
1452 }
1453
1454
setName(const char * name)1455 void defiNet::setName(const char* name) {
1456 int len = strlen(name) + 1;
1457 clear();
1458 if (len > nameSize_) bumpName(len);
1459 strcpy(name_, defData->DEFCASE(name));
1460 }
1461
1462
addMustPin(const char * instance,const char * pin,int syn)1463 void defiNet::addMustPin(const char* instance, const char* pin, int syn) {
1464 clear();
1465 addPin(instance, pin, syn);
1466 musts_[numPins_ - 1] = 1;
1467 }
1468
1469
addPin(const char * instance,const char * pin,int syn)1470 void defiNet::addPin(const char* instance, const char* pin, int syn) {
1471 int len;
1472
1473 if (numPins_ == pinsAllocated_)
1474 bumpPins(pinsAllocated_ * 2);
1475
1476 len = strlen(instance)+ 1;
1477 instances_[numPins_] = (char*)malloc(len);
1478 strcpy(instances_[numPins_], defData->DEFCASE(instance));
1479
1480 len = strlen(pin)+ 1;
1481 // printf("len: %d\n", len);
1482 // printf("numPins_: %d\n", numPins_);
1483 // printf("pins_ address: %x\n", pins_);
1484 // fflush(stdout);
1485 pins_[numPins_] = (char*)malloc(len);
1486 strcpy(pins_[numPins_], defData->DEFCASE(pin));
1487
1488 musts_[numPins_] = 0;
1489 synthesized_[numPins_] = syn;
1490
1491 (numPins_)++;
1492 }
1493
1494
setWeight(int w)1495 void defiNet::setWeight(int w) {
1496 hasWeight_ = 1;
1497 weight_ = w;
1498 }
1499
1500
addProp(const char * name,const char * value,const char type)1501 void defiNet::addProp(const char* name, const char* value, const char type) {
1502 int len;
1503
1504 if (numProps_ == propsAllocated_)
1505 bumpProps(propsAllocated_ * 2);
1506
1507 len = strlen(name)+ 1;
1508 propNames_[numProps_] = (char*)malloc(len);
1509 strcpy(propNames_[numProps_], defData->DEFCASE(name));
1510
1511 len = strlen(value)+ 1;
1512 propValues_[numProps_] = (char*)malloc(len);
1513 strcpy(propValues_[numProps_], defData->DEFCASE(value));
1514
1515 propDValues_[numProps_] = 0;
1516 propTypes_[numProps_] = type;
1517
1518 (numProps_)++;
1519 }
1520
1521
addNumProp(const char * name,const double d,const char * value,const char type)1522 void defiNet::addNumProp(const char* name, const double d,
1523 const char* value, const char type) {
1524 int len;
1525
1526 if (numProps_ == propsAllocated_)
1527 bumpProps(propsAllocated_ * 2);
1528
1529 len = strlen(name)+ 1;
1530 propNames_[numProps_] = (char*)malloc(len);
1531 strcpy(propNames_[numProps_], defData->DEFCASE(name));
1532
1533 len = strlen(value)+ 1;
1534 propValues_[numProps_] = (char*)malloc(len);
1535 strcpy(propValues_[numProps_], defData->DEFCASE(value));
1536
1537 propDValues_[numProps_] = d;
1538 propTypes_[numProps_] = type;
1539
1540 (numProps_)++;
1541 }
1542
1543
addSubnet(defiSubnet * subnet)1544 void defiNet::addSubnet(defiSubnet* subnet) {
1545
1546 if (numSubnets_ >= subnetsAllocated_)
1547 bumpSubnets(subnetsAllocated_ * 2);
1548
1549 subnets_[numSubnets_++] = subnet;
1550 }
1551
1552 // WMD -- will be removed after the next release
setType(const char * typ)1553 void defiNet::setType(const char* typ) {
1554 if (*typ == 'F') {
1555 isFixed_ = 1;
1556 } else if (*typ == 'C') {
1557 isCover_ = 1;
1558 } else if (*typ == 'R') {
1559 isRouted_ = 1;
1560 } else {
1561 // Silently do nothing with bad input.
1562 }
1563 }
1564
addWire(const char * type,const char * wireShieldName)1565 void defiNet::addWire(const char* type, const char* wireShieldName) {
1566 defiWire* wire;
1567 if (numWires_ == wiresAllocated_) {
1568 defiWire** array;
1569 int i;
1570 wiresAllocated_ = wiresAllocated_ ?
1571 wiresAllocated_ * 2 : 2 ;
1572 array = (defiWire**)malloc(sizeof(defiWire*)*wiresAllocated_);
1573 for (i = 0; i < numWires_; i++)
1574 array[i] = wires_[i];
1575 if (wires_) free((char*)(wires_));
1576 wires_ = array;
1577 }
1578 wire = wires_[numWires_] = new defiWire(defData);
1579 numWires_ += 1;
1580 wire->Init(type, wireShieldName);
1581 }
1582
1583
addWirePath(defiPath * p,int reset,int netOsnet,int * needCbk)1584 void defiNet::addWirePath(defiPath* p, int reset, int netOsnet, int *needCbk) {
1585 if (numWires_ > 0)
1586 wires_[numWires_-1]->addPath(p, reset, netOsnet,
1587 needCbk);
1588 else
1589 // Something screw up, can't be both be zero.
1590 defiError(0, 6081, "ERROR (DEFPARS-6081): An internal error has occurred. The index number for the NET PATH wires array is less then or equal to 0.\nContact Cadence Customer Support with this error information.", defData);
1591 }
1592
1593
addShield(const char * name)1594 void defiNet::addShield(const char* name) {
1595 defiShield* shield;
1596 if (numShields_ == shieldsAllocated_) {
1597 defiShield** array;
1598 int i;
1599 shieldsAllocated_ = shieldsAllocated_ ?
1600 shieldsAllocated_ * 2 : 2 ;
1601 array = (defiShield**)malloc(sizeof(defiShield*)*shieldsAllocated_);
1602 for (i = 0; i < numShields_; i++)
1603 array[i] = shields_[i];
1604 if (shields_) free((char*)(shields_));
1605 shields_ = array;
1606 }
1607 shield = shields_[numShields_] = new defiShield(defData);
1608 numShields_ += 1;
1609 shield->Init(name);
1610 }
1611
1612
addShieldPath(defiPath * p,int reset,int netOsnet,int * needCbk)1613 void defiNet::addShieldPath(defiPath* p, int reset, int netOsnet, int *needCbk) {
1614 // Since shield and noshield share the list shields_, the
1615 // only way to tell whether the list is currently contained
1616 // data for shields_ or noshields_ is from the variables
1617 // numShields_ and numNoShields_.
1618 // Since shield and noshield are mutual exclusive, only one
1619 // numShields_ or numNoShields will be non-zero
1620 // in this method. Whichever is non-zero will be the current
1621 // working list
1622 if (numShields_ > 0)
1623 shields_[numShields_-1]->addPath(p, reset,
1624 netOsnet, needCbk);
1625 else if (numNoShields_ > 0)
1626 shields_[numNoShields_-1]->addPath(p, reset,
1627 netOsnet, needCbk);
1628 else
1629 // Something screw up, can't be both be zero.
1630 defiError(0, 6082, "ERROR (DEFPARS-6082): An internal error has occurred. The index number for the NET SHIELDPATH wires array is less then or equal to 0.\nContact Cadence Customer Support with this error information.", defData);
1631 }
1632
1633
addNoShield(const char * name)1634 void defiNet::addNoShield(const char* name) {
1635 defiShield* shield;
1636 if (numNoShields_ == shieldsAllocated_) {
1637 defiShield** array;
1638 int i;
1639 shieldsAllocated_ = shieldsAllocated_ ?
1640 shieldsAllocated_ * 2 : 2 ;
1641 array = (defiShield**)malloc(sizeof(defiShield*)*shieldsAllocated_);
1642 for (i = 0; i < numNoShields_; i++)
1643 array[i] = shields_[i];
1644 if (shields_) free((char*)(shields_));
1645 shields_ = array;
1646 }
1647 shield = shields_[numNoShields_] = new defiShield(defData);
1648 numNoShields_ += 1;
1649 shield->Init(name);
1650 }
1651
1652
addShieldNet(const char * name)1653 void defiNet::addShieldNet(const char* name) {
1654 int len;
1655
1656 if (numShieldNet_ == shieldNetsAllocated_) {
1657 if (shieldNetsAllocated_ == 0)
1658 bumpShieldNets(2);
1659 else
1660 bumpShieldNets(shieldNetsAllocated_ * 2);
1661
1662 }
1663
1664 len = strlen(name) + 1;
1665 shieldNet_[numShieldNet_] = (char*)malloc(len);
1666 strcpy(shieldNet_[numShieldNet_], defData->DEFCASE(name));
1667 (numShieldNet_)++;
1668 }
1669
1670
changeNetName(const char * name)1671 void defiNet::changeNetName(const char* name) {
1672 int len = strlen(name) + 1;
1673 if (len > nameSize_) bumpName(len);
1674 strcpy(name_, defData->DEFCASE(name));
1675 }
1676
changeInstance(const char * instance,int index)1677 void defiNet::changeInstance(const char* instance, int index) {
1678 int len;
1679 char errMsg[256];
1680
1681 if ((index < 0) || (index > numPins_)) {
1682 sprintf (errMsg, "ERROR (DEFPARS-6083): The index number %d specified for the NET INSTANCE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
1683 index, numPins_);
1684 defiError(0, 6083, errMsg, defData);
1685 }
1686
1687 len = strlen(instance)+ 1;
1688 if (instances_[index])
1689 free((char*)(instances_[index]));
1690 instances_[index] = (char*)malloc(len);
1691 strcpy(instances_[index], defData->DEFCASE(instance));
1692 return;
1693 }
1694
changePin(const char * pin,int index)1695 void defiNet::changePin(const char* pin, int index) {
1696 int len;
1697 char errMsg[256];
1698
1699 if ((index < 0) || (index > numPins_)) {
1700 sprintf (errMsg, "ERROR (DEFPARS-6084): The index number %d specified for the NET PIN is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
1701 index, numPins_);
1702 defiError(0, 6084, errMsg, defData);
1703 }
1704
1705 len = strlen(pin)+ 1;
1706 if (pins_[index])
1707 free((char*)(pins_[index]));
1708 pins_[index] = (char*)malloc(len);
1709 strcpy(pins_[index], defData->DEFCASE(pin));
1710 return;
1711 }
1712
name() const1713 const char* defiNet::name() const {
1714 return name_;
1715 }
1716
1717
weight() const1718 int defiNet::weight() const {
1719 return weight_;
1720 }
1721
1722
numProps() const1723 int defiNet::numProps() const {
1724 return numProps_;
1725 }
1726
1727
hasProps() const1728 int defiNet::hasProps() const {
1729 return numProps_ ? 1 : 0 ;
1730 }
1731
1732
hasWeight() const1733 int defiNet::hasWeight() const {
1734 return (int)(hasWeight_);
1735 }
1736
1737
propName(int index) const1738 const char* defiNet::propName(int index) const {
1739 if (index >= 0 && index < numProps_)
1740 return propNames_[index];
1741 return 0;
1742 }
1743
1744
propValue(int index) const1745 const char* defiNet::propValue(int index) const {
1746 if (index >= 0 && index < numProps_)
1747 return propValues_[index];
1748 return 0;
1749 }
1750
1751
propNumber(int index) const1752 double defiNet::propNumber(int index) const {
1753 if (index >= 0 && index < numProps_)
1754 return propDValues_[index];
1755 return 0;
1756 }
1757
1758
propType(int index) const1759 char defiNet::propType(int index) const {
1760 if (index >= 0 && index < numProps_)
1761 return propTypes_[index];
1762 return 0;
1763 }
1764
1765
propIsNumber(int index) const1766 int defiNet::propIsNumber(int index) const {
1767 if (index >= 0 && index < numProps_)
1768 return propDValues_[index] ? 1 : 0;
1769 return 0;
1770 }
1771
1772
propIsString(int index) const1773 int defiNet::propIsString(int index) const {
1774 if (index >= 0 && index < numProps_)
1775 return propDValues_[index] ? 0 : 1;
1776 return 0;
1777 }
1778
1779
numConnections() const1780 int defiNet::numConnections() const {
1781 return numPins_;
1782 }
1783
1784
numShieldNets() const1785 int defiNet::numShieldNets() const {
1786 return numShieldNet_;
1787 }
1788
1789
instance(int index) const1790 const char* defiNet::instance(int index) const {
1791 if (index >= 0 && index < numPins_)
1792 return instances_[index];
1793 return 0;
1794 }
1795
1796
pin(int index) const1797 const char* defiNet::pin(int index) const {
1798 if (index >= 0 && index < numPins_)
1799 return pins_[index];
1800 return 0;
1801 }
1802
1803
pinIsMustJoin(int index) const1804 int defiNet::pinIsMustJoin(int index) const {
1805 if (index >= 0 && index < numPins_)
1806 return (int)(musts_[index]);
1807 return 0;
1808 }
1809
1810
pinIsSynthesized(int index) const1811 int defiNet::pinIsSynthesized(int index) const {
1812 if (index >= 0 && index < numPins_){
1813 // printf("curidx: %d\n", index);
1814 // printf("numPins_ : %d\n", numPins_);
1815 // printf("synthesized_ addr: %x\n", synthesized_);
1816 // fflush(stdout);
1817 return (int)(synthesized_[index]);
1818 }
1819 return 0;
1820 }
1821
1822
hasSubnets() const1823 int defiNet::hasSubnets() const {
1824 return numSubnets_ ? 1 : 0 ;
1825 }
1826
1827
numSubnets() const1828 int defiNet::numSubnets() const {
1829 return numSubnets_;
1830 }
1831
1832
subnet(int index)1833 defiSubnet* defiNet::subnet(int index) {
1834 if (index >= 0 && index < numSubnets_)
1835 return subnets_[index];
1836 return 0;
1837 }
1838
1839
subnet(int index) const1840 const defiSubnet* defiNet::subnet(int index) const {
1841 if (index >= 0 && index < numSubnets_)
1842 return subnets_[index];
1843 return 0;
1844 }
1845
1846
isFixed() const1847 int defiNet::isFixed() const {
1848 return (int)(isFixed_);
1849 }
1850
1851
isRouted() const1852 int defiNet::isRouted() const {
1853 return (int)(isRouted_);
1854 }
1855
1856
isCover() const1857 int defiNet::isCover() const {
1858 return (int)(isCover_);
1859 }
1860
1861
1862 // this method will only call if the callback defrSNetWireCbk is set
1863 // which will callback every wire. Therefore, only one wire should be here
freeWire()1864 void defiNet::freeWire() {
1865 int i;
1866
1867 if (numWires_) {
1868 for (i = 0; i < numWires_; i++) {
1869 wires_[i]->Destroy();
1870 free((char*)(wires_[i]));
1871 wires_[i] = 0;
1872 }
1873 free((char*)(wires_));
1874 wires_ = 0;
1875 numWires_ = 0;
1876 wiresAllocated_ = 0;
1877 }
1878
1879 clearRectPoly();
1880 clearVia();
1881 }
1882
1883
freeShield()1884 void defiNet::freeShield() {
1885 int i;
1886
1887 if (numShields_) {
1888 for (i = 0; i < numShields_; i++) {
1889 shields_[i]->Destroy();
1890 free((char*)(shields_[i]));
1891 shields_[i] = 0;
1892 }
1893 numShields_ = 0;
1894 shieldsAllocated_ = 0;
1895 }
1896 }
1897
1898
print(FILE * f) const1899 void defiNet::print(FILE* f) const {
1900 int i, j, x, y, newLayer;
1901 int numX, numY, stepX, stepY;
1902 const defiPath* p;
1903 const defiSubnet* s;
1904 const defiVpin* vp;
1905 const defiWire* w;
1906 int path;
1907
1908 fprintf(f, "Net '%s'", name_);
1909 fprintf(f, "\n");
1910
1911 if (hasWeight())
1912 fprintf(f, " weight=%d\n", weight());
1913
1914 if (hasFixedbump())
1915 fprintf(f, " fixedbump\n");
1916
1917 if (hasFrequency())
1918 fprintf(f, " frequency=%f\n", frequency());
1919
1920 if (hasCap())
1921 fprintf(f, " cap=%f\n", cap());
1922
1923 if (hasSource())
1924 fprintf(f, " source='%s'\n", source());
1925
1926 if (hasPattern())
1927 fprintf(f, " pattern='%s'\n", pattern());
1928
1929 if (hasOriginal())
1930 fprintf(f, " original='%s'\n", original());
1931
1932 if (hasUse())
1933 fprintf(f, " use='%s'\n", use());
1934
1935 if (hasNonDefaultRule())
1936 fprintf(f, " nonDefaultRule='%s'\n", nonDefaultRule());
1937
1938 if (hasXTalk())
1939 fprintf(f, " xtalk=%d\n", XTalk());
1940
1941 if (hasStyle())
1942 fprintf(f, " style='%d'\n", style());
1943
1944 if (hasProps()) {
1945 fprintf(f, " Props:\n");
1946 for (i = 0; i < numProps(); i++) {
1947 fprintf(f, " '%s' '%s'\n", propName(i),
1948 propValue(i));
1949 }
1950 }
1951
1952 if (numConnections()) {
1953 fprintf(f, " Pins:\n");
1954 for (i = 0; i < numConnections(); i++) {
1955 fprintf(f, " '%s' '%s'%s%s\n",
1956 instance(i),
1957 pin(i),
1958 pinIsMustJoin(i) ? " MUSTJOIN" : "",
1959 pinIsSynthesized(i) ? " SYNTHESIZED" : "");
1960 }
1961 }
1962
1963 for (i = 0; i < numVpins_; i++) {
1964 vp = vpin(i);
1965 fprintf(f,
1966 " VPIN %s status '%c' layer %s %d,%d orient %s bounds %d,%d to %d,%d\n",
1967 vp->name(),
1968 vp->status(),
1969 vp->layer() ? vp->layer() : "",
1970 vp->xLoc(),
1971 vp->yLoc(),
1972 vp->orientStr(),
1973 vp->xl(),
1974 vp->yl(),
1975 vp->xh(),
1976 vp->yh());
1977 }
1978
1979 for (i = 0; i < numWires_; i++) {
1980 newLayer = 0;
1981 w = wire(i);
1982 fprintf(f, "+ %s ", w->wireType());
1983 for (j = 0; j < w->numPaths(); j++) {
1984 p = w->path(j);
1985 p->initTraverse();
1986 while ((path = (int)(p->next())) != DEFIPATH_DONE) {
1987 switch (path) {
1988 case DEFIPATH_LAYER:
1989 if (newLayer == 0) {
1990 fprintf(f, "%s ", p->getLayer());
1991 newLayer = 1;
1992 } else
1993 fprintf(f, "NEW %s ", p->getLayer());
1994 break;
1995 case DEFIPATH_VIA:
1996 fprintf(f, "%s\n", p->getVia());
1997 break;
1998 case DEFIPATH_VIAROTATION:
1999 fprintf(f, "%d\n", p->getViaRotation());
2000 break;
2001 case DEFIPATH_VIADATA:
2002 p->getViaData(&numX, &numY, &stepX, &stepY);
2003 fprintf(f, "%d %d %d %d\n", numX, numY, stepX, stepY);
2004 break;
2005 case DEFIPATH_WIDTH:
2006 fprintf(f, "%d\n", p->getWidth());
2007 break;
2008 case DEFIPATH_POINT:
2009 p->getPoint(&x, &y);
2010 fprintf(f, "( %d %d )\n", x, y);
2011 break;
2012 case DEFIPATH_TAPER:
2013 fprintf(f, "TAPER\n");
2014 break;
2015 }
2016 }
2017 }
2018 }
2019
2020 if (hasSubnets()) {
2021 fprintf(f, " Subnets:\n");
2022 for (i = 0; i < numSubnets(); i++) {
2023 s = subnet(i);
2024 s->print(f);
2025 }
2026 }
2027
2028 }
2029
2030
bumpName(long long size)2031 void defiNet::bumpName(long long size) {
2032 if (name_) free(name_);
2033 name_ = (char*)malloc(size);
2034 nameSize_ = size;
2035 name_[0] = '\0';
2036 }
2037
2038
bumpPins(long long size)2039 void defiNet::bumpPins(long long size) {
2040 char** newInstances = (char**)malloc(sizeof(char*)*size);
2041 char** newPins = (char**)malloc(sizeof(char*)*size);
2042 char* newMusts = (char*)malloc(size);
2043 char* newSyn = (char*)malloc(size);
2044 long long i;
2045
2046 if (instances_) {
2047 for (i = 0; i < pinsAllocated_; i++) {
2048 newInstances[i] = instances_[i];
2049 newPins[i] = pins_[i];
2050 newMusts[i] = musts_[i];
2051 newSyn[i] = synthesized_[i];
2052 }
2053 free((char*)(instances_));
2054 free((char*)(pins_));
2055 free(musts_);
2056 free(synthesized_);
2057 }
2058
2059 instances_ = newInstances;
2060 pins_ = newPins;
2061 musts_ = newMusts;
2062 synthesized_ = newSyn;
2063 pinsAllocated_ = size;
2064 }
2065
2066
bumpProps(long long size)2067 void defiNet::bumpProps(long long size) {
2068 char** newNames = (char**)malloc(sizeof(char*)*size);
2069 char** newValues = (char**)malloc(sizeof(char*)*size);
2070 double* newDValues = (double*)malloc(sizeof(double)*size);
2071 char* newTypes = (char*)malloc(sizeof(char)*size);
2072 long long i;
2073
2074 if (propNames_) {
2075 for (i = 0; i < numProps_; i++) {
2076 newNames[i] = propNames_[i];
2077 newValues[i] = propValues_[i];
2078 newDValues[i] = propDValues_[i];
2079 newTypes[i] = propTypes_[i];
2080 }
2081 free((char*)(propNames_));
2082 free((char*)(propValues_));
2083 free((char*)(propDValues_));
2084 free((char*)(propTypes_));
2085 }
2086
2087 propNames_ = newNames;
2088 propValues_ = newValues;
2089 propDValues_ = newDValues;
2090 propTypes_ = newTypes;
2091 propsAllocated_ = size;
2092 }
2093
2094
bumpSubnets(long long size)2095 void defiNet::bumpSubnets(long long size) {
2096 defiSubnet** newSubnets = (defiSubnet**)malloc(sizeof(defiSubnet*)*size);
2097 int i;
2098 if (subnets_) {
2099 for (i = 0; i < numSubnets_; i++) {
2100 newSubnets[i] = subnets_[i];
2101 }
2102 free((char*)(subnets_));
2103 }
2104
2105 subnets_ = newSubnets;
2106 subnetsAllocated_ = size;
2107 }
2108
2109
clear()2110 void defiNet::clear() {
2111 int i;
2112
2113 // WMD -- this will be removed by the next release
2114 isFixed_ = 0;
2115 isRouted_ = 0;
2116 isCover_ = 0;
2117
2118 hasWeight_ = 0;
2119 hasCap_ = 0;
2120 hasFrequency_ = 0;
2121 hasVoltage_ = 0;
2122 xTalk_ = -1;
2123
2124 if (vpins_) {
2125 for (i = 0; i < numVpins_; i++) {
2126 delete vpins_[i];
2127 }
2128 free((char*)vpins_);
2129 vpins_ = 0;
2130 numVpins_ = 0;
2131 vpinsAllocated_ = 0;
2132 }
2133
2134 for (i = 0; i < numProps_; i++) {
2135 free(propNames_[i]);
2136 free(propValues_[i]);
2137 propNames_[i] = 0;
2138 propValues_[i] = 0;
2139 propDValues_[i] = 0;
2140 }
2141 numProps_ = 0;
2142
2143 for (i = 0; i < numPins_; i++) {
2144 free(instances_[i]);
2145 free(pins_[i]);
2146 instances_[i] = 0;
2147 pins_[i] = 0;
2148 musts_[i] = 0;
2149 synthesized_[i] = 0;
2150 }
2151 numPins_ = 0;
2152
2153 for (i = 0; i < numSubnets_; i++) {
2154 delete subnets_[i];
2155 subnets_[i] = 0;
2156 }
2157 numSubnets_ = 0;
2158
2159 if (name_)
2160 name_[0] = '\0';
2161
2162 // WMD -- this will be removed by the next release
2163 if (paths_) {
2164 for (i = 0; i < numPaths_; i++) {
2165 delete paths_[i];
2166 }
2167
2168 delete [] paths_;
2169 paths_ = 0;
2170 numPaths_ = 0;
2171 pathsAllocated_ = 0;
2172 }
2173
2174 // 5.4.1
2175 fixedbump_ = 0;
2176
2177 if (source_) { free(source_); source_ = 0; }
2178 if (pattern_) { free(pattern_); pattern_ = 0; }
2179 if (original_) { free(original_); original_ = 0; }
2180 if (use_) { free(use_); use_ = 0; }
2181 if (nonDefaultRule_) { free(nonDefaultRule_);
2182 nonDefaultRule_ = 0; }
2183 style_ = 0;
2184
2185 if (numWires_) {
2186 for (i = 0; i < numWires_; i++) {
2187 delete wires_[i];
2188 wires_[i] = 0;
2189 }
2190 free((char*)(wires_));
2191 wires_ = 0;
2192 numWires_ = 0;
2193 wiresAllocated_ = 0;
2194 }
2195
2196 if (numShields_) {
2197 for (i = 0; i < numShields_; i++) {
2198 delete shields_[i];
2199 shields_[i] = 0;
2200 }
2201 numShields_ = 0;
2202 shieldsAllocated_ = 0;
2203 }
2204
2205 if (numNoShields_) {
2206 for (i = 0; i < numNoShields_; i++) {
2207 delete shields_[i];
2208 shields_[i] = 0;
2209 }
2210 numNoShields_ = 0;
2211 shieldsAllocated_ = 0;
2212 }
2213 if (shields_)
2214 free((char*)(shields_));
2215
2216 shields_ = 0;
2217
2218 if (numWidths_) {
2219 for (i = 0; i < numWidths_; i++)
2220 free(wlayers_[i]);
2221 numWidths_ = 0;
2222 }
2223
2224 if (numSpacing_) {
2225 for (i = 0; i < numSpacing_; i++)
2226 free(slayers_[i]);
2227 numSpacing_ = 0;
2228 }
2229
2230 if (numShieldNet_) {
2231 for (i = 0; i < numShieldNet_; i++)
2232 free(shieldNet_[i]);
2233 numShieldNet_ = 0;
2234 }
2235
2236 if (polygonNames_) {
2237 struct defiPoints* p;
2238 for (i = 0; i < numPolys_; i++) {
2239 if (polygonNames_[i]){
2240 free((char*)(polygonNames_[i]));
2241 }
2242 if (polyRouteStatus_[i]) {
2243 free((char*)(polyRouteStatus_[i]));
2244 }
2245 if (polyShapeTypes_[i]) {
2246 free((char*)(polyShapeTypes_[i]));
2247 }
2248 if (polyRouteStatusShieldNames_[i]) {
2249 free((char*)(polyRouteStatusShieldNames_[i]));
2250 }
2251 p = polygons_[i];
2252 free((char*)(p->x));
2253 free((char*)(p->y));
2254 free((char*)(polygons_[i]));
2255 }
2256 free((char*)(polygonNames_));
2257 free((char*)(polygons_));
2258 free((char*)(polyMasks_));
2259 free((char*)(polyRouteStatus_));
2260 free((char*)(polyShapeTypes_));
2261 free((char*)(polyRouteStatusShieldNames_));
2262 polygonNames_ = 0;
2263 polygons_ = 0;
2264 polyMasks_ = 0;
2265 polyRouteStatus_ = 0;
2266 polyShapeTypes_ = 0;
2267 polyRouteStatusShieldNames_ = 0;
2268 }
2269 numPolys_ = 0;
2270 polysAllocated_ = 0;
2271
2272 if (rectNames_) {
2273 for (i = 0; i < numRects_; i++) {
2274 if (rectNames_[i]) {
2275 free ((char*)(rectNames_[i]));
2276 }
2277 if (rectRouteStatus_[i]) {
2278 free ((char*)(rectRouteStatus_[i]));
2279 }
2280 if (rectRouteStatusShieldNames_[i]) {
2281 free ((char*)(rectRouteStatusShieldNames_[i]));
2282 }
2283 if (rectShapeTypes_[i]) {
2284 free ((char*)(rectShapeTypes_[i]));
2285 }
2286 }
2287 free((char*)(rectNames_));
2288 free((char*)(xl_));
2289 free((char*)(yl_));
2290 free((char*)(xh_));
2291 free((char*)(yh_));
2292 free((char*)(rectMasks_));
2293 free((char*)(rectRouteStatus_));
2294 free((char*)(rectRouteStatusShieldNames_));
2295 free((char*)(rectShapeTypes_));
2296 }
2297 rectNames_ = 0;
2298 rectRouteStatus_ = 0;
2299 rectShapeTypes_ = 0;
2300 rectRouteStatusShieldNames_ = 0;
2301 numRects_ = 0;
2302 rectsAllocated_ = 0;
2303 xl_ = 0;
2304 yl_ = 0;
2305 xh_ = 0;
2306 yh_ = 0;
2307 rectMasks_ = 0;
2308
2309 if (viaNames_) {
2310 struct defiPoints* p;
2311
2312 for (i = 0; i < numPts_; i++) {
2313 p = viaPts_[i];
2314 free((char*)(p->x));
2315 free((char*)(p->y));
2316 free((char*)(viaPts_[i]));
2317 if (viaNames_[i]) {
2318 free ((char*)(viaNames_[i]));
2319 }
2320 if (viaRouteStatus_[i]) {
2321 free ((char*)(viaRouteStatus_[i]));
2322 }
2323 if (viaShapeTypes_[i]) {
2324 free ((char*)(viaShapeTypes_[i]));
2325 }
2326 if (viaRouteStatusShieldNames_[i]) {
2327 free ((char*)(viaRouteStatusShieldNames_[i]));
2328 }
2329 }
2330 free((char*)(viaNames_));
2331 free((char*)(viaPts_));
2332 free((char*)(viaMasks_));
2333 free((char*)(viaOrients_));
2334 free((char*)(viaRouteStatus_));
2335 free((char*)(viaShapeTypes_));
2336 free((char*)(viaRouteStatusShieldNames_));
2337 viaNames_ = 0;
2338 viaPts_ = 0;
2339 viaRouteStatus_ = 0;
2340 viaShapeTypes_ = 0;
2341 viaRouteStatusShieldNames_ = 0 ;
2342 }
2343 numPts_ = 0;
2344 ptsAllocated_ = 0;
2345 viaOrients_ = 0;
2346 viaMasks_ = 0;
2347 }
2348
clearRectPolyNPath()2349 void defiNet::clearRectPolyNPath() {
2350 int i;
2351
2352 if (paths_) {
2353 for (i = 0; i < numPaths_; i++) {
2354 delete paths_[i];
2355 }
2356 numPaths_ = 0;
2357 }
2358
2359 clearRectPoly();
2360
2361 }
2362
clearRectPoly()2363 void defiNet::clearRectPoly() {
2364 int i;
2365
2366 if (polygonNames_) {
2367 struct defiPoints* p;
2368 for (i = 0; i < numPolys_; i++) {
2369 if (polygonNames_[i]){
2370 free((char*)(polygonNames_[i]));
2371 }
2372 if (polyRouteStatus_[i]) {
2373 free((char*)(polyRouteStatus_[i]));
2374 }
2375 if (polyShapeTypes_[i]) {
2376 free((char*)(polyShapeTypes_[i]));
2377 }
2378 if (polyRouteStatusShieldNames_[i]) {
2379 free((char*)(polyRouteStatusShieldNames_[i]));
2380 }
2381 p = polygons_[i];
2382 free((char*)(p->x));
2383 free((char*)(p->y));
2384 free((char*)(polygons_[i]));
2385 }
2386 free((char*)(polyMasks_));
2387 free((char*)(polygonNames_));
2388 free((char*)(polygons_));
2389 free((char*)(polyRouteStatus_));
2390 free((char*)(polyShapeTypes_));
2391 free((char*)(polyRouteStatusShieldNames_));
2392 }
2393 numPolys_ = 0;
2394 polysAllocated_ = 0;
2395 polyMasks_ = 0;
2396 polygonNames_ = 0;
2397 polyRouteStatus_= 0;
2398 polyShapeTypes_= 0;
2399 polyRouteStatusShieldNames_ = 0;
2400 polygons_ = 0;
2401
2402 if (rectNames_) {
2403 for (i = 0; i < numRects_; i++) {
2404 if (rectNames_[i]){
2405 free((char*)(rectNames_[i]));
2406 }
2407 if (rectRouteStatus_[i]){
2408 free((char*)(rectRouteStatus_[i]));
2409 }
2410 if (rectShapeTypes_[i]) {
2411 free((char*)(rectShapeTypes_[i]));
2412 }
2413 if (rectRouteStatusShieldNames_[i]) {
2414 free((char*)(rectRouteStatusShieldNames_[i]));
2415 }
2416 }
2417 free((char*)(rectMasks_));
2418 free((char*)(rectNames_));
2419 free((char*)(xl_));
2420 free((char*)(yl_));
2421 free((char*)(xh_));
2422 free((char*)(yh_));
2423 free((char*)(rectShapeTypes_));
2424 free((char*)(rectRouteStatus_));
2425 free((char*)(rectRouteStatusShieldNames_));
2426 }
2427 rectNames_ = 0;
2428 rectsAllocated_ = 0;
2429 xl_ = 0;
2430 yl_ = 0;
2431 xh_ = 0;
2432 yh_ = 0;
2433 numRects_ = 0;
2434 rectMasks_ = 0;
2435 rectRouteStatus_ = 0;
2436 rectShapeTypes_ = 0;
2437 rectRouteStatusShieldNames_=0;
2438 }
2439
hasSource() const2440 int defiNet::hasSource() const {
2441 return source_ ? 1 : 0;
2442 }
2443
2444
hasFixedbump() const2445 int defiNet::hasFixedbump() const {
2446 return fixedbump_ ? 1 : 0;
2447 }
2448
2449
hasFrequency() const2450 int defiNet::hasFrequency() const {
2451 return (int)(hasFrequency_);
2452 }
2453
2454
hasPattern() const2455 int defiNet::hasPattern() const {
2456 return pattern_ ? 1 : 0;
2457 }
2458
2459
hasOriginal() const2460 int defiNet::hasOriginal() const {
2461 return original_ ? 1 : 0;
2462 }
2463
2464
hasCap() const2465 int defiNet::hasCap() const {
2466 return (int)(hasCap_);
2467 }
2468
2469
hasUse() const2470 int defiNet::hasUse() const {
2471 return use_ ? 1 : 0;
2472 }
2473
2474
hasStyle() const2475 int defiNet::hasStyle() const {
2476 return style_ ? 1 : 0;
2477 }
2478
2479
hasXTalk() const2480 int defiNet::hasXTalk() const {
2481 return (xTalk_ != -1) ? 1 : 0;
2482 }
2483
2484
hasNonDefaultRule() const2485 int defiNet::hasNonDefaultRule() const {
2486 return nonDefaultRule_ ? 1 : 0;
2487 }
2488
2489
setSource(const char * typ)2490 void defiNet::setSource(const char* typ) {
2491 int len;
2492 if (source_) free(source_);
2493 len = strlen(typ) + 1;
2494 source_ = (char*)malloc(len);
2495 strcpy(source_, defData->DEFCASE(typ));
2496 }
2497
2498
setFixedbump()2499 void defiNet::setFixedbump() {
2500 fixedbump_ = 1;
2501 }
2502
2503
setFrequency(double frequency)2504 void defiNet::setFrequency(double frequency) {
2505 frequency_ = frequency;
2506 hasFrequency_ = 1;
2507 }
2508
2509
setOriginal(const char * typ)2510 void defiNet::setOriginal(const char* typ) {
2511 int len;
2512 if (original_) free(original_);
2513 len = strlen(typ) + 1;
2514 original_ = (char*)malloc(len);
2515 strcpy(original_, defData->DEFCASE(typ));
2516 }
2517
2518
setPattern(const char * typ)2519 void defiNet::setPattern(const char* typ) {
2520 int len;
2521 if (pattern_) free(pattern_);
2522 len = strlen(typ) + 1;
2523 pattern_ = (char*)malloc(len);
2524 strcpy(pattern_, defData->DEFCASE(typ));
2525 }
2526
2527
setCap(double w)2528 void defiNet::setCap(double w) {
2529 cap_ = w;
2530 hasCap_ = 1;
2531 }
2532
2533
setUse(const char * typ)2534 void defiNet::setUse(const char* typ) {
2535 int len;
2536 if (use_) free(use_);
2537 len = strlen(typ) + 1;
2538 use_ = (char*)malloc(len);
2539 strcpy(use_, defData->DEFCASE(typ));
2540 }
2541
2542
setStyle(int style)2543 void defiNet::setStyle(int style) {
2544 style_ = style;
2545 }
2546
2547
setNonDefaultRule(const char * typ)2548 void defiNet::setNonDefaultRule(const char* typ) {
2549 int len;
2550 if (nonDefaultRule_) free(nonDefaultRule_);
2551 len = strlen(typ) + 1;
2552 nonDefaultRule_ = (char*)malloc(len);
2553 strcpy(nonDefaultRule_, defData->DEFCASE(typ));
2554 }
2555
2556
source() const2557 const char* defiNet::source() const {
2558 return source_;
2559 }
2560
2561
original() const2562 const char* defiNet::original() const {
2563 return original_;
2564 }
2565
2566
pattern() const2567 const char* defiNet::pattern() const {
2568 return pattern_;
2569 }
2570
2571
cap() const2572 double defiNet::cap() const {
2573 return (hasCap_ ? cap_ : 0.0);
2574 }
2575
2576
frequency() const2577 double defiNet::frequency() const {
2578 return (hasFrequency_ ? frequency_ : 0.0);
2579 }
2580
2581
use() const2582 const char* defiNet::use() const {
2583 return use_;
2584 }
2585
2586
style() const2587 int defiNet::style() const {
2588 return style_;
2589 }
2590
2591
shieldNet(int index) const2592 const char* defiNet::shieldNet(int index) const {
2593 return shieldNet_[index];
2594 }
2595
2596
nonDefaultRule() const2597 const char* defiNet::nonDefaultRule() const {
2598 return nonDefaultRule_;
2599 }
2600
2601 // WMD -- this will be removed by the next release
bumpPaths(long long size)2602 void defiNet::bumpPaths(long long size) {
2603 long long i;
2604
2605 defiPath** newPaths = new defiPath*[size];
2606
2607 for (i = 0; i < numPaths_; i++)
2608 newPaths[i] = paths_[i];
2609
2610 delete [] paths_;
2611 pathsAllocated_ = size;
2612 paths_ = newPaths;
2613 }
2614
2615 // WMD -- this will be removed by the next release
numPaths() const2616 int defiNet::numPaths() const {
2617 return numPaths_;
2618 }
2619
2620
2621 // WMD -- this will be removed by the next release
path(int index)2622 defiPath* defiNet::path(int index) {
2623 if (index >= 0 && index < numPaths_)
2624 return paths_[index];
2625 return 0;
2626 }
2627
2628
path(int index) const2629 const defiPath* defiNet::path(int index) const {
2630 if (index >= 0 && index < numPaths_)
2631 return paths_[index];
2632 return 0;
2633 }
2634
2635
numWires() const2636 int defiNet::numWires() const {
2637 return numWires_;
2638 }
2639
2640
wire(int index)2641 defiWire* defiNet::wire(int index) {
2642 if (index >= 0 && index < numWires_)
2643 return wires_[index];
2644 return 0;
2645 }
2646
2647
wire(int index) const2648 const defiWire* defiNet::wire(int index) const {
2649 if (index >= 0 && index < numWires_)
2650 return wires_[index];
2651 return 0;
2652 }
2653
2654
bumpShieldNets(long long size)2655 void defiNet::bumpShieldNets(long long size) {
2656 char** newShieldNets = (char**)malloc(sizeof(char*)*size);
2657 long long i;
2658
2659 if (shieldNet_) {
2660 for (i = 0; i < shieldNetsAllocated_; i++) {
2661 newShieldNets[i] = shieldNet_[i];
2662 }
2663 free((char*)(shieldNet_));
2664 }
2665
2666 shieldNet_ = newShieldNets;
2667 shieldNetsAllocated_ = size;
2668 }
2669
2670
numShields() const2671 int defiNet::numShields() const {
2672 return numShields_;
2673 }
2674
2675
shield(int index)2676 defiShield* defiNet::shield(int index) {
2677 if (index >= 0 && index < numShields_)
2678 return shields_[index];
2679 return 0;
2680 }
2681
2682
shield(int index) const2683 const defiShield* defiNet::shield(int index) const {
2684 if (index >= 0 && index < numShields_)
2685 return shields_[index];
2686 return 0;
2687 }
2688
numNoShields() const2689 int defiNet::numNoShields() const {
2690 return numNoShields_;
2691 }
2692
2693
noShield(int index)2694 defiShield* defiNet::noShield(int index) {
2695 if (index >= 0 && index < numNoShields_)
2696 return shields_[index];
2697 return 0;
2698 }
2699
noShield(int index) const2700 const defiShield* defiNet::noShield(int index) const {
2701 if (index >= 0 && index < numNoShields_)
2702 return shields_[index];
2703 return 0;
2704 }
2705
hasVoltage() const2706 int defiNet::hasVoltage() const {
2707 return (int)(hasVoltage_);
2708 }
2709
2710
voltage() const2711 double defiNet::voltage() const {
2712 return voltage_;
2713 }
2714
2715
numWidthRules() const2716 int defiNet::numWidthRules() const {
2717 return numWidths_;
2718 }
2719
2720
numSpacingRules() const2721 int defiNet::numSpacingRules() const {
2722 return numSpacing_;
2723 }
2724
2725
hasWidthRules() const2726 int defiNet::hasWidthRules() const {
2727 return numWidths_;
2728 }
2729
2730
hasSpacingRules() const2731 int defiNet::hasSpacingRules() const {
2732 return numSpacing_;
2733 }
2734
2735
setXTalk(int i)2736 void defiNet::setXTalk(int i) {
2737 xTalk_ = i;
2738 }
2739
2740
XTalk() const2741 int defiNet::XTalk() const {
2742 return xTalk_;
2743 }
2744
2745
addVpin(const char * name)2746 void defiNet::addVpin(const char* name) {
2747 defiVpin* vp;
2748 if (numVpins_ == vpinsAllocated_) {
2749 defiVpin** array;
2750 int i;
2751 vpinsAllocated_ = vpinsAllocated_ ?
2752 vpinsAllocated_ * 2 : 2 ;
2753 array = (defiVpin**)malloc(sizeof(defiVpin*)*vpinsAllocated_);
2754 for (i = 0; i < numVpins_; i++)
2755 array[i] = vpins_[i];
2756 if (vpins_) free((char*)(vpins_));
2757 vpins_ = array;
2758 }
2759 vp = vpins_[numVpins_] = new defiVpin(defData);
2760 numVpins_ += 1;
2761 vp->Init(name);
2762 }
2763
2764
addVpinLayer(const char * name)2765 void defiNet::addVpinLayer(const char* name) {
2766 defiVpin* vp = vpins_[numVpins_-1];
2767 vp->setLayer(name);
2768 }
2769
2770
addVpinLoc(const char * status,int x,int y,int orient)2771 void defiNet::addVpinLoc(const char* status, int x, int y, int orient) {
2772 defiVpin* vp = vpins_[numVpins_-1];
2773 vp->setStatus(*status);
2774 vp->setLoc(x,y);
2775 vp->setOrient(orient);
2776 }
2777
2778
addVpinBounds(int xl,int yl,int xh,int yh)2779 void defiNet::addVpinBounds(int xl, int yl, int xh, int yh) {
2780 defiVpin* vp = vpins_[numVpins_-1];
2781 vp->setBounds(xl, yl, xh, yh);
2782 }
2783
2784
numVpins() const2785 int defiNet::numVpins() const {
2786 return numVpins_;
2787 }
2788
2789
vpin(int index)2790 defiVpin* defiNet::vpin(int index) {
2791 if (index < 0 || index >= numVpins_) return 0;
2792 return vpins_[index];
2793 }
2794
2795
vpin(int index) const2796 const defiVpin* defiNet::vpin(int index) const {
2797 if (index < 0 || index >= numVpins_) return 0;
2798 return vpins_[index];
2799 }
2800
spacingRule(int index,char ** layer,double * dist,double * left,double * right) const2801 void defiNet::spacingRule(int index, char** layer, double* dist,
2802 double* left, double* right) const {
2803 if (index >= 0 && index < numSpacing_) {
2804 if (layer) *layer = slayers_[index];
2805 if (dist) *dist = sdist_[index];
2806 if (left) *left = sleft_[index];
2807 if (right) *right = sright_[index];
2808 }
2809 }
2810
2811
widthRule(int index,char ** layer,double * dist) const2812 void defiNet::widthRule(int index, char** layer, double* dist) const {
2813 if (index >= 0 && index < numWidths_) {
2814 if (layer) *layer = wlayers_[index];
2815 if (dist) *dist = wdist_[index];
2816 }
2817 }
2818
2819
setVoltage(double v)2820 void defiNet::setVoltage(double v) {
2821 voltage_ = v;
2822 hasVoltage_ = 1;
2823 }
2824
2825
setWidth(const char * layer,double d)2826 void defiNet::setWidth(const char* layer, double d) {
2827 int len = strlen(layer) + 1;
2828 char* l = (char*)malloc(len);
2829 strcpy(l, defData->DEFCASE(layer));
2830
2831 if (numWidths_ >= widthsAllocated_) {
2832 int i;
2833 char** nl;
2834 double* nd;
2835 widthsAllocated_ = widthsAllocated_ ?
2836 widthsAllocated_ * 2 : 4 ;
2837 nl = (char**)malloc(sizeof(char*) * widthsAllocated_);
2838 nd = (double*)malloc(sizeof(double) * widthsAllocated_);
2839 for (i = 0; i < numWidths_; i++) {
2840 nl[i] = wlayers_[i];
2841 nd[i] = wdist_[i];
2842 }
2843 free((char*)(wlayers_));
2844 free((char*)(wdist_));
2845 wlayers_ = nl;
2846 wdist_ = nd;
2847 }
2848
2849 wlayers_[numWidths_] = l;
2850 wdist_[numWidths_] = d;
2851 (numWidths_)++;
2852 }
2853
2854
setSpacing(const char * layer,double d)2855 void defiNet::setSpacing(const char* layer, double d) {
2856 int len = strlen(layer) + 1;
2857 char* l = (char*)malloc(len);
2858 strcpy(l, defData->DEFCASE(layer));
2859
2860 if (numSpacing_ >= spacingAllocated_) {
2861 int i;
2862 char** nl;
2863 double* nd;
2864 double* n1;
2865 double* n2;
2866 spacingAllocated_ = spacingAllocated_ ?
2867 spacingAllocated_ * 2 : 4 ;
2868 nl = (char**)malloc(sizeof(char*) * spacingAllocated_);
2869 nd = (double*)malloc(sizeof(double) * spacingAllocated_);
2870 n1 = (double*)malloc(sizeof(double) * spacingAllocated_);
2871 n2 = (double*)malloc(sizeof(double) * spacingAllocated_);
2872 for (i = 0; i < numSpacing_; i++) {
2873 nl[i] = slayers_[i];
2874 nd[i] = sdist_[i];
2875 n1[i] = sleft_[i];
2876 n2[i] = sright_[i];
2877 }
2878 free((char*)(slayers_));
2879 free((char*)(sdist_));
2880 free((char*)(sleft_));
2881 free((char*)(sright_));
2882 slayers_ = nl;
2883 sdist_ = nd;
2884 sleft_ = n1;
2885 sright_ = n2;
2886 }
2887
2888 slayers_[numSpacing_] = l;
2889 sdist_[numSpacing_] = d;
2890 sleft_[numSpacing_] = d;
2891 sright_[numSpacing_] = d;
2892 (numSpacing_)++;
2893 }
2894
2895
setRange(double left,double right)2896 void defiNet::setRange(double left, double right) {
2897 // This is always called right after setSpacing.
2898 sleft_[numSpacing_-1] = left;
2899 sright_[numSpacing_-1] = right;
2900 }
2901
2902 // 5.6
addPolygon(const char * layerName,defiGeometries * geom,int * needCbk,int colorMask,const char * routeStatus,const char * shapeType,const char * routeStatusShieldName)2903 void defiNet::addPolygon(const char* layerName, defiGeometries* geom,
2904 int *needCbk, int colorMask,
2905 const char* routeStatus,
2906 const char* shapeType,
2907 const char* routeStatusShieldName) {
2908 struct defiPoints* p;
2909 int x, y;
2910 int i;
2911
2912 // This method will only call by specialnet, need to change if net also
2913 // calls it.
2914 *needCbk = 0;
2915 if (numPolys_ == polysAllocated_) {
2916 char** newn;
2917 char** newRS;
2918 char** newST;
2919 char** newRSN;
2920 int* maskn;
2921 struct defiPoints** poly;
2922 polysAllocated_ = (polysAllocated_ == 0) ?
2923 1000 : polysAllocated_ * 2;
2924 newn = (char**)malloc(sizeof(char*) * polysAllocated_);
2925 newRS = (char**)malloc(sizeof(char*) * polysAllocated_);
2926 newST = (char**)malloc(sizeof(char*) * polysAllocated_);
2927 newRSN = (char**)malloc(sizeof(char*) * polysAllocated_);
2928 maskn = (int*)malloc(sizeof(int) * polysAllocated_);
2929 poly = (struct defiPoints**)malloc(sizeof(struct defiPoints*) *
2930 polysAllocated_);
2931 for (i = 0; i < numPolys_; i++) {
2932 newn[i] = polygonNames_[i];
2933 poly[i] = polygons_[i];
2934 maskn[i] = polyMasks_[i];
2935 newRS[i] = polyRouteStatus_[i];
2936 newST[i] = polyShapeTypes_[i];
2937 newRSN[i] = polyRouteStatusShieldNames_[i];
2938
2939 }
2940 if (polygons_)
2941 free((char*)(polygons_));
2942 if (polygonNames_)
2943 free((char*)(polygonNames_));
2944 if (polyMasks_)
2945 free((char*)(polyMasks_));
2946 if (polyRouteStatus_)
2947 free((char*)(polyRouteStatus_));
2948 if (polyShapeTypes_)
2949 free((char*)(polyShapeTypes_));
2950 if (polyRouteStatusShieldNames_)
2951 free((char*)(polyRouteStatusShieldNames_));
2952 polygonNames_ = newn;
2953 polygons_ = poly;
2954 polyMasks_ = maskn;
2955 polyShapeTypes_ = newST;
2956 polyRouteStatus_= newRS;
2957 polyRouteStatusShieldNames_ = newRSN;
2958 }
2959 polygonNames_[numPolys_] = strdup(layerName);
2960 polyRouteStatus_[numPolys_] = strdup(routeStatus);
2961 polyShapeTypes_[numPolys_] = strdup(shapeType);
2962 polyRouteStatusShieldNames_[numPolys_] = strdup(routeStatusShieldName);
2963 p = (struct defiPoints*)malloc(sizeof(struct defiPoints));
2964 p->numPoints = geom->numPoints();
2965 p->x = (int*)malloc(sizeof(int)*p->numPoints);
2966 p->y = (int*)malloc(sizeof(int)*p->numPoints);
2967 for (i = 0; i < p->numPoints; i++) {
2968 geom->points(i, &x, &y);
2969 p->x[i] = x;
2970 p->y[i] = y;
2971 }
2972 polyMasks_[numPolys_] = colorMask;
2973 polygons_[numPolys_] = p;
2974 numPolys_ += 1;
2975 if (numPolys_ == 1000) // Want to invoke the partial callback if set
2976 *needCbk = 1;
2977 }
2978
2979
2980 // 5.6
numPolygons() const2981 int defiNet::numPolygons() const {
2982 return numPolys_;
2983 }
2984
2985
2986 // 5.6
polygonName(int index) const2987 const char* defiNet::polygonName(int index) const {
2988 char errMsg[256];
2989 if (index < 0 || index > numPolys_) {
2990 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
2991 index, numPolys_);
2992 defiError(0, 6085, errMsg, defData);
2993 return 0;
2994 }
2995 return polygonNames_[index];
2996 }
2997
polyRouteStatus(int index) const2998 const char* defiNet::polyRouteStatus(int index) const {
2999 char errMsg[256];
3000 if (index < 0 || index > numPolys_) {
3001 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3002 index, numPolys_);
3003 defiError(0, 6085, errMsg, defData);
3004 return 0;
3005 }
3006 return polyRouteStatus_[index];
3007 }
3008
polyRouteStatusShieldName(int index) const3009 const char* defiNet::polyRouteStatusShieldName(int index) const {
3010 char errMsg[256];
3011 if (index < 0 || index > numPolys_) {
3012 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3013 index, numPolys_);
3014 defiError(0, 6085, errMsg, defData);
3015 return 0;
3016 }
3017 return polyRouteStatusShieldNames_[index];
3018 }
3019
polyShapeType(int index) const3020 const char* defiNet::polyShapeType(int index) const {
3021 char errMsg[256];
3022 if (index < 0 || index > numPolys_) {
3023 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3024 index, numPolys_);
3025 defiError(0, 6085, errMsg, defData);
3026 return 0;
3027 }
3028 return polyShapeTypes_[index];
3029 }
3030
polyMask(int index) const3031 int defiNet::polyMask(int index) const {
3032 char errMsg[256];
3033 if (index < 0 || index > numPolys_) {
3034 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3035 index, numPolys_);
3036 defiError(0, 6085, errMsg, defData);
3037 return 0;
3038 }
3039 return polyMasks_[index];
3040 }
3041
3042 // 5.6
getPolygon(int index) const3043 struct defiPoints defiNet::getPolygon(int index) const {
3044 return *(polygons_[index]);
3045 }
3046
3047 // 5.6
addRect(const char * layerName,int xl,int yl,int xh,int yh,int * needCbk,int colorMask,const char * routeStatus,const char * shapeType,const char * routeStatusName)3048 void defiNet::addRect(const char* layerName, int xl, int yl, int xh, int yh,
3049 int *needCbk,
3050 int colorMask,
3051 const char* routeStatus,
3052 const char* shapeType,
3053 const char* routeStatusName) {
3054 // This method will only call by specialnet, need to change if net also
3055 // calls it.
3056 *needCbk = 0;
3057 if (numRects_ == rectsAllocated_) {
3058 int i;
3059 int max;
3060 char** newn;
3061 int* newxl;
3062 int* newyl;
3063 int* newxh;
3064 int* newyh;
3065 int* newMask;
3066 char** newRS;
3067 char** newST;
3068 char** newRSN;
3069
3070 max = rectsAllocated_ = (rectsAllocated_ == 0) ? 1000 :
3071 rectsAllocated_ * 2;
3072 newn = (char**)malloc(sizeof(char*)*max);
3073 newRS = (char**)malloc(sizeof(char*)*max);
3074 newST = (char**)malloc(sizeof(char*)*max);
3075 newRSN = (char**)malloc(sizeof(char*)*max);
3076 newxl = (int*)malloc(sizeof(int)*max);
3077 newyl = (int*)malloc(sizeof(int)*max);
3078 newxh = (int*)malloc(sizeof(int)*max);
3079 newyh = (int*)malloc(sizeof(int)*max);
3080 newMask = (int*)malloc(sizeof(int)*max);
3081 for (i = 0; i < numRects_; i++) {
3082 newn[i] = rectNames_[i];
3083 newxl[i] = xl_[i];
3084 newyl[i] = yl_[i];
3085 newxh[i] = xh_[i];
3086 newyh[i] = yh_[i];
3087 newMask[i] = rectMasks_[i];
3088 newRS[i] = rectRouteStatus_[i];
3089 newST[i] = rectShapeTypes_[i];
3090 newRSN[i] = rectRouteStatusShieldNames_[i];
3091 }
3092 if (rectNames_)
3093 free((char*)(rectNames_));
3094 if (rectRouteStatus_)
3095 free((char*)(rectRouteStatus_));
3096 if (rectShapeTypes_)
3097 free((char*)(rectShapeTypes_));
3098 if (rectRouteStatusShieldNames_)
3099 free((char*)(rectRouteStatusShieldNames_));
3100 if (xl_) {
3101 free((char*)(xl_));
3102 free((char*)(yl_));
3103 free((char*)(xh_));
3104 free((char*)(yh_));
3105 free((char*)(rectMasks_));
3106 }
3107 rectNames_ = newn;
3108 xl_ = newxl;
3109 yl_ = newyl;
3110 xh_ = newxh;
3111 yh_ = newyh;
3112 rectMasks_ = newMask;
3113 rectRouteStatus_ = newRS;
3114 rectShapeTypes_ = newST;
3115 rectRouteStatusShieldNames_ = newRSN;
3116 }
3117 rectNames_[numRects_] = strdup(layerName);
3118 xl_[numRects_] = xl;
3119 yl_[numRects_] = yl;
3120 xh_[numRects_] = xh;
3121 yh_[numRects_] = yh;
3122 rectMasks_[numRects_] = colorMask;
3123 rectRouteStatus_[numRects_] = strdup(routeStatus);
3124 rectShapeTypes_[numRects_] = strdup(shapeType);
3125 rectRouteStatusShieldNames_[numRects_] = strdup(routeStatusName);
3126 numRects_ += 1;
3127 if (numRects_ == 1000) // Want to invoke the partial callback if set
3128 *needCbk = 1;
3129 }
3130
3131 // 5.6
numRectangles() const3132 int defiNet::numRectangles() const {
3133 return numRects_;
3134 }
3135
3136 // 5.6
rectName(int index) const3137 const char* defiNet::rectName(int index) const {
3138 char errMsg[256];
3139 if (index < 0 || index > numRects_) {
3140 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3141 index, numRects_);
3142 defiError(0, 6086, errMsg, defData);
3143 return 0;
3144 }
3145 return rectNames_[index];
3146 }
3147
rectRouteStatus(int index) const3148 const char* defiNet::rectRouteStatus(int index) const {
3149 char errMsg[256];
3150 if (index < 0 || index > numRects_) {
3151 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3152 index, numRects_);
3153 defiError(0, 6086, errMsg, defData);
3154 return 0;
3155 }
3156 return rectRouteStatus_[index];
3157 }
3158
rectRouteStatusShieldName(int index) const3159 const char* defiNet::rectRouteStatusShieldName(int index) const {
3160 char errMsg[256];
3161 if (index < 0 || index > numRects_) {
3162 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3163 index, numRects_);
3164 defiError(0, 6086, errMsg, defData);
3165 return 0;
3166 }
3167 return rectRouteStatusShieldNames_[index];
3168 }
3169
rectShapeType(int index) const3170 const char* defiNet::rectShapeType(int index) const {
3171 char errMsg[256];
3172 if (index < 0 || index > numRects_) {
3173 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3174 index, numRects_);
3175 defiError(0, 6086, errMsg, defData);
3176 return 0;
3177 }
3178 return rectShapeTypes_[index];
3179 }
3180
3181 // 5.6
xl(int index) const3182 int defiNet::xl(int index) const {
3183 char errMsg[256];
3184 if (index < 0 || index >= numRects_) {
3185 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3186 index, numRects_);
3187 defiError(0, 6086, errMsg, defData);
3188 return 0;
3189 }
3190 return xl_[index];
3191 }
3192
3193 // 5.6
yl(int index) const3194 int defiNet::yl(int index) const {
3195 char errMsg[256];
3196 if (index < 0 || index >= numRects_) {
3197 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3198 index, numRects_);
3199 defiError(0, 6086, errMsg, defData);
3200 return 0;
3201 }
3202 return yl_[index];
3203 }
3204
3205 // 5.6
xh(int index) const3206 int defiNet::xh(int index) const {
3207 char errMsg[256];
3208 if (index < 0 || index >= numRects_) {
3209 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3210 index, numRects_);
3211 defiError(0, 6086, errMsg, defData);
3212 return 0;
3213 }
3214 return xh_[index];
3215 }
3216
3217 // 5.6
yh(int index) const3218 int defiNet::yh(int index) const {
3219 char errMsg[256];
3220 if (index < 0 || index >= numRects_) {
3221 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3222 index, numRects_);
3223 defiError(0, 6086, errMsg, defData);
3224 return 0;
3225 }
3226 return yh_[index];
3227 }
3228
rectMask(int index) const3229 int defiNet::rectMask(int index) const {
3230 char errMsg[256];
3231 if (index < 0 || index >= numRects_) {
3232 sprintf (errMsg, "ERROR (DEFPARS-6086): The index number %d specified for the NET RECTANGLE is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3233 index, numRects_);
3234 defiError(0, 6086, errMsg, defData);
3235 return 0;
3236 }
3237 return rectMasks_[index];
3238 }
3239
3240
addPts(const char * viaName,int o,defiGeometries * geom,int * needCbk,int colorMask,const char * routeStatus,const char * shapeType,const char * routeStatusShieldName)3241 void defiNet::addPts(const char* viaName, int o, defiGeometries* geom,
3242 int *needCbk, int colorMask,
3243 const char* routeStatus,
3244 const char* shapeType,
3245 const char* routeStatusShieldName) {
3246 struct defiPoints* p;
3247 int x, y;
3248 int i;
3249
3250 *needCbk = 0;
3251 if (numPts_ == ptsAllocated_) {
3252 struct defiPoints** pts;
3253 char** newn;
3254 char** newRS;
3255 char** newST;
3256 char** newRSN;
3257 int* orientn;
3258 int* maskn;
3259
3260 ptsAllocated_ = (ptsAllocated_ == 0) ?
3261 1000 : ptsAllocated_ * 2;
3262 newn = (char**)malloc(sizeof(char*) *ptsAllocated_);
3263 newRS = (char**)malloc(sizeof(char*) *ptsAllocated_);
3264 newST = (char**)malloc(sizeof(char*) *ptsAllocated_);
3265 newRSN = (char**)malloc(sizeof(char*) *ptsAllocated_);
3266 orientn = (int*)malloc(sizeof(int) *ptsAllocated_);
3267 pts= (struct defiPoints**)malloc(sizeof(struct defiPoints*) *
3268 ptsAllocated_);
3269 maskn = (int*)malloc(sizeof(int) *ptsAllocated_);
3270 for (i = 0; i < numPts_; i++) {
3271 pts[i] = viaPts_[i];
3272 newn[i] = viaNames_[i];
3273 newRS[i] = viaRouteStatus_[i];
3274 newST[i] = viaShapeTypes_[i];
3275 newRSN[i] = viaRouteStatusShieldNames_[i];
3276 orientn[i] = viaOrients_[i];
3277 maskn[i] = viaMasks_[i];
3278 }
3279 if (viaPts_)
3280 free((char*)(viaPts_));
3281 if (viaNames_)
3282 free((char*)(viaNames_));
3283 if (viaOrients_)
3284 free((char*)(viaOrients_));
3285 if (viaMasks_)
3286 free((char*)(viaMasks_));
3287 if (viaRouteStatus_)
3288 free((char*)(viaRouteStatus_));
3289 if (viaShapeTypes_)
3290 free((char*)(viaShapeTypes_));
3291 if (viaRouteStatusShieldNames_)
3292 free((char*)(viaRouteStatusShieldNames_));
3293
3294 viaPts_ = pts;
3295 viaNames_ = newn;
3296 viaOrients_ = orientn;
3297 viaMasks_ = maskn;
3298 viaShapeTypes_= newST;
3299 viaRouteStatus_ = newRS;
3300 viaRouteStatusShieldNames_ = newRSN;
3301 }
3302 viaNames_[numPts_] = strdup(viaName);
3303 viaShapeTypes_[numPts_] = strdup(shapeType);
3304 viaRouteStatus_[numPts_] = strdup(routeStatus);
3305 viaRouteStatusShieldNames_[numPts_] = strdup(routeStatusShieldName);
3306 viaOrients_[numPts_] = o;
3307 viaMasks_[numPts_] = colorMask;
3308 p = (struct defiPoints*)malloc(sizeof(struct defiPoints));
3309 p->numPoints = geom->numPoints();
3310 p->x = (int*)malloc(sizeof(int)*p->numPoints);
3311 p->y = (int*)malloc(sizeof(int)*p->numPoints);
3312 for (i = 0; i < p->numPoints; i++) {
3313 geom->points(i, &x, &y);
3314 p->x[i] = x;
3315 p->y[i] = y;
3316 }
3317 viaPts_[numPts_] = p;
3318 numPts_ += 1;
3319 if (numPts_ == 1000) // Want to invoke the partial callback if set
3320 *needCbk = 1;
3321 }
3322
numViaSpecs() const3323 int defiNet::numViaSpecs() const {
3324 return numPts_;
3325 }
3326
viaName(int index) const3327 const char* defiNet::viaName(int index) const {
3328 char errMsg[256];
3329 if (index < 0 || index > numPts_) {
3330 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3331 index, numPts_);
3332 defiError(0, 6085, errMsg, defData);
3333 return 0;
3334 }
3335 return viaNames_[index];
3336 }
3337
viaRouteStatus(int index) const3338 const char* defiNet::viaRouteStatus(int index) const {
3339 char errMsg[256];
3340 if (index < 0 || index > numPts_) {
3341 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3342 index, numPts_);
3343 defiError(0, 6085, errMsg, defData);
3344 return 0;
3345 }
3346 return viaRouteStatus_[index];
3347 }
3348
viaRouteStatusShieldName(int index) const3349 const char* defiNet::viaRouteStatusShieldName(int index) const {
3350 char errMsg[256];
3351 if (index < 0 || index > numPts_) {
3352 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3353 index, numPts_);
3354 defiError(0, 6085, errMsg, defData);
3355 return 0;
3356 }
3357 return viaRouteStatusShieldNames_[index];
3358 }
3359
viaShapeType(int index) const3360 const char* defiNet::viaShapeType(int index) const {
3361 char errMsg[256];
3362 if (index < 0 || index > numPts_) {
3363 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3364 index, numPts_);
3365 defiError(0, 6085, errMsg, defData);
3366 return 0;
3367 }
3368 return viaShapeTypes_[index];
3369 }
3370
viaOrient(int index) const3371 int defiNet::viaOrient(int index) const {
3372 char errMsg[256];
3373 if (index < 0 || index > numPts_) {
3374 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3375 index, numPts_);
3376 defiError(0, 6085, errMsg, defData);
3377 return 0;
3378 }
3379 return viaOrients_[index];
3380 }
3381
viaOrientStr(int index) const3382 const char* defiNet::viaOrientStr(int index) const {
3383 char errMsg[256];
3384
3385 if (index < 0 || index > numPts_) {
3386 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3387 index, numPts_);
3388 defiError(0, 6085, errMsg, defData);
3389 return 0;
3390 }
3391 return (defiOrientStr(viaOrients_[index]));
3392 }
3393
topMaskNum(int index) const3394 int defiNet::topMaskNum(int index) const {
3395 char errMsg[256];
3396 if (index < 0 || index > numPts_) {
3397 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3398 index, numPts_);
3399 defiError(0, 6085, errMsg, defData);
3400 return 0;
3401 }
3402
3403 return viaMasks_[index] / 100;
3404 }
3405
cutMaskNum(int index) const3406 int defiNet::cutMaskNum(int index) const {
3407 char errMsg[256];
3408 if (index < 0 || index > numPts_) {
3409 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3410 index, numPts_);
3411 defiError(0, 6085, errMsg, defData);
3412 return 0;
3413 }
3414
3415 return viaMasks_[index] / 10 % 10;
3416 }
3417
bottomMaskNum(int index) const3418 int defiNet::bottomMaskNum(int index) const {
3419 char errMsg[256];
3420 if (index < 0 || index > numPts_) {
3421 sprintf (errMsg, "ERROR (DEFPARS-6085): The index number %d specified for the NET POLYGON is invalid.\nValid index is from 0 to %d. Specify a valid index number and then try again.",
3422 index, numPts_);
3423 defiError(0, 6085, errMsg, defData);
3424 return 0;
3425 }
3426
3427 return viaMasks_[index] % 10;
3428 }
3429
getViaPts(int index) const3430 struct defiPoints defiNet::getViaPts(int index)const {
3431 return *(viaPts_[index]);
3432 }
3433
clearVia()3434 void defiNet::clearVia() {
3435 if (viaNames_) {
3436 struct defiPoints* p;
3437 for (int i = 0; i < numPts_; i++) {
3438 if (viaNames_[i]) {
3439 free((char*)(viaNames_[i]));
3440 }
3441 if (viaRouteStatus_[i]) {
3442 free ((char*)(viaRouteStatus_[i]));
3443 }
3444 if (viaShapeTypes_[i]) {
3445 free ((char*)(viaShapeTypes_[i]));
3446 }
3447 if (viaRouteStatusShieldNames_[i]) {
3448 free ((char*)(viaRouteStatusShieldNames_[i]));
3449 }
3450 p = viaPts_[i];
3451 free((char*)(p->x));
3452 free((char*)(p->y));
3453 free((char*)(viaPts_[i]));
3454 }
3455 if (viaMasks_) {
3456 free((char*)(viaMasks_));
3457 }
3458 if (viaOrients_) {
3459 free((char*)(viaOrients_));
3460 }
3461 if (viaNames_) {
3462 free((char*)(viaNames_));
3463 }
3464 if (viaRouteStatus_) {
3465 free((char*)(viaRouteStatus_));
3466 }
3467 if (viaShapeTypes_) {
3468 free((char*)(viaShapeTypes_));
3469 }
3470 if (viaRouteStatusShieldNames_) {
3471 free((char*)(viaRouteStatusShieldNames_));
3472 }
3473 if (viaPts_) {
3474 free((char*)(viaPts_));
3475 }
3476 }
3477
3478 viaMasks_ = 0;
3479 viaOrients_ = 0;
3480 numPts_ = 0;
3481 ptsAllocated_ = 0;
3482 viaPts_ = 0;
3483 viaRouteStatus_ = 0;
3484 viaShapeTypes_ = 0;
3485 viaRouteStatusShieldNames_ = 0;
3486 viaNames_ = 0;
3487 }
3488
3489 END_LEFDEF_PARSER_NAMESPACE
3490
3491