Sharing is caring

Draw SR Flip Flop with CircuiTikZ

  • In this post, we will learn how to draw SR flip flop in LaTeX using CircuiTikZ package. The SR flip flop circuit of two AND logic gates and two NOR logic gates connected as shown in the illustration below. We will learn how to access inputs and outputs of logic gates and align outputs with inputs of two connected logic gates.
SR Flip Flop circuitikz latex

Short description

  • The SR flip flop circuit consists of the following elements: 2 AND port and 2 NOR logic gates. These gates correspond to IEEESTD styles which are provide by the CircuiTikZ package. We need to align the output of the top AND logic gate with the first input of the NOR logic gate which can be achieved by specifying anchors of each logic gate. Check the below code !   

LaTeX code of the SR Flip Flop


% Package with American Style


% AND logic gates
\node[ieeestd and port, fill=yellow] (and1) at (0,2) {};
\node[ieeestd and port, fill=yellow] (and2) at (0,-2) {};

% NOR logic gates
\draw (and1.out) -- ++(2.5,0) node[ieeestd nor port, fill=cyan,anchor=in 1] (nor1) {};
\draw (and2.out) -- ++(2.5,0) node[ieeestd nor port, fill=cyan,anchor=in 2] (nor2) {};

\draw (nor1.in 2) -| ++ (-0.2,-0.85) -- ++(3,-1.5) coordinate(a) |- (nor2.out);
\draw (nor2.in 1) -| ++ (-0.2,0.85) -- ++(3,1.5) |- (nor1.out);

% Labels
\draw (and1.in 1) -- ++(-0.75,0) node[left]{R};
\draw (and2.in 2) -- ++(-0.75,0) node[left]{S};
\draw (and1.in 2) -- (and2.in 1)node[midway](clk){};
\draw (clk.center) -- ++(-0.75,0) node[left]{Clk};

\draw (nor1.out -| a) -- ++(0.75,0) node[right]{Q(t)};
\draw (nor2.out -| a) -- ++(0.75,0) node[right]{Q(t)$^{'}$};

  • If you would to write a detailed tutorial about it, leave me a comment below or reach me via e-mail at admin@latexdraw.com, I will be happy to hear from you!

Leave a Comment: