How do you code the following logic gate diagrams?
My current attempts:
\begin{circuitikz}
%Top OR Gate
\draw
(0,-1)
node[label = left:$A$] {}
to [short]
(1,-1)
node[american or port, anchor = in 1] (or1){}
(or1.in 2)
-- ++(-1,0)
node[label = left:$B$] {}
to[short]
(or1.in 2)
(or1.in 2)
-- ++(-1,0)
(or1.out)
to[short] (2.5,-3)
node[american and port, anchor = in 1] (and1){}
(and1.in 2)
-- ++(-2.5,0)
node[label = left:$C$] {}
(0,-5)
node[label = left:$D$] {}
to [short]
(2.5,-5)
node[american not port, anchor = in 1] (not1){}
(and1.out)
to[short] (4,-4)
node[american or port, anchor = in 1] (or2){}
(and1.in 2)
(not1.out)
to[short] (4, 52 |- or2.in 2)
(or2.out)
-- ++(1,0)
node[label = right:$X$] {}
%labels
(or1.out)
node[label = right:$X_1$] {}
(and1.out)
node[label = right:$X_2$] {}
(xor2.out)
node[label = right:$X_3$] {}
\end{circuitikz}






