% Copyright 2007-2009 by Massimo Redaelli
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/LICENSE for more details.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tripoles



\newcommand{\pgfcircdeclarelogicport}[2]{
	\pgfdeclareshape{#1 port}
	{
	  \savedanchor\northwest{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1 port/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1 port/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }
	  \anchor{south}{
		\north
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\left{%
	  	\pgf@y=0pt
	  }
	  \savedanchor\inOne{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1 port/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1 port/input height}\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1 port/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }	  
	  \anchor{in 1}{
		\inOne
	  }
	  \anchor{in 2}{
		\inOne
		\pgf@y=-\pgf@y
	  }
	  \anchor{out}{
		\northwest
		\pgf@y=0pt
		\pgf@x=-\pgf@x
	  }
  	  \anchor{center}{
		\northwest
		\pgf@y=0pt
		\pgf@x=-.8\pgf@x  
	  }

	  \backgroundpath{			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
			
			
			\northwest
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@down = -\pgf@y
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
			
			#2
	  
	  }
	}
}


\pgfcircdeclarelogicport{and}{
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@right}
		{0pt}}
	
	\pgfusepath{draw}
	
	\pgfsetlinewidth{2\pgflinewidth}
	\pgfpathmoveto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@left}
		{\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@left}
		{\pgf@circ@res@down}}
	\pgfpathcurveto
		{\pgfpoint{.0\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint
			{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@right}
			{.5\pgf@circ@res@down}}
		{\pgfpoint
			{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@right}
			{0pt}}
	\pgfpathcurveto
		{\pgfpoint
			{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@right}
			{.5\pgf@circ@res@up}}
		{\pgfpoint{.0\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint
			{\pgfkeysvalueof{/tikz/circuitikz/tripoles/and port/port width}\pgf@circ@res@left}
			{\pgf@circ@res@up}}	
	\pgfusepath{draw}
}



\pgfcircdeclarelogicport{nand}{
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/port width}\pgf@circ@res@right}
		{0pt}}
	
	\pgfusepath{draw}
	
	\pgfsetlinewidth{2\pgflinewidth}

	\pgf@circ@res@step = \pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/circle width}\pgf@circ@res@right
	\pgf@circ@res@other = \pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/port width}\pgf@circ@res@right
	
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}
	\pgfpathcurveto
		{\pgfpoint{.0\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{.5\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{.5\pgf@circ@res@up}}
		{\pgfpoint{.0\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint
			{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/port width}\pgf@circ@res@left}
			{\pgf@circ@res@up}}	
	\pgfpathellipse
		{\pgfpoint{\pgf@circ@res@other-.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{0pt}{.5\pgf@circ@res@step}}

	\pgfusepath{draw}
}


\pgfcircdeclarelogicport{nor}{
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/port width}\pgf@circ@res@right}
		{0pt}}	
	
	\pgfusepath{draw}
	
	\pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/port width}\pgf@circ@res@right
	\pgf@circ@res@step = \pgfkeysvalueof{/tikz/circuitikz/tripoles/nand port/circle width}\pgf@circ@res@right
		
	\pgfsetlinewidth{2\pgflinewidth}
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}	

	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}	
		
	\pgfpathellipse
		{\pgfpoint{\pgf@circ@res@other-.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{0pt}{.5\pgf@circ@res@step}}
		
	\pgfusepath{draw}
}




\pgfcircdeclarelogicport{or}{

	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/port width}\pgf@circ@res@right}
		{0pt}}	
	
	\pgfusepath{draw}
	\pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/port width}\pgf@circ@res@right
	\pgfsetlinewidth{2\pgflinewidth}
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/aaa}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/aaa}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}	

	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ddd}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@res@other}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/or port/ddd}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}	
	\pgfusepath{draw}
}


\pgfcircdeclarelogicport{xor}{

	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/port width}\pgf@circ@res@right}
		{0pt}}	
	
	\pgfusepath{draw}
	\pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/port width}\pgf@circ@res@right
	\pgfsetlinewidth{2\pgflinewidth}
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}	

	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@res@other}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}	
		
	\def\pgf@circ@temp{-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/distance}\pgf@circ@res@right+}
	\pgfpathmoveto{\pgfpoint{\pgf@circ@temp-\pgf@circ@res@other}{\pgf@circ@res@up}}
	
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/aaa}\pgf@circ@res@left}{.95*\pgf@circ@res@up}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xor port/aaa}\pgf@circ@res@left}{.95*\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@temp-\pgf@circ@res@other}{.95*\pgf@circ@res@down}}	
				
	\pgfusepath{draw}
}



