%bipoles: speaker, sfuse, isourcbr, 
%multipoles: dip8, dip14, dip16, qfp64
%macros: \whereami

\newlength{\whereamix} \newlength{\whereamiy}

\newif\ifpgftextempty

\makeatletter
\newcommand{\whereami}[2]{	% #1 = anchor name, #2 = color
 \draw[color=#2] (#1) node{
  \setlength{\whereamix}{0.0352\pgf@x}
  \setlength{\whereamiy}{0.0352\pgf@y}
  (\strip@pt\whereamix, \strip@pt\whereamiy)
 };
}

\newcommand{\Compass}% define anchors for compass points
{\anchor{north east}{\northeast}
\anchor{south west}{\southwest}
\anchor{north}{\pgfextracty{\pgf@circ@res@up}{\northeast}\pgfpoint{0cm}{\pgf@circ@res@up}}
\anchor{north west}{\pgfextracty{\pgf@circ@res@up}{\northeast}\pgfextractx{\pgf@circ@res@left}{\southwest}\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\anchor{west}{\pgfextractx{\pgf@circ@res@left}{\sosuthwest}\pgfpoint{\pgf@circ@res@left}{0cm}}
\anchor{south}{\pgfextracty{\pgf@circ@res@down}{\southwest}\pgfpoint{0cm}{\pgf@circ@res@down}}
\anchor{south east}{\pgfextracty{\pgf@circ@res@down}{\southwest}\pgfextractx{\pgf@circ@res@right}{\northeast}\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
\anchor{east}{\pgfextractx{\pgf@circ@res@right}{\northeast}\pgfpoint{\pgf@circ@res@right}{0cm}}}

% *************************** speaker **********************************

\ctikzset{bipoles/speaker/height/.initial=.30}
\ctikzset{bipoles/speaker/width/.initial=.80}

\pgfcircdeclarebipole{}
 {\ctikzvalof{bipoles/speaker/height}}
 {speaker}
 {\ctikzvalof{bipoles/speaker/height}}
 {\ctikzvalof{bipoles/speaker/width}}
 {
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@down}{\southwest}
  \pgfpathrectanglecorners{\southwest}{\northeast}
  \pgfmoveto{\pgfpoint{0.5\pgf@circ@res@right}{\pgf@circ@res@down}}
  \pgflineto{\pgfpoint{1.25\pgf@circ@res@right}{2.5\pgf@circ@res@down}}
  \pgflineto{\pgfpoint{1.25\pgf@circ@res@left}{2.5\pgf@circ@res@down}}
  \pgflineto{\pgfpoint{0.5\pgf@circ@res@left}{\pgf@circ@res@down}}
  \pgfusepath{draw}	%draw speaker
 }

\def\speakerpath#1{\pgf@circ@bipole@path{speaker}{#1}}
\compattikzset{speaker/.style = {\circuitikzbasekey, /tikz/to path=\speakerpath, l=#1}}


% ****************************** sfuse **********************************


\ctikzset{bipoles/sfuse/width/.initial=.5}
\ctikzset{bipoles/sfuse/height/.initial=.3}	%label offset only

\pgfcircdeclarebipole{}
 {\ctikzvalof{bipoles/sfuse/height}}
 {sfuse}
 {\ctikzvalof{bipoles/sfuse/height}}
 {\ctikzvalof{bipoles/sfuse/width}}
 {
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}

	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0cm}}
	\pgfpatharc{180}{0}{0.5\pgf@circ@res@right}
	\pgfpatharc{0}{180}{0.5\pgf@circ@res@left}
  \pgfusepath{draw}	%draw sfuse
 }

\def\sfusepath#1{\pgf@circ@bipole@path{sfuse}{#1}}
\compattikzset{sfuse/.style = {\circuitikzbasekey, /tikz/to path=\sfusepath, l=#1}}

% ****************************** isourcebr **********************************

\ctikzset{bipoles/isourcebr/height/.initial=.4}
\ctikzset{bipoles/isourcebr/width/.initial=.6}

\pgfcircdeclarebipole{}
 {\ctikzvalof{bipoles/isourcebr/height}}
 {isourcebr}
 {\ctikzvalof{bipoles/isourcebr/height}}
 {\ctikzvalof{bipoles/isourcebr/width}}
 {
	\pgfsetlinewidth{\ctikzvalof{bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}

  \pgfmoveto{\pgfpoint{\pgf@circ@res@left}{0cm}}
	\pgfpathellipse{\pgfpoint{0.333\pgf@circ@res@left}{0cm}}{\pgfpoint{0.667\pgf@circ@res@right}{0cm}}{\pgfpoint{0cm}{\pgf@circ@res@up}}
  \pgfmoveto{\pgfpoint{\pgf@circ@res@right}{0cm}}
	\pgfpathellipse{\pgfpoint{0.333\pgf@circ@res@right}{0cm}}{\pgfpoint{0.667\pgf@circ@res@right}{0cm}}{\pgfpoint{0cm}{\pgf@circ@res@up}}
  \pgfusepath{draw}	%draw isourcebr
 	\pgfscope
	\pgfsetarrowsend{latex'}
	\pgfpathmoveto{\pgfpoint{.5\pgf@circ@res@left}{1.333\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{.8\pgf@circ@res@right}{1.333\pgf@circ@res@up}}
	\pgfusepath{draw}	%draw arrow
	\endpgfscope
 }

\def\isourcebrpath#1{\pgf@circ@bipole@path{isourcebr}{#1}}

\compattikzset{isourcebr/.style = {\circuitikzbasekey, /tikz/to path=\isourcebrpath,
\circuitikzbasekey/bipole/is current=true, l=#1}}

\compattikzset{british current source/.style = {\circuitikzbasekey, /tikz/to path=\isourcebrpath, 
\circuitikzbasekey/bipole/is current=true, i=#1}}


% ****************************** motor **********************************

\ctikzset{bipoles/motor/height/.initial=.8}
\ctikzset{bipoles/motor/width/.initial=.8}

% create motor shape

\pgfcircdeclarebipole{}
 {\ctikzvalof{bipoles/motor/height}}
 {motor}
 {\ctikzvalof{bipoles/motor/height}}
 {\ctikzvalof{bipoles/motor/width}}
 {
	\pgfsetlinewidth{\ctikzvalof{bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@down}{\southwest}

  \pgfpathmoveto{\pgfpoint{0.775\pgf@circ@res@left}{0.2\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0.2\pgf@circ@res@down}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0.2\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{0.775\pgf@circ@res@left}{0.2\pgf@circ@res@up}}
 	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0.8\pgf@circ@res@right}{0cm}}{\pgfpoint{0cm}{0.8\pgf@circ@res@up}}
  \pgfpathmoveto{\pgfpoint{0.775\pgf@circ@res@right}{0.2\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.2\pgf@circ@res@down}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0.2\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{0.775\pgf@circ@res@right}{0.2\pgf@circ@res@up}}
  \pgfusepath{draw}	%draw motor
%	\pgftext[rotate=-\pgf@circ@direction]{\textsf{M}}
 }

% create motor to-path style

\def\motorpath#1{\pgf@circ@bipole@path{motor}{#1}}
\compattikzset{motor/.style = {\circuitikzbasekey, /tikz/to path=\motorpath, l=#1}}

% ************************* battery with thick negative *************

\ctikzset{bipoles/batteryN/width/.initial=.1}
\ctikzset{bipoles/batteryN/plus/.initial=$+$}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/battery/height}}
  {batteryN}
  {\ctikzvalof{bipoles/battery/height}}
  {\ctikzvalof{bipoles/batteryN/width}}
{
  \pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@down}{\southwest}
  \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth
        
  \pgfsetlinewidth{2\pgf@circ@res@temp}
  \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{.5\pgf@circ@res@down}}
  \pgfusepath{draw}
        
  \pgfsetlinewidth{\pgf@circ@res@temp}
  \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
  \pgfusepath{draw}
  
 \pgfscope
    \pgftransformyshift{-1.2ex}
    \pgftransformxshift{\dimexpr\pgf@circ@res@right+1.2ex}
    \pgftext[rotate=-\pgf@circ@direction]{\ctikzvalof{bipoles/batteryN/plus}}
 \endpgfscope
}

% create batteryN to-path style

\def\batteryNpath#1{\pgf@circ@bipole@path{batteryN}{#1}}
\compattikzset{batteryN/.style = {\circuitikzbasekey, /tikz/to path=\batteryNpath, \circuitikzbasekey/bipole/is voltage=true, v=#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% two emitter npn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ctikzset{tripoles/npn2/height/.initial=1.1}% before expansion
\ctikzset{tripoles/npn2/width/.initial=.6}% before expansion
\ctikzset{tripoles/npn2/gate height/.initial=.45}
\ctikzset{tripoles/npn2/gate height 2/.initial=.15}
\ctikzset{tripoles/npn2/base height/.initial=.4}
\ctikzset{tripoles/npn2/step/.initial=.15}% both vertical and horizontal separation
\ctikzset{tripoles/npn2/slope/.initial=.6}% (height - height 2) / (gate width)
\ctikzset{tripoles/npn2/gate width/.initial=.5}
\ctikzset{tripoles/npn2/curr direction/.initial=1}

\pgfcircdeclaretransistor{npn2}{
  \savedanchor{\southeast}{% \northeast is actually north (x=0pt)
    \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/step}\pgf@circ@Rlen
  	\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/height}\pgf@circ@Rlen
  	\pgf@y=-.5\pgf@y
  	\advance\pgf@y by -\pgf@x
  }
% redefine anchors for larger size
  \anchor{north east}{
    \southeast
    \pgf@circ@res@temp=\pgf@x
    \northeast
    \pgf@x=\pgf@circ@res@temp
  }
  \anchor{south east}{\southeast}
  \anchor{east}{
    \southeast
    \pgf@y=0pt
  }
  \anchor{south}{
    \southeast
    \pgf@x=0pt
  }
  \anchor{south west}{
    \southeast
    \pgf@circ@res@temp=\pgf@y
    \left
    \pgf@y=\pgf@circ@res@temp
  }
  \anchor{text}{
  	\northeast
  	\pgfpoint{.333em}{0.6\pgf@y}
  }
  
  \anchor{C}{\northeast}
  \anchor{collector}{\northeast}

  \anchor{B}{\left}
  \anchor{base}{\left}

  \anchor{E}{
    \southeast
  	\pgf@x=0pt
  }
  \anchor{emitter}{
    \southeast
  	\pgf@x=0pt
  }
  \anchor{E1}{
    \southeast
  	\pgf@x=0pt
  }
  
  \anchor{E2}{\southeast}
}{%
    \southeast
    \pgf@circ@res@right=\pgf@x
    \pgf@circ@res@down=\pgf@y
    \pgf@circ@res@step=\pgf@circ@res@right
    
    \pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0pt}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}}
    \pgfusepath{draw}

 	  \pgfscope
     \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/base height}\pgf@circ@res@up
     \pgfpathmoveto{\pgfpoint
 	  	{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
 	  	{\pgf@circ@res@temp}}
     \advance\pgf@circ@res@temp by \pgf@circ@res@step
 	  \pgfpathlineto{\pgfpoint
       {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
       {-\pgf@circ@res@temp}}
 	  \pgfsetlinewidth{2\pgflinewidth}
 	  \pgfusepath{draw}
 	  \endpgfscope
  	  
 	  \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/slope}\pgf@circ@res@step
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}  	
    \pgfusepath{draw}
   	  
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
    \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
      {-\pgf@circ@res@temp}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
  	\pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@temp}}%
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}%
  	\pgfusepath{draw}
  
    \pgfscope
  	  \pgfslopedattimetrue
  	  \pgfallowupsidedownattimetrue
  	  \pgfresetnontranslationattimefalse
  	  \pgftransformlineattime{.5}{%
  	  	\pgfpoint%
  	  	  {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}%
  	  	  {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up}%
  	  }{\pgfpoint{0pt}{-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up}}%
  	  \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
    \endpgfscope
      
    \pgfscope
  	  \pgfslopedattimetrue
  	  \pgfallowupsidedownattimetrue
  	  \pgfresetnontranslationattimefalse
      
      \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height 2}\pgf@circ@res@up
      \advance\pgf@circ@res@temp by \pgf@circ@res@step
      \pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate height}\pgf@circ@res@up
      \advance\pgf@circ@res@other by \pgf@circ@res@step
      
      \pgftransformlineattime{.5}{%
        \pgfpoint%
  	  	  {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}%
  	  	  {-\pgf@circ@res@temp}%
  	  }{\pgfpoint{0pt}{-\pgf@circ@res@other}}%
  	  \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
  	\endpgfscope
  	
  	\pgfpathmoveto{\pgfpoint
  		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn2/gate width}\pgf@circ@res@left}
  		{0pt}}
  	\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
  	\pgfusepath{draw}
}
% create Tnpn2 to-path style
\pgf@circ@definetranspath{npn2}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% three emitter npn %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ctikzset{tripoles/npn3/height/.initial=1.1}% before expansion
\ctikzset{tripoles/npn3/width/.initial=.6}% before expansion
\ctikzset{tripoles/npn3/gate height/.initial=.45}
\ctikzset{tripoles/npn3/gate height 2/.initial=.15}
\ctikzset{tripoles/npn3/base height/.initial=.4}
\ctikzset{tripoles/npn3/step/.initial=.15}% both vertical and horizontal separation
\ctikzset{tripoles/npn3/slope/.initial=.6}% (height - height 2) / (gate width)
\ctikzset{tripoles/npn3/gate width/.initial=.5}
\ctikzset{tripoles/npn3/curr direction/.initial=1}

