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?

  • 1
    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.

\usetikzlibrary{shapes.geometric, positioning, calc}

            trapezium angle=30,
            shape border rotate=180,
            minimum width=4cm,
            minimum height=3cm,
            trapezium stretches=true,
            append after command={%
                        \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);

\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);

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.