\pgfcircdeclarelogicport{xnor}{

	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input height}\pgf@circ@res@up}}
	
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{(\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/port width}-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input skip})*\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/input height}\pgf@circ@res@down}}
	
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/port width}\pgf@circ@res@right}
		{0pt}}	
	
	\pgfusepath{draw}
	\pgf@circ@res@other=\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/port width}\pgf@circ@res@right
	\pgf@circ@res@step = \pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/circle width}\pgf@circ@res@right

	\pgfsetlinewidth{2\pgflinewidth}
	\pgfpathmoveto{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/aaa}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@down}}	

	\pgfpathcurveto
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@res@other-\pgf@circ@res@step}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ddd}\pgf@circ@res@left}{\pgf@circ@res@up}}
		{\pgfpoint{-\pgf@circ@res@other}{\pgf@circ@res@up}}	
		
	\def\pgf@circ@temp{-\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/distance}\pgf@circ@res@right+}
	\pgfpathmoveto{\pgfpoint{\pgf@circ@temp-\pgf@circ@res@other}{\pgf@circ@res@up}}
	
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/aaa}\pgf@circ@res@left}{.95*\pgf@circ@res@up}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@up}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{0pt}}
	\pgfpathcurveto
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/bbb}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/ccc}\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@temp\pgfkeysvalueof{/tikz/circuitikz/tripoles/xnor port/aaa}\pgf@circ@res@left}{.95*\pgf@circ@res@down}}
		{\pgfpoint{\pgf@circ@temp-\pgf@circ@res@other}{.95*\pgf@circ@res@down}}	
		
		
	\pgfpathellipse
		{\pgfpoint{\pgf@circ@res@other-.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{.5\pgf@circ@res@step}{0pt}}
		{\pgfpoint{0pt}{.5\pgf@circ@res@step}}
				
	\pgfusepath{draw}
}





\newcommand{\pgfcircdeclaretransistor}[3]{
	\pgfdeclareshape{#1}
	{
	  \anchor{center}{\pgfpointorigin}
	  \savedanchor\north{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x=0pt
	  }
	  \anchor{south}{
		\north
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\left{%
	  	\pgf@y=0pt
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1/width}\pgf@x
	  }
	  #2
	  \backgroundpath{			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
			
			
			\north
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@down = -\pgf@y
			\pgf@circ@res@right = \pgf@x
			\left
			\pgf@circ@res@left = \pgf@x
			
			#3
	  
	  }
	}
}






\newcommand{\pgfcircdeclaremos}[3]{
	\pgfcircdeclaretransistor{#1}{
		  \anchor{G}{
			\left
		  }
		  \anchor{gate}{
			\left
		  }
		  \anchor{B}{
			\left
			\pgf@x=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1/base width}\pgf@x
		  }
		  \anchor{base}{
			\left
			\pgf@x=\pgfkeysvalueof{/tikz/circuitikz/tripoles/#1/base width}\pgf@x
		  }
		  #2
	  }
	  {#3}
}









\pgfcircdeclaremos{nmos}{
		  \anchor{D}{
			\north
		  }
		  \anchor{drain}{
			\north
		  }
		  \anchor{S}{
			\north
			\pgf@y=-\pgf@y
		  }
		  \anchor{source}{
			\north
			\pgf@y=-\pgf@y
		  }
}{%
			\pgfmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@up}}

			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base height}\pgf@circ@res@down}}

			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}		
			\pgfusepath{draw}
			
			\pgfscope
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@down}}
			\pgfsetlinewidth{2\pgflinewidth}
			\pgfusepath{draw}
			\endpgfscope
			
		\ifpgf@circuit@mos@arrows
			\pgfscope             
			\pgfslopedattimetrue 
			\pgfallowupsidedownattimetrue
			\pgfresetnontranslationattimefalse
			\pgftransformlineattime{.6}{%
				\pgfpoint%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate width}\pgf@circ@res@left}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@down}%
			}{%
				\pgfpoint
					{\pgf@circ@res@right}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate height}\pgf@circ@res@down}%
			}
			\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
			\endpgfscope
		\fi

					
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/nmos/gate width}\pgf@circ@res@left}
				{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgfusepath{draw}
}


\pgfcircdeclaremos{pmos}{
		  \anchor{S}{
			\north
		  }
		  \anchor{source}{
			\north
		  }
		  \anchor{D}{
			\north
			\pgf@y=-\pgf@y
		  }
		  \anchor{drain}{
			\north
			\pgf@y=-\pgf@y
		  }
}{%
			\pgfmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
			\pgfusepath{draw}

		\ifpgf@circuit@mos@arrows
			\pgfscope             
			\pgfslopedattimetrue 
			\pgfallowupsidedownattimetrue
			\pgfresetnontranslationattimefalse
			\pgftransformlineattime{.4}{%
				\pgfpoint%
					{\pgf@circ@res@right}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}%
			}{%
				\pgfpoint
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}%
			}
			\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
			\endpgfscope
		\fi

			\pgfscope
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base height}\pgf@circ@res@down}}
			\pgfsetlinewidth{2\pgflinewidth}
			\pgfusepath{draw}
			\endpgfscope
			
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/base width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}		

			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate height}\pgf@circ@res@down}}
					
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pmos/gate width}\pgf@circ@res@left}
				{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgfusepath{draw}
}