\pgfcircdeclaretransistor{npn3}{
  \savedanchor{\southeast}{% \northeast is actually north (x=0pt)
    \pgf@x=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/step}\pgf@circ@Rlen
    \pgf@x=2\pgf@x
  	\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/height}\pgf@circ@Rlen
  	\pgf@y=-.5\pgf@y
  	\advance\pgf@y by -\pgf@x
  }
% redefine anchors for larger size
  \anchor{north east}{
    \southeast
    \pgf@circ@res@temp=\pgf@x
    \northeast
    \pgf@x=\pgf@circ@res@temp
  }
  \anchor{south east}{\southeast}
  \anchor{east}{
    \southeast
    \pgf@y=0pt
  }
  \anchor{south}{
    \southeast
    \pgf@x=0pt
  }
  \anchor{south west}{
    \southeast
    \pgf@circ@res@temp=\pgf@y
    \left
    \pgf@y=\pgf@circ@res@temp
  }
  \anchor{text}{
  	\northeast
  	\pgfpoint{.333em}{0.6\pgf@y}
  }
  
  \anchor{C}{\northeast}
  \anchor{collector}{\northeast}

  \anchor{B}{\left}
  \anchor{base}{\left}

  \anchor{E}{
    \southeast
  	\pgf@x=0pt
  }
  \anchor{emitter}{
    \southeast
  	\pgf@x=0pt
  }
  \anchor{E1}{
    \southeast
  	\pgf@x=0pt
  }
  
  \anchor{E2}{
    \southeast
  	\pgf@x=0.5\pgf@x
  }
  
  \anchor{E3}{\southeast}
}{%
    \southeast
    \pgf@circ@res@right=\pgf@x
    \pgf@circ@res@down=\pgf@y
    \pgf@circ@res@step=0.5\pgf@circ@res@right
    
    \pgfpathmoveto{\pgfpoint{0pt}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0pt}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up}}
    \pgfusepath{draw}

 	  \pgfscope
     \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/base height}\pgf@circ@res@up
     \pgfpathmoveto{\pgfpoint
 	  	{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
 	  	{\pgf@circ@res@temp}}
     \advance\pgf@circ@res@temp by 2\pgf@circ@res@step
 	  \pgfpathlineto{\pgfpoint
       {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
       {-\pgf@circ@res@temp}}
 	  \pgfsetlinewidth{2\pgflinewidth}
 	  \pgfusepath{draw}
 	  \endpgfscope
  	  
 	  \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
      {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/slope}\pgf@circ@res@right
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@temp}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}  	
    \pgfusepath{draw}
   	  
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
    \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
      {-\pgf@circ@res@temp}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by \pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/slope}\pgf@circ@res@step
    \advance\pgf@circ@res@temp by \pgf@circ@res@step
  	\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{-\pgf@circ@res@temp}}%
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{\pgf@circ@res@down}}%
  	\pgfusepath{draw}
    
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by 2\pgf@circ@res@step
    \pgfpathmoveto{\pgfpoint
      {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
      {-\pgf@circ@res@temp}}
    \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up
    \advance\pgf@circ@res@temp by 2\pgf@circ@res@step
  	\pgfpathlineto{\pgfpoint{0pt}{-\pgf@circ@res@temp}}%
    \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}%
  	\pgfusepath{draw}
  
    \pgfscope
  	  \pgfslopedattimetrue
  	  \pgfallowupsidedownattimetrue
  	  \pgfresetnontranslationattimefalse
  	  \pgftransformlineattime{.5}{%
  	  	\pgfpoint%
  	  	  {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}%
  	  	  {-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up}%
  	  }{\pgfpoint{0pt}{-\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up}}%
  	  \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
    \endpgfscope
      
    \pgfscope
  	  \pgfslopedattimetrue
  	  \pgfallowupsidedownattimetrue
  	  \pgfresetnontranslationattimefalse
      
      \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up
      \advance\pgf@circ@res@temp by 2\pgf@circ@res@step
      \pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up
      \advance\pgf@circ@res@other by 2\pgf@circ@res@step
      
      \pgftransformlineattime{.5}{%
        \pgfpoint%
  	  	  {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}%
  	  	  {-\pgf@circ@res@temp}%
  	  }{\pgfpoint{0pt}{-\pgf@circ@res@other}}%
  	  \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
  	\endpgfscope
    
    \pgfscope
  	  \pgfslopedattimetrue
  	  \pgfallowupsidedownattimetrue
  	  \pgfresetnontranslationattimefalse
      
      \pgf@circ@res@temp=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height 2}\pgf@circ@res@up
      \advance\pgf@circ@res@temp by \pgf@circ@res@step
      \pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate height}\pgf@circ@res@up
      \advance\pgf@circ@res@other by \pgf@circ@res@step
      
      \pgftransformlineattime{.5}{%
        \pgfpoint%
  	  	  {\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}%
  	  	  {-\pgf@circ@res@temp}%
  	  }{\pgfpoint{0pt}{-\pgf@circ@res@other}}%
  	  \pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
  	\endpgfscope
  	
  	\pgfpathmoveto{\pgfpoint
  		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn3/gate width}\pgf@circ@res@left}
  		{0pt}}
  	\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
  	\pgfusepath{draw}
}
% create Tnpn2 to-path style
\pgf@circ@definetranspath{npn3}

% ************************* mechanical dashpot **************************
\ctikzset{bipoles/dashpot/height/.initial=.6}
\ctikzset{bipoles/dashpot/width/.initial=.8}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/dashpot/height}}
	{dashpot}
	{\ctikzvalof{bipoles/dashpot/height}}
	{\ctikzvalof{bipoles/dashpot/width}}
{
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
  \pgfextracty{\pgf@circ@res@down}{\southwest}

  \pgfmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
  \pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
  \pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
  \pgflineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
  \pgfmoveto{\pgfpoint{0}{0.9\pgf@circ@res@up}}
  \pgflineto{\pgfpoint{0}{0.9\pgf@circ@res@down}}
  \pgfusepath{draw}
  \pgfsetlinewidth{\pgfstartlinewidth}
  \pgfmoveto{\pgfpointorigin}
  \pgflineto{\pgfpoint{\pgf@circ@res@right}{0}}
  \pgfusepath{draw}
}
% create dashpot to-path style

\def\dashpotpath#1{\pgf@circ@bipole@path{dashpot}{#1}}
\compattikzset{dashpot/.style = {\circuitikzbasekey, /tikz/to path=\dashpotpath}}

% ************************* voltage source **************************
% American style replacement: plus and minus signs remain vertical
% Does not use /tikz/circuitikz/bipoles/vsourceam/margin

\ctikzset{bipoles/vsourceam/plus/.initial=$+$}
\ctikzset{bipoles/vsourceam/minus/.initial=$-$}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/vsourceam/height}}
	{vsourceAM}
	{\ctikzvalof{bipoles/vsourceam/height}}
	{\ctikzvalof{bipoles/vsourceam/width}}
{
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
	
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
		\pgfusepath{draw}
	\pgfscope
		\pgftransformxshift{.5\pgf@circ@res@left}
		\pgftext[rotate=-\pgf@circ@direction]{\ctikzvalof{bipoles/vsourceam/minus}}
		\pgfusepath{draw}
	\endpgfscope
	\pgfscope
		\pgftransformxshift{.5\pgf@circ@res@right}
		\pgftext[rotate=-\pgf@circ@direction]{\ctikzvalof{bipoles/vsourceam/plus}}
		\pgfusepath{draw}
	\endpgfscope
}
% ************************* analog meter **************************

