Skip to content

Commit

Permalink
Adding the transmission gate symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Rmano committed Sep 27, 2020
1 parent 092c950 commit 36e15ea
Show file tree
Hide file tree
Showing 3 changed files with 332 additions and 0 deletions.
62 changes: 62 additions & 0 deletions doc/circuitikzmanual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4267,6 +4267,8 @@ \subsubsection{IEEE logic gates}\label{sec:ieeestdports}

These ports are completely independent from the legacy set (either \texttt{american} or \texttt{european}); they are not eanbled by default because the relative size of the ports is very different from the legacy ones, and that will disrupt every schematic (especially if drawn with absolute coordinate). If you want to use them as default, you can use the command \verb|\ctikzset{logic ports=ieee}| and by default the shapes \texttt{and port}, \texttt{or port} and so on will be the IEEE standard ones.

The transmission gate (also known as ``bowtie'') components are not described in the IEEE standard, so they are simply inspired by the other IEEE ports --- this is why their name is prefixed by \texttt{ieee} and not by \texttt{ieeestd}. They are aliased to \texttt{tgate} and \texttt{double tgate} though, and it is recommended to use those names (maybe in the future there will be \texttt{american ports} and/or \texttt{european ports} versions available).

\begin{groupdesc}
\circuitdesc*{ieeestd and port}{IEEE standard ``and'' port}{}(in 1/180/0.2, in 2/180/0.2, out/0/0.2, bout/45/0.2)
\circuitdesc*{ieeestd nand port}{IEEE standard ``nand'' port}{}(in 1/180/0.2, out/0/0.2, bout/45/0.2)
Expand All @@ -4280,8 +4282,11 @@ \subsubsection{IEEE logic gates}\label{sec:ieeestdports}
\circuitdesc*{ieeestd not port}{IEEE standard ``not'' port}{}(in/180/0.2, bin/-155/0.2, out/0/0.2, bout/45/0.2)
\circuitdesc*{ieeestd schmitt port}{Schmitt port matched to IEEE standard ports}{}(in/180/0.2, out/0/0.2, bout/45/0.2)
\circuitdesc*{ieeestd invschmitt port}{Inverting Schmitt port matched to IEEE standard ports}{}
\circuitdesc*{ieee tgate}{IEEE style transmission gate}{}(in 1/180/0.2, bin 1/-155/0.2, up/30/0.2, down/-30/0.2, out/0/0.2, bout/45/0.2, notgate/135/0.4, gate/-135/0.4)
\circuitdesc*{ieee double tgate}{IEEE style double transmission gate}{}(in/180/0.2, bin/-155/0.2, out/0/0.2, bout/45/0.2, up/30/0.2, down/-30/0.2, bnotgate/135/0.4, bgate/-115/0.4)
\circuitdesc*{notcirc}{Inverting dot for IEEE ports}{}(west/180/0.1, east/0/0.1)
\circuitdesc*{schmitt symbol}{Schmitt symbol to add to input pins if needed}{}(north west/145/0.1, south east/-45/0.1)

\end{groupdesc}

\subsubsection{European Logic gates}
Expand Down Expand Up @@ -4314,6 +4319,9 @@ \subsubsection{Path-style logic ports}
\circuitdescbip*{inline buffer}<buffer port>{``buffer'' logic port}{}
\circuitdescbip*{inline schmitt}<schmitt port>{Schmitt logic port}{}
\circuitdescbip*{inline invschmitt}<invschmitt port>{Inverting Schmitt logic port}{}
\ctikzset{tgate scale=0.7}
\circuitdescbip*{inline tgate}<tgate>{transmission gate}{}(bgate/-90/0.2, bnotgate/90/0.2)
\circuitdescbip*{inline double tgate}<double tgate>{double transmission gate}{}(bgate/-90/0.2, bnotgate/90/0.2)
\end{groupdesc}

Those ports follows the current selected style, although you can change it on the fly (even if it has not a lot of sense); you can apply labels, annotations and (again, not a lot of sense) voltages to them. The assigned value is typeset as if it were the main text of the node.
Expand All @@ -4326,6 +4334,18 @@ \subsubsection{Path-style logic ports}
\end{circuitikz}
\end{LTXexample}

Notice that in the inline version the leading pins are not drawn, so in the case of the transmission gates
you have to use the border pins to connect the gates.

\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[ ]
\ctikzset{logic ports=ieee,
tgate scale=0.7, logic ports/fill=yellow}
\draw (0,0) to[inline not] ++(2,0)
to[inline double tgate, name=P] ++(3,0)
(P.bnotgate) |- ++(-3,1);
\end{circuitikz}
\end{LTXexample}

