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
?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityIs 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
?
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}