3

I don't have any idea how to reproduce this logic circuit (in picture at the end). I know I can use circuitikz package, but it's difficult to align correctly everything.

Is it possible to help me ?

Thanks a lot.

New :

\begin{circuitikz}[label distance=2mm, scale=2]
\node (x3) at (0.5,0) {$a$};
\node (x2) at (1,0) {$b$};
\node (x1) at (1.5,0) {$c$};
\node (x0) at (2,0) {$d$};
\node[or gate US, draw, logic gate inputs=nnn] at ($(x0)+(1,-1)$) (Or1) {};
\node[not gate US, draw, logic gate inputs=n, scale=1.2] at ($(x0)+(1,-1.75)$) (Not1) {};
\node[or gate US, draw, logic gate inputs=nn] at ($(x0)+(1,-2.75)$) (Or2) {};
\node[and gate US, draw, logic gate inputs=nnn] at ($(x0)+(2,-2)$) (And1) {};
\node[not gate US, draw, logic gate inputs=n, scale=1.2] at ($(x0)+(1,-3.5)$) (Not2) {};
\node[or gate US, draw, logic gate inputs=nn] at ($(x0)+(2,-3.65)$) (Or3) {};
\node[or gate US, draw, logic gate inputs=nn] at ($(x0)+(1,-4.5)$) (Or4) {};
\node[and gate US, draw, logic gate inputs=nn] at ($(x0)+(3,-2.75)$) (And2) {};
\node[or gate US, draw, logic gate inputs=nn] at ($(x0)+(4,-2.7)$) (Or5) {};
\node[and gate US, draw, logic gate inputs=nnn] at ($(x0)+(5,-2.65)$) (And3) {};
\draw (x3) |- (Or1.input 1);
\draw (x2) |- (Or1.input 2);
\draw (x1) |- (Or1.input 3);
\draw (x0) |- (Not1.input);
\draw (Not1.output) |- (And1.input 1);
\draw (x2) |- (And1.input 2);
\draw (x1) |- (And1.input 3);
\draw (x2) |- (Or2.input 1);
\draw (x0) |- (Or2.input 2);
\draw (Or2.output) |- (And2.input 1);
\draw (x3) |- (Not2.input);
\draw (Not2.output) |- (Or3.input 1);
\draw (x3) |- (Or3.input 2);
\draw (And1.output) -| (Or5.input 1);
\draw (Or3.output) |- (And2.input 2);
\draw (x3) |- (Or4.input 1);
\draw (x1) |- (Or4.input 2);
\draw (And2.output) -| (Or5.input 2);
\draw (Or1.output) -| (And3.input 1);
\draw (Or5.output) -| (And3.input 2);
\draw (Or4.output) -| (And3.input 3);
\end{circuitikz}

Dominik enter image description here

2
  • 2
    Hi! Could you edit in what you have tried? This makes it easier for people to see where you are stuck and they will be more willing to help. Commented Oct 23, 2016 at 18:49
  • Welcome to TeX.SX! Can you please expand the code snippets that you have posted to a full minimal working example. It is much easier to help you you if we can start with some compilable code that illustrates your problem. A MWE should compile and be as small as possible to demonstrate your problem.
    – user30471
    Commented Oct 24, 2016 at 3:14

2 Answers 2

3

First, you used the wrong names for almost everything (RTFM). Second, the logic gates only have two inputs. To add a third input you have to be creative. Lastly, it is often easier to align gates to the left of the corresponding input ports, although one can also align input ports to the right of output ports using [anchor=in 1] (for example)

I added the text fields just to keep track of which gate was which. Go ahead an remove them when satisfied.