\ctikzset{bipoles/meter/height/.initial=.80}
\ctikzset{bipoles/meter/width/.initial=.80}
\ctikzset{bipoles/meter/logo/.initial=$\Omega$}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/meter/height}}
	{meter}
	{\ctikzvalof{bipoles/meter/height}}
	{\ctikzvalof{bipoles/meter/width}}
{
	\pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	\pgfextractx{\pgf@circ@res@right}{\northeast}
	\pgfextractx{\pgf@circ@res@left}{\southwest}
	\pgfextracty{\pgf@circ@res@up}{\northeast}
  \pgfextracty{\pgf@circ@res@down}{\southwest}
%
	\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0}{\pgf@circ@res@up}}{\pgfpoint{\pgf@circ@res@left}{0}}
	\pgfusepath{draw}
  \pgfpathcircle{\pgfpointorigin}{2\pgfstartlinewidth}
  \pgfusepath{fill}
  \pgfscope
    \pgfsetlinewidth{\pgfstartlinewidth}
		\pgftransformrotate{-\pgf@circ@direction}
    \pgfmoveto{\pgfpoint{0.7\pgf@circ@res@left}{0}}
    \pgflineto{\pgfpoint{0.9\pgf@circ@res@left}{0}}
    \pgfmoveto{\pgfpoint{0.566\pgf@circ@res@left}{0.411\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.728\pgf@circ@res@left}{0.529\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.216\pgf@circ@res@left}{0.666\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.278\pgf@circ@res@left}{0.856\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.216\pgf@circ@res@right}{0.666\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.278\pgf@circ@res@right}{0.856\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.566\pgf@circ@res@right}{0.411\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{0.728\pgf@circ@res@right}{0.529\pgf@circ@res@up}}
    \pgfmoveto{\pgfpoint{0.7\pgf@circ@res@right}{0}}
    \pgflineto{\pgfpoint{0.9\pgf@circ@res@right}{0}}
    \pgfusepath{draw}
	\endpgfscope
	\pgfscope
		\pgftransformrotate{-\pgf@circ@direction}
    \pgfsetarrowsend{latex}
    \pgfmoveto{\pgfpointorigin}
    %\pgfmoveto{\pgfpoint{.1414\pgf@circ@res@left}{.1414\pgf@circ@res@up}}
    \pgflineto{\pgfpoint{.6363\pgf@circ@res@left}{.6363\pgf@circ@res@up}}
		\pgfusepath{draw}
	\endpgfscope
  \pgfscope
    \pgftransformrotate{-\pgf@circ@direction}
    \pgftransformyshift{0.5\pgf@circ@res@down}
    \pgftext{\ctikzvalof{bipoles/meter/logo}}
  \endpgfscope
}

% create meter to-path style

\def\meterpath#1{\pgf@circ@bipole@path{meter}{#1}}
\compattikzset{meter/.style = {\circuitikzbasekey, /tikz/to path=\meterpath, \circuitikzbasekey/bipole/is voltage=true, v=#1}}

% ***************************** ADC and dADC *********************************
% dADC has extra anchors out,in1,in2,vref

\ctikzset{bipoles/ADC/width/.initial=1}
\ctikzset{bipoles/ADC/height/.initial=.5}
\ctikzset{bipoles/ADC/corner/.initial=-.25}
\ctikzset{bipoles/ADC/part/.initial=\texttt{ADC}}

\def\drawADC{% used by both bipole and node
  \pgf@circ@res@right=\ctikzvalof{bipoles/ADC/width}\pgf@circ@Rlen
  \pgf@circ@res@right=0.5\pgf@circ@res@right
  \pgf@circ@res@left=-\pgf@circ@res@right
  \pgf@circ@res@up=\ctikzvalof{bipoles/ADC/height}\pgf@circ@Rlen
  \pgf@circ@res@up=0.5\pgf@circ@res@up
  \pgf@circ@res@down=-\pgf@circ@res@up
  \pgf@circ@res@temp=\ctikzvalof{bipoles/ADC/corner}\pgf@circ@Rlen
  \pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@down}}
  \pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
  \pgfpathclose
  \pgfusepath{draw}
}

\pgfcircdeclarebipole{% overide
  \anchor{nw}{%
    \pgf@circ@res@up=\ctikzvalof{bipoles/ADC/height}\pgf@circ@Rlen
    \pgf@circ@res@up=0.5\pgf@circ@res@up
    \pgf@circ@res@temp=\ctikzvalof{bipoles/ADC/corner}\pgf@circ@Rlen
    \pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@up}}
  \anchor{sw}{%
    \pgf@circ@res@down=\ctikzvalof{bipoles/ADC/height}\pgf@circ@Rlen
    \pgf@circ@res@down=-0.5\pgf@circ@res@down
    \pgf@circ@res@temp=\ctikzvalof{bipoles/ADC/corner}\pgf@circ@Rlen
    \pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@down}}
  }
  {\ctikzvalof{bipoles/ADC/height}}
  {ADC}
  {\ctikzvalof{bipoles/ADC/height}}
  {\ctikzvalof{bipoles/ADC/width}}
  {
    \pgfsetlinewidth{\ctikzvalof{bipoles/thickness}\pgfstartlinewidth}
    \drawADC
    \pgftext{\ctikzvalof{bipoles/ADC/part}}
  }

\def\ADCpath#1{\pgf@circ@bipole@path{ADC}{#1}}
\compattikzset{ADC/.style = {\circuitikzbasekey, /tikz/to path=\ADCpath, l_=#1}}

\pgfdeclareshape{dADC}{%
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% expanded automatically
  \pgf@circ@res@right=\ctikzvalof{bipoles/ADC/width}\pgf@circ@Rlen
  \pgf@circ@res@right=0.5\pgf@circ@res@right
  \pgf@circ@res@left=-\pgf@circ@res@right
  \pgf@circ@res@up=\ctikzvalof{bipoles/ADC/height}\pgf@circ@Rlen
  \pgf@circ@res@up=0.5\pgf@circ@res@up
  \pgf@circ@res@down=-\pgf@circ@res@up
  \pgf@circ@res@temp=\ctikzvalof{bipoles/ADC/corner}\pgf@circ@Rlen
  \pgf@circ@res@other=\pgf@circ@res@temp% location of in1 and in2
  \advance\pgf@circ@res@other by \pgf@circ@res@left
  \pgf@circ@res@other=0.5\pgf@circ@res@other
  \ifdim\wd\pgfnodeparttextbox=0pt\relax\pgftextemptytrue
  \else\pgftextemptyfalse\fi
}% while these can be used for savedanchors, they will be fogotten by anchors

\savedanchor{\northeast}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\savedanchor{\southwest}{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}
\savedanchor{\northcorner}{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@up}}
\savedanchor{\southcorner}{\pgfpoint{\pgf@circ@res@temp}{\pgf@circ@res@down}}

\savedanchor\InOne{\pgfpoint{\pgf@circ@res@other}{0.5\pgf@circ@res@up}}
\savedanchor\InTwo{\pgfpoint{\pgf@circ@res@other}{0.5\pgf@circ@res@down}}
\savedanchor\Out{\pgfpoint{\pgf@circ@res@right}{0pt}}
\savedanchor\Vref{\pgfpoint{0pt}{\pgf@circ@res@down}}

\Compass% standard anchors

\anchor{north west}{\northcorner}% overides previous definition
\anchor{south west}{\southcorner}

\anchor{in1}{\InOne}
\anchor{in2}{\InTwo}
\anchor{out}{\Out}
\anchor{vref}{\Vref}

\foregroundpath{
  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth}
  \drawADC
  \ifpgftextempty\pgftext{\ctikzvalof{bipoles/ADC/part}}\fi
}}

% ************************ h-gate ***************************

\ctikzset{bipoles/hgate/width/.initial=.65}
\ctikzset{bipoles/hgate/height/.initial=.65}
\ctikzset{bipoles/hgate/symbol/.initial=\textit{\Large H}}

\pgfcircdeclarebipole{}
  {\ctikzvalof{bipoles/hgate/height}}
  {hgate}
  {\ctikzvalof{bipoles/hgate/height}}
  {\ctikzvalof{bipoles/hgate/width}}
  {
	  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	  \pgfpathrectanglecorners{\southwest}{\northeast}
	  \pgfusepath{draw}
    \pgftext[rotate=-\pgf@circ@direction]{\ctikzvalof{bipoles/hgate/symbol}}
  }

