11

enter image description here

I've got this so far:

\begin{circuitikz}
\node[flipflop D] (D) at (2,0) {};
\node[flipflop T] (T) at (6,0) {};
\node[flipflop JK] (JK) at (10,0) {};

\draw[SkyBlue] (D.pin 4) -| (3.8,0) |- (T.pin 1);
\draw[SkyBlue] (T.pin 6) -- (JK.pin 1);
\draw[OliveGreen] (D.pin 6) -| (3.5,-1.5) -| (JK.pin 3);

\draw (JK.pin 6) -- ++(1, 0)node[right] {$Q_4$};
\draw (D.pin 1) -- ++(-1, 0)node[left] {D};

\draw (0,-2) node[left] {$clock$} -- (0.5,-2) node[circ] (clk1) {};
\draw (clk1) -- (4,-2) node[circ] (clk2) {};
\draw (clk2) -- (8,-2) |- (JK.pin 2);
\draw (clk1) |- (D.pin 3);
\draw (clk2) |- (T.pin 3);
\end{circuitikz}

enter image description here

How do I add the preset and clear?

ETA: Figured it out:

    \draw (0,-3) node[left] {$clear$} -| (D.bdown)node[ocirc,below]{};
\draw (0,2) node[left] {$preset$} -| (D.bup)node[ocirc,above]{};
2

1 Answer 1

11

You may define a custom flip-flop with preset and clear.

\documentclass{article}

\usepackage{circuitikz}

%---------------------------------------------------
\tikzset{flipflop DMod/.style={flipflop,
    flipflop def={t1=D, t6=Q, t4={\ctikztextnot{Q}},
        tu=pre, nu=1, td=clr, nd=1, c3=1},
}} 
%---------------------------------------------------

\begin{document}

\begin{circuitikz}
\node[flipflop DMod] (D) at (2,0) {};
\node[flipflop T] (T) at (6,0) {};
\node[flipflop JK] (JK) at (10,0) {};

\draw (D.pin 4) -| (3.8,0) |- (T.pin 1);
\draw (T.pin 6) -- (JK.pin 1);
\draw (D.pin 6) -| (3.5,-1.5) -| (JK.pin 3);

\draw (JK.pin 6) -- ++(1, 0)node[right] {$Q_4$};
\draw (D.pin 1) -- ++(-1, 0)node[left] {D};

\draw (0,-2) node[left] {$clock$} -- (0.5,-2) node[circ] (clk1) {};
\draw (clk1) -- (4,-2) node[circ] (clk2) {};
\draw (clk2) -- (8,-2) |- (JK.pin 2);
\draw (clk1) |- (D.pin 3);
\draw (clk2) |- (T.pin 3);

\draw (D.up) |- ++(-2, 0)node[left] {preset}; %--> added
\draw (D.down) |- ++(-2, 0)node[left] {clear}; %--> added
\end{circuitikz}

\end{document}

enter image description here

1
  • 1
    To add to @Imran's excellent answer, I just want to point out that section 3.25 of the manual on page 127 describes what all those nu, td, nd, etc are. 2 pages later, in section 3.25.1, there is a very good example. (Valid for version 1.3.0 of the manual)
    – Bill Nace
    Apr 7 at 2:46

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.