  "",
  "/isTrace false def",
  "/LogoWidth 60 def",
  "/PBsize 60 def",
  "",
  "%",
  "% /key font defLatin1",
  "%",
  "% Define key as a latin-1 version of font ",
  "%",
  "/defLatin1 {",
  "  dup length dict begin",
  "    {1 index /FID ne {def} {pop pop} ifelse} forall",
  "    /Encoding ISOLatin1Encoding def",
  "    currentdict",
  "  end",
  "  definefont pop",
  "} def",
  "",
  "% Calculate the height of an equalateral triangle with the given sides.",
  "/theight {",
  "	2 div",
  "	3 sqrt",
  "	mul",
  "} bind def",
  "%",
  "% Genaral parameters to start a gate.",
  "%",
  "% x y r startgate",
  "%",
  "/startgate {",
  "	gsave",
  "	1 setlinewidth",
  "	3 1 roll",
  "	translate",
  "	rotate",
  "	1 -1 scale",
  "	newpath",
  "} bind def",
  "%",
  "% x y r startnorotgate",
  "%",
  "/startnorotgate {",
  "  pop 0 startgate",
  "} def",
  "%",
  "% Genaral parameters to start a gate (with position adjustment)",
  "%",
  "% x y r [[][][][]] startgate",
  "%",
  "/adjstartgate {",
  "  gsave",
  "  1 setlinewidth",
  "  1 index 90 div neg cvi get {} forall	% x y r dx dy",
  "  exch 5 -1 roll add exch 4 -1 roll add",
  "  translate",
  "  rotate",
  "  1 -1 scale",
  "  newpath",
  "} bind def",
  "%",
  "% x y r adjstartnorotgate",
  "%",
  "/adjstartnorotgate {",
  "  exch pop 0 exch adjstartgate",
  "} def",
  "%",
  "% Wire",
  "/wire {",
  "	gsave",
  "	10 div",
  "	setlinewidth",
  "	newpath",
  "	moveto lineto",
  "	stroke",
  "	grestore",
  "} bind def",
  "%",
  "% (l) j x y wirelabel",
  "%",
  "% j=0, j=1	left justified",
  "% j=2, j=3	centered",
  "%",
  "/wirelabel {",
  "  gsave",
  "  translate",
  "  8 rfont",
  "",
  "  2 lt {",
  "    0 -4 LJ",
  "  } {",
  "    0 -4 CT",
  "  } ifelse",
  "  grestore",
  "} def",
  "%",
  "% x y sizesymbol",
  "%",
  "/sizesymbol {",
  "  gsave",
  "  translate",
  "  1 setlinewidth",    
  "  -5 5 5 -5 line",
  "  grestore",
  "} def",
  "%",
  "% x1 y1 x2 y2 s wiresizenote",
  "%",
  "/wiresizenote {",
  "    gsave",
  "    8 rfont",
  "    5 1 roll              % s x1 y1 x2 y2",
  "    dup                   % s x1 y1 x2 y2 y2",
  "    3 index               % s x1 y1 x2 y2 y2 y1",
  "    eq 5 1 roll           % s t x1 y1 x2 y2",
  "    3 -1 roll add 2 div   % s t x1 x2 y'",
  "    3 1 roll add 2 div    % s t y' x'",
  "    exch translate        % s t",
  "    newpath -4 -4 moveto",
  "    4 4 lineto stroke",
  "    { 0 -7 CT } { 7 3 LJ } ifelse",
  "    grestore",
  "} bind def",
  "%",
  "% An inverter bubble",
  "/inverter {",
  "   0 startgate",
  "   1 setgray",
  "   0 0 2 0 360 arc fill",
  "   0 setgray",
  "   0 0 2 0 360 arc stroke",
  "   grestore",
  "} bind def",
  "%",
  "% x y r arrow",
  "%",
  "/arrow {",
  "    gsave",
  "    3 1 roll",
  "    translate",
  "    1 -1 scale",
  "    90 mul rotate",
  "    newpath",
  "    -2 -.5 moveto 1 -.5 lineto 1 -2.5 lineto",
  "    4 0 lineto 1 2.5 lineto 1 .5 lineto -2 .5 lineto closepath",
  "    fill",
  "    grestore",
  "} def",
  "%",
  "% x y r tri",
  "%",
  "/tri {",
  "    gsave",
  "    3 1 roll",
  "    translate",
  "    90 mul rotate",
  "    newpath",
  "    -5 0 moveto -1 -2.5 lineto -1 -.5 lineto 1 -.5 lineto",
  "    1 -2.5 lineto 5 0 lineto 1 2.5 lineto 1 .5 lineto",
  "    -1 .5 lineto -1 2.5 lineto closepath",
  "    fill",
  "    grestore",
  "} def",
  "%",
  "% Arrow head for ends of wires",
  "/arrowhead {",
  "	startgate",
  "	0.5 setlinewidth",
  "	newpath",
  "	-2 -1.5 moveto",
  "	0 0 lineto",
  "	-2 1.5 lineto",
  "	stroke",
  "	grestore",
  "} bind def",
  "%",
  "% w h pbox",
  "%",
  "/pbox {",
  "  newpath",
  "  2 copy 2 copy",
  "  0 0 moveto",
  "  exch pop 0 exch lineto",
  "  lineto",
  "  pop 0 lineto",
  "  closepath",
  "} bind def",
  "%",
  "% x y w h box",
  "%",
  "/box {",
  "  gsave",
  "  1 add exch 1 add exch",
  "  4 2 roll",
  "  translate",
  "  -.5 -.5 translate",
  "  pbox stroke",
  "  grestore",
  "} bind def",
  "",
  "%",
  "% x y w h bold_box",
  "%",
  "/bold_box {",
  "  gsave",
  "  2 setlinewidth",
  "  4 2 roll",
  "  translate",
  "  pbox stroke",
  "  grestore",
  "} def",
  "",
  "%",
  "% x1 y2 x2 y2 line",
  "%",
  "/line {",
  "  moveto lineto stroke",
  "} def",
  "",
  "%",
  "% x1 y2 x2 y2 gline",
  "%",
  "/gline {",
  "  gsave",
  "  0.5 setgray",
  "  moveto lineto stroke",
  "  grestore",
  "} def",
  "",
  "%",
  "%",
  "/ds {",
  "	gsave",
  "	translate",
  "	newpath",
  "	0 0 moveto",
  "	3 0 lineto",
  "	3 11 lineto",
  "	0 11 lineto",
  "	closepath stroke",
  "	0 2 moveto 3 2 lineto stroke",
  "	0 9 moveto 3 9 lineto stroke",
  "	0 5 moveto",
  "	3 5 lineto",
  "	3 6 lineto",
  "	0 6 lineto",
  "	closepath fill",
  "	grestore",
  "} def",
  "%",
  "% x y () hsize",
  "%",
  "/hsize {",
  "	gsave",
  "	3 1 roll",
  "	translate",
  "	6 rfont",
  "	0 -5 CT",
  "	newpath",
  "	0.5 setlinewidth",
  "	3 -3 moveto -3 3 lineto stroke",
  "	grestore",
  "} def",
  "%",
  "% x y () hsize",
  "%",
  "/vsize {",
  "	gsave",
  "	3 1 roll",
  "	translate",
  "	6 rfont ",
  "	5 2 LJ",
  "	newpath",
  "	0.5 setlinewidth",
  "	3 -3 moveto -3 3 lineto stroke",
  "	grestore",
  "} def",
  "%",
  "% a b max",
  "%",
  "/max {",
  "	2 copy",
  "	le {exch pop} {pop} ifelse",
  "} def",
  "%",
  "%",
  "/longestwidth {",
  "	exch stringwidth pop exch",
  "	1 sub",
  "	{exch stringwidth pop max} repeat",
  "} def",
  "%",
  "%",
  "% Gate Logo (by Miles Bader)",
  "%",
  "/size 10 def",
  "",
  "/2dup {",
  "	1 index 1 index",
  "} def",
  "",
  "/gatelogo {",
  "  gsave",
  "  translate",
  "  0 12 translate		% Make space for label",
  "",
  "  .45 .45 scale",
  "  5 size mul neg 0 translate",
  "",
  "  0 0 post",
  "  8 size mul 0 post",
  "",
  "  1 setlinewidth",
  "  0 setgray",
  "",
  "  size 2 mul			% 2s",
  "  dup 4 mul			% 2s 8s",
  "  2dup				% 2s 8s 2s 8s  ",
  "  size				% 2s 8s 2s 8s s",
  "  3 1 roll			% 2s 8s s 2s 8s",
  "  {",
  "    newpath",
  "    dup 2 index exch moveto",
  "    2 index exch lineto",
  "    stroke",
  "  } for",
  "",
  "  pop pop",
  "",
  "  size dup 2.5 mul exch 8.5 mul spikedraw",
  "  size dup 3.5 mul exch 9.25 mul spikedraw",
  "  size dup 4.5 mul exch 9.5 mul spikedraw",
  "",
  "  newpath",
  "  size dup 5 mul exch 9 mul 1 index exch moveto",
  "  0 lineto",
  "  1 setlinewidth",
  "  1 setgray",
  "  stroke",
  "",
  "  size dup 5.5 mul exch 9.5 mul spikedraw",
  "  size dup 6.5 mul exch 9.25 mul spikedraw",
  "  size dup 7.5 mul exch 8.5 mul spikedraw",
  "",
  "  1.5 size mul ifont",
  "  GateVersion 5 size mul -18 showCentered",
  "",
  "  grestore",
  "} def",
  "",
  "/spikedraw {",
  "	0 setgray",
  "",
  "	newpath				% x y",
  "	2dup moveto			% x y",
  "	2dup size 2 div 250 290 arc	% x y",
  "	closepath",
  "	fill",
  "",
  "	newpath",
  "	2dup size 2 div sub moveto	% x y",
  "	pop size 2 div lineto		% x y",
  "	1 setlinewidth",
  "	stroke",
  "} def",
  "",
  "%",
  "% Centered show text.",
  "% (TEXT) x y showCentered",
  "/showCentered {",
  "	gsave",
  "	3 -1 roll",
  "	dup",
  "	stringwidth",
  "	pop 2 div neg 0 translate",
  "	3 1 roll",
  "	moveto",
  "	show",
  "	grestore",
  "} def",
  "",
  "/post {",
  "  gsave",
  "  translate",
  "",
  "  newpath",
  "  0 0 moveto",
  "  size 2 mul 0 lineto",
  "  size dup 3.5 mul 4.12 size mul 75.96 104.04 arc",
  "  closepath",
  "  gsave 0 setgray 2 setlinewidth stroke grestore",
  "%	1 setgray fill",
  "",
  "  size .66 mul size moveto",
  "  0 6 size mul rlineto",
  "  size 1.33 mul size moveto",
  "  0 6 size mul rlineto",
  "  0 setgray 0.5 setlinewidth stroke",
  "",
  "  newpath",
  "  size .8	mul					% .8s",
  "  4.12 3.5 add					% .8s 7.72",
  "  size mul 1 index add				% .8s 8.52s",
  "  size exch					% .8s s 8.52s",
  "  3 -1 roll 0 360 arc",
  "  gsave 0 setgray 2 setlinewidth stroke grestore",
  "  .95 setgray fill",
  "",
  "  grestore",
  "} def",
  "",
  "",
  "%",
  "%  Draw the page box",
  "%",
  "% t/f pagebox",
  "%",
  "/pagebox {",
  "  gsave",
  "",
  "  %",
  "  % Draw main frame",
  "  %",
  "  1 setlinewidth",
  "  {",
  "    newpath",
  "    LMargin BMargin moveto",
  "    PageWidth RMargin sub	BMargin	lineto",
  "    PageWidth RMargin sub PageHeight TMargin sub lineto",
  "    LMargin PageHeight TMargin sub lineto",
  "    closepath",
  "    stroke",
  "  } {",
  "    newpath",
  "    LMargin BMargin moveto",
  "    PageWidth RMargin sub BMargin lineto",
  "    PageWidth RMargin sub BMargin LBlock add lineto",
  "    LMargin BMargin LBlock add lineto",
  "    closepath",
  "    stroke",
  "  } ifelse",
  "",
  "  10 dict begin",
  "    /X1 LMargin def",
  "    /X2 PageWidth RMargin sub def",
  "    /X3 PageWidth RMargin sub LogoWidth sub def",
  "    /XM X1 X3 add 2 div def",
  "    /Y0 BMargin LBlock add def",
  "    /Y1 BMargin LBlock 2 mul 3 div add def",
  "    /Y2 BMargin LBlock 3 div add def",
  "    /Y3 BMargin def",
  "",
  "",
  "    X1 Y0 moveto  X2 Y0 lineto stroke",
  "    X1 Y1 moveto  X3 Y1 lineto stroke",
  "    X1 Y2 moveto  X3 Y2 lineto stroke",
  "",
  "    /x1delta 10 def",
  "    /x2delta 0 def",
  "    /ydelta 5 def",
  "",
  "    12 bfont ",
  "    X1 x1delta add Y1 ydelta add moveto (Designer:) show",
  "    X1 x1delta add Y2 ydelta add moveto (Site:) show",
  "    X1 x1delta add Y3 ydelta add moveto (Date:) show",
  "",
  "    XM x2delta add Y1 ydelta add moveto (Document:) show",
  "    XM x2delta add Y2 ydelta add moveto (Page:) show",
  "    isTrace {",
  "      XM x2delta add Y3 ydelta add moveto (Interval:) show",
  "    } {",
  "      XM x2delta add Y3 ydelta add moveto (Module:) show",
  "    } ifelse",
  "",
  "    /x1delta 15 (Designer:) stringwidth pop add def",
  "    /x2delta 5 (Document:) stringwidth pop add def",
  "",
  "    12 rfont",
  "    X1 x1delta add Y1 ydelta add moveto Author show",
  "    X1 x1delta add Y2 ydelta add moveto Site show",
  "    X1 x1delta add Y3 ydelta add moveto Date show",
  "",
  "    XM x2delta add Y1 ydelta add moveto CircuitName show",
  "    XM x2delta add Y2 ydelta add moveto PageNumber show",
  "    XM x2delta add Y3 ydelta add moveto ModuleNames show",
  "  end",
  "",
  "  %",
  "  % Draw logo",
  "  %",
  "  PageWidth RMargin sub LogoWidth sub BMargin moveto",
  "  0 LBlock rlineto stroke",
  "  PageWidth RMargin sub LogoWidth 2 div sub BMargin gatelogo",
  "",
  "  grestore",
  "} bind def",
  "",
  "%",
  "% () x y pshow",
  "%",
  "/pshow {",
  "	gsave",
  "	translate",
  "	1 -1 scale",
  "	(_) anchorsearch {",
  "	    newpath 0 0 moveto",
  "	    pop dup true charpath pathbbox",
  "	    0.5 setlinewidth",
  "	    newpath dup 3 1 roll 2 add moveto exch pop 2 add lineto stroke",
  "	} if",
  "	0 0 moveto show",
  "	grestore",
  "} def",
  "%",
  "% () hj vj x y pjshow ",
  "%",
  "/pjshow {",
  "  gsave",
  "  translate",
  "  3 dict begin",
  "    2 index stringwidth pop /W exch def",
  "    /S currentfont /ScaleMatrix get 0 get def",
  "    currentfont /FontBBox get cvx exec",
  "    /A exch S mul 1000 div def pop /D exch S mul 1000 div def pop",
  "",
  "    dup /C eq {",
  "      0 A D add 2 div translate",
  "    } if",
  "    dup /T eq {",
  "      0 A translate",
  "    } if",
  "    dup /B eq {",
  "      0 D translate",
  "    } if",
  "    pop",
  "",
  "    dup /C eq {",
  "      W 2 div neg 0 translate",
  "    } if",
  "    dup /R eq {",
  "      W neg 0 translate",
  "    } if",
  "    pop",
  "  end",
  "  0 0 pshow",
  "  grestore",
  "} def",
  "",
  "%",
  "% () x y pshow",
  "%",
  "/prshow {",
  "	gsave",
  "	translate",
  "	(_) anchorsearch {",
  "	    newpath 0 0 moveto",
  "	    pop dup true charpath pathbbox",
  "	    0.5 setlinewidth",
  "	    newpath dup 3 1 roll 2 add moveto exch pop 2 add lineto stroke",
  "	} if",
  "	0 0 moveto show",
  "	grestore",
  "} def",
  "",
  "%",
  "% Show a value in a trace.  Do not display if width is greater than wmax",
  "%",
  "% () x y wmax trshow",
  "%",
  "/trshow {",
  "  gsave",
  "  3 1 roll translate",
  "  1 index stringwidth pop lt {",
  "    pop",
  "  } {",
  "    0 0 prshow",
  "  } ifelse",
  "  grestore",
  "} def",
  "",
  "",
  "%",
  "% Centered show text.",
  "% (TEXT) x y CT",
  "/CT {",
  "	gsave",
  "	3 -1 roll",
  "	dup",
  "	stringwidth",
  "	pop 2 div neg 0 translate",
  "	3 1 roll",
  "	pshow",
  "	grestore",
  "} bind def",
  "%",
  "% Centered show text (reversed).",
  "% (TEXT) x y rCT",
  "/rCT {",
  "  gsave",
  "  translate      ",
  "  1 -1 scale",
  "  dup",
  "  stringwidth",
  "  pop 2 div neg 0 translate",
  "  0 0 pshow",
  "  grestore",
  "} bind def",
  "%",
  "% Left Justified show text",
  "% (TEXT) x y LJ",
  "/LJ {",
  "	pshow",
  "} bind def",
  "%",
  "% Right Justified show text.",
  "% (TEXT) x y RJ",
  "/RJ {",
  "	gsave",
  "	3 -1 roll",
  "	dup",
  "	stringwidth",
  "	pop neg 0 translate",
  "	3 1 roll",
  "	pshow",
  "	grestore",
  "} bind def",
  "",
  "%",
  "% begin a trace",
  "%",
  "% x y w h BT",
  "%",
  "/BT {",
  "  gsave",
  "  newpath",
  "  4 2 roll moveto",
  "  dup 0 exch rlineto",
  "  exch 0 rlineto",
  "  neg 0 exch rlineto",
  "  closepath",
  "  clip",
  "  newpath",
  "} def",
  "",
  "%",
  "% end a trace",
  "%",
  "/ET {",
  "  grestore",
  "} def",
  "",
  "%",
  "% Begin page",
  "%",
  "% (n of n) (mod) BP",
  "%",
  "/BP {",
  "  /ModuleNames exch def",
  "  gsave",
  "  IsLandscape { makeLandscape } if",
  "",
  "  isepsf {",
  "    pop",
  "  } {",
  "    /PageNumber exch def",
  "    isTrace not pagebox",
  "    LMargin BMargin LBlock add translate",
  "  } ifelse",
  "} def",
  "%",
  "",
  "% Begin a quandrent page",
  "%",
  "% r c nr nc (n of n) (mod) BP_P",
  "%",
  "/BP_P {",
  "  BP",
  "  PageWidth LMargin sub RMargin sub LogoWidth sub PBsize sub LBlock neg PartBox",
  "} def",
  "",
  "% Begin a scope trace page",
  "%",
  "% (n of n) (n-m) BP_T",
  "/BP_T {",
  "  /isTrace true def",
  "  BP",
  "} def",
  "",
  "%",
  "% End page",
  "%",
  "% EP",
  "%",
  "/EP { grestore showpage } def",
  "%",
  "% Begin module",
  "%",
  "% () x y w h BM",
  "%",
  "/BM {",
  "  gsave",
  "  4 2 roll translate",
  "",
  "  newpath",
  "  0 0 moveto",
  "  exch dup 0 lineto",
  "  exch 2 copy lineto",
  "  exch pop 0 exch lineto",
  "  closepath",
  "  clip",
  "  newpath",
  "",
  "  10 rfont",
  "  5 5 moveto show",
  "",
  "} def",
  "",
  "%",
  "% x y w h",
  "%",
  "/corners {",
  "  gsave",
  "  4 2 roll	% w h x y",
  "",
  "  newpath",
  "  2 copy 5 add moveto 0 -5 rlineto 5 0 rlineto stroke",
  "  2 copy 4 index add 5 sub moveto 0 5 rlineto 5 0 rlineto stroke",
  "  2 copy 4 index add exch 5 index add exch 5 sub moveto 0 5 rlineto -5 0 rlineto stroke",
  "  exch 3 index add 5 sub exch moveto 5 0 rlineto 0 5 rlineto stroke  ",
  "  pop pop",
  "",
  "  grestore",
  "} def",
  "",
  "%",
  "% Begin module with corners",
  "%",
  "% () x y w h BM",
  "%",
  "/BM_C {",
  "  4 copy corners",
  "  BM",
  "} def",
  "",
  "%",
  "% x y w h",
  "%",
  "/PBox {",
  "  newpath",
  "  4 2 roll moveto",
  "  1 index 0 rlineto",
  "  neg 0 exch rlineto",
  "  neg 0 rlineto",
  "  closepath",
  "} def",
  "",
  "%",
  "% r c nr nc x y",
  "%",
  "/PartBox {",
  "  gsave",
  "  translate",
  "  6 dict begin",
  "    /nc exch def",
  "    /nr exch def",
  "    /c exch def",
  "    /r exch def",
  "    /boxW PBsize nc div def ",
  "    /boxH PBsize nr div def ",
  "",
  "    0 1 nc 1 sub {",
  "      0 1 nr 1 sub {",
  "        2 copy r eq exch c eq and {",
  "	   2 copy",
  "	   boxH mul PBsize exch sub exch boxW mul exch  ",
  "           boxW boxH PBox gsave fill grestore stroke",
  "	} {",
  "           2 copy",
  "	   boxH mul PBsize exch sub exch boxW mul exch  ",
  "           boxW boxH PBox gsave 1 setgray fill grestore stroke",
  "	} ifelse",
  "        pop",
  "      } for",
  "      pop",
  "    } for",
  "  end",
  "  grestore",
  "} def",
  "",
  "%",
  "% End module",
  "%",
  "% EM",
  "/EM { grestore } def",
  "",
  "%",
  "% makeLandscape",
  "%",
  "/makeLandscape {",
  "   90 rotate",
  "   0 PageHeight neg translate",
  "} def",
  "%",
  "% x y joint_gray",
  "%",
  "/joint_gray {",
  "   gsave",
  "   translate",
  "   0.5 setgray",
  "   -4 -4 moveto -4 4 lineto 4 4 lineto 4 -4 lineto closepath fill",
  "   grestore",
  "} def",
  "%",
  "% () t/f x y hgnode",
  "%",
  "/hgnode {",
  "  gsave",
  "  translate",
  "  {[3 3] 0 setdash} if",
  "  dup 5 -5 moveto show newpath",
  "  0 -10 moveto stringwidth pop 10 add 0 rlineto 0 20 rlineto 0 10 lineto closepath stroke",
  "  grestore",
  "} def",