\def\hgatepath#1{\pgf@circ@bipole@path{hgate}{#1}}
\compattikzset{hgate/.style = {\circuitikzbasekey, /tikz/to path=\hgatepath, l_=#1}}

% u-gate

\ctikzset{bipoles/ugate/width/.initial=.65}
\ctikzset{bipoles/ugate/height/.initial=.65}
\ctikzset{bipoles/ugate/symbol/.initial=\textit{\Large U}}

\pgfcircdeclarebipole
  {
  \anchor{control}{
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfpoint{0cm}{\pgf@circ@res@up}
  }}
  {\ctikzvalof{bipoles/ugate/height}}
  {ugate}
  {\ctikzvalof{bipoles/ugate/height}}
  {\ctikzvalof{bipoles/ugate/width}}
  {
	  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
	  \pgfpathrectanglecorners{\southwest}{\northeast}
	  \pgfusepath{draw}
    \pgftext[rotate=-\pgf@circ@direction]{\ctikzvalof{bipoles/ugate/symbol}}
  }

\def\ugatepath#1{\pgf@circ@bipole@path{ugate}{#1}}
\compattikzset{ugate/.style = {\circuitikzbasekey, /tikz/to path=\ugatepath, l_=#1}}

% ****************************** cnot gate ************************************

\ctikzset{bipoles/cnot/width/.initial=.4}
\ctikzset{bipoles/cnot/height/.initial=.4}

\pgfcircdeclarebipole
  {
    \anchor{control}{
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfpoint{0cm}{\pgf@circ@res@up}
  }}
  {\ctikzvalof{bipoles/cnot/height}}
  {cnot}
  {\ctikzvalof{bipoles/cnot/height}}
  {\ctikzvalof{bipoles/cnot/width}}
  {
	  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgfextracty{\pgf@circ@res@up}{\northeast}
	  \pgfpathellipse{\pgfpointorigin}{\pgfpoint{\pgf@circ@res@right}{0cm}}{\pgfpoint{0cm}{\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{0cm}{\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{0cm}{-\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0cm}}
    \pgfpathlineto{\pgfpoint{-\pgf@circ@res@right}{0cm}}
	  \pgfusepath{draw}
  }

\def\cnotpath#1{\pgf@circ@bipole@path{cnot}{#1}}
\compattikzset{cnot/.style = {\circuitikzbasekey, /tikz/to path=\cnotpath, l_=#1}}

% ******************************* swap gate (half) ************************************
% User must connect centers of bipole to complete swap gate

\ctikzset{bipoles/swap/width/.initial=.4}
\ctikzset{bipoles/swap/height/.initial=.4}

\pgfcircdeclarebipole
  {\anchor{control}{\pgfpointorigin}}% equivalent to center
  {\ctikzvalof{bipoles/swap/height}}
  {swap}
  {\ctikzvalof{bipoles/swap/height}}
  {\ctikzvalof{bipoles/swap/width}}
  {
	  \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgfstartlinewidth}
    \pgfextractx{\pgf@circ@res@right}{\northeast}
    \pgfextracty{\pgf@circ@res@up}{\northeast}
    \pgfpathmoveto{\pgfpoint{.707\pgf@circ@res@right}{.707\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{-.707\pgf@circ@res@right}{-.707\pgf@circ@res@up}}
    \pgfpathmoveto{\pgfpoint{.707\pgf@circ@res@right}{-.707\pgf@circ@res@up}}
    \pgfpathlineto{\pgfpoint{-.707\pgf@circ@res@right}{.707\pgf@circ@res@up}}
    \pgfusepath{draw}
    \pgfsetlinewidth{\pgfstartlinewidth}
    \pgfpathmoveto{\pgfpoint{-\pgf@circ@res@right}{0cm}}
    \pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0cm}}
    \pgfusepath{draw}
  }

\def\swappath#1{\pgf@circ@bipole@path{swap}{#1}}
\compattikzset{swap/.style = {\circuitikzbasekey, /tikz/to path=\swappath, l_=#1}}


% ************************** multipoles *****************************

\ctikzset{multipoles/.is family}
\ctikzset{multipoles/pin spacing/.initial = 5mm} % default value
\ctikzset{multipoles/gate spacing/.initial = 1cm} % default value

\pgfkeys{/tikz/pin spacing/.initial = 0mm}
\pgfkeys{/tikz/pin spacing/.default = 0mm}

\newlength{\IClen}	% scale factor
\newcommand{\pinsize}{\ifdim\IClen<3.5mm \tiny \else \scriptsize \fi}

\pgfkeys{/tikz/gate spacing/.initial = 0cm}
\pgfkeys{/tikz/gate spacing/.default = 0cm}

\newlength{\GateSpacing}

% ***************************** u2gate *********************************
% anchors in1, in2, out1 and out2

\pgfdeclareshape{u2gate}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\GateSpacing}{\pgfkeysvalueof{/tikz/gate spacing}}	% from node[]
 \ifdim\GateSpacing=0mm \setlength{\GateSpacing}%  
  {\ctikzvalof{multipoles/gate spacing}} \fi	% from \ctikzset{}
 \setlength{\pgf@circ@res@up}{\ctikzvalof{bipoles/ugate/height}\pgf@circ@Rlen}
 \addtolength{\pgf@circ@res@up}{\GateSpacing}
 \setlength{\pgf@circ@res@up}{0.5\pgf@circ@res@up}
 \setlength{\pgf@circ@res@down}{-\pgf@circ@res@up}
 \setlength{\pgf@circ@res@right}{\ctikzvalof{bipoles/ugate/width}\pgf@circ@Rlen}
 \setlength{\pgf@circ@res@right}{0.5\pgf@circ@res@right}
 \setlength{\pgf@circ@res@left}{-\pgf@circ@res@right}
}% while these can be used for savedanchors, they will be fogotten by anchors

\savedanchor{\northeast}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\savedanchor{\southwest}{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}

\savedanchor\InOne{\pgfpoint{\pgf@circ@res@left}{0.5\GateSpacing}}
\savedanchor\OutOne{\pgfpoint{\pgf@circ@res@right}{0.5\GateSpacing}}
\savedanchor\InTwo{\pgfpoint{\pgf@circ@res@left}{-0.5\GateSpacing}}
\savedanchor\OutTwo{\pgfpoint{\pgf@circ@res@right}{-0.5\GateSpacing}}

\Compass% standard anchors

\anchor{control}{\pgfextracty{\pgf@circ@res@up}{\northeast}\pgfpoint{0cm}{\pgf@circ@res@up}}
\anchor{in1}{\InOne}
\anchor{out1}{\OutOne}
\anchor{in2}{\InTwo}
\anchor{out2}{\OutTwo}

\foregroundpath{% draw border and symbol
 \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth}
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}
 \pgftext{\ctikzvalof{bipoles/ugate/symbol}}
}}

% ***************************** u3gate *********************************
% anchors in1 - in3, and  out1 - out3

\pgfdeclareshape{u3gate}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\GateSpacing}{\pgfkeysvalueof{/tikz/gate spacing}}	% from node[]
 \ifdim\GateSpacing=0mm \setlength{\GateSpacing}%  
  {\ctikzvalof{multipoles/gate spacing}} \fi	% from \ctikzset{}
 \setlength{\pgf@circ@res@up}{\ctikzvalof{bipoles/ugate/height}\pgf@circ@Rlen}
 \addtolength{\pgf@circ@res@up}{2\GateSpacing}
 \setlength{\pgf@circ@res@up}{0.5\pgf@circ@res@up}
 \setlength{\pgf@circ@res@down}{-\pgf@circ@res@up}
 \setlength{\pgf@circ@res@right}{\ctikzvalof{bipoles/ugate/width}\pgf@circ@Rlen}
 \setlength{\pgf@circ@res@right}{0.5\pgf@circ@res@right}
 \setlength{\pgf@circ@res@left}{-\pgf@circ@res@right}
}% these can be used for savedanchors only

\savedanchor{\northeast}{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\savedanchor{\southwest}{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@down}}

\savedanchor\InOne{\pgfpoint{\pgf@circ@res@left}{\GateSpacing}}
\savedanchor\OutOne{\pgfpoint{\pgf@circ@res@right}{\GateSpacing}}
\savedanchor\InTwo{\pgfpoint{\pgf@circ@res@left}{0cm}}
\savedanchor\OutTwo{\pgfpoint{\pgf@circ@res@right}{0cm}}
\savedanchor\InThree{\pgfpoint{\pgf@circ@res@left}{-\GateSpacing}}
\savedanchor\OutThree{\pgfpoint{\pgf@circ@res@right}{-\GateSpacing}}

\Compass% standard anchors

\anchor{control}{\pgfextracty{\pgf@circ@res@up}{\northeast}\pgfpoint{0cm}{\pgf@circ@res@up}}
\anchor{in1}{\InOne}
\anchor{out1}{\OutOne}
\anchor{in2}{\InTwo}
\anchor{out2}{\OutTwo}
\anchor{in3}{\InThree}
\anchor{out3}{\OutThree}

\foregroundpath{% draw border and symbol
 \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/bipoles/thickness}\pgflinewidth}
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}
 \pgftext{\ctikzvalof{bipoles/ugate/symbol}}
}}

% ***************************** dip 8 *********************************
% anchors pin1 - pin8

\pgfdeclareshape{dip8}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\IClen}{\pgfkeysvalueof{/tikz/pin spacing}}	% from node[]
 \ifdim\IClen=0mm \setlength{\IClen}
  {\pgfkeysvalueof{/tikz/circuitikz/multipoles/pin spacing}} \fi	% from \ctikzset{}
}
\savedanchor\icpina{\pgfpoint{-1.5\IClen}{-1.25\IClen}}	% pin 1
\anchor{p1}{\icpina}
\savedanchor\icpinb{\pgfpoint{-.5\IClen}{-1.25\IClen}}	% pin 2
\anchor{p2}{\icpinb}
\savedanchor\icpinc{\pgfpoint{.5\IClen}{-1.25\IClen}}	% pin 3
\anchor{p3}{\icpinc}
\savedanchor\icpind{\pgfpoint{1.5\IClen}{-1.25\IClen}}	% pin 4
\anchor{p4}{\icpind}
\savedanchor\icpine{\pgfpoint{1.5\IClen}{1.25\IClen}}	% pin 5
\anchor{p5}{\icpine}
\savedanchor\icpinf{\pgfpoint{.5\IClen}{1.25\IClen}}	% pin 6
\anchor{p6}{\icpinf}
\savedanchor\icping{\pgfpoint{-.5\IClen}{1.25\IClen}}	% pin 7
\anchor{p7}{\icping}
\savedanchor\icpinh{\pgfpoint{-1.5\IClen}{1.25\IClen}}	% pin 8
\anchor{p8}{\icpinh}

\savedanchor{\northeast}{\pgfpoint{2\IClen}{1.25\IClen}}
\savedanchor{\southwest}{\pgfpoint{-2\IClen}{-1.25\IClen}}
\Compass% standard anchors

\foregroundpath{ % border and pin numbers are drawn here
 \pgfsetlinewidth{.1\IClen} % line thickness 
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}	%draw rectangle
 \pgfsetlinewidth{.06\IClen} % line thickness 
 \pgfpathmoveto{\pgfpoint{-2\IClen}{-.6\IClen}}
 \pgfpatharc{-90}{90}{.6\IClen}
 \pgfusepath{draw}	%draw semicircle
 \pgftext[bottom,at={\pgfpoint{-1.5\IClen}{-1.1\IClen}}]{\pinsize 1}
 \pgftext[bottom,at={\pgfpoint{-.5\IClen}{-1.1\IClen}}]{\pinsize 2}
 \pgftext[bottom,at={\pgfpoint{.5\IClen}{-1.1\IClen}}]{\pinsize 3}
 \pgftext[bottom,at={\pgfpoint{1.5\IClen}{-1.1\IClen}}]{\pinsize 4}
 \pgftext[top,at={\pgfpoint{1.5\IClen}{1.1\IClen}}]{\pinsize 5}
 \pgftext[top,at={\pgfpoint{.5\IClen}{1.1\IClen}}]{\pinsize 6}
 \pgftext[top,at={\pgfpoint{-.5\IClen}{1.1\IClen}}]{\pinsize 7}
 \pgftext[top,at={\pgfpoint{-1.5\IClen}{1.1\IClen}}]{\pinsize 8}
}}

% ***************************** dip 14 *********************************

