8

How can I draw a multiplexer 8 to 1 with tikz or circuitikz? A hand-drawn example is shown below.

mux-8-1

ChrisS
  • 13,529
sr_x
  • 81

2 Answers2

9

With TiKz:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
\begin{tikzpicture}
\draw (0,0)coordinate (O)--++(30:1)coordinate (A)--++(90:4)coordinate (B)--++(150:1)coordinate (C)--cycle;
\draw ($(A)!0.5!(B)$)--++(0:1)node[right]{$F$};
\draw ($(O)!0.5!(A)$)--++(-90:1)--++(180:2)node[left]{$b$};
\draw ($(O)!0.25!(A)$)--++(-90:0.5)--++(180:1.75)node[left]{$a$};
\draw ($(O)!0.75!(A)$)--++(-90:1.5)--++(180:2.25)node[left]{$c$};
\foreach \y/\t in {0.1/1,0.2/2,0.3/3,0.4/4,0.5/5,0.6/6,0.7/7,0.8/8} {
\draw ($(C)! \y*1.1 !(O)$)--++(180:1) node[left] {$X \t$};}
\end{tikzpicture}

\end{document}

enter image description here

  • how can I use this as a reusable fillable shape? e.g. instead of rectangle or circle? – Jason S May 13 '15 at 17:21
  • @JasonS, if I understood right you, use \filldraw instead of \draw ,e.g. \filldraw [color=](0,0)coordinate (O)... –  May 14 '15 at 16:59
  • no, it was more of how to save it as a shape and just be able to do \node [mux, draw](A){};. But I found trapezium so I'm all set. – Jason S May 16 '15 at 23:39
  • Maybe this help: http://tex.stackexchange.com/a/75516/31034 –  May 17 '15 at 09:33
7

The circuits.logic.IEC library offers an and gate that gives you as many input anchors as required:

\documentclass{article}
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.IEC,calc}

\begin{document}

\begin{circuitikz}[circuit logic IEC] 
\node[and gate,inputs={nnnnnnnn},and gate IEC symbol={},text height=3cm,
] (A) {};
\foreach \Valor in {1,...,8}
{
  \draw  ([xshift=-10pt]A.input \Valor) node[left] {$I_{\Valor}$} -- (A.input \Valor);
}
\draw (A.output) -- ++(10pt,0) node[right] {$F$};
\draw ( $ (A.south west)!0.25!(A.south east) $ ) -- ++(-90:0.25) |- ++(-10pt,0) node[left] {$a$};
\draw (A.south) -- ++(-90:0.5) |- ++(-15pt,0) node[left] {$b$};
\draw ( $ (A.south west)!0.75!(A.south east) $ ) -- ++(-90:0.75) |- ++(-20pt,0) node[left] {$c$};
\end{circuitikz}

\end{document}

enter image description here

Gonzalo Medina
  • 505,128