2

I want to duplicate this circuit in latex.

enter image description here

So far I have gotten this. I cannot seem to align the lines. Also how do I make the gates border bold?

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Madrid}
\usepackage[american]{circuitikz}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,calc}

\begin{document}
\maketitle

\begin{frame}{Frame Title}
    \begin{tikzpicture}

        \node(J) at (1,0) {$J$};
        \node[nand gate US,draw,logic gate inputs = nnn] at ($(J)+(2,0)$) (Nand1){};

        \node(K) at ($(J)+(0,-2)$) {$K$};
        \node[nand gate US, draw, logic gate inputs = nnn] at ($(K)+(2,0)$) (Nand2) {};

        \node[nand gate US, draw, logic gate inputs = nnn] at ($(Nand1)+(3,0)$) (Nand3) {};
        \node[nand gate US, draw, logic gate inputs = nnn] at ($(Nand2)+(3,0)$) (Nand4) {};

        \draw(J) |- (Nand1.input 2);
        \draw(K) |- (Nand2.input 2);

        \draw(Nand1.output) |- (Nand3.input 2);
        \draw(Nand2.output) |- (Nand4.input 2);

        \draw (Nand3.output) -- ([xshift=2cm]Nand3.output) node[above] {$Q_n$};
        \draw([xshift=1.5cm]Nand3.output) |- ([yshift=-0.5cm]Nand2.input 3) |- (Nand2.input 3);

        \draw (Nand4.output) -- ([xshift=2cm]Nand4.output) node[above] {$\overline{Q_n}$};
        \draw ([xshift=1cm]Nand4.output) |-([yshift=0.5cm]Nand1.input 1);

        \draw ([xshift=0.5cm]Nand3.output) |- ([yshift=0.5cm]Nand4.input 1);
        \draw ([xshift=0.5cm]Nand4.output) |- (Nand3.input 1);


    \end{tikzpicture}
\end{frame}

\end{document}

enter image description here

3

Try to understand this code. I've used 'positioninglibrary instead ofcalc`, and declared some auxiliary coordinates to help on drawing connections.

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Madrid}
\usepackage[american]{circuitikz}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes.gates.logic.US,shapes.gates.logic.IEC,positioning}

\begin{document}
\maketitle

\begin{frame}{Frame Title}
    \begin{tikzpicture}

        \node(J) at (1,0) {$J$};
        \node[nand gate US, draw, logic gate inputs = nnn, thick, right=2cm of J] (Nand1){};


        \node[below= 2cm of J] (K) {$K$};
        \node[nand gate US, draw, logic gate inputs = nnn, thick, right=2cm of K] (Nand2) {};

         \path (J) -- (K) node[midway] (CLK) {$CLK$};

        \node[nand gate US, draw, logic gate inputs = nnn, thick, right=2cm of Nand1, anchor=input 1] (Nand3) {};
        \node[nand gate US, draw, logic gate inputs = nnn, thick, right=2cm of Nand2, anchor=input 3] (Nand4) {};

         \draw(J) -- (Nand1.input 2);
        \draw(K) -- (Nand2.input 2);
         \draw (Nand1.input 3) --++(180:5mm) coordinate (aux) |- (CLK);
         \draw (CLK-|aux)|- (Nand2.input 1);

        \draw(Nand1.output) -- (Nand3.input 1);
        \draw(Nand2.output) -- (Nand4.input 3);

        \draw (Nand3.output) --++(0:2cm) node[right] {$Q_n$} coordinate[pos=.25] (aux1) coordinate[pos=.5] (aux2);

        \draw (Nand4.output) --++(0:2cm) node[right] {$\overline{Q_n}$} coordinate[pos=.25] (aux3) coordinate[pos=.75] (aux4);

        \draw (Nand2.input 3)--(Nand2.input 3-|aux)--++(-90:5mm)-|(aux2);
        \draw (Nand1.input 1)--(Nand1.input 1-|aux)--++(90:5mm)-|(aux4);

        \draw (Nand3.input 3)--++(180:5mm)--++(-90:3mm)--([yshift=3mm]aux3)--(aux3);
        \draw (Nand4.input 1)--++(180:5mm)--++(90:3mm)--([yshift=-3mm]aux1)--(aux1);
     \foreach \i in {CLK-|aux,aux1,aux2,aux3,aux4}
        \filldraw (\i) circle (1.5pt);

    \end{tikzpicture}
\end{frame}

\end{document}

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.