\pgfdeclareshape{dip14}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\IClen}{\pgfkeysvalueof{/tikz/pin spacing}}	% from node[]
 \ifdim\IClen=0mm \setlength{\IClen}
  {\pgfkeysvalueof{/tikz/circuitikz/multipoles/pin spacing}} \fi	% from \ctikzset{}
}
\savedanchor\icpina{\pgfpoint{-3\IClen}{-1.25\IClen}}	% pin 1
\anchor{p1}{\icpina}
\savedanchor\icpinb{\pgfpoint{-2\IClen}{-1.25\IClen}}	% pin 2
\anchor{p2}{\icpinb}
\savedanchor\icpinc{\pgfpoint{-\IClen}{-1.25\IClen}}	% pin 3
\anchor{p3}{\icpinc}
\savedanchor\icpind{\pgfpoint{0cm}{-1.25\IClen}}	% pin 4
\anchor{p4}{\icpind}
\savedanchor\icpine{\pgfpoint{\IClen}{-1.25\IClen}}	% pin 5
\anchor{p5}{\icpine}
\savedanchor\icpinf{\pgfpoint{2\IClen}{-1.25\IClen}}	% pin 6
\anchor{p6}{\icpinf}
\savedanchor\icping{\pgfpoint{3\IClen}{-1.25\IClen}}	% pin 7
\anchor{p7}{\icping}
\savedanchor\icpinh{\pgfpoint{3\IClen}{1.25\IClen}}	% pin 8
\anchor{p8}{\icpinh}
\savedanchor\icpini{\pgfpoint{2\IClen}{1.25\IClen}}	% pin 9
\anchor{p9}{\icpini}
\savedanchor\icpinj{\pgfpoint{\IClen}{1.25\IClen}}	% pin 10
\anchor{p10}{\icpinj}
\savedanchor\icpink{\pgfpoint{0cm}{1.25\IClen}}	% pin 11
\anchor{p11}{\icpink}
\savedanchor\icpinl{\pgfpoint{-\IClen}{1.25\IClen}}	% pin 12
\anchor{p12}{\icpinl}
\savedanchor\icpinm{\pgfpoint{-2\IClen}{1.25\IClen}}	% pin 13
\anchor{p13}{\icpinm}
\savedanchor\icpinn{\pgfpoint{-3\IClen}{1.25\IClen}}	% pin 14
\anchor{p14}{\icpinn}

\savedanchor{\northeast}{\pgfpoint{3.5\IClen}{1.25\IClen}}
\savedanchor{\southwest}{\pgfpoint{-3.5\IClen}{-1.25\IClen}}
\Compass% standard anchors

\foregroundpath{ % border and pin numbers are drawn here
 \pgfsetlinewidth{.1\IClen} % line thickness 
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}	%draw rectangle
 \pgfsetlinewidth{.06\IClen} % line thickness 
 \pgfpathmoveto{\pgfpoint{-3.5\IClen}{-.6\IClen}}
 \pgfpatharc{-90}{90}{.6\IClen}
 \pgfusepath{draw}	%draw semicircle
 \pgftext[bottom,at={\pgfpoint{-3\IClen}{-1.1\IClen}}]{\pinsize 1}
 \pgftext[bottom,at={\pgfpoint{-2\IClen}{-1.1\IClen}}]{\pinsize 2}
 \pgftext[bottom,at={\pgfpoint{-\IClen}{-1.1\IClen}}]{\pinsize 3}
 \pgftext[bottom,at={\pgfpoint{0cm}{-1.1\IClen}}]{\pinsize 4}
 \pgftext[bottom,at={\pgfpoint{\IClen}{-1.1\IClen}}]{\pinsize 5}
 \pgftext[bottom,at={\pgfpoint{2\IClen}{-1.1\IClen}}]{\pinsize 6}
 \pgftext[bottom,at={\pgfpoint{3\IClen}{-1.1\IClen}}]{\pinsize 7}
 \pgftext[top,at={\pgfpoint{3\IClen}{1.1\IClen}}]{\pinsize 8}
 \pgftext[top,at={\pgfpoint{2\IClen}{1.1\IClen}}]{\pinsize 9}
 \pgftext[top,at={\pgfpoint{\IClen}{1.1\IClen}}]{\pinsize 10}
 \pgftext[top,at={\pgfpoint{0cm}{1.1\IClen}}]{\pinsize 11}
 \pgftext[top,at={\pgfpoint{-\IClen}{1.1\IClen}}]{\pinsize 12}
 \pgftext[top,at={\pgfpoint{-2\IClen}{1.1\IClen}}]{\pinsize 13}
 \pgftext[top,at={\pgfpoint{-3\IClen}{1.1\IClen}}]{\pinsize 14}
}}

% ***************************** dip 16 *********************************

\pgfdeclareshape{dip16}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\IClen}{\pgfkeysvalueof{/tikz/pin spacing}}	% from node[]
 \ifdim\IClen=0mm \setlength{\IClen}
  {\pgfkeysvalueof{/tikz/circuitikz/multipoles/pin spacing}} \fi	% from \ctikzset{}
}
\savedanchor\icpina{\pgfpoint{-3.5\IClen}{-1.25\IClen}}	% pin 1
\anchor{p1}{\icpina}
\savedanchor\icpinb{\pgfpoint{-2.5\IClen}{-1.25\IClen}}	% pin 2
\anchor{p2}{\icpinb}
\savedanchor\icpinc{\pgfpoint{-1.5\IClen}{-1.25\IClen}}	% pin 3
\anchor{p3}{\icpinc}
\savedanchor\icpind{\pgfpoint{-.5\IClen}{-1.25\IClen}}	% pin 4
\anchor{p4}{\icpind}
\savedanchor\icpine{\pgfpoint{.5\IClen}{-1.25\IClen}}	% pin 5
\anchor{p5}{\icpine}
\savedanchor\icpinf{\pgfpoint{1.5\IClen}{-1.25\IClen}}	% pin 6
\anchor{p6}{\icpinf}
\savedanchor\icping{\pgfpoint{2.5\IClen}{-1.25\IClen}}	% pin 7
\anchor{p7}{\icping}
\savedanchor\icpinh{\pgfpoint{3.5\IClen}{-1.25\IClen}}	% pin 8
\anchor{p8}{\icpinh}
\savedanchor\icpini{\pgfpoint{3.5\IClen}{1.25\IClen}}	% pin 9
\anchor{p9}{\icpini}
\savedanchor\icpinj{\pgfpoint{2.5\IClen}{1.25\IClen}}	% pin 10
\anchor{p10}{\icpinj}
\savedanchor\icpink{\pgfpoint{1.5\IClen}{1.25\IClen}}	% pin 11
\anchor{p11}{\icpink}
\savedanchor\icpinl{\pgfpoint{.5\IClen}{1.25\IClen}}	% pin 12
\anchor{p12}{\icpinl}
\savedanchor\icpinm{\pgfpoint{-.5\IClen}{1.25\IClen}}	% pin 13
\anchor{p13}{\icpinm}
\savedanchor\icpinn{\pgfpoint{-1.5\IClen}{1.25\IClen}}	% pin 14
\anchor{p14}{\icpinn}
\savedanchor\icpino{\pgfpoint{-2.5\IClen}{1.25\IClen}}	% pin 15
\anchor{p15}{\icpino}
\savedanchor\icpinp{\pgfpoint{-3.5\IClen}{1.25\IClen}}	% pin 16
\anchor{p16}{\icpinp}

\savedanchor{\northeast}{\pgfpoint{4\IClen}{1.25\IClen}}
\savedanchor{\southwest}{\pgfpoint{-4\IClen}{-1.25\IClen}}
\Compass% standard anchors

\foregroundpath{ % border and pin numbers are drawn here
 \pgfsetlinewidth{.1\IClen} % line thickness 
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}	%draw rectangle
 \pgfsetlinewidth{.06\IClen} % line thickness 
 \pgfpathmoveto{\pgfpoint{-4\IClen}{-.6\IClen}}
 \pgfpatharc{-90}{90}{.6\IClen}
 \pgfusepath{draw}	%draw semicircle
 \pgftext[bottom,at={\pgfpoint{-3.5\IClen}{-1.1\IClen}}]{\pinsize 1}
 \pgftext[bottom,at={\pgfpoint{-2.5\IClen}{-1.1\IClen}}]{\pinsize 2}
 \pgftext[bottom,at={\pgfpoint{-1.5\IClen}{-1.1\IClen}}]{\pinsize 3}
 \pgftext[bottom,at={\pgfpoint{-.5\IClen}{-1.1\IClen}}]{\pinsize 4}
 \pgftext[bottom,at={\pgfpoint{.5\IClen}{-1.1\IClen}}]{\pinsize 5}
 \pgftext[bottom,at={\pgfpoint{1.5\IClen}{-1.1\IClen}}]{\pinsize 6}
 \pgftext[bottom,at={\pgfpoint{2.5\IClen}{-1.1\IClen}}]{\pinsize 7}
 \pgftext[bottom,at={\pgfpoint{3.5\IClen}{-1.1\IClen}}]{\pinsize 8}
 \pgftext[top,at={\pgfpoint{3.5\IClen}{1.1\IClen}}]{\pinsize 9}
 \pgftext[top,at={\pgfpoint{2.5\IClen}{1.1\IClen}}]{\pinsize 10}
 \pgftext[top,at={\pgfpoint{1.5\IClen}{1.1\IClen}}]{\pinsize 11}
 \pgftext[top,at={\pgfpoint{.5\IClen}{1.1\IClen}}]{\pinsize 12}
 \pgftext[top,at={\pgfpoint{-.5\IClen}{1.1\IClen}}]{\pinsize 13}
 \pgftext[top,at={\pgfpoint{-1.5\IClen}{1.1\IClen}}]{\pinsize 14}
 \pgftext[top,at={\pgfpoint{-2.5\IClen}{1.1\IClen}}]{\pinsize 15}
 \pgftext[top,at={\pgfpoint{-3.5\IClen}{1.1\IClen}}]{\pinsize 16}
}}