\subsubsection{American ports usage}

Expand Down Expand Up @@ -4792,6 +4812,48 @@ \subsubsection{IEEE logic gates usage.}
\endgroup % for IEEE ports ctikzset
%%

\paragraph{Transmission gate symbols.}

The \texttt{tgate} and \texttt{double tgate} components are available since \texttt{1.2.4} but only in the IEEE style. An additional parameter \texttt{tgate scale} (default \texttt{1.0}, meaning that the triangle is the same size as a \texttt{ieeestd not port}) select the relative scale of the components.

\begin{LTXexample}[varwidth=true]
\begin{circuitikz}[ ]
\ctikzset{logic ports=ieee, tgate scale=0.7, }
\draw (0,0) to[inline not, *-*] ++(2,0)
node[tgate, anchor=in]{};
\end{circuitikz}
\end{LTXexample}

The anchors for the tgate's control point are called \texttt{gate} and \texttt{notgate} (and the corresponding \texttt{bgate} and \texttt{bnotgate} for the border anchors).

\begin{quote}
\begin{circuitikz}
\node[ieee tgate](A) at (0,0) {};
\path (A.in) \showcoord(in)<180:0.2>;
\path (A.bin) \showcoordb(bin)<-135:0.2>;
\path (A.out) \showcoord(out)<0:0.2>;
\path (A.bout) \showcoordb(bout)<-45:0.2>;
\path (A.left) \showcoord(left)<135:0.4>;
\path (A.right) \showcoord(right)<45:0.4>;
\path (A.gate) \showcoord(gate)<-160:0.3>;
\path (A.bgate) \showcoordb(bgate)<-75:0.3>;
\path (A.notgate) \showcoord(notgate)<160:0.3>;
\path (A.bnotgate) \showcoordb(bnotgate)<75:0.3>;
\node[ieee double tgate](A) at (5,0) {};
\path (A.in) \showcoord(in)<180:0.2>;
\path (A.bin) \showcoordb(bin)<-135:0.2>;
\path (A.out) \showcoord(out)<0:0.2>;
\path (A.bout) \showcoordb(bout)<-45:0.2>;
\path (A.left) \showcoord(left)<135:0.4>;
\path (A.right) \showcoord(right)<45:0.4>;
\path (A.gate) \showcoord(gate)<-160:0.3>;
\path (A.bgate) \showcoordb(bgate)<-75:0.3>;
\path (A.notgate) \showcoord(notgate)<160:0.3>;
\path (A.bnotgate) \showcoordb(bnotgate)<75:0.3>;
\end{circuitikz}
\end{quote}


\subsubsection{European logic port usage}

European logic port are the same class as american and IEEE-style ones, and they obey the same class modifier. Moreover, you can use the \texttt{no inputs pin} as in the other logic ports to suppress input pins.
Expand Down
266 changes: 266 additions & 0 deletions tex/pgfcircmultipoles.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2758,4 +2758,270 @@
}
}

