Here's one way to do it
\documentclass{article}
\usepackage{tikz}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}
% Gates
\node[and port] (and1) at (0, 0) {};
\node[and port] (and2) at (0, -2) {};
\node[not port, scale=0.5] (not) at ($(and2.in 2) - (2, 0)$) {};
\node[or port] (or) at (4, -1) {};
% Circuit inputs
\node (in1) at ($(and1.in 1) - (3, 0)$) {};
\node (in2) at ($(and1.in 2) - (3, 0)$) {};
\node (in3) at ($(and2.in 1) - (3, 0)$) {};
\node (in4) at ($(and2.in 2) - (3, 0)$) {};
% Input wires
\draw (in1) -- (and1.in 1);
\draw (in2) -- (and1.in 2);
\draw (in3) -- (and2.in 1);
\draw (in4) -- (not.in);
\draw (not.out) -- (and2.in 2) node[midway, below] {\(z'\)};
% Input labels
\node at (in1) {\(x\)};
\node at (in2) {\(y\)};
\node at (in3) {\(y\)};
\node at (in4) {\(z\)};
% Output wires from first round of gates
\draw (and1.out) -- ++ (1, 0) |- (or.in 1) node[midway, above right] {\(xy\)};
\draw (and2.out) -- ++ (1, 0) |- (or.in 2) node[midway, below right] {\(yz'\)};
% Final output
\draw (or.out) -- ++ (1, 0) node[right] {\(xy + yz'\)};
\end{circuitikz}
\end{document}
This makes use of |-
which, along with -|
allow you to project out a single coordinate. That is (A |- B)
has the same x
coordinate as the node (A)
and the same y
coordinate as the node (B)
.
Similarly (A -| B)
has the same x
coordinate as (B)
and the same y
coordinate as (A)
.