\documentclass{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}[label distance=2mm, scale=2]
\node (x3) at (0.5,0) {$a$};
\node (x2) at (1,0) {$b$};
\node (x1) at (1.5,0) {$c$};
\node (x0) at (2,0) {$d$};
\node[american or port] at ($(x0)+(1,-1)$) (Or1) {a};
\node[american not port] at ($(x0)+(1,-1.65)$) (Not1) {b};
\node[american and port] at ($(x0)+(2.5,-2)$) (And1) {d};
\node[american not port] at ($(x0)+(.9,-3.4)$) (Not2) {e};
\node[american or port] at ($(x0)+(2,-3.65)$) (Or3) {f};
\node[american or port] at ($(x0)+(1,-4.5)$) (Or4) {g};
\node[american or port] at ($(x0)+(4,-2.7)$) (Or5) {i};
\node[american and port] at ($(x0)+(5,-2.7)$) (And3) {j};
\node[american and port, left=1cm] at (Or5.in 2) (And2) {h};
\node[american or port, left=2cm] at (And2.in 1) (Or2) {c};
\draw (x3) |- (Or1.in 1);
\draw (x2) |- ($(Or1.west)!.33!(Or1.center)$);
\draw (x1) |- (Or1.in 2);
\draw (x0) |- (Not1.in);
\draw (Not1.out) |- (And1.in 1);
\draw (x2) |- ($(And1.west)!.16!(And1.center)$);
\draw (x1) |- (And1.in 2);
\draw (x2) |- (Or2.in 1);
\draw (x0) |- (Or2.in 2);
\draw (Or2.out) |- (And2.in 1);
\draw (x3) |- (Not2.in);
\draw (Not2.out) |- (Or3.in 1);
\draw (x3) |- (Or3.in 2);
\draw (And1.out) -| (Or5.in 1);
\draw (Or3.out) |- (And2.in 2);
\draw (x3) |- (Or4.in 1);
\draw (x1) |- (Or4.in 2);
\draw (And2.out) -| (Or5.in 2);
\draw (Or1.out) -| (And3.in 1);
\draw (Or5.out) -| ($(And3.west)!.16!(And3.center)$);
\draw (Or4.out) -| (And3.in 2);
\end{circuitikz}
\end{document}

demo

0
1

This could be another distribution.

It doesn't use circuittikz but circuits library which allows definition of logic gates inputs number.

enter image description here

\documentclass[tikz,border=1mm]{standalone}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usetikzlibrary{positioning,circuits.logic.US,calc}

\begin{document}

\begin{tikzpicture}[%
    circuit logic US,
    tiny circuit symbols,
    every circuit symbol/.style={fill=white, draw},
    node distance=3mm and 0mm,
    branch/.style={fill,shape=circle,minimum size=3pt,inner sep=0pt}]

    \coordinate[label=above:$a$] (a) at (0,0);
    \coordinate[label=above:$b$] (b) at (1,0);
    \coordinate[label=above:$c$] (c) at (1.5,0);
    \coordinate[label=above:$d$] (d) at (2,0);

    \node[not gate, rotate=-90] at ($(a)+(0.5,-.5)$) (Nota) {};
    \node[not gate, rotate=-90] at ($(d)+(0.5,-.5)$) (Notd) {};

    \node[or gate, logic gate inputs=nnn, anchor=north west] at ($(d)+(1.5,-1)$) (Or1) {};
    \node[and gate, logic gate inputs=nnn, below=of Or1]  (And1) {};
    \node[or gate, below=of And1] (Or2) {};
    \node[or gate, below=of Or2] (Or3) {};
    \node[or gate, below=of Or3] (Or4) {};
    \node[and gate] at ($(Or2)!.5!(Or3)+(10mm,0)$) (And2) {};
    \node[or gate, right=6mm of And2, anchor=input 2] (Or5) {};
    \node[and gate, logic gate inputs=nnn, right=6mm of Or5, anchor=input 2]  (And3) {};

    \draw ($(a)+(0,-1mm)$)-|(Nota);
    \draw ($(d)+(0,-1mm)$)-|(Notd);

    \draw (a)|-(Or1.input 1);
    \draw (b)|-(Or1.input 2);
    \draw (c)|-(Or1.input 3);

    \draw (Notd)|-(And1.input 1);
    \draw (b)|-(And1.input 2);
    \draw (c)|-(And1.input 3);

    \draw (b)|-(Or2.input 1);
    \draw (d)|-(Or2.input 2);

    \draw (Nota)|-(Or3.input 1);
    \draw (a)|-(Or3.input 2);

    \draw (a)|-(Or4.input 1);
    \draw (c)|-(Or4.input 2);

    \draw (Or2.output)--++(0:2mm)|-(And2.input 1);
    \draw (Or3.output)--++(0:2mm)|-(And2.input 2);

     \draw (And2.output)--(Or5.input 2);
     \draw (Or5.input 1)--++(180:3mm)|-(And1.output);

     \draw (Or5.output)--(And3.input 2);
     \draw (And3.input 1)--++(180:3mm)|-(Or1.output);
     \draw (And3.input 3)--++(180:3mm)|-(Or4.output);

    \draw (And3)--++(0:1) node[right]{$S$};
\end{tikzpicture}
\end{document} 
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .