1 /* Header files for resistance extraction */ 2 3 /* Type declarations */ 4 5 /* contact points: keeps track where contacts are and what tiles they 6 refer to both before and after processing. 7 */ 8 9 #ifndef _RESIS_H 10 #define _RESIS_H 11 12 #define LAYERS_PER_CONTACT 4 13 #define TILES_PER_JUNCTION 2 14 15 typedef struct contactpoint 16 { 17 struct contactpoint *cp_nextcontact;/* Next contact in linked */ 18 /* list. */ 19 Point cp_center; /*Center of contact */ 20 Rect cp_rect; /* Tile rectangle */ 21 Tile *cp_contactTile; 22 /* 23 The following two keep 24 track of the tiles where 25 the contact was before 26 preprocessing, and the 27 next contact in that tile's 28 area. 29 */ 30 31 Tile *cp_tile[LAYERS_PER_CONTACT]; 32 int cp_currentcontact; /* keeps track of tile 33 being processed 34 */ 35 TileType cp_type; /* Type of contact */ 36 int cp_width; /* Width (in x) of contact region */ 37 int cp_height; /* Height (in y) of contact region */ 38 struct resnode *cp_cnode[LAYERS_PER_CONTACT];/* this contact's nodes */ 39 int cp_status; /* status of processing on 40 this contact 41 */ 42 } ResContactPoint; 43 44 typedef struct resistor 45 { 46 struct resistor *rr_nextResistor; /* Doubly linked list pointers */ 47 struct resistor *rr_lastResistor; 48 struct resnode *rr_node[2]; 49 float rr_value; /* Resistor's value in milliohms */ 50 int rr_status; /* Status bit used for processing */ 51 union 52 { 53 float rr_area; /* area in resistor. Used to */ 54 /* distribute capacitance */ 55 float rr_i; /* Branch current in mA */ 56 } rr_float; 57 int rr_cl; /* resistor centerline for geometry */ 58 int rr_width; /* resistor width for geometry */ 59 TileType rr_tt; /* type that composes this */ 60 /* resistor. */ 61 #ifdef ARIEL 62 int rr_csArea; /* crosssectional area in lamba**2*/ 63 #endif 64 } resResistor; 65 66 #define rr_connection1 rr_node[0] 67 #define rr_connection2 rr_node[1] 68 69 /* Definitions for old FET-style MOSFET devices */ 70 #define RT_GATE 0 71 #define RT_SOURCE 1 72 #define RT_DRAIN 2 73 #define RT_SUBS 3 74 75 #define rd_fet_gate rd_terminals[RT_GATE] 76 #define rd_fet_source rd_terminals[RT_SOURCE] 77 #define rd_fet_drain rd_terminals[RT_DRAIN] 78 #define rd_fet_subs rd_terminals[RT_SUBS] 79 80 typedef struct device 81 { 82 int rd_status; /* status bits */ 83 struct device *rd_nextDev; /* next device in linked list */ 84 /* terminals of device */ 85 struct resnode **rd_terminals; 86 int rd_nterms; /* number of terminals in rt_terminals */ 87 int rd_perim; /* info about device */ 88 int rd_area; /* used in .ext and .sim file */ 89 int rd_length; /* patches. */ 90 int rd_width; 91 int rd_tiles; /* number of tiles in device */ 92 int rd_devtype; /* tiletype of device. */ 93 Rect rd_inside; /* 1x1 rectangle inside device */ 94 Tile *rd_tile; /* pointer to a tile in device */ 95 #ifdef ARIEL 96 float rd_i; /* Current injected from this device */ 97 /* in milliamps */ 98 #endif 99 } resDevice; 100 101 /* 102 a junction is formed when two tiles that connect are next to one another. 103 */ 104 105 typedef struct junction 106 { 107 struct junction *rj_nextjunction[TILES_PER_JUNCTION]; 108 Tile *rj_Tile[TILES_PER_JUNCTION]; 109 Point rj_loc; 110 int rj_status; 111 struct resnode *rj_jnode; 112 } ResJunction; 113 114 /* 115 * A port is declared for subcircuits; its name overrides any locally- 116 * generated node name. 117 */ 118 119 typedef struct resport 120 { 121 struct resport *rp_nextPort; 122 Rect rp_bbox; 123 Point rp_loc; 124 char *rp_nodename; 125 } resPort; 126 127 /* 128 ?element are 'cons' cells used to make linked lists of their referential 129 structures. 130 */ 131 132 typedef struct reselement 133 { 134 struct reselement *re_nextEl; 135 resResistor *re_thisEl; 136 } resElement; 137 138 typedef struct relement 139 { 140 struct relement *rel_nextEl; 141 struct relement *rel_lastEl; 142 resResistor *rel_thisEl; 143 } rElement; 144 145 typedef struct jelement 146 { 147 struct jelement *je_nextj; 148 ResJunction *je_thisj; 149 } jElement; 150 151 typedef struct telement 152 { 153 struct telement *te_nextt; 154 resDevice *te_thist; 155 } tElement; 156 157 typedef struct celement 158 { 159 struct celement *ce_nextc; 160 ResContactPoint *ce_thisc; 161 } cElement; 162 163 /* 164 Nodes formed from network. These are linked both forwards and backwords 165 to other nodes. Lists of devices, resistors, junctions, and contacts 166 corresponding to this node are kept. 167 */ 168 typedef struct resnode 169 { 170 struct resnode *rn_more; /* doubly linked list pointers */ 171 struct resnode *rn_less; 172 tElement *rn_te; /* widgets connected to this node */ 173 resElement *rn_re; 174 jElement *rn_je; 175 cElement *rn_ce; 176 int rn_noderes; /* resistance from origin node */ 177 Point rn_loc; /* location of node */ 178 unsigned rn_why; /* Why is there a node here? */ 179 int rn_status; /* Status bits */ 180 union { /* At various times, we need to */ 181 /* keep track of the node area, */ 182 /* node capacitance, and node */ 183 /* voltage. Since none of these */ 184 /* values is used concurrently */ 185 /* only one word of storage is */ 186 /* needed. */ 187 float rn_area; /* area of resistors collapsed */ 188 /* into node. */ 189 float rn_cap; /* capacitance of node. */ 190 } rn_float; 191 char *rn_name; /* Pointer to hash table name */ 192 /* for this node. */ 193 ClientData rn_client; /* Random pointer */ 194 int rn_id; 195 } resNode; 196 197 typedef struct nelement 198 { 199 struct nelement *ne_nextEl; 200 struct nelement *ne_lastEl; 201 resNode *ne_thisEl; 202 } nElement; 203 204 /* 205 Breakpoints are places on a tile which may serve as sources/sinks of 206 current. When resistance is calculated for a tile. this is calculated 207 between these points. 208 */ 209 210 typedef struct breakpoint 211 { 212 struct breakpoint *br_next; 213 resNode *br_this; 214 Point br_loc; 215 Rect *br_crect; 216 } Breakpoint; 217 218 /* 219 Each tile needs to keep track of the following things associated with it. 220 Since there are too many things to fit in the single ti_client field, 221 this 1 to 6 adaptor is used. 222 */ 223 224 typedef struct tilejunk 225 { 226 cElement *contactList; /*widgets connected to this tile */ 227 resDevice *deviceList; 228 resPort *portList; 229 ResJunction *junctionList; 230 Breakpoint *breakList; 231 int sourceEdge; /* used in device tiles to keep 232 * of which diffusion edges are 233 * a transistor's source 234 */ 235 int tj_status; /* status of tile processing */ 236 } tileJunk; 237 238 /* ResDevTile keeps track of the location and type of devices. 239 These areas are painted into our copied def after the tree is totally 240 flattened. (They can't be painted right away becasue the copy routine 241 uses the new def to keep track of where it is in the design. It is also 242 used when devices are preproceesed. 243 */ 244 245 typedef struct resdevtile 246 { 247 struct resdevtile *nextDev; 248 Rect area; 249 TileType type; 250 ExtDevice *devptr; 251 int perim; 252 int overlap; 253 } ResDevTile; 254 255 /* 256 Goodies contains random stuff passed between the node extractor 257 and ResCheckSimNodes. The location of a start tile and the resistive 258 tolerance are passed down, while the derived network is passed back. 259 */ 260 261 typedef struct goodstuff 262 { 263 TileType rg_ttype; 264 float rg_maxres; 265 float rg_nodecap; 266 float rg_Tdi; 267 int rg_bigdevres; 268 int rg_tilecount; 269 int rg_status; 270 Point *rg_devloc; 271 char *rg_name; 272 } ResGlobalParams; 273 274 /* Used in RC delay calculations for Tdi filter */ 275 /* Attaches to rn_client field of resNode */ 276 277 typedef struct rcdelaystuff 278 { 279 float rc_Cdownstream; /* capacitance down the tree from node */ 280 float rc_Tdi; /* Tdi for node */ 281 } RCDelayStuff; 282 283 284 /* ResSim.c type declarations */ 285 286 typedef struct rdev 287 { 288 struct rdev *nextDev; /* Next device in linked list */ 289 struct rdev *realDev; /* Single Lumped Device for */ 290 /* devices connected in parallel */ 291 resDevice *layout; /* pointer to resDevice that */ 292 /* corresponds to RDev */ 293 int status; 294 struct ressimnode *gate; /* Terminals of transistor. */ 295 struct ressimnode *source; 296 struct ressimnode *drain; 297 struct ressimnode *subs; /* Used with subcircuit type only */ 298 Point location; /* Location of lower left point of */ 299 /* device. */ 300 float resistance; /* "Resistance" of device. */ 301 TileType rs_ttype; /* tile type for device */ 302 ExtDevice *rs_devptr; /* device extraction record */ 303 char *rs_gattr; /* Gate attributes, if any */ 304 char *rs_sattr; 305 char *rs_dattr; 306 } RDev; 307 308 typedef struct ressimnode 309 { 310 struct ressimnode *nextnode; /* next node in OriginalNodes */ 311 /* linked list. */ 312 int status; 313 struct ressimnode *forward; /* If node has been merged, this */ 314 /* points to the merged node. */ 315 float capacitance; /* capacitance between node and */ 316 /* GND for power connections */ 317 /* and all capacitance for every */ 318 /* thing else. */ 319 float cap_vdd; /* capacitance to VDD (used for */ 320 /* power calculations only */ 321 float cap_couple; /* coupling capacitance */ 322 float resistance; /* lumped resistance */ 323 float minsizeres; /* Minimum size resistor allowed */ 324 Point drivepoint; /* optional, user specified drive */ 325 /* point for network. */ 326 TileType rs_ttype; /* tiletype of drivepoint */ 327 Point location; /* location of bottom of leftmost */ 328 /* tile in the lowest numbered */ 329 /* plane contained in the node . */ 330 Rect rs_bbox; /* location of bottom of leftmost */ 331 /* tile in the lowest numbered */ 332 /* plane contained in the node . */ 333 TileType type; /* Tile type of tile at location */ 334 struct devptr *firstDev; /* linked list of devices */ 335 /* connected to node. */ 336 char *name; /* Pointer to name of node stored */ 337 /* in hash table. */ 338 char *oldname; /* Pointer to previous name of */ 339 /* node, if it exists */ 340 tElement *rs_sublist[2]; /* pointers to Gnd and Vdd sub */ 341 /* strate connections, 342 if they exist */ 343 } ResSimNode; 344 345 #define RES_SUB_GND 0 346 #define RES_SUB_VDD 1 347 348 /* `cons' cell for linked list of devices connected to node */ 349 350 typedef struct devptr 351 { 352 struct devptr *nextDev; 353 struct rdev *thisDev; 354 int terminal; /* which terminal of device */ 355 /* is connected to node. */ 356 } devPtr; 357 358 /* ResTime.c type declarations */ 359 360 typedef struct resevent /* Raw event list read in from rsim/tv */ 361 { 362 int rv_node; /* node number */ 363 int rv_final; /* final value; (0,1, or X) */ 364 int rv_tmin; /* minimum event time in units of 100ps */ 365 int rv_tmax; /* maximum event time in units of 100ps */ 366 float rv_i; /* event current in milliamps */ 367 resDevice *rv_dev; /* device where charge drains */ 368 } ResEvent; 369 370 typedef struct reseventcell 371 { 372 ResEvent *rl_this; 373 struct reseventcell *rl_next; 374 } REcell; 375 376 typedef struct rescurrentevent /* processed event used to feed relaxer */ 377 { 378 struct rescurrentevent *ri_next; 379 float ri_i; 380 resDevice *ri_dev; 381 } ResCurrentEvent; 382 383 typedef struct restimebin /* Holds one timestep's worth of Events */ 384 { 385 struct restimebin *rb_next; 386 struct restimebin *rb_last; 387 int rb_start; 388 int rb_end; 389 ResCurrentEvent *rb_first; 390 } ResTimeBin; 391 392 typedef struct resfixpoint /* Keeps track of where voltage sources are */ 393 { 394 struct resfixpoint *fp_next; 395 Point fp_loc; 396 TileType fp_ttype; 397 int fp_status; 398 Tile *fp_tile; 399 resNode *fp_node; 400 char fp_name[1]; 401 } ResFixPoint; 402 403 typedef struct clump 404 { 405 unsigned rp_status; 406 rElement *rp_grouplist; 407 nElement *rp_nodelist; 408 rElement *rp_downlist; 409 rElement *rp_singlelist; 410 } ResClump; 411 412 /* the first two fields of this plug must be the the same as for 413 resDevice 414 */ 415 typedef struct plug 416 { 417 float rpl_i; /* current injected through 418 this plug 419 */ 420 int rpl_status; /* status bits for this plug */ 421 struct plug *rpl_next; /* next plug in this bin */ 422 Point rpl_loc; /*location of plug */ 423 int rpl_type; /*type of plug */ 424 resNode *rpl_node; /* this point's node */ 425 } ResPlug; 426 427 typedef struct capval 428 { 429 float cap[1][2]; /* multipliers telling what portion of capacitance is 430 to Vdd and what part is to ground. Right now, 431 coupling capacitance is counted twice, so 432 cap[0]+cap[1] = (c_vdd+c_gnd+2*c_couple)/ 433 (c_vdd+c_gnd+c_couple); 434 */ 435 } ResCapVal; 436 437 /* node flags */ 438 #define RES_REACHED_NODE 0x00200000 439 #define RES_NODE_XADJ 0x00400000 440 #define RES_NODE_YADJ 0x00800000 441 442 /* type of node flags */ 443 #define RES_NODE_JUNCTION 0x00000001 444 #define RES_NODE_DEVICE 0x00000002 445 #define RES_NODE_CONTACT 0x00000004 446 #define RES_NODE_ORIGIN 0x00000008 447 448 /* resistor flags */ 449 #define RES_DEADEND 0x00001000 450 #define RES_DONE_ONCE 0x00002000 451 #define RES_MARKED 0x00000100 452 #define RES_EW 0x00000200 453 #define RES_NS 0x00000400 454 #define RES_DIAGONAL 0x00000800 455 #define RES_TDI_IGNORE 0x00010000 456 #define RES_REACHED_RESISTOR 0x00100000 457 #define RES_HEAP 0x00200000 458 459 /* device flags */ 460 #define RES_DEV_SAVE 0x00000001 461 #define RES_DEV_PLUG 0x00000002 462 463 /* flags for tiles */ 464 /* A tile which is part of a substrate region. */ 465 #define RES_TILE_SUBS 0x01 466 /* A tile which is part of a source/drain region. */ 467 #define RES_TILE_SD 0x02 468 /* A tile which is actually a device */ 469 #define RES_TILE_DEV 0x04 470 /* Indicates whether the tile has been processed or not */ 471 #define RES_TILE_DONE 0x08 472 /*a temporary marking flag */ 473 #define RES_TILE_MARK 0x10 474 /* indicates that tile has unidirectional current flow */ 475 #ifdef LAPLACE 476 #define RES_TILE_1D 0x20 477 #define RES_TILE_GDONE 0x40 478 #endif 479 /* tree walking flags */ 480 #define RES_LOOP_OK 1 481 #define RES_NO_LOOP 1 482 #define RES_DO_LAST 0 483 #define RES_DO_FIRST 1 484 #define RES_NO_FLAGS 0 485 486 487 /* ResSim Constants */ 488 #define FORWARD 0x0000010 489 #define SKIP 0x0000020 490 #define FORCE 0x0000040 491 #define MINSIZE 0x0000080 492 #define DRIVELOC 0x0000100 493 #define PORTNODE 0x0000200 494 #define REDUNDANT 0x0000400 495 496 /* Capacitance table constants */ 497 #define RES_CAP_GND 0 498 #define RES_CAP_VDD 1 499 #define RES_CAP_COUPLE 2 500 501 #define OHMSTOMILLIOHMS 1000 502 #define FEMTOTOATTO 1000 503 #define ATTOTOFEMTO 0.001 504 505 #define UNTOUCHED 0 506 #define SERIES 1 507 #define PARALLEL 2 508 #define LOOP 4 509 #define SINGLE 8 510 #define TRIANGLE 32 511 512 #define PENDING 2 513 #define FINISHED 4 514 515 #define LEFTEDGE 1 516 #define RIGHTEDGE 4 517 #define TOPEDGE 8 518 #define BOTTOMEDGE 16 519 #define OTHERPLANE 32 520 521 #define RN_MAXTDI 0x00001000 522 523 #define MARKED 0x00000100 524 525 #define GATE 1 526 #define SOURCE 2 527 #define DRAIN 3 528 #define SUBS 4 529 530 #define DRIVEONLY 0x00001000 531 #define ORIGIN 0x00000008 532 533 /* magic's normal value of infinity is too small- */ 534 /* 67108863 is only 67K ohms. */ 535 536 #define RES_INFINITY 0x3FFFFFFF 537 538 #define ResCheckIntegrity 539 540 /* The following turns on and off various options */ 541 542 #define ResOpt_ExtractAll 0x00000002 543 #define ResOpt_Simplify 0x00000004 544 #define ResOpt_DoExtFile 0x00000008 545 #define ResOpt_DoRsmFile 0x00000010 546 #define ResOpt_DoLumpFile 0x00000020 547 #define ResOpt_RunSilent 0x00000040 548 #define ResOpt_ExplicitRtol 0x00000080 549 #define ResOpt_ExplicitTditol 0x00000100 550 #define ResOpt_Tdi 0x00000200 551 #define ResOpt_Stat 0x00000400 552 #define ResOpt_Power 0x00000800 553 #define ResOpt_Signal 0x00001000 554 #define ResOpt_Pname 0x00002000 555 #define ResOpt_Geometry 0x00004000 556 #define ResOpt_FastHenry 0x00008000 557 #define ResOpt_Blackbox 0x00010000 558 #define ResOpt_Dump 0x00020000 559 #define ResOpt_DoSubstrate 0x00040000 560 #define ResOpt_GndPlugs 0x00200000 561 #define ResOpt_VddPlugs 0x00400000 562 #define ResOpt_CMOS 0x00800000 563 #define ResOpt_Bipolar 0x01000000 564 #define ResOpt_Box 0x02000000 565 #ifdef LAPLACE 566 #define ResOpt_DoLaplace 0x04000000 567 #define ResOpt_CacheLaplace 0x08000000 568 #define ResOpt_Checkpoint 0x80000000 569 #endif 570 571 #define ResOpt_VDisplay 0x10000000 572 #define ResOpt_IDisplay 0x20000000 573 #define ResOpt_PDisplay 0x40000000 574 575 /* Assorted Variables */ 576 577 extern RDev *ResRDevList; 578 extern REcell *ResBigEventList; 579 extern int ResOptionsFlags; 580 extern char *ResCurrentNode; 581 extern ResSimNode *ResOriginalNodes; 582 #ifdef ARIEL 583 extern int ResMinEventTime; 584 extern int ResMaxEventTime; 585 typedef float ResCapElement[2]; 586 extern ResCapElement *ResCapTableMax; 587 extern ResCapElement *ResCapTableMin; 588 extern HashTable ResPlugTable; 589 #endif 590 591 extern CellUse *ResUse; 592 extern CellDef *ResDef; 593 extern TileTypeBitMask ResConnectWithSD[NT]; 594 extern TileTypeBitMask ResCopyMask[NT]; 595 extern resResistor *ResResList; 596 extern resNode *ResNodeList; 597 extern resDevice *ResDevList; 598 extern ResContactPoint *ResContactList; 599 extern resNode *ResNodeQueue; 600 extern resNode *ResOriginNode; 601 extern resNode *resCurrentNode; 602 extern HashTable ResNodeTable; 603 extern HashTable ResSimDevTable; 604 extern ResFixPoint *ResFixList; 605 extern int ResTileCount; 606 extern ResSimNode **ResNodeArray; 607 extern CellDef *mainDef; 608 extern TileTypeBitMask ResSDTypesBitMask; 609 extern TileTypeBitMask ResSubTypesBitMask; 610 extern HashTable ResDevTable; 611 extern TileTypeBitMask ResNoMergeMask[NT]; 612 extern ResGlobalParams gparams; 613 extern int ResPortIndex; 614 615 extern int ResSimDevice(); 616 extern int ResSimCombineParallel(); 617 extern int ResSimCapacitor(); 618 extern int ResSimResistor(); 619 extern int ResSimAttribute(); 620 extern int ResSimMerge(); 621 extern int ResSimSubckt(); 622 extern int dbSrConnectStartFunc(); 623 extern int ResEach(),ResAddPlumbing(),ResRemovePlumbing(); 624 extern float ResCalculateChildCapacitance(); 625 extern ResDevTile *DBTreeCopyConnectDCS(); 626 extern Tile *ResFindTile(); 627 extern resDevice *ResImageAddPlug(); 628 extern resDevice *ResGetDevice(); 629 extern tileJunk *resAddField(); 630 extern int ResCheckPorts(); 631 extern int ResCheckBlackbox(); 632 extern void ResCheckSimNodes(); 633 extern void ResSortByGate(); 634 extern void ResFixDevName(); 635 extern void ResWriteLumpFile(); 636 extern void ResSortBreaks(); 637 638 639 /* macros */ 640 641 #define InitializeNode(node,x,y,why) \ 642 {\ 643 (node)->rn_te = NULL;\ 644 (node)->rn_id=0;\ 645 (node)->rn_float.rn_area = 0.0;\ 646 (node)->rn_name = NULL;\ 647 (node)->rn_client = (ClientData)NULL;\ 648 (node)->rn_noderes = RES_INFINITY;\ 649 (node)->rn_je = NULL;\ 650 (node)->rn_status = FALSE;\ 651 (node)->rn_loc.p_x = (x);\ 652 (node)->rn_loc.p_y = (y);\ 653 (node)->rn_why = (why);\ 654 (node)->rn_ce = (cElement *) NULL;\ 655 (node)->rn_re = (resElement *) NULL;\ 656 } 657 658 #define ResJunkInit(Junk) \ 659 { \ 660 Junk->contactList = (cElement *) NULL; \ 661 Junk->deviceList = (resDevice *) NULL; \ 662 Junk->junctionList = (ResJunction *) NULL; \ 663 Junk->breakList = (Breakpoint *) NULL; \ 664 Junk->portList = (resPort *) NULL; \ 665 Junk->tj_status = FALSE; \ 666 Junk->sourceEdge = 0 ; \ 667 } 668 669 #define NEWBREAK(node,tile,px,py,crect)\ 670 {\ 671 Breakpoint *bp;\ 672 tileJunk *jX_ = (tileJunk *)((tile)->ti_client); \ 673 bp = (Breakpoint *) mallocMagic((unsigned)(sizeof(Breakpoint))); \ 674 bp->br_next= jX_->breakList; \ 675 bp->br_this = (node); \ 676 bp->br_loc.p_x = px; \ 677 bp->br_loc.p_y = py; \ 678 bp->br_crect = (Rect *) (crect); \ 679 jX_->breakList = bp; \ 680 } 681 682 #define NEWPORT(node,tile)\ 683 {\ 684 resPort *rp;\ 685 tileJunk *pX_ = (tileJunk *)((tile)->ti_client); \ 686 rp = (resPort *) mallocMagic((unsigned)(sizeof(resPort))); \ 687 rp->rp_nextPort = pX_->portList; \ 688 rp->rp_bbox = node->rs_bbox; \ 689 rp->rp_loc = node->drivepoint; \ 690 rp->rp_nodename = node->name; \ 691 pX_->portList = rp; \ 692 } 693 694 #endif /* _RESIS_H */ 695