1 "", 2 "/isTrace false def", 3 "/LogoWidth 60 def", 4 "/PBsize 60 def", 5 "", 6 "%", 7 "% /key font defLatin1", 8 "%", 9 "% Define key as a latin-1 version of font ", 10 "%", 11 "/defLatin1 {", 12 " dup length dict begin", 13 " {1 index /FID ne {def} {pop pop} ifelse} forall", 14 " /Encoding ISOLatin1Encoding def", 15 " currentdict", 16 " end", 17 " definefont pop", 18 "} def", 19 "", 20 "% Calculate the height of an equalateral triangle with the given sides.", 21 "/theight {", 22 " 2 div", 23 " 3 sqrt", 24 " mul", 25 "} bind def", 26 "%", 27 "% Genaral parameters to start a gate.", 28 "%", 29 "% x y r startgate", 30 "%", 31 "/startgate {", 32 " gsave", 33 " 1 setlinewidth", 34 " 3 1 roll", 35 " translate", 36 " rotate", 37 " 1 -1 scale", 38 " newpath", 39 "} bind def", 40 "%", 41 "% x y r startnorotgate", 42 "%", 43 "/startnorotgate {", 44 " pop 0 startgate", 45 "} def", 46 "%", 47 "% Genaral parameters to start a gate (with position adjustment)", 48 "%", 49 "% x y r [[][][][]] startgate", 50 "%", 51 "/adjstartgate {", 52 " gsave", 53 " 1 setlinewidth", 54 " 1 index 90 div neg cvi get {} forall % x y r dx dy", 55 " exch 5 -1 roll add exch 4 -1 roll add", 56 " translate", 57 " rotate", 58 " 1 -1 scale", 59 " newpath", 60 "} bind def", 61 "%", 62 "% x y r adjstartnorotgate", 63 "%", 64 "/adjstartnorotgate {", 65 " exch pop 0 exch adjstartgate", 66 "} def", 67 "%", 68 "% Wire", 69 "/wire {", 70 " gsave", 71 " 10 div", 72 " setlinewidth", 73 " newpath", 74 " moveto lineto", 75 " stroke", 76 " grestore", 77 "} bind def", 78 "%", 79 "% (l) j x y wirelabel", 80 "%", 81 "% BetweenLeftAndRight 0x1", 82 "% AtRight 0x2", 83 "% AtLeft 0x4", 84 "% BetweenTopAndBottom 0x8", 85 "% AtBaseline 0x10", 86 "% AtTop 0x20", 87 "% AtBottom 0x40", 88 "%", 89 "/wirelabel {", 90 " gsave", 91 " translate", 92 " 8 rfont", 93 " 3 dict begin", 94 "", 95 " /just exch def", 96 " /dx 0 def", 97 " /dy 0 def", 98 "", 99 " just 64 and 0 ne { %AtBottom", 100 " /dy -3 def" 101 " } if", 102 " just 32 and 0 ne { %AtTop", 103 " /dy 8 def" 104 " } if", 105 " just 8 and 0 ne { %BetweenTopAndBottom", 106 " /dy 4 def" 107 " } if", 108 "", 109 " just 4 and 0 ne { % AtLeft", 110 " 0 dy LJ", 111 " } if", 112 " just 2 and 0 ne { % AtRight", 113 " 0 dy RJ", 114 " } if", 115 " just 1 and 0 ne { % BetweenLeftAndRight", 116 " 0 dy CT", 117 " } if", 118 " end", 119 " grestore", 120 "} def", 121 "%", 122 "% x y sizesymbol", 123 "%", 124 "/sizesymbol {", 125 " gsave", 126 " translate", 127 " 1 setlinewidth", 128 " -5 5 5 -5 line", 129 " grestore", 130 "} def", 131 "%", 132 "% x1 y1 x2 y2 s wiresizenote", 133 "%", 134 "/wiresizenote {", 135 " gsave", 136 " 8 rfont", 137 " 5 1 roll % s x1 y1 x2 y2", 138 " dup % s x1 y1 x2 y2 y2", 139 " 3 index % s x1 y1 x2 y2 y2 y1", 140 " eq 5 1 roll % s t x1 y1 x2 y2", 141 " 3 -1 roll add 2 div % s t x1 x2 y'", 142 " 3 1 roll add 2 div % s t y' x'", 143 " exch translate % s t", 144 " newpath -4 -4 moveto", 145 " 4 4 lineto stroke", 146 " { 0 -7 CT } { 7 3 LJ } ifelse", 147 " grestore", 148 "} bind def", 149 "%", 150 "% An inverter bubble", 151 "/inverter {", 152 " 0 startgate", 153 " 1 setgray", 154 " 0 0 2 0 360 arc fill", 155 " 0 setgray", 156 " 0 0 2 0 360 arc stroke", 157 " grestore", 158 "} bind def", 159 "%", 160 "% x y r arrow", 161 "%", 162 "/arrow {", 163 " gsave", 164 " 3 1 roll", 165 " translate", 166 " 1 -1 scale", 167 " 90 mul rotate", 168 " newpath", 169 " -2 -.5 moveto 1 -.5 lineto 1 -2.5 lineto", 170 " 4 0 lineto 1 2.5 lineto 1 .5 lineto -2 .5 lineto closepath", 171 " fill", 172 " grestore", 173 "} def", 174 "%", 175 "% x y r tri", 176 "%", 177 "/tri {", 178 " gsave", 179 " 3 1 roll", 180 " translate", 181 " 90 mul rotate", 182 " newpath", 183 " -5 0 moveto -1 -2.5 lineto -1 -.5 lineto 1 -.5 lineto", 184 " 1 -2.5 lineto 5 0 lineto 1 2.5 lineto 1 .5 lineto", 185 " -1 .5 lineto -1 2.5 lineto closepath", 186 " fill", 187 " grestore", 188 "} def", 189 "%", 190 "% Arrow head for ends of wires", 191 "/arrowhead {", 192 " startgate", 193 " 0.5 setlinewidth", 194 " newpath", 195 " -2 -1.5 moveto", 196 " 0 0 lineto", 197 " -2 1.5 lineto", 198 " stroke", 199 " grestore", 200 "} bind def", 201 "%", 202 "% w h pbox", 203 "%", 204 "/pbox {", 205 " newpath", 206 " 2 copy 2 copy", 207 " 0 0 moveto", 208 " exch pop 0 exch lineto", 209 " lineto", 210 " pop 0 lineto", 211 " closepath", 212 "} bind def", 213 "%", 214 "% x y w h box", 215 "%", 216 "/box {", 217 " gsave", 218 " 1 add exch 1 add exch", 219 " 4 2 roll", 220 " translate", 221 " -.5 -.5 translate", 222 " pbox stroke", 223 " grestore", 224 "} bind def", 225 "", 226 "%", 227 "% x y w h bold_box", 228 "%", 229 "/bold_box {", 230 " gsave", 231 " 2 setlinewidth", 232 " 4 2 roll", 233 " translate", 234 " pbox stroke", 235 " grestore", 236 "} def", 237 "", 238 "%", 239 "% x1 y2 x2 y2 line", 240 "%", 241 "/line {", 242 " moveto lineto stroke", 243 "} def", 244 "", 245 "%", 246 "% x1 y2 x2 y2 gline", 247 "%", 248 "/gline {", 249 " gsave", 250 " 0.5 setgray", 251 " moveto lineto stroke", 252 " grestore", 253 "} def", 254 "", 255 "%", 256 "%", 257 "/ds {", 258 " gsave", 259 " translate", 260 " newpath", 261 " 0 0 moveto", 262 " 3 0 lineto", 263 " 3 11 lineto", 264 " 0 11 lineto", 265 " closepath stroke", 266 " 0 2 moveto 3 2 lineto stroke", 267 " 0 9 moveto 3 9 lineto stroke", 268 " 0 5 moveto", 269 " 3 5 lineto", 270 " 3 6 lineto", 271 " 0 6 lineto", 272 " closepath fill", 273 " grestore", 274 "} def", 275 "%", 276 "% x y () hsize", 277 "%", 278 "/hsize {", 279 " gsave", 280 " 3 1 roll", 281 " translate", 282 " 6 rfont", 283 " 0 -5 CT", 284 " newpath", 285 " 0.5 setlinewidth", 286 " 3 -3 moveto -3 3 lineto stroke", 287 " grestore", 288 "} def", 289 "%", 290 "% x y () hsize", 291 "%", 292 "/vsize {", 293 " gsave", 294 " 3 1 roll", 295 " translate", 296 " 6 rfont ", 297 " 5 2 LJ", 298 " newpath", 299 " 0.5 setlinewidth", 300 " 3 -3 moveto -3 3 lineto stroke", 301 " grestore", 302 "} def", 303 "%", 304 "% a b max", 305 "%", 306 "/max {", 307 " 2 copy", 308 " le {exch pop} {pop} ifelse", 309 "} def", 310 "%", 311 "%", 312 "/longestwidth {", 313 " exch stringwidth pop exch", 314 " 1 sub", 315 " {exch stringwidth pop max} repeat", 316 "} def", 317 "%", 318 "%", 319 "% Gate Logo (by Miles Bader)", 320 "%", 321 "/size 10 def", 322 "", 323 "/2dup {", 324 " 1 index 1 index", 325 "} def", 326 "", 327 "/gatelogo {", 328 " gsave", 329 " translate", 330 " 0 12 translate % Make space for label", 331 "", 332 " .45 .45 scale", 333 " 5 size mul neg 0 translate", 334 "", 335 " 0 0 post", 336 " 8 size mul 0 post", 337 "", 338 " 1 setlinewidth", 339 " 0 setgray", 340 "", 341 " size 2 mul % 2s", 342 " dup 4 mul % 2s 8s", 343 " 2dup % 2s 8s 2s 8s ", 344 " size % 2s 8s 2s 8s s", 345 " 3 1 roll % 2s 8s s 2s 8s", 346 " {", 347 " newpath", 348 " dup 2 index exch moveto", 349 " 2 index exch lineto", 350 " stroke", 351 " } for", 352 "", 353 " pop pop", 354 "", 355 " size dup 2.5 mul exch 8.5 mul spikedraw", 356 " size dup 3.5 mul exch 9.25 mul spikedraw", 357 " size dup 4.5 mul exch 9.5 mul spikedraw", 358 "", 359 " newpath", 360 " size dup 5 mul exch 9 mul 1 index exch moveto", 361 " 0 lineto", 362 " 1 setlinewidth", 363 " 1 setgray", 364 " stroke", 365 "", 366 " size dup 5.5 mul exch 9.5 mul spikedraw", 367 " size dup 6.5 mul exch 9.25 mul spikedraw", 368 " size dup 7.5 mul exch 8.5 mul spikedraw", 369 "", 370 " 1.5 size mul ifont", 371 " GateVersion 5 size mul -18 showCentered", 372 "", 373 " grestore", 374 "} def", 375 "", 376 "/spikedraw {", 377 " 0 setgray", 378 "", 379 " newpath % x y", 380 " 2dup moveto % x y", 381 " 2dup size 2 div 250 290 arc % x y", 382 " closepath", 383 " fill", 384 "", 385 " newpath", 386 " 2dup size 2 div sub moveto % x y", 387 " pop size 2 div lineto % x y", 388 " 1 setlinewidth", 389 " stroke", 390 "} def", 391 "", 392 "%", 393 "% Centered show text.", 394 "% (TEXT) x y showCentered", 395 "/showCentered {", 396 " gsave", 397 " 3 -1 roll", 398 " dup", 399 " stringwidth", 400 " pop 2 div neg 0 translate", 401 " 3 1 roll", 402 " moveto", 403 " show", 404 " grestore", 405 "} def", 406 "", 407 "/post {", 408 " gsave", 409 " translate", 410 "", 411 " newpath", 412 " 0 0 moveto", 413 " size 2 mul 0 lineto", 414 " size dup 3.5 mul 4.12 size mul 75.96 104.04 arc", 415 " closepath", 416 " gsave 0 setgray 2 setlinewidth stroke grestore", 417 "% 1 setgray fill", 418 "", 419 " size .66 mul size moveto", 420 " 0 6 size mul rlineto", 421 " size 1.33 mul size moveto", 422 " 0 6 size mul rlineto", 423 " 0 setgray 0.5 setlinewidth stroke", 424 "", 425 " newpath", 426 " size .8 mul % .8s", 427 " 4.12 3.5 add % .8s 7.72", 428 " size mul 1 index add % .8s 8.52s", 429 " size exch % .8s s 8.52s", 430 " 3 -1 roll 0 360 arc", 431 " gsave 0 setgray 2 setlinewidth stroke grestore", 432 " .95 setgray fill", 433 "", 434 " grestore", 435 "} def", 436 "", 437 "", 438 "%", 439 "% Draw the page box", 440 "%", 441 "% t/f pagebox", 442 "%", 443 "/pagebox {", 444 " gsave", 445 "", 446 " %", 447 " % Draw main frame", 448 " %", 449 " 1 setlinewidth", 450 " {", 451 " newpath", 452 " LMargin BMargin moveto", 453 " PageWidth RMargin sub BMargin lineto", 454 " PageWidth RMargin sub PageHeight TMargin sub lineto", 455 " LMargin PageHeight TMargin sub lineto", 456 " closepath", 457 " stroke", 458 " } {", 459 " newpath", 460 " LMargin BMargin moveto", 461 " PageWidth RMargin sub BMargin lineto", 462 " PageWidth RMargin sub BMargin LBlock add lineto", 463 " LMargin BMargin LBlock add lineto", 464 " closepath", 465 " stroke", 466 " } ifelse", 467 "", 468 " 10 dict begin", 469 " /X1 LMargin def", 470 " /X2 PageWidth RMargin sub def", 471 " /X3 PageWidth RMargin sub LogoWidth sub def", 472 " /XM X1 X3 add 2 div def", 473 " /Y0 BMargin LBlock add def", 474 " /Y1 BMargin LBlock 2 mul 3 div add def", 475 " /Y2 BMargin LBlock 3 div add def", 476 " /Y3 BMargin def", 477 "", 478 "", 479 " X1 Y0 moveto X2 Y0 lineto stroke", 480 " X1 Y1 moveto X3 Y1 lineto stroke", 481 " X1 Y2 moveto X3 Y2 lineto stroke", 482 "", 483 " /x1delta 10 def", 484 " /x2delta 0 def", 485 " /ydelta 5 def", 486 "", 487 " 12 bfont ", 488 " X1 x1delta add Y1 ydelta add moveto (Designer:) show", 489 " X1 x1delta add Y2 ydelta add moveto (Site:) show", 490 " X1 x1delta add Y3 ydelta add moveto (Date:) show", 491 "", 492 " XM x2delta add Y1 ydelta add moveto (Document:) show", 493 " XM x2delta add Y2 ydelta add moveto (Page:) show", 494 " isTrace {", 495 " XM x2delta add Y3 ydelta add moveto (Interval:) show", 496 " } {", 497 " XM x2delta add Y3 ydelta add moveto (Module:) show", 498 " } ifelse", 499 "", 500 " /x1delta 15 (Designer:) stringwidth pop add def", 501 " /x2delta 5 (Document:) stringwidth pop add def", 502 "", 503 " 12 rfont", 504 " X1 x1delta add Y1 ydelta add moveto Author show", 505 " X1 x1delta add Y2 ydelta add moveto Site show", 506 " X1 x1delta add Y3 ydelta add moveto Date show", 507 "", 508 " XM x2delta add Y1 ydelta add moveto CircuitName show", 509 " XM x2delta add Y2 ydelta add moveto PageNumber show", 510 " XM x2delta add Y3 ydelta add moveto ModuleNames show", 511 " end", 512 "", 513 " %", 514 " % Draw logo", 515 " %", 516 " PageWidth RMargin sub LogoWidth sub BMargin moveto", 517 " 0 LBlock rlineto stroke", 518 " PageWidth RMargin sub LogoWidth 2 div sub BMargin gatelogo", 519 "", 520 " grestore", 521 "} bind def", 522 "", 523 "%", 524 "% () x y pshow", 525 "%", 526 "/pshow {", 527 " gsave", 528 " translate", 529 " 1 -1 scale", 530 " (_) anchorsearch {", 531 " newpath 0 0 moveto", 532 " pop dup true charpath pathbbox", 533 " 0.5 setlinewidth", 534 " newpath dup 3 1 roll 2 add moveto exch pop 2 add lineto stroke", 535 " } if", 536 " 0 0 moveto show", 537 " grestore", 538 "} def", 539 "%", 540 "% () hj vj x y pjshow ", 541 "%", 542 "/pjshow {", 543 " gsave", 544 " translate", 545 " 3 dict begin", 546 " 2 index stringwidth pop /W exch def", 547 " /S currentfont /ScaleMatrix get 0 get def", 548 " currentfont /FontBBox get cvx exec", 549 " /A exch S mul 1000 div def pop /D exch S mul 1000 div def pop", 550 "", 551 " dup /C eq {", 552 " 0 A D add 2 div translate", 553 " } if", 554 " dup /T eq {", 555 " 0 A translate", 556 " } if", 557 " dup /B eq {", 558 " 0 D translate", 559 " } if", 560 " pop", 561 "", 562 " dup /C eq {", 563 " W 2 div neg 0 translate", 564 " } if", 565 " dup /R eq {", 566 " W neg 0 translate", 567 " } if", 568 " pop", 569 " end", 570 " 0 0 pshow", 571 " grestore", 572 "} def", 573 "", 574 "%", 575 "% () x y pshow", 576 "%", 577 "/prshow {", 578 " gsave", 579 " translate", 580 " (_) anchorsearch {", 581 " newpath 0 0 moveto", 582 " pop dup true charpath pathbbox", 583 " 0.5 setlinewidth", 584 " newpath dup 3 1 roll 2 add moveto exch pop 2 add lineto stroke", 585 " } if", 586 " 0 0 moveto show", 587 " grestore", 588 "} def", 589 "", 590 "%", 591 "% Show a value in a trace. Do not display if width is greater than wmax", 592 "%", 593 "% () x y wmax trshow", 594 "%", 595 "/trshow {", 596 " gsave", 597 " 3 1 roll translate", 598 " 1 index stringwidth pop lt {", 599 " pop", 600 " } {", 601 " 0 0 prshow", 602 " } ifelse", 603 " grestore", 604 "} def", 605 "", 606 "", 607 "%", 608 "% Centered show text.", 609 "% (TEXT) x y CT", 610 "/CT {", 611 " gsave", 612 " 3 -1 roll", 613 " dup", 614 " stringwidth", 615 " pop 2 div neg 0 translate", 616 " 3 1 roll", 617 " pshow", 618 " grestore", 619 "} bind def", 620 "%", 621 "% Centered show text (reversed).", 622 "% (TEXT) x y rCT", 623 "/rCT {", 624 " gsave", 625 " translate ", 626 " 1 -1 scale", 627 " dup", 628 " stringwidth", 629 " pop 2 div neg 0 translate", 630 " 0 0 pshow", 631 " grestore", 632 "} bind def", 633 "%", 634 "% Left Justified show text", 635 "% (TEXT) x y LJ", 636 "/LJ {", 637 " pshow", 638 "} bind def", 639 "%", 640 "% Right Justified show text.", 641 "% (TEXT) x y RJ", 642 "/RJ {", 643 " gsave", 644 " 3 -1 roll", 645 " dup", 646 " stringwidth", 647 " pop neg 0 translate", 648 " 3 1 roll", 649 " pshow", 650 " grestore", 651 "} bind def", 652 "", 653 "%", 654 "% begin a trace", 655 "%", 656 "% x y w h BT", 657 "%", 658 "/BT {", 659 " gsave", 660 " newpath", 661 " 4 2 roll moveto", 662 " dup 0 exch rlineto", 663 " exch 0 rlineto", 664 " neg 0 exch rlineto", 665 " closepath", 666 " clip", 667 " newpath", 668 "} def", 669 "", 670 "%", 671 "% end a trace", 672 "%", 673 "/ET {", 674 " grestore", 675 "} def", 676 "", 677 "%", 678 "% Begin page", 679 "%", 680 "% (n of n) (mod) BP", 681 "%", 682 "/BP {", 683 " /ModuleNames exch def", 684 " gsave", 685 " IsLandscape { makeLandscape } if", 686 "", 687 " isepsf {", 688 " pop", 689 " } {", 690 " /PageNumber exch def", 691 " isTrace not pagebox", 692 " LMargin BMargin LBlock add translate", 693 " } ifelse", 694 "} def", 695 "%", 696 "", 697 "% Begin a quandrent page", 698 "%", 699 "% r c nr nc (n of n) (mod) BP_P", 700 "%", 701 "/BP_P {", 702 " BP", 703 " PageWidth LMargin sub RMargin sub LogoWidth sub PBsize sub LBlock neg PartBox", 704 "} def", 705 "", 706 "% Begin a scope trace page", 707 "%", 708 "% (n of n) (n-m) BP_T", 709 "/BP_T {", 710 " /isTrace true def", 711 " BP", 712 "} def", 713 "", 714 "%", 715 "% End page", 716 "%", 717 "% EP", 718 "%", 719 "/EP { grestore showpage } def", 720 "%", 721 "% Begin module", 722 "%", 723 "% () x y w h BM", 724 "%", 725 "/BM {", 726 " gsave", 727 " 4 2 roll translate", 728 "", 729 " newpath", 730 " 0 0 moveto", 731 " exch dup 0 lineto", 732 " exch 2 copy lineto", 733 " exch pop 0 exch lineto", 734 " closepath", 735 " clip", 736 " newpath", 737 "", 738 " 10 rfont", 739 " 5 5 moveto show", 740 "", 741 "} def", 742 "", 743 "%", 744 "% x y w h", 745 "%", 746 "/corners {", 747 " gsave", 748 " 4 2 roll % w h x y", 749 "", 750 " newpath", 751 " 2 copy 5 add moveto 0 -5 rlineto 5 0 rlineto stroke", 752 " 2 copy 4 index add 5 sub moveto 0 5 rlineto 5 0 rlineto stroke", 753 " 2 copy 4 index add exch 5 index add exch 5 sub moveto 0 5 rlineto -5 0 rlineto stroke", 754 " exch 3 index add 5 sub exch moveto 5 0 rlineto 0 5 rlineto stroke ", 755 " pop pop", 756 "", 757 " grestore", 758 "} def", 759 "", 760 "%", 761 "% Begin module with corners", 762 "%", 763 "% () x y w h BM", 764 "%", 765 "/BM_C {", 766 " 4 copy corners", 767 " BM", 768 "} def", 769 "", 770 "%", 771 "% x y w h", 772 "%", 773 "/PBox {", 774 " newpath", 775 " 4 2 roll moveto", 776 " 1 index 0 rlineto", 777 " neg 0 exch rlineto", 778 " neg 0 rlineto", 779 " closepath", 780 "} def", 781 "", 782 "%", 783 "% r c nr nc x y", 784 "%", 785 "/PartBox {", 786 " gsave", 787 " translate", 788 " 6 dict begin", 789 " /nc exch def", 790 " /nr exch def", 791 " /c exch def", 792 " /r exch def", 793 " /boxW PBsize nc div def ", 794 " /boxH PBsize nr div def ", 795 "", 796 " 0 1 nc 1 sub {", 797 " 0 1 nr 1 sub {", 798 " 2 copy r eq exch c eq and {", 799 " 2 copy", 800 " boxH mul PBsize exch sub exch boxW mul exch ", 801 " boxW boxH PBox gsave fill grestore stroke", 802 " } {", 803 " 2 copy", 804 " boxH mul PBsize exch sub exch boxW mul exch ", 805 " boxW boxH PBox gsave 1 setgray fill grestore stroke", 806 " } ifelse", 807 " pop", 808 " } for", 809 " pop", 810 " } for", 811 " end", 812 " grestore", 813 "} def", 814 "", 815 "%", 816 "% End module", 817 "%", 818 "% EM", 819 "/EM { grestore } def", 820 "", 821 "%", 822 "% makeLandscape", 823 "%", 824 "/makeLandscape {", 825 " 90 rotate", 826 " 0 PageHeight neg translate", 827 "} def", 828 "%", 829 "% x y joint_gray", 830 "%", 831 "/joint_gray {", 832 " gsave", 833 " translate", 834 " 0.5 setgray", 835 " -4 -4 moveto -4 4 lineto 4 4 lineto 4 -4 lineto closepath fill", 836 " grestore", 837 "} def", 838 "%", 839 "% () t/f x y hgnode", 840 "%", 841 "/hgnode {", 842 " gsave", 843 " translate", 844 " {[3 3] 0 setdash} if", 845 " dup 5 -5 moveto show newpath", 846 " 0 -10 moveto stringwidth pop 10 add 0 rlineto 0 20 rlineto 0 10 lineto closepath stroke", 847 " grestore", 848 "} def", 849