% ***************************** dip 28 *********************************
\pgfdeclareshape{dip28}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\IClen}{\pgfkeysvalueof{/tikz/pin spacing}}	% from node[]
 \ifdim\IClen=0mm \setlength{\IClen}
  {\pgfkeysvalueof{/tikz/circuitikz/multipoles/pin spacing}} \fi	% from \ctikzset{}
}
\savedanchor\icpina{\pgfpoint{-6.5\IClen}{-2.5\IClen}}	% pin 1
\anchor{p1}{\icpina}
\savedanchor\icpinb{\pgfpoint{-5.5\IClen}{-2.5\IClen}}	% pin 2
\anchor{p2}{\icpinb}
\savedanchor\icpinc{\pgfpoint{-4.5\IClen}{-2.5\IClen}}	% pin 3
\anchor{p3}{\icpinc}
\savedanchor\icpind{\pgfpoint{-3.5\IClen}{-2.5\IClen}}	% pin 4
\anchor{p4}{\icpind}
\savedanchor\icpine{\pgfpoint{-2.5\IClen}{-2.5\IClen}}	% pin 5
\anchor{p5}{\icpine}
\savedanchor\icpinf{\pgfpoint{-1.5\IClen}{-2.5\IClen}}	% pin 6
\anchor{p6}{\icpinf}
\savedanchor\icping{\pgfpoint{-.5\IClen}{-2.5\IClen}}	% pin 7
\anchor{p7}{\icping}
\savedanchor\icpinh{\pgfpoint{.5\IClen}{-2.5\IClen}}	% pin 8
\anchor{p8}{\icpinh}
\savedanchor\icpini{\pgfpoint{1.5\IClen}{-2.5\IClen}}	% pin 9
\anchor{p9}{\icpini}
\savedanchor\icpinj{\pgfpoint{2.5\IClen}{-2.5\IClen}}	% pin 10
\anchor{p10}{\icpinj}
\savedanchor\icpink{\pgfpoint{3.5\IClen}{-2.5\IClen}}	% pin 11
\anchor{p11}{\icpink}
\savedanchor\icpinl{\pgfpoint{4.5\IClen}{-2.5\IClen}}	% pin 12
\anchor{p12}{\icpinl}
\savedanchor\icpinm{\pgfpoint{5.5\IClen}{-2.5\IClen}}	% pin 13
\anchor{p13}{\icpinm}
\savedanchor\icpinn{\pgfpoint{6.5\IClen}{-2.5\IClen}}	% pin 14
\anchor{p14}{\icpinn}
\savedanchor\icpino{\pgfpoint{6.5\IClen}{2.5\IClen}}	% pin 15
\anchor{p15}{\icpino}
\savedanchor\icpinp{\pgfpoint{5.5\IClen}{2.5\IClen}}	% pin 16
\anchor{p16}{\icpinp}
\savedanchor\icpinq{\pgfpoint{4.5\IClen}{2.5\IClen}}	% pin 17
\anchor{p17}{\icpinq}
\savedanchor\icpinr{\pgfpoint{3.5\IClen}{2.5\IClen}}	% pin 18
\anchor{p18}{\icpinr}
\savedanchor\icpins{\pgfpoint{2.5\IClen}{2.5\IClen}}	% pin 19
\anchor{p19}{\icpins}
\savedanchor\icpint{\pgfpoint{1.5\IClen}{2.5\IClen}}	% pin 20
\anchor{p20}{\icpint}
\savedanchor\icpinu{\pgfpoint{.5\IClen}{2.5\IClen}}	% pin 21
\anchor{p21}{\icpinu}
\savedanchor\icpinv{\pgfpoint{-.5\IClen}{2.5\IClen}}	% pin 22
\anchor{p22}{\icpinv}
\savedanchor\icpinw{\pgfpoint{-1.5\IClen}{2.5\IClen}}	% pin 23
\anchor{p23}{\icpinw}
\savedanchor\icpinx{\pgfpoint{-2.5\IClen}{2.5\IClen}}	% pin 24
\anchor{p24}{\icpinx}
\savedanchor\icpiny{\pgfpoint{-3.5\IClen}{2.5\IClen}}	% pin 25
\anchor{p25}{\icpiny}
\savedanchor\icpinz{\pgfpoint{-4.5\IClen}{2.5\IClen}}	% pin 26
\anchor{p26}{\icpinz}
\savedanchor\icpinaa{\pgfpoint{-5.5\IClen}{2.5\IClen}}	% pin 27
\anchor{p27}{\icpinaa}
\savedanchor\icpinab{\pgfpoint{-6.5\IClen}{2.5\IClen}}	% pin 28
\anchor{p28}{\icpinab}

\savedanchor{\northeast}{\pgfpoint{7\IClen}{2.5\IClen}}
\savedanchor{\southwest}{\pgfpoint{-7\IClen}{-2.5\IClen}}
\Compass% standard anchors

\foregroundpath{ % border and pin numbers are drawn here
 \pgfsetlinewidth{.1\IClen} % line thickness 
 \pgfpathrectanglecorners{\southwest}{\northeast}
 \pgfusepath{draw}	%draw rectangle
 \pgfsetlinewidth{.06\IClen} % line thickness 
 \pgfpathmoveto{\pgfpoint{-7\IClen}{-.6\IClen}}
 \pgfpatharc{-90}{90}{.6\IClen}
 \pgfusepath{draw}	%draw semicircle
 \pgftext[bottom,at={\pgfpoint{-6.5\IClen}{-2.2\IClen}}]{\pinsize 1}
 \pgftext[bottom,at={\pgfpoint{-5.5\IClen}{-2.2\IClen}}]{\pinsize 2}
 \pgftext[bottom,at={\pgfpoint{-4.5\IClen}{-2.2\IClen}}]{\pinsize 3}
 \pgftext[bottom,at={\pgfpoint{-3.5\IClen}{-2.2\IClen}}]{\pinsize 4}
 \pgftext[bottom,at={\pgfpoint{-2.5\IClen}{-2.2\IClen}}]{\pinsize 5}
 \pgftext[bottom,at={\pgfpoint{-1.5\IClen}{-2.2\IClen}}]{\pinsize 6}
 \pgftext[bottom,at={\pgfpoint{-.5\IClen}{-2.2\IClen}}]{\pinsize 7}
 \pgftext[bottom,at={\pgfpoint{.5\IClen}{-2.2\IClen}}]{\pinsize 8}
 \pgftext[bottom,at={\pgfpoint{1.5\IClen}{-2.2\IClen}}]{\pinsize 9}
 \pgftext[bottom,at={\pgfpoint{2.5\IClen}{-2.2\IClen}}]{\pinsize 10}
 \pgftext[bottom,at={\pgfpoint{3.5\IClen}{-2.2\IClen}}]{\pinsize 11}
 \pgftext[bottom,at={\pgfpoint{4.5\IClen}{-2.2\IClen}}]{\pinsize 12}
 \pgftext[bottom,at={\pgfpoint{5.5\IClen}{-2.2\IClen}}]{\pinsize 13}
 \pgftext[bottom,at={\pgfpoint{6.5\IClen}{-2.2\IClen}}]{\pinsize 14}
 \pgftext[top,at={\pgfpoint{6.5\IClen}{2.2\IClen}}]{\pinsize 15}
 \pgftext[top,at={\pgfpoint{5.5\IClen}{2.2\IClen}}]{\pinsize 16}
 \pgftext[top,at={\pgfpoint{4.5\IClen}{2.2\IClen}}]{\pinsize 17}
 \pgftext[top,at={\pgfpoint{3.5\IClen}{2.2\IClen}}]{\pinsize 18}
 \pgftext[top,at={\pgfpoint{2.5\IClen}{2.2\IClen}}]{\pinsize 19}
 \pgftext[top,at={\pgfpoint{1.5\IClen}{2.2\IClen}}]{\pinsize 20}
 \pgftext[top,at={\pgfpoint{.5\IClen}{2.2\IClen}}]{\pinsize 21}
 \pgftext[top,at={\pgfpoint{-.5\IClen}{2.2\IClen}}]{\pinsize 22}
 \pgftext[top,at={\pgfpoint{-1.5\IClen}{2.2\IClen}}]{\pinsize 23}
 \pgftext[top,at={\pgfpoint{-2.5\IClen}{2.2\IClen}}]{\pinsize 24}
 \pgftext[top,at={\pgfpoint{-3.5\IClen}{2.2\IClen}}]{\pinsize 25}
 \pgftext[top,at={\pgfpoint{-4.5\IClen}{2.2\IClen}}]{\pinsize 26}
 \pgftext[top,at={\pgfpoint{-5.5\IClen}{2.2\IClen}}]{\pinsize 27}
 \pgftext[top,at={\pgfpoint{-6.5\IClen}{2.2\IClen}}]{\pinsize 28}
}}

% ***************************** QFP 64 *********************************
% anchors p1 - p64