\pgfcircdeclaretransistor{pnp}{
		  \anchor{E}{
			\north
		  }
		  \anchor{emitter}{
			\north
		  }
		  \anchor{B}{
			\left
		  }
		  \anchor{base}{
			\left
		  }		  
		  \anchor{C}{
			\north
			\pgf@y=-\pgf@y
		  }
		  \anchor{collector}{
			\north
			\pgf@y=-\pgf@y
		  }
}{
			\pgfmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height 2}\pgf@circ@res@up}}
			\pgfusepath{draw}

			\pgfscope
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/base height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/base height}\pgf@circ@res@down}}
			\pgfsetlinewidth{2\pgflinewidth}
			\pgfusepath{draw}
			\endpgfscope
			
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height 2}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}		
			\pgfusepath{draw}
	
			\pgfscope             
			\pgfslopedattimetrue 
			\pgfallowupsidedownattimetrue
			\pgfresetnontranslationattimefalse
			\pgftransformlineattime{.5}{%
				\pgfpoint%
					{\pgf@circ@res@right}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height}\pgf@circ@res@up}%
			}{%
				\pgfpoint
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate height 2}\pgf@circ@res@up}%
			}
			\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
			\endpgfscope
		
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/pnp/gate width}\pgf@circ@res@left}
				{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgfusepath{draw}
			
			
}






\pgfcircdeclaretransistor{npn}{
		  \anchor{C}{
			\north
		  }
		  \anchor{collector}{
			\north
		  }
		  \anchor{B}{
			\left
		  }
		  \anchor{base}{
			\left
		  }		  
		  \anchor{E}{
			\north
			\pgf@y=-\pgf@y
		  }
		  \anchor{emitter}{
			\north
			\pgf@y=-\pgf@y
		  }
}{
			\pgfmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height 2}\pgf@circ@res@up}}
			\pgfusepath{draw}

			\pgfscope
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/base height}\pgf@circ@res@up}}
			\pgflineto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/base height}\pgf@circ@res@down}}
			\pgfsetlinewidth{2\pgflinewidth}
			\pgfusepath{draw}
			\endpgfscope
			
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height 2}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height}\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@down}}		
			\pgfusepath{draw}
	
			\pgfscope
			\pgfslopedattimetrue
			\pgfallowupsidedownattimetrue
			\pgfresetnontranslationattimefalse
			\pgftransformlineattime{.5}{%
				\pgfpoint%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height 2}\pgf@circ@res@down}%
			}{%
				\pgfpoint{\pgf@circ@res@right}%
					{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate height}\pgf@circ@res@down}%
			}
			\pgfnode{currarrow}{center}{}{}{\pgfusepath{stroke}}
			\endpgfscope
		
			\pgfmoveto{\pgfpoint
				{\pgfkeysvalueof{/tikz/circuitikz/tripoles/npn/gate width}\pgf@circ@res@left}
				{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgflineto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up+\pgf@circ@res@down}}
			\pgfusepath{draw}
			
			
}





















\pgfdeclareshape{op amp}
	{
	  \anchor{center}{\pgfpointorigin}
	  \savedanchor\northwest{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }
	  \anchor{south}{
		\northwest
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\left{%
	  	\pgf@y=0pt
	  }
	  \savedanchor\inOne{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@x
		\pgf@x=.5\pgf@x
	  }	  
	  \anchor{-}{
		\inOne
	  }
	  \anchor{+}{
		\inOne
		\pgf@y=-\pgf@y
	  }
	  \savedanchor\up{%
		\pgf@y= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@y
		\pgf@y=.5\pgf@y
		\pgf@x= \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}
		\pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@x
		\pgf@x=.5\pgf@x
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
	    \pgfpointlineattime{
			\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/up pos}}{
			\pgfpoint{
				\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
				{\pgf@circ@res@up}}
			{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
	  }
	  \anchor{up}{
		\up
	  }
	  \anchor{down}{
		\up
		\pgf@y=-\pgf@y
	  }
	  \anchor{out}{
		\northwest
		\pgf@y=0pt
		\pgf@x=-\pgf@x
	  }
	  
	  \backgroundpath{			
			\pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}	
			
			
			\northwest
			\pgf@circ@res@up = \pgf@y 
			\pgf@circ@res@down = -\pgf@y
			\pgf@circ@res@right = -\pgf@x
			\pgf@circ@res@left = \pgf@x
			
	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}}
	\pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}]{\ $-$}
	

	\pgfpathmoveto{\pgfpoint
		{\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}}
	\pgfpathlineto{\pgfpoint
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
		{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}}
	\pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}]{\ $+$}
		
	\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
	\pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
	
	\pgfusepath{draw}

						
	\pgfscope
		\pgfsetlinewidth{2\pgflinewidth}
		\pgftransformxshift{.7\pgf@circ@res@left}
		\pgf@circ@res@step=\pgf@circ@res@right
		\advance\pgf@circ@res@step by -\pgf@circ@res@left
		\pgf@circ@res@step=.7\pgf@circ@res@step
		
		\pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
		\pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
		\pgfpathlineto{\pgfpoint{\pgf@circ@res@step}{0pt}}
		\pgfusepath{draw}
	\endpgfscope
		
		
	  
	  }
	}



\endinput