%%%% tgateS
% tgate is just ieee style for now
\tikzset{%
tgate/.style ={shape=ieee tgate},
double tgate/.style ={shape=ieee double tgate},
}
\ctikzset{tgate scale/.initial=1}
% Buffer and inverters
%
% #1: name
% #2: 1: one-not, 2:double-not
% #3: content
\long\def\pgfcircdeclareieeetgate#1#2#3{%
\pgfdeclareshape{ieee #1}%
{%
\savedmacro{\ctikzclass}{\edef\ctikzclass{logic ports}}
\saveddimen{\scaledRlen}{\pgfmathsetlength{\pgf@x}{\ctikzvalof{\ctikzclass/scale}\pgf@circ@Rlen}}
\savedmacro{\thisshape}{\def\thisshape{\tikz@fig@name}}
\saveddimen{\baselen}{%
\pgf@circ@ieeestd@baselen\pgf@x=\pgf@circ@res@temp
}
\saveddimen{\stdH}{% This is HALF the height of the inner port
\pgf@circ@ieeestd@stdH\pgf@x=\pgf@circ@res@temp
}
\saveddimen{\notdiameter}{
\pgf@circ@notradius\pgf@x=2\pgf@circ@res@temp
}
\saveddimen{\notradius}{
\pgf@circ@notradius\pgf@x=\pgf@circ@res@temp
}
\saveddimen{\pinlen}{%
\pgf@circ@ieeestd@pinlen\pgf@x=\pgf@circ@res@temp
}
% anchors for the body (no pins included here)
% Notice that 0.8660254 is cos(30)
\savedanchor{\bodyleft}{% This DOES NOT take into account the pointy or/xor thing
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{-2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\topleft}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{-2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\bodyright}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\bottomright}{% Here it is the same as \bodyright
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
% geographical anchors --- must be rectangulars!
\savedanchor{\northwest}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{-2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\southwest}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{-2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{-#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\southeast}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{-#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\savedanchor{\northeast}{%
\pgf@circ@ieeestd@stdH
\pgfmathsetlength{\pgf@x}{2*0.8660254*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
\pgfmathsetlength{\pgf@y}{#2*\pgf@circ@res@temp*\ctikzvalof{tgate scale}}
}
\anchor{center}{\pgfpointorigin}
\anchor{text}{
\ifpgf@circ@center@text
\pgfpoint{-.5\wd\pgfnodeparttextbox}{\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox}
\else
\pgf@circ@ieeestd@stdH
\pgfpoint{-0.8660254*\pgf@circ@res@temp + \ctikzvalof{left text distance}}{\dimexpr.5\dp\pgfnodeparttextbox-.5\ht\pgfnodeparttextbox}
\fi
}
% input anchors
\anchor{in}{\bodyleft\pgf@y=0pt\advance\pgf@x by-\pinlen}
\anchor{in 1}{\bodyleft\pgf@y=0pt\advance\pgf@x by-\pinlen}
\anchor{bin}{\bodyleft\pgf@y=0pt\relax}
\anchor{bin 1}{\bodyleft\pgf@y=0pt\relax}
% gates
\anchor{gate}{\bodyleft\pgf@circ@res@up=\pgf@y
\pgf@x=0pt\pgfmathsetlength{\pgf@y}{-(#2-1)*0.5*\pgf@circ@res@up-\pinlen}}
\anchor{bgate}{\bodyleft\pgf@circ@res@up=\pgf@y
\pgf@x=0pt\pgfmathsetlength{\pgf@y}{-(#2-1)*0.5*\pgf@circ@res@up}}
% gate (up) (2.1547 = 1+1/cos(30)
\anchor{notgate}{\bodyleft\pgf@circ@res@up=\pgf@y
\pgf@x=0pt\relax
\pgfmathsetlength{\pgf@circ@res@temp}{2.1547*\notradius}
\ifdim\pinlen>\pgf@circ@res@temp
\pgfmathsetlength{\pgf@y}{(#2-1)*0.5*\pgf@circ@res@up+\pinlen}
\else
\pgf@y=\pgf@circ@res@temp
\fi
}
\anchor{bnotgate}{\bodyleft\pgf@circ@res@up=\pgf@y
\pgf@x=0pt\pgfmathsetlength{\pgf@y}{(#2-1)*0.5*\pgf@circ@res@up+2.1547*\notradius}}

% output anchors
\anchor{out}{%
\pgfextractx{\pgf@circ@res@other}{\bodyright} %body border, without not ball
\advance\pgf@circ@res@other by\pinlen
\pgfextractx{\pgf@circ@res@temp}{\bottomright} %body + ball border
\ifdim \pgf@circ@res@temp > \pgf@circ@res@other
\pgf@circ@res@other = \pgf@circ@res@temp % do not enter in the ball...
\fi
\pgf@x=\pgf@circ@res@other\pgf@y=0pt
}
\anchor{bout}{\bottomright\pgf@y=0pt}

\anchor{body right}{\bodyright\pgf@y=0pt}
\anchor{right}{\bottomright\pgf@y=0pt}
\anchor{body left}{\bodyleft\pgf@y=0pt}% central edge of the body
\anchor{left}{\bodyleft\pgf@y=0pt}
\anchor{up}{%
\bodyleft
\pgf@x=0pt
\ifnum#2=1\relax
\pgf@y=0pt
\else
\pgf@y=.5\pgf@y
\fi
\advance\pgf@y by \notdiameter
}
\anchor{down}{%
\bodyleft
\pgf@x=0pt
\ifnum#2=1\relax
\pgf@y=0pt
\else
\pgf@y=-.5\pgf@y
\fi
}
% this is for when it's used as a bipole
% we use the enclosing rectangle (see below)
\anchorborder{%
%
% this is the square border to position the path label with a bit of horizontal space
%
\pgf@xa=\pgf@x
\pgf@ya=\pgf@y
\pgfextracty{\pgf@circ@res@up}{\bodyleft}
\pgfextractx{\pgf@circ@res@left}{\bodyleft}
\pgfpointborderrectangle{\pgfpoint{\pgf@xa}{\pgf@ya}}
{\pgfpoint{-\pgf@circ@res@left}{\pgf@circ@res@up}}
}
% geographical anchors
\anchor{nw}{\northwest}
\anchor{ne}{\northeast}
\anchor{se}{\southeast}
\anchor{sw}{\southwest}
\anchor{north west}{\northwest}
\anchor{north east}{\northeast}
\anchor{south east}{\southeast}
\anchor{south west}{\southwest}
% over 0,0 even if asymmetric
% will break if the geocoords are not rectangular
\anchor{n}{\northwest\pgf@x=0pt\relax}
\anchor{e}{\northeast\pgf@y=0pt\relax}
\anchor{s}{\southwest\pgf@x=0pt\relax}
\anchor{w}{\northwest\pgf@y=0pt\relax}
\anchor{north}{\northwest\pgf@x=0pt\relax}
\anchor{east}{\northeast\pgf@y=0pt\relax}
\anchor{south}{\southwest\pgf@x=0pt\relax}
\anchor{west}{\northwest\pgf@y=0pt\relax}

\backgroundpath{
\pgfscope
\pgfsetcolor{\ctikzvalof{color}}
\pgfextractx{\pgf@circ@res@left}{\bodyleft}
\pgfextracty{\pgf@circ@res@up}{\bodyleft}
\pgfextractx{\pgf@circ@res@right}{\bodyright}
% \draw input pins
\ifpgfcirc@draw@input@leads
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left-\pinlen}{0pt}}
% gate (down)
\pgfpathmoveto{\pgfpoint{0pt}{-(#2-1)*0.5*\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{-(#2-1)*0.5*\pgf@circ@res@up-\pinlen}}
% gate (up) (2.1547 = 1+1/cos(30)
\pgfmathsetlength{\pgf@circ@res@temp}{2.1547*\notradius}
\ifdim\pinlen>\pgf@circ@res@temp
\pgfpathmoveto{\pgfpoint{0pt}{(#2-1)*0.5*\pgf@circ@res@up+\pgf@circ@res@temp}}
\pgfpathlineto{\pgfpoint{0pt}{(#2-1)*0.5*\pgf@circ@res@up+\pinlen}}
\fi
\pgfusepath{draw}
\fi
#3
\endpgfscope
% output lead:
\pgfextractx{\pgf@circ@res@right}{\bottomright} %body+ball border
\pgfextractx{\pgf@circ@res@other}{\bodyright} %body border, without "not" ball
\advance\pgf@circ@res@other by \pinlen\relax
\ifdim \pgf@circ@res@other > \pgf@circ@res@right
\ifpgfcirc@draw@output@leads
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@other}{0pt}}
\pgfusepath{draw}
\fi
\fi
}
}
}

\pgfcircdeclareieeetgate{tgate}{1}{%
\pgfscope
\pgf@circ@setlinewidth{tripoles}{\pgflinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}}
\pgfpathclose
\pgf@circ@draworfill
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{0pt}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@up}}
\pgfpathclose
\pgf@circ@draworfill
\endpgfscope
\pgfscope
% 1.1547 is 1/cos(30)
\pgftransformshift{\pgfpoint{0pt}{1.1547*\notradius}}
\pgfnode{notcirc}{center}{}{\thisshape-not}{\pgfusepath{stroke}}
\endpgfscope
}

\pgfcircdeclareieeetgate{double tgate}{2}{%
\pgfscope
\pgf@circ@setlinewidth{tripoles}{\pgflinewidth}
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathclose
\pgf@circ@draworfill
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
\pgfpathclose
\pgf@circ@draworfill
% bottom triangles
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@left}{-\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{-.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@left}{0pt}}
\pgfpathclose
\pgf@circ@draworfill
\pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{-\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{0pt}{-.5\pgf@circ@res@up}}
\pgfpathlineto{\pgfpoint{\pgf@circ@res@right}{0pt}}
\pgfpathclose
\pgf@circ@draworfill
\endpgfscope
\pgfscope
% 1.1547 is 1/cos(30)
\pgftransformshift{\pgfpoint{0pt}{.5*\pgf@circ@res@up+1.1547*\notradius}}
\pgfnode{notcirc}{center}{}{\thisshape-not}{\pgfusepath{stroke}}
\endpgfscope
}

4 changes: 4 additions & 0 deletions tex/pgfcircpath.tex
Original file line number Diff line number Diff line change
Expand Up @@ -961,3 +961,7 @@
\pgfcirc@port@node@to@path{buffer port}{inline buffer}
\pgfcirc@port@node@to@path{schmitt port}{inline schmitt}
\pgfcirc@port@node@to@path{invschmitt port}{inline invschmitt}

\pgfcirc@port@node@to@path{tgate}{inline tgate}
\pgfcirc@port@node@to@path{double tgate}{inline double tgate}

0 comments on commit 36e15ea

Please sign in to comment.