\pgfdeclareshape{qfp64}{
\anchor{center}{\pgfpointorigin}	% within the node, (0,0) is the center
 
\anchor{text}	% this is used to center the text in the node
	{\pgfpoint{-.5\wd\pgfnodeparttextbox}{-.5\ht\pgfnodeparttextbox}}

\savedmacro{\resize}{	% called automatically
 \setlength{\IClen}{\pgfkeysvalueof{/tikz/pin spacing}}	% from node[]
 \ifdim\IClen=0mm \setlength{\IClen}
  {\pgfkeysvalueof{/tikz/circuitikz/multipoles/pin spacing}} \fi	% from \ctikzset{}
}
\savedanchor\icpinla{\pgfpoint{-9.8\IClen}{7.5\IClen}}	% pin 1
\anchor{p1}{\icpinla}
\savedanchor\icpinlb{\pgfpoint{-9.8\IClen}{6.5\IClen}}	% pin 2
\anchor{p2}{\icpinlb}
\savedanchor\icpinlc{\pgfpoint{-9.8\IClen}{5.5\IClen}}	% pin 3
\anchor{p3}{\icpinlc}
\savedanchor\icpinld{\pgfpoint{-9.8\IClen}{4.5\IClen}}	% pin 4
\anchor{p4}{\icpinld}
\savedanchor\icpinle{\pgfpoint{-9.8\IClen}{3.5\IClen}}	% pin 5
\anchor{p5}{\icpinle}
\savedanchor\icpinlf{\pgfpoint{-9.8\IClen}{2.5\IClen}}	% pin 6
\anchor{p6}{\icpinlf}
\savedanchor\icpinlg{\pgfpoint{-9.8\IClen}{1.5\IClen}}	% pin 7
\anchor{p7}{\icpinlg}
\savedanchor\icpinlh{\pgfpoint{-9.8\IClen}{0.5\IClen}}	% pin 8
\anchor{p8}{\icpinlh}
\savedanchor\icpinli{\pgfpoint{-9.8\IClen}{-0.5\IClen}}  % pin 9
\anchor{p9}{\icpinli}
\savedanchor\icpinlj{\pgfpoint{-9.8\IClen}{-1.5\IClen}}  % pin 10
\anchor{p10}{\icpinlj}
\savedanchor\icpinlk{\pgfpoint{-9.8\IClen}{-2.5\IClen}}  % pin 11
\anchor{p11}{\icpinlk}
\savedanchor\icpinll{\pgfpoint{-9.8\IClen}{-3.5\IClen}}  % pin 12
\anchor{p12}{\icpinll}
\savedanchor\icpinlm{\pgfpoint{-9.8\IClen}{-4.5\IClen}}  % pin 13
\anchor{p13}{\icpinlm}
\savedanchor\icpinln{\pgfpoint{-9.8\IClen}{-5.5\IClen}}  % pin 14
\anchor{p14}{\icpinln}
\savedanchor\icpinlo{\pgfpoint{-9.8\IClen}{-6.5\IClen}}  % pin 15
\anchor{p15}{\icpinlo}
\savedanchor\icpinlp{\pgfpoint{-9.8\IClen}{-7.5\IClen}}  % pin 16
\anchor{p16}{\icpinlp}

\savedanchor\icpinba{\pgfpoint{-7.5\IClen}{-9.8\IClen}}	% pin 17
\anchor{p17}{\icpinba}
\savedanchor\icpinbb{\pgfpoint{-6.5\IClen}{-9.8\IClen}}	% pin 18
\anchor{p18}{\icpinbb}
\savedanchor\icpinbc{\pgfpoint{-5.5\IClen}{-9.8\IClen}}	% pin 19
\anchor{p19}{\icpinbc}
\savedanchor\icpinbd{\pgfpoint{-4.5\IClen}{-9.8\IClen}}	% pin 20
\anchor{p20}{\icpinbd}
\savedanchor\icpinbe{\pgfpoint{-3.5\IClen}{-9.8\IClen}}	% pin 21
\anchor{p21}{\icpinbe}
\savedanchor\icpinbf{\pgfpoint{-2.5\IClen}{-9.8\IClen}}	% pin 22
\anchor{p22}{\icpinbf}
\savedanchor\icpinbg{\pgfpoint{-1.5\IClen}{-9.8\IClen}}	% pin 23
\anchor{p23}{\icpinbg}
\savedanchor\icpinbh{\pgfpoint{-0.5\IClen}{-9.8\IClen}}	% pin 24
\anchor{p24}{\icpinbh}
\savedanchor\icpinbi{\pgfpoint{0.5\IClen}{-9.8\IClen}}  % pin 25
\anchor{p25}{\icpinbi}
\savedanchor\icpinbj{\pgfpoint{1.5\IClen}{-9.8\IClen}}  % pin 26
\anchor{p26}{\icpinbj}
\savedanchor\icpinbk{\pgfpoint{2.5\IClen}{-9.8\IClen}}  % pin 27
\anchor{p27}{\icpinbk}
\savedanchor\icpinbl{\pgfpoint{3.5\IClen}{-9.8\IClen}}  % pin 28
\anchor{p38}{\icpinbl}
\savedanchor\icpinbm{\pgfpoint{4.5\IClen}{-9.8\IClen}}  % pin 29
\anchor{p29}{\icpinbm}
\savedanchor\icpinbn{\pgfpoint{5.5\IClen}{-9.8\IClen}}  % pin 30
\anchor{p30}{\icpinbn}
\savedanchor\icpinbo{\pgfpoint{6.5\IClen}{-9.8\IClen}}  % pin 31
\anchor{p31}{\icpinbo}
\savedanchor\icpinbp{\pgfpoint{7.5\IClen}{-9.8\IClen}}  % pin 32
\anchor{p32}{\icpinbp}

\savedanchor\icpinra{\pgfpoint{9.8\IClen}{-7.5\IClen}}	% pin 33
\anchor{p33}{\icpinra}
\savedanchor\icpinrb{\pgfpoint{9.8\IClen}{-6.5\IClen}}	% pin 34
\anchor{p34}{\icpinrb}
\savedanchor\icpinrc{\pgfpoint{9.8\IClen}{-5.5\IClen}}	% pin 35
\anchor{p35}{\icpinrc}
\savedanchor\icpinrd{\pgfpoint{9.8\IClen}{-4.5\IClen}}	% pin 36
\anchor{p36}{\icpinrd}
\savedanchor\icpinre{\pgfpoint{9.8\IClen}{-3.5\IClen}}	% pin 37
\anchor{p37}{\icpinre}
\savedanchor\icpinrf{\pgfpoint{9.8\IClen}{-2.5\IClen}}	% pin 28
\anchor{p38}{\icpinrf}
\savedanchor\icpinrg{\pgfpoint{9.8\IClen}{-1.5\IClen}}	% pin 39
\anchor{p39}{\icpinrg}
\savedanchor\icpinrh{\pgfpoint{9.8\IClen}{-0.5\IClen}}	% pin 40
\anchor{p40}{\icpinrh}
\savedanchor\icpinri{\pgfpoint{9.8\IClen}{0.5\IClen}}  % pin 41
\anchor{p41}{\icpinri}
\savedanchor\icpinrj{\pgfpoint{9.8\IClen}{1.5\IClen}}  % pin 42
\anchor{p42}{\icpinrj}
\savedanchor\icpinrk{\pgfpoint{9.8\IClen}{2.5\IClen}}  % pin 43
\anchor{p43}{\icpinrk}
\savedanchor\icpinrl{\pgfpoint{9.8\IClen}{3.5\IClen}}  % pin 44
\anchor{p44}{\icpinrl}
\savedanchor\icpinrm{\pgfpoint{9.8\IClen}{4.5\IClen}}  % pin 45
\anchor{p45}{\icpinrm}
\savedanchor\icpinrn{\pgfpoint{9.8\IClen}{5.5\IClen}}  % pin 46
\anchor{p46}{\icpinrn}
\savedanchor\icpinro{\pgfpoint{9.8\IClen}{6.5\IClen}}  % pin 47
\anchor{p47}{\icpinro}
\savedanchor\icpinrp{\pgfpoint{9.8\IClen}{7.5\IClen}}  % pin 48
\anchor{p48}{\icpinrp}

\savedanchor\icpinta{\pgfpoint{7.5\IClen}{9.8\IClen}}	% pin 49
\anchor{p49}{\icpinta}
\savedanchor\icpintb{\pgfpoint{6.5\IClen}{9.8\IClen}}	% pin 50
\anchor{p50}{\icpintb}
\savedanchor\icpintc{\pgfpoint{5.5\IClen}{9.8\IClen}}	% pin 51
\anchor{p51}{\icpintc}
\savedanchor\icpintd{\pgfpoint{4.5\IClen}{9.8\IClen}}	% pin 52
\anchor{p52}{\icpintd}
\savedanchor\icpinte{\pgfpoint{3.5\IClen}{9.8\IClen}}	% pin 53
\anchor{p53}{\icpinte}
\savedanchor\icpintf{\pgfpoint{2.5\IClen}{9.8\IClen}}	% pin 54
\anchor{p54}{\icpintf}
\savedanchor\icpintg{\pgfpoint{1.5\IClen}{9.8\IClen}}	% pin 55
\anchor{p55}{\icpintg}
\savedanchor\icpinth{\pgfpoint{0.5\IClen}{9.8\IClen}}	% pin 56
\anchor{p56}{\icpinth}
\savedanchor\icpinti{\pgfpoint{-0.5\IClen}{9.8\IClen}}  % pin 57
\anchor{p57}{\icpinti}
\savedanchor\icpintj{\pgfpoint{-1.5\IClen}{9.8\IClen}}  % pin 58
\anchor{p58}{\icpintj}
\savedanchor\icpintk{\pgfpoint{-2.5\IClen}{9.8\IClen}}  % pin 59
\anchor{p59}{\icpintk}
\savedanchor\icpintl{\pgfpoint{-3.5\IClen}{9.8\IClen}}  % pin 60
\anchor{p60}{\icpintl}
\savedanchor\icpintm{\pgfpoint{-4.5\IClen}{9.8\IClen}}  % pin 61
\anchor{p61}{\icpintm}
\savedanchor\icpintn{\pgfpoint{-5.5\IClen}{9.8\IClen}}  % pin 30
\anchor{p62}{\icpintn}
\savedanchor\icpinto{\pgfpoint{-6.5\IClen}{9.8\IClen}}  % pin 31
\anchor{p63}{\icpinto}
\savedanchor\icpintp{\pgfpoint{-7.5\IClen}{9.8\IClen}}  % pin 32
\anchor{p64}{\icpintp}

\savedanchor{\northeast}{\pgfpoint{9.8\IClen}{9.8\IClen}}
\savedanchor{\southwest}{\pgfpoint{-9.8\IClen}{-9.8\IClen}}
\Compass% standard anchors

\foregroundpath{ % border and pin numbers are drawn here
 \pgfsetlinewidth{0.1\IClen}
 \pgfpathmoveto{\pgfpoint{-9\IClen}{8.4\IClen}}
 \pgfpathlineto{\pgfpoint{-9\IClen}{-8.4\IClen}}
 \pgfpathlineto{\pgfpoint{-8.4\IClen}{-9\IClen}}
 \pgfpathlineto{\pgfpoint{8.4\IClen}{-9\IClen}}
 \pgfpathlineto{\pgfpoint{9\IClen}{-8.4\IClen}}
 \pgfpathlineto{\pgfpoint{9\IClen}{8.4\IClen}}
 \pgfpathlineto{\pgfpoint{8.4\IClen}{9\IClen}}
 \pgfpathlineto{\pgfpoint{-8.4\IClen}{9\IClen}}
 \pgfpathlineto{\pgfpoint{-9\IClen}{8.4\IClen}}
 \pgfpathclose
 \pgfusepath{draw}	%draw border
 \pgfsetlinewidth{0.06\IClen}
 \pgfpathcircle{\pgfpoint{-7.8\IClen}{7.8\IClen}}{0.6\IClen}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{7.2\IClen}}{\pgfpoint{-9\IClen}{7.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{6.2\IClen}}{\pgfpoint{-9\IClen}{6.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{5.2\IClen}}{\pgfpoint{-9\IClen}{5.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{4.2\IClen}}{\pgfpoint{-9\IClen}{4.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{3.2\IClen}}{\pgfpoint{-9\IClen}{3.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{2.2\IClen}}{\pgfpoint{-9\IClen}{2.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{1.2\IClen}}{\pgfpoint{-9\IClen}{1.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{0.2\IClen}}{\pgfpoint{-9\IClen}{0.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-0.2\IClen}}{\pgfpoint{-9\IClen}{-0.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-1.2\IClen}}{\pgfpoint{-9\IClen}{-1.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-2.2\IClen}}{\pgfpoint{-9\IClen}{-2.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-3.2\IClen}}{\pgfpoint{-9\IClen}{-3.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-4.2\IClen}}{\pgfpoint{-9\IClen}{-4.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-5.2\IClen}}{\pgfpoint{-9\IClen}{-5.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-6.2\IClen}}{\pgfpoint{-9\IClen}{-6.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-9.8\IClen}{-7.2\IClen}}{\pgfpoint{-9\IClen}{-7.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-7.2\IClen}{-9.8\IClen}}{\pgfpoint{-7.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-6.2\IClen}{-9.8\IClen}}{\pgfpoint{-6.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-5.2\IClen}{-9.8\IClen}}{\pgfpoint{-5.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-4.2\IClen}{-9.8\IClen}}{\pgfpoint{-4.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-3.2\IClen}{-9.8\IClen}}{\pgfpoint{-3.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-2.2\IClen}{-9.8\IClen}}{\pgfpoint{-2.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-1.2\IClen}{-9.8\IClen}}{\pgfpoint{-1.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-0.2\IClen}{-9.8\IClen}}{\pgfpoint{-0.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{0.2\IClen}{-9.8\IClen}}{\pgfpoint{0.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{1.2\IClen}{-9.8\IClen}}{\pgfpoint{1.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{2.2\IClen}{-9.8\IClen}}{\pgfpoint{2.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{3.2\IClen}{-9.8\IClen}}{\pgfpoint{3.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{4.2\IClen}{-9.8\IClen}}{\pgfpoint{4.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{5.2\IClen}{-9.8\IClen}}{\pgfpoint{5.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{6.2\IClen}{-9.8\IClen}}{\pgfpoint{6.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{7.2\IClen}{-9.8\IClen}}{\pgfpoint{7.8\IClen}{-9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-7.2\IClen}}{\pgfpoint{9\IClen}{-7.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-6.2\IClen}}{\pgfpoint{9\IClen}{-6.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-5.2\IClen}}{\pgfpoint{9\IClen}{-5.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-4.2\IClen}}{\pgfpoint{9\IClen}{-4.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-3.2\IClen}}{\pgfpoint{9\IClen}{-3.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-2.2\IClen}}{\pgfpoint{9\IClen}{-2.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-1.2\IClen}}{\pgfpoint{9\IClen}{-1.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{-0.2\IClen}}{\pgfpoint{9\IClen}{-0.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{0.2\IClen}}{\pgfpoint{9\IClen}{0.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{1.2\IClen}}{\pgfpoint{9\IClen}{1.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{2.2\IClen}}{\pgfpoint{9\IClen}{2.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{3.2\IClen}}{\pgfpoint{9\IClen}{3.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{4.2\IClen}}{\pgfpoint{9\IClen}{4.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{5.2\IClen}}{\pgfpoint{9\IClen}{5.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{6.2\IClen}}{\pgfpoint{9\IClen}{6.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{9.8\IClen}{7.2\IClen}}{\pgfpoint{9\IClen}{7.8\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{7.2\IClen}{9.8\IClen}}{\pgfpoint{7.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{6.2\IClen}{9.8\IClen}}{\pgfpoint{6.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{5.2\IClen}{9.8\IClen}}{\pgfpoint{5.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{4.2\IClen}{9.8\IClen}}{\pgfpoint{4.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{3.2\IClen}{9.8\IClen}}{\pgfpoint{3.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{2.2\IClen}{9.8\IClen}}{\pgfpoint{2.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{1.2\IClen}{9.8\IClen}}{\pgfpoint{1.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{0.2\IClen}{9.8\IClen}}{\pgfpoint{0.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-0.2\IClen}{9.8\IClen}}{\pgfpoint{-0.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-1.2\IClen}{9.8\IClen}}{\pgfpoint{-1.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-2.2\IClen}{9.8\IClen}}{\pgfpoint{-2.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-3.2\IClen}{9.8\IClen}}{\pgfpoint{-3.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-4.2\IClen}{9.8\IClen}}{\pgfpoint{-4.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-5.2\IClen}{9.8\IClen}}{\pgfpoint{-5.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-6.2\IClen}{9.8\IClen}}{\pgfpoint{-6.8\IClen}{9\IClen}}
 \pgfpathrectanglecorners{\pgfpoint{-7.2\IClen}{9.8\IClen}}{\pgfpoint{-7.8\IClen}{9\IClen}}
 \pgfusepath{draw}	%draw pins
 \pgftext[at=\pgfpoint{-9.4\IClen}{7.5\IClen}]{\pinsize 1}
 \pgftext[at=\pgfpoint{-9.4\IClen}{6.5\IClen}]{\pinsize 2}
 \pgftext[at=\pgfpoint{-9.4\IClen}{5.5\IClen}]{\pinsize 3}
 \pgftext[at=\pgfpoint{-9.4\IClen}{4.5\IClen}]{\pinsize 4}
 \pgftext[at=\pgfpoint{-9.4\IClen}{3.5\IClen}]{\pinsize 5}
 \pgftext[at=\pgfpoint{-9.4\IClen}{2.5\IClen}]{\pinsize 6}
 \pgftext[at=\pgfpoint{-9.4\IClen}{1.5\IClen}]{\pinsize 7}
 \pgftext[at=\pgfpoint{-9.4\IClen}{0.5\IClen}]{\pinsize 8}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-0.5\IClen}]{\pinsize 9}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-1.5\IClen}]{\pinsize 10}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-2.5\IClen}]{\pinsize 11}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-3.5\IClen}]{\pinsize 12}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-4.5\IClen}]{\pinsize 13}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-5.5\IClen}]{\pinsize 14}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-6.5\IClen}]{\pinsize 15}
 \pgftext[at=\pgfpoint{-9.4\IClen}{-7.5\IClen}]{\pinsize 16}
 \pgftext[at=\pgfpoint{-7.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 17}
 \pgftext[at=\pgfpoint{-6.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 18}
 \pgftext[at=\pgfpoint{-5.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 19}
 \pgftext[at=\pgfpoint{-4.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 20}
 \pgftext[at=\pgfpoint{-3.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 21}
 \pgftext[at=\pgfpoint{-2.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 22}
 \pgftext[at=\pgfpoint{-1.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 23}
 \pgftext[at=\pgfpoint{-0.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 24}
 \pgftext[at=\pgfpoint{0.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 25}
 \pgftext[at=\pgfpoint{1.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 26}
 \pgftext[at=\pgfpoint{2.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 27}
 \pgftext[at=\pgfpoint{3.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 28}
 \pgftext[at=\pgfpoint{4.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 29}
 \pgftext[at=\pgfpoint{5.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 30}
 \pgftext[at=\pgfpoint{6.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 31}
 \pgftext[at=\pgfpoint{7.5\IClen}{-9.4\IClen},rotate=90]{\pinsize 32}
 \pgftext[at=\pgfpoint{9.4\IClen}{-7.5\IClen}]{\pinsize 33}
 \pgftext[at=\pgfpoint{9.4\IClen}{-6.5\IClen}]{\pinsize 34}
 \pgftext[at=\pgfpoint{9.4\IClen}{-5.5\IClen}]{\pinsize 35}
 \pgftext[at=\pgfpoint{9.4\IClen}{-4.5\IClen}]{\pinsize 36}
 \pgftext[at=\pgfpoint{9.4\IClen}{-3.5\IClen}]{\pinsize 37}
 \pgftext[at=\pgfpoint{9.4\IClen}{-2.5\IClen}]{\pinsize 38}
 \pgftext[at=\pgfpoint{9.4\IClen}{-1.5\IClen}]{\pinsize 39}
 \pgftext[at=\pgfpoint{9.4\IClen}{-0.5\IClen}]{\pinsize 40}
 \pgftext[at=\pgfpoint{9.4\IClen}{0.5\IClen}]{\pinsize 41}
 \pgftext[at=\pgfpoint{9.4\IClen}{1.5\IClen}]{\pinsize 42}
 \pgftext[at=\pgfpoint{9.4\IClen}{2.5\IClen}]{\pinsize 43}
 \pgftext[at=\pgfpoint{9.4\IClen}{3.5\IClen}]{\pinsize 44}
 \pgftext[at=\pgfpoint{9.4\IClen}{4.5\IClen}]{\pinsize 45}
 \pgftext[at=\pgfpoint{9.4\IClen}{5.5\IClen}]{\pinsize 46}
 \pgftext[at=\pgfpoint{9.4\IClen}{6.5\IClen}]{\pinsize 47}
 \pgftext[at=\pgfpoint{9.4\IClen}{7.5\IClen}]{\pinsize 48}
 \pgftext[at=\pgfpoint{7.5\IClen}{9.4\IClen},rotate=90]{\pinsize 49}
 \pgftext[at=\pgfpoint{6.5\IClen}{9.4\IClen},rotate=90]{\pinsize 50}
 \pgftext[at=\pgfpoint{5.5\IClen}{9.4\IClen},rotate=90]{\pinsize 51}
 \pgftext[at=\pgfpoint{4.5\IClen}{9.4\IClen},rotate=90]{\pinsize 52}
 \pgftext[at=\pgfpoint{3.5\IClen}{9.4\IClen},rotate=90]{\pinsize 53}
 \pgftext[at=\pgfpoint{2.5\IClen}{9.4\IClen},rotate=90]{\pinsize 54}
 \pgftext[at=\pgfpoint{1.5\IClen}{9.4\IClen},rotate=90]{\pinsize 55}
 \pgftext[at=\pgfpoint{0.5\IClen}{9.4\IClen},rotate=90]{\pinsize 56}
 \pgftext[at=\pgfpoint{-0.5\IClen}{9.4\IClen},rotate=90]{\pinsize 57}
 \pgftext[at=\pgfpoint{-1.5\IClen}{9.4\IClen},rotate=90]{\pinsize 58}
 \pgftext[at=\pgfpoint{-2.5\IClen}{9.4\IClen},rotate=90]{\pinsize 59}
 \pgftext[at=\pgfpoint{-3.5\IClen}{9.4\IClen},rotate=90]{\pinsize 60}
 \pgftext[at=\pgfpoint{-4.5\IClen}{9.4\IClen},rotate=90]{\pinsize 61}
 \pgftext[at=\pgfpoint{-5.5\IClen}{9.4\IClen},rotate=90]{\pinsize 62}
 \pgftext[at=\pgfpoint{-6.5\IClen}{9.4\IClen},rotate=90]{\pinsize 63}
 \pgftext[at=\pgfpoint{-7.5\IClen}{9.4\IClen},rotate=90]{\pinsize 64}
}}
\makeatother
