# Drawing custom logic gates with circuitikz or circuits.logic library

Is it possible to draw custom logic gates like the following one using circuitikz?

Alternatively, is it possible to draw them easily with the circuits.logic library in tikz?

• Is it a one-off or do you plan to use it a lot? For a one-off, you could just draw it using tikz (circuitikz is built on top of tikz). – John Kormylo Jun 2 '15 at 13:05
• @JohnKormylo I might not use this particular one often, but I need to use other designs, like flip flops, quite often. – Aakash Jog Jun 2 '15 at 14:05
• You can find a flip-flop shape in TeXample.net – Ignasi Jun 2 '15 at 14:38

Here you have a possible solution. It uses a trapezium shape as reference to draw the ALU.

\documentclass[tikz,border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, positioning, calc}

\begin{document}
\begin{tikzpicture}[%
alu/.style={trapezium,
trapezium angle=30,
shape border rotate=180,
minimum width=4cm,
minimum height=3cm,
trapezium stretches=true,
append after command={%
\pgfextra
\draw (\tikzlastnode.top left corner) --
(\tikzlastnode.top right corner) --
(\tikzlastnode.bottom right corner) --
($(\tikzlastnode.bottom right corner)!.666!(\tikzlastnode.bottom side)$)--
([yshift=-8mm]\tikzlastnode.bottom side)--
($(\tikzlastnode.bottom side)!.334!(\tikzlastnode.bottom left corner)$)--
(\tikzlastnode.bottom left corner)--
(\tikzlastnode.top left corner);
\endpgfextra}},
]

\node[alu] (alu) {ADDER($n$)};
\draw (alu.south) -- ++(-90:5mm) node [below] (out) {$S[n-1:0]$};
\draw (alu.20) -- ++(0:5mm) node [right] {$C[0]$};
\draw (alu.50) -- ++(90:5mm) node [above] {$B[n-1:0]$};
\draw (alu.130) -- ++(90:5mm) node [above] {$A[n-1:0]$};
\draw (alu.130) -- ++(90:5mm) node [above] {$A[n-1:0]$};
\node[left=8mm of out] (carry) {$C[n]$};
\draw (carry) |- (alu.200);
\end{tikzpicture}
\end{document}