3

simply doing it this way results in an unreadable mess, as you can see in the picture following it, I want to know if there's a better way of doing it without changing the pin order of the XNN components.

\documentclass{article}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}

% Define positions for the w, x, y, z labels
\node (label_w) at (-4, 1.5) {$w$};
\node (label_x) at (-4, 0.5) {$x$};
\node (label_y) at (-4, -0.5) {$y$};
\node (label_z) at (-4, -1.5) {$z$};

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](A) at (0,2) {\rotatebox{0}{\small \ttfamily XNN}}; 
\node[above] at (A.lpin 1) {$x$}; 
\node[above] at (A.lpin 2) {$y$}; 
\node[above] at (A.lpin 3) {$z$}; 
\node[above] at (A.lpin 4) {$w$}; 

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](B) at (0,-2) {\rotatebox{0}{\small \ttfamily XNN}}; 
\node[above] at (B.lpin 1) {$z$}; 
\node[above] at (B.lpin 2) {$w$}; 
\node[above] at (B.lpin 3) {$x$}; 
\node[above] at (B.lpin 4) {$y$};

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](C) at (5,0) {\rotatebox{0}{\small \ttfamily XNN}}; 
\node[left] at (C.lpin 1) {\scriptsize XNN$\left(x,y,z,w\right)$}; 
\node[left] at (C.lpin 2) {\scriptsize XNN$\left(z,w,x,y\right)$}; 
\node[above] at (C.lpin 3) {$0$}; 
\node[above] at (C.lpin 4) {$0$};
\node[above] at (C.rpin 1) {$F$};

\begin{scope}
\draw[draw opacity=0.4] (A.rpin 1) -| ([xshift=-1cm]C.lpin 1) |- (C.lpin 1);
\draw[draw opacity=0.4] (B.rpin 1) -| ([xshift=-1cm]C.lpin 2) |- (C.lpin 2); 
\end{scope}

% Wire from labels w,x,y,z to A and B pin's
\draw (label_w) -- ++(0.5,0) |- (A.lpin 4);
\draw (label_w) -- ++(0.5,0) |- (B.lpin 2);

\draw (label_x) -- ++(0.75,0) |- (A.lpin 1);
\draw (label_x) -- ++(0.75,0) |- (B.lpin 3);

\draw (label_y) -- ++(1,0) |- (A.lpin 2);
\draw (label_y) -- ++(1,0) |- (B.lpin 4);

\draw (label_z) -- ++(1.5,0) |- (A.lpin 3);
\draw (label_z) -- ++(1.5,0) |- (B.lpin 1);

\end{circuitikz}
\end{document}

enter image description here

1

1 Answer 1

7

One of the most used solutions in similar situations is to use a kind of "vertical bus" for the inputs.

\documentclass{article}
\usepackage{circuitikz}

\begin{document}
\begin{circuitikz}

% Define positions for the w, x, y, z labels
\node[anchor=base] (label_w) at (-4, 4) {$w$};
\node[anchor=base] (label_x) at (-3.5, 4) {$x$};
\node[anchor=base] (label_y) at (-3, 4) {$y$};
\node[anchor=base] (label_z) at (-2.5, 4) {$z$};

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](A) at (0,2) {\rotatebox{0}{\small \ttfamily XNN}};
\node[above] at (A.lpin 1) {$x$};
\node[above] at (A.lpin 2) {$y$};
\node[above] at (A.lpin 3) {$z$};
\node[above] at (A.lpin 4) {$w$};

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](B) at (0,-2) {\rotatebox{0}{\small \ttfamily XNN}};
\node[above] at (B.lpin 1) {$z$};
\node[above] at (B.lpin 2) {$w$};
\node[above] at (B.lpin 3) {$x$};
\node[above] at (B.lpin 4) {$y$};

\node [muxdemux,   muxdemux def={NL=4, NR=1, NB=0, w=3, square pins=0, Lh=6, Rh=6}, rotate=0](C) at (5,0) {\rotatebox{0}{\small \ttfamily XNN}};
\node[below left] at (C.lpin 1) {\scriptsize XNN$\left(x,y,z,w\right)$};
\node[above left] at (C.lpin 2) {\scriptsize XNN$\left(z,w,x,y\right)$};
\node[above] at (C.lpin 3) {$0$};
\node[above] at (C.lpin 4) {$0$};
\node[above] at (C.rpin 1) {$F$};

\begin{scope}
\draw[draw opacity=0.4] (A.rpin 1) -| ([xshift=-1cm]C.lpin 1) |- (C.lpin 1);
\draw[draw opacity=0.4] (B.rpin 1) -| ([xshift=-1cm]C.lpin 2) |- (C.lpin 2);
\end{scope}

% Wire from labels w,x,y,z to A and B pin's
\draw (label_w)  |- (A.lpin 4);
\draw (label_w)  |- (B.lpin 2);

\draw (label_x)  |- (A.lpin 1);
\draw (label_x)  |- (B.lpin 3);

\draw (label_y)  |- (A.lpin 2);
\draw (label_y)  |- (B.lpin 4);

\draw (label_z)  |- (A.lpin 3);
\draw (label_z)  |- (B.lpin 1);

\end{circuitikz}
\end{document}

enter image description here

It could be improved — now the connecting wires are re-drawn above the existing ones, and you must take care that this does not change the meaning of the connections, but I think this is a general idea.

2
  • this looks almost perfect! Do you know how I can add dots to represent intersections and small jumpers to represent lines that don't intersect?
    – Nate3384
    Commented May 29 at 18:33
  • dots are easy, just add a node[circ]{} at the coordinates of the intersection. Jumps are more complex (but if you use dots, do not use jumps --- that's the standard and jumps are distracting in that case). Look at the manual, section 4.10, "Crossings" for discussion, elements and examples.
    – Rmano
    Commented May 29 at 19:58

You must log in to answer this question.

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