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 #ifndef defiNet_h 31 #define defiNet_h 32 33 #include <stdio.h> 34 #include "defiKRDefs.hpp" 35 #include "defiPath.hpp" 36 #include "defiMisc.hpp" 37 38 BEGIN_LEFDEF_PARSER_NAMESPACE 39 40 class defrData; 41 42 /* Return codes for defiNet::viaOrient 43 DEF_ORIENT_N 0 44 DEF_ORIENT_W 1 45 DEF_ORIENT_S 2 46 DEF_ORIENT_E 3 47 DEF_ORIENT_FN 4 48 DEF_ORIENT_FW 5 49 DEF_ORIENT_FS 6 50 DEF_ORIENT_FE 7 51 */ 52 53 class defiWire { 54 public: 55 defiWire(defrData *data); 56 ~defiWire(); 57 DEF_COPY_CONSTRUCTOR_H( defiWire ); 58 DEF_ASSIGN_OPERATOR_H( defiWire ); 59 60 void Init(const char* type, const char* wireShieldName); 61 void Destroy(); 62 void clear(); 63 void addPath(defiPath *p, int reset, int netOsnet, int *needCbk); 64 65 const char* wireType() const; 66 const char* wireShieldNetName() const; 67 int numPaths() const; 68 69 defiPath* path(int index); 70 const defiPath* path(int index) const; 71 72 void bumpPaths(long long size); 73 74 protected: 75 char* type_; 76 char* wireShieldName_; // It only set from specialnet SHIELD, 5.4 77 int numPaths_; 78 long long pathsAllocated_; 79 defiPath** paths_; 80 81 defrData *defData; 82 }; 83 84 85 86 class defiSubnet { 87 public: 88 defiSubnet(defrData *data); 89 void Init(); 90 91 DEF_COPY_CONSTRUCTOR_H( defiSubnet ); 92 DEF_ASSIGN_OPERATOR_H( defiSubnet ); 93 94 void Destroy(); 95 ~defiSubnet(); 96 97 void setName(const char* name); 98 void setNonDefault(const char* name); 99 void addPin(const char* instance, const char* pin, int syn); 100 void addMustPin(const char* instance, const char* pin, int syn); 101 102 // WMD -- the following will be removed by the next release 103 void setType(const char* typ); // Either FIXED COVER ROUTED 104 void addPath(defiPath* p, int reset, int netOsnet, int *needCbk); 105 106 // NEW: a net can have more than 1 wire 107 void addWire(const char *typ); 108 void addWirePath(defiPath *p, int reset, int netOsnet, int *needCbk); 109 110 // Debug printing 111 void print(FILE* f) const; 112 113 const char* name() const; 114 int numConnections() const; 115 const char* instance(int index) const; 116 const char* pin(int index) const; 117 int pinIsSynthesized(int index) const; 118 int pinIsMustJoin(int index) const; 119 120 // WMD -- the following will be removed by the next release 121 int isFixed() const; 122 int isRouted() const; 123 int isCover() const; 124 125 int hasNonDefaultRule() const; 126 127 // WMD -- the following will be removed by the next release 128 int numPaths() const; 129 defiPath* path(int index); 130 const defiPath* path(int index) const; 131 132 const char* nonDefaultRule() const; 133 134 int numWires() const; 135 defiWire* wire(int index); 136 const defiWire* wire(int index) const; 137 138 void bumpName(long long size); 139 void bumpPins(long long size); 140 void bumpPaths(long long size); 141 void clear(); 142 143 protected: 144 char* name_; // name. 145 int nameSize_; // allocated size of name. 146 int numPins_; // number of pins used in array. 147 long long pinsAllocated_; // number of pins allocated in array. 148 char** instances_; // instance names for connections 149 char** pins_; // pin names for connections 150 char* synthesized_; // synthesized flags for pins 151 char* musts_; // must-join flags 152 153 // WMD -- the following will be removed by the next release 154 char isFixed_; // net type 155 char isRouted_; 156 char isCover_; 157 defiPath** paths_; // paths for this subnet 158 int numPaths_; // number of paths used 159 long long pathsAllocated_; // allocated size of paths array 160 161 int numWires_; // number of wires defined in the subnet 162 long long wiresAllocated_; // number of wires allocated in the subnet 163 defiWire** wires_; // this replace the paths 164 char* nonDefaultRule_; 165 166 defrData *defData; 167 }; 168 169 170 171 class defiVpin { 172 public: 173 defiVpin(defrData *data); 174 ~defiVpin(); 175 176 DEF_COPY_CONSTRUCTOR_H( defiVpin ); 177 DEF_ASSIGN_OPERATOR_H( defiVpin ); 178 179 void Init(const char* name); 180 void Destroy(); 181 void setLayer(const char* name); 182 void setBounds(int xl, int yl, int xh, int yh); 183 void setOrient(int orient); 184 void setLoc(int x, int y); 185 void setStatus(char st); 186 187 int xl() const ; 188 int yl() const ; 189 int xh() const ; 190 int yh() const ; 191 char status() const; /* P-placed, F-fixed, C-cover, ' ' - not set */ 192 int orient() const ; 193 const char* orientStr() const ; 194 int xLoc() const; 195 int yLoc() const; 196 const char* name() const; 197 const char* layer() const; 198 199 protected: 200 int xl_; 201 int yl_; 202 int xh_; 203 int yh_; 204 int orient_; /* 0-7 -1 is no orient */ 205 char status_; /* P-placed F-fixed C-cover ' '- none */ 206 int xLoc_; 207 int yLoc_; 208 char* name_; 209 char* layer_; 210 211 defrData *defData; 212 }; 213 214 215 216 // Pre 5.4 217 class defiShield { 218 public: 219 defiShield(defrData *data); 220 ~defiShield(); 221 222 DEF_COPY_CONSTRUCTOR_H( defiShield ); 223 DEF_ASSIGN_OPERATOR_H( defiShield ); 224 225 void Init(const char* name); 226 void Destroy(); 227 void clear(); 228 void addPath(defiPath *p, int reset, int netOsnet, int *needCbk); 229 230 const char* shieldName() const; 231 int numPaths() const; 232 233 defiPath* path(int index); 234 const defiPath* path(int index) const; 235 236 void bumpPaths(long long size); 237 238 protected: 239 char* name_; 240 int numPaths_; 241 long long pathsAllocated_; 242 defiPath** paths_; 243 244 defrData *defData; 245 }; 246 247 248 249 250 // Struct holds the data for one component. 251 class defiNet { 252 public: 253 defiNet(defrData *data); 254 void Init(); 255 256 DEF_COPY_CONSTRUCTOR_H( defiNet ); 257 DEF_ASSIGN_OPERATOR_H( defiNet ); 258 259 void Destroy(); 260 ~defiNet(); 261 262 // Routines used by YACC to set the fields in the net. 263 void setName(const char* name); 264 void addPin(const char* instance, const char* pin, int syn); 265 void addMustPin(const char* instance, const char* pin, int syn); 266 void setWeight(int w); 267 268 // WMD -- the following will be removed by the next release 269 void setType(const char* typ); // Either FIXED COVER ROUTED 270 271 void addProp(const char* name, const char* value, const char type); 272 void addNumProp(const char* name, const double d, 273 const char* value, const char type); 274 void addSubnet(defiSubnet* subnet); 275 // NEW: a net can have more than 1 wire 276 void addWire(const char *typ, const char* wireShieldName); 277 void addWirePath(defiPath* p, int reset, int netOsnet, int *needCbk); 278 void addShape(const char *shapeType); // 5.8 279 void setSource(const char* typ); 280 void setFixedbump(); // 5.4.1 281 void setFrequency(double frequency); // 5.4.1 282 void setOriginal(const char* typ); 283 void setPattern(const char* typ); 284 void setCap(double w); 285 void setUse(const char* typ); 286 void setNonDefaultRule(const char* typ); 287 void setStyle(int style); 288 void addShield(const char* shieldNetName); // pre 5.4 289 void addNoShield(const char* shieldNetName); // pre 5.4 290 void addShieldNet(const char* shieldNetName); 291 292 void addShieldPath(defiPath* p, int reset, int netOsnet, int *needCbk); 293 void clear(); 294 void setWidth(const char* layer, double dist); 295 void setSpacing(const char* layer, double dist); 296 void setVoltage(double num); 297 void setRange(double left, double right); 298 void setXTalk(int num); 299 void addVpin(const char* name); 300 void addVpinLayer(const char* name); 301 void addVpinLoc(const char* status, int x, int y, int orient); 302 void addVpinBounds(int xl, int yl, int xh, int yh); 303 // 5.6 304 void addPolygon(const char* layerName, defiGeometries* geom, int *needCbk, 305 int mask, const char* routeStatus, 306 const char* shapeType, 307 const char* shieldNetName); 308 void addRect(const char* layerName, int xl, int yl, int xh, int yh, 309 int *needCbk, int mask, const char* routeStatus, 310 const char* shapeType, 311 const char* shieldNetName); // 5.6 312 void addPts(const char* viaName, int o, defiGeometries* geom, 313 int *needCbk, int mask, const char* routeStatus, 314 const char* shapeType, 315 const char* shieldNetName); //VIA 5.8 316 317 // For OA to modify the netName, id & pinName 318 void changeNetName(const char* name); 319 void changeInstance(const char* name, int index); 320 void changePin(const char* name, int index); 321 322 // Routines to return the value of net data. 323 const char* name() const; 324 int weight() const; 325 int numProps() const; 326 const char* propName(int index) const; 327 const char* propValue(int index) const; 328 double propNumber(int index) const; 329 char propType(int index) const; 330 int propIsNumber(int index) const; 331 int propIsString(int index) const; 332 int numConnections() const; 333 const char* instance(int index) const; 334 const char* pin(int index) const; 335 int pinIsMustJoin(int index) const; 336 int pinIsSynthesized(int index) const; 337 int numSubnets() const; 338 339 defiSubnet* subnet(int index); 340 const defiSubnet* subnet(int index) const; 341 342 // WMD -- the following will be removed by the next release 343 int isFixed() const; 344 int isRouted() const; 345 int isCover() const; 346 347 /* The following routines are for wiring */ 348 int numWires() const; 349 350 defiWire* wire(int index); 351 const defiWire* wire(int index) const; 352 353 /* Routines to get the information about Virtual Pins. */ 354 int numVpins() const; 355 356 defiVpin* vpin(int index); 357 const defiVpin* vpin(int index) const; 358 359 int hasProps() const; 360 int hasWeight() const; 361 int hasSubnets() const; 362 int hasSource() const; 363 int hasFixedbump() const; // 5.4.1 364 int hasFrequency() const; // 5.4.1 365 int hasPattern() const; 366 int hasOriginal() const; 367 int hasCap() const; 368 int hasUse() const; 369 int hasStyle() const; 370 int hasNonDefaultRule() const; 371 int hasVoltage() const; 372 int hasSpacingRules() const; 373 int hasWidthRules() const; 374 int hasXTalk() const; 375 376 int numSpacingRules() const; 377 void spacingRule(int index, char** layer, double* dist, double* left, 378 double* right) const; 379 int numWidthRules() const; 380 void widthRule(int index, char** layer, double* dist) const; 381 double voltage() const; 382 383 int XTalk() const; 384 const char* source() const; 385 double frequency() const; 386 const char* original() const; 387 const char* pattern() const; 388 double cap() const; 389 const char* use() const; 390 int style() const; 391 const char* nonDefaultRule() const; 392 393 // WMD -- the following will be removed by the next release 394 int numPaths() const; 395 396 defiPath* path(int index); 397 const defiPath* path(int index) const; 398 399 int numShields() const; // pre 5.4 400 401 defiShield* shield(int index); // pre 5.4 402 const defiShield* shield(int index) const ; // pre 5.4 403 404 int numShieldNets() const; 405 const char* shieldNet(int index) const; 406 int numNoShields() const; // pre 5.4 407 408 defiShield* noShield(int index); // pre 5.4 409 const defiShield* noShield(int index) const; // pre 5.4 410 411 // 5.6 412 int numPolygons() const; // 5.6 413 const char* polygonName(int index) const; // 5.6 414 struct defiPoints getPolygon(int index) const; // 5.6 415 int polyMask(int index) const; 416 const char* polyRouteStatus(int index) const; 417 const char* polyRouteStatusShieldName(int index) const; 418 const char* polyShapeType(int index) const; 419 420 421 int numRectangles() const; // 5.6 422 const char* rectName(int index) const; // 5.6 423 int xl(int index)const; // 5.6 424 int yl(int index)const; // 5.6 425 int xh(int index)const; // 5.6 426 int yh(int index)const; // 5.6 427 int rectMask(int index)const; 428 const char* rectRouteStatus(int index) const; 429 const char* rectRouteStatusShieldName(int index) const; 430 const char* rectShapeType(int index) const; 431 432 433 // 5.8 434 int numViaSpecs() const; 435 struct defiPoints getViaPts(int index) const; 436 const char* viaName(int index) const; 437 int viaOrient(int index) const; 438 const char* viaOrientStr(int index) const; 439 int topMaskNum(int index) const; 440 int cutMaskNum(int index) const; 441 int bottomMaskNum(int index) const; 442 const char* viaRouteStatus(int index) const; 443 const char* viaRouteStatusShieldName(int index) const; 444 const char* viaShapeType(int index) const; 445 446 // Debug printing 447 void print(FILE* f) const; 448 449 450 void bumpName(long long size); 451 void bumpPins(long long size); 452 void bumpProps(long long size); 453 void bumpSubnets(long long size); 454 void bumpPaths(long long size); 455 void bumpShieldNets(long long size); 456 457 // The method freeWire() is added is user select to have a callback 458 // per wire within a net This is an internal method and is not public 459 void freeWire(); 460 void freeShield(); 461 462 // Clear the rectangles & polygons data if partial path callback is set 463 void clearRectPolyNPath(); 464 void clearRectPoly(); 465 void clearVia(); 466 467 protected: 468 char* name_; // name. 469 int nameSize_; // allocated size of name. 470 int numPins_; // number of pins used in array. 471 long long pinsAllocated_; // number of pins allocated in array. 472 char** instances_; // instance names for connections 473 char** pins_; // pin names for connections 474 char* musts_; // must-join flags for pins 475 char* synthesized_; // synthesized flags for pins 476 int weight_; // net weight 477 char hasWeight_; // flag for optional weight 478 479 // WMD -- the following will be removed by the nex release 480 char isFixed_; // net type 481 char isRouted_; 482 char isCover_; 483 484 char hasCap_; // file supplied a capacitance value 485 char hasFrequency_; // file supplied a frequency value 486 char hasVoltage_; 487 int numProps_; // num of props in array 488 char** propNames_; // Prop names 489 char** propValues_; // Prop values All in strings! 490 double* propDValues_; // Prop values in numbers! 491 char* propTypes_; // Prop types, 'I' - Integer, 'R' - Real, 'S' - String 492 493 long long propsAllocated_; // allocated size of props array 494 int numSubnets_; // num of subnets in array 495 defiSubnet** subnets_; // Prop names 496 long long subnetsAllocated_; // allocated size of props array 497 double cap_; // cap value 498 char* source_; 499 int fixedbump_; // 5.4.1 500 double frequency_; // 5.4.1 501 char* pattern_; 502 char* original_; 503 char* use_; 504 char* nonDefaultRule_; 505 int style_; 506 507 // WMD -- the following will be removed by the nex release 508 defiPath** paths_; // paths for this subnet 509 int numPaths_; // number of paths used 510 long long pathsAllocated_; // allocated size of paths array 511 512 double voltage_; 513 514 int numWires_; // number of wires defined in the net 515 long long wiresAllocated_; // allocated size of wire paths array 516 defiWire** wires_; // this replace the paths 517 518 long long widthsAllocated_; 519 int numWidths_; 520 char** wlayers_; 521 double* wdist_; 522 523 long long spacingAllocated_; 524 int numSpacing_; 525 char** slayers_; 526 double* sdist_; 527 double* sleft_; 528 double* sright_; 529 int xTalk_; 530 531 int numVpins_; 532 long long vpinsAllocated_; 533 defiVpin** vpins_; 534 535 int numShields_; // number of SHIELD paths used 536 long long shieldsAllocated_; // allocated size of SHIELD paths array 537 defiShield** shields_; // SHIELD data 538 int numNoShields_; // number of NOSHIELD paths used 539 540 int numShieldNet_; // number of SHIELDNETS used in array. 541 long long shieldNetsAllocated_; // number of SHIELDNETS allocated in array. 542 char** shieldNet_; // name of the SHIELDNET 543 544 int numPolys_; // 5.6 545 char** polygonNames_; // 5.6 layerName for POLYGON 546 long long polysAllocated_; // 5.6 547 struct defiPoints** polygons_; // 5.6 548 int* polyMasks_; 549 char** polyRouteStatus_; 550 char** polyShapeTypes_; 551 char** polyRouteStatusShieldNames_; 552 553 int numRects_; // 5.6 554 long long rectsAllocated_; // 5.6 555 char** rectNames_; // 5.6 556 int* xl_; 557 int* yl_; 558 int* xh_; 559 int* yh_; 560 int* rectMasks_; 561 char** rectRouteStatus_; 562 char** rectRouteStatusShieldNames_; 563 char** rectShapeTypes_; 564 565 566 struct defiPoints** viaPts_; // 5.8 567 char** viaNames_; 568 int numPts_; 569 long long ptsAllocated_; 570 int* viaOrients_; 571 int* viaMasks_; 572 char** viaRouteStatus_; 573 char** viaRouteStatusShieldNames_; 574 char** viaShapeTypes_; 575 576 defrData *defData; 577 }; 578 579 END_LEFDEF_PARSER_NAMESPACE 580 581 USE_LEFDEF_PARSER_NAMESPACE 582 583 #endif 584