3

How can I draw a 3-input logic gate with circuitikz? Is there a way to do so?

For example,

\begin{circuitikz}
\draw
  (0,0) node[and port](myand){}
  (myand.in 1) node[left]{A}
  (myand.in 2) node[left]{B}
  (myand.in 3) node[left]{C}
  (myand.out) node[right]{Y}
\end{circuitikz}
2
  • I don't know about circuitikz, but with tikz you could see this answer. Who knows, maybe it even helps with circuitikz.
    – morbusg
    Jan 20, 2013 at 23:14
  • Yeah, I've seen it. But it's because I use circuitikz to draw my circuits, so I'm used to it. But thank you anyway. Jan 26, 2013 at 16:39

3 Answers 3

6
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US,circuits.logic.IEC}
\begin{document}
    \begin{tikzpicture}[minimum height=0.75cm] 
        \node[or gate US, draw,logic gate inputs=nnn] (A) {}; 
        \foreach \a in {1,...,3}
            \draw (A.input \a -| -1,0) -- (A.input \a); 
        \draw (A.output) -- ([xshift=0.5cm]A.output);
    \end{tikzpicture}

    \begin{tikzpicture}[minimum height=0.75cm] 
        \node[and gate US, draw,logic gate inputs=nnn] (A) {}; 
        \foreach \a in {1,...,3}
            \draw (A.input \a -| -1,0) -- (A.input \a); 
        \draw (A.output) -- ([xshift=0.5cm]A.output);
    \end{tikzpicture}   

\end{document}

enter image description here

By slight modification of this code you can acheive gates with more inputs (modifying inputs=nnn and \foreach \a in {1,...,3}).

For more, check TikZ & PGF manual section 29.3 Page 300

2
  • I was trying to do it with circuitikz, but it seems there's no way. Thanks anyway. Feb 27, 2013 at 23:05
  • @Pouya, this is not working with american nor port.
    – CroCo
    Oct 11, 2015 at 16:37
3

This can also be done!!

\documentclass[border=10pt]{standalone}
\usepackage[american,siunitx]{circuitikz}
\usepackage{amsmath}
\usepackage{tikz}
%\usepackage{everyshi-2001-05-15}
%\usetikzlibrary{circuits.logic.US,circuits.logic.IEC}
\begin{document}
    \begin{circuitikz}%[circuit logic US]
        \draw (0,0) node[xor port ,scale=2, number inputs=3](XOR1){}
        ;
    \end{circuitikz}    
\end{document}
0

You could even scale only the width of the port if you dont want it to take up half your page by using yscale:

\draw (0,0) node[nor port ,yscale=2, number inputs=3](nor_1){}
3
  • you probably mean "scale only height of the port".
    – Zarko
    Jun 8, 2022 at 11:52
  • Depends how you see it, hehe. On your screen it would be the height, yes, but the width of the input is widened with yscale.
    – Simen
    Jun 8, 2022 at 12:53
  • well, with yscale you scale "height", but as you say ... ;-)
    – Zarko
    Jun 8, 2022 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .