The SR Latch

A latch is a small circuit that can remember one bit. In this lesson you will build the simplest one, the SR latch, from two NOR gates, test it, break it, and then build it again from NAND gates. Every section has a Try it box so you can work the circuit yourself, on a computer or on your phone.

Background reading: this lesson sits alongside two earlier posts. Flip Flops gives the definitions of combinational and sequential circuits and the Stallings reading, and The SR Flip-Flop – Practical Introduction walks through the class demonstration step by step, with a timing diagram.

Why do we need memory?

Every gate you have met so far is combinational: its output depends only on its inputs right now. If you take your finger off the input, the output goes back. You saw this in Truth Tables – An application of abstraction to physical circuits and Logic Gates – Formal Introduction: one row of the truth table for each set of inputs, and nothing else matters.

A computer needs more than that. It has to keep a value after the input has gone: the number you typed, the next instruction to run, the result of a sum. A circuit whose output depends on its inputs and on what it was doing before is called a sequential circuit. The trick that makes it work is feedback: the output of a gate is wired back into the input of another gate.

Build it: two cross-coupled NOR gates

Recall the NOR gate. Its output is 1 only when both inputs are 0. One useful way to remember it: any 1 into a NOR gate forces its output to 0.

ABA NOR B
001
010
100
110

Now take two NOR gates, G1 and G2, and cross-couple them: the output of each one goes into an input of the other. That leaves one free input on each gate. These are the latch inputs, S (Set) and R (Reset). The outputs are Q and Q (read “Q-bar”, sometimes written Q’), which should always be opposites.

  • G1 has inputs R and Q. Its output is Q, so Q = NOR(R, Q).
  • G2 has inputs S and Q. Its output is Q, so Q = NOR(S, Q).

Notice that R goes into the gate that makes Q. That looks back-to-front at first, but it makes sense: R = 1 forces that gate to output 0, and Reset means Q = 0.

The simulator below is the one from The SR Flip-Flop – Practical Introduction. It writes Q as Q’ (Q-prime), which means the same thing. Use the switches (or tap the S and R circles), try Step by step mode to watch one gate at a time, and follow the guided tour of the class scenarios.

Try it 1Play with the SR latch

This is the latch described above: two NOR gates, with the top gate (G1) making Q and the bottom gate (G2) making Q’. Each output is fed back into the other gate. Flip S (Set) and R (Reset) and watch what happens.

Key: wire = 1 (high)   wire = 0 (low)   unknown (?)

SR latch made from two cross-coupled NOR gates G1NOR G2NOR R S 0 1 0 0 R Q’ Q S Q = 0 Q’ = 1 Q Q’ Feedback: Q goes back into G2, Q’ goes back into G1
Mode:
NOR gate reference
ABA NOR BUsed by
001
010
100
110

G1: A = R, B = Q’
G2: A = S, B = Q

What the signals are doing:
    Current state

    Hold

    SR latch truth table (NOR version)
    SRQ (next)Q’ (next)State
    00Q (no change)Q’ (no change)Hold (memory)
    0101Reset
    1010Set
    1100Invalid (forbidden)

    The highlighted row matches the switches right now.

    Guided tour: the class scenarios

    Tip: switch to Step by step mode first, then press Next to watch each gate work in turn.

    Timing diagram

    Every time the switches change, a new time slot is added. Drag the slider (or tap a slot) to move the cursor: the circuit above jumps to that moment.

    How to read a timing diagram
    • Time runs left to right. Each column (t0, t1, t2…) is one moment, one after the other.
    • High means 1, low means 0. When a line is at the top of its row the signal is 1; at the bottom it is 0.
    • Read straight down. Pick one column (or use the cursor) and read down the S, R, Q and Q’ rows to see every signal at that same moment.
    • Edges are changes. A vertical jump in a line is an edge: going up is a 0 → 1 change (rising edge), going down is 1 → 0 (falling edge).
    • Q only changes when S or R tells it to. Look for an S pulse (Q goes high) or an R pulse (Q goes low). When S and R are both 0, Q stays flat: that flat line is the latch’s memory.
    • Normally Q’ is the mirror image of Q. Wherever the two lines are NOT opposites, something is wrong.
    • Spot the invalid region. The red-shaded slot is where S = 1 and R = 1: Q and Q’ are both 0. The amber slot after it is the race when both are released together: the result is unpredictable.
    The SR latch characteristic table

    A NOR gate’s truth table only needs its two inputs. A latch is different: it is a memory element, so what happens next depends on the inputs and on what it is already storing. A characteristic table shows this. It lists S, R and the present state Q(t) (the value of Q before the change) and gives the next state Q+ (the value of Q after the latch settles).

    SRQ(t)Q+ (t+1)Action
    0000Hold
    0011Hold
    0100Reset
    0110Reset
    1001Set
    1011Set
    110XInvalid
    111XInvalid

    • How to read a row: pick the S and R values, then the value Q had before. The Q+ column tells you what Q will be next. For example, the row S = 0, R = 1, Q(t) = 1 says: “Q was 1, we pressed Reset, so Q becomes 0.” The highlighted row follows the switches above (and the timing cursor).
    • Why S = 0, R = 0 gives Q+ = Q: with no Set or Reset signal, each gate is kept where it is by the output fed back from the other gate. So Q+ simply copies Q(t): if it was 1 it stays 1, if it was 0 it stays 0. That is the latch’s memory (Hold).
    • Why S = 1, R = 1 is marked X: both NOR gates are forced to 0, so Q = Q’ = 0, which breaks the rule that Q’ is the opposite of Q. And when both inputs are released together the gates race, so the next Q cannot be predicted. We mark it X (forbidden) and never use it.
    • Where the equation comes from: look at the rows where Q+ = 1. Either S = 1 (Set), or S = 0, R = 0 and Q(t) = 1 (Hold a 1). Ignoring the forbidden rows, Q+ is 1 when “S is 1, OR R is 0 AND Q is 1”. Written in Boolean algebra that is Q+ = S + R’Q, with the rule SR = 0 (S and R are never both 1).

    Q+ = S + R’Q (with SR = 0)

    Quick check

    Challenges

    Use the switches above. Before each press, predict what Q will be, then check! The ticks fill in by themselves.

    • ✓Set the latch (Q = 1), then turn S back to 0 and show that Q remembers 1.
    • ✓Reset the latch (Q = 0), then turn R back to 0 and show that Q remembers 0.
    • ✓Go into the forbidden state (S = 1, R = 1), then press Release S and R together and watch the race. Try it a few times: is Q always the same?

    Challenge question: looking at your timing diagram, can you find a time slot where S = 0 and R = 0 but Q = 1? Explain why that can happen.

    Things to try in the box above:

    1. Make S = 1, then put it back to 0. Q stays 1 even though S is back to 0. That is memory.
    2. Now make R = 1, then put it back to 0. Q stays 0.
    3. With S = 0 and R = 0, the latch can be showing Q = 0 or Q = 1. The inputs are the same, so the only thing deciding the output is what happened before.

    Predict, then test

    Here is the full behaviour of the NOR latch. "Q (next)" means the value of Q after the gates have settled.

    SRQ (next)Q (next)What it does
    00Q (no change)Q (no change)Hold (memory)
    0101Reset
    1010Set
    1100Forbidden (not allowed)

    Do not just learn the table. Work out each row from the NOR rule. In the box below you are given a stored value and a pair of inputs. Make a prediction first, then check it.

    Try it 2Predict, then test

    Read the scenario. Choose what you think Q and Q̄ will be, then press Check. Each answer fills in a row of the truth table below.

    Q will be:
    Q̄ will be:

    Your truth table (NOR latch)

    SRQ (next)Q̄ (next)
    00??
    01??
    10??
    11??

    Hint: start with whichever gate has a 1 on its external input. That gate must output 0. Then use that 0 to work out the other gate.

    The forbidden state: S = 1 and R = 1

    What happens when S = 1 and R = 1? Each gate has a 1 on its input, so both gates output 0: Q = 0 and Q = 0. That breaks the rule that Q is the opposite of Q, which is the first problem.

    The second problem is worse. Suppose S and R both go back to 0 at exactly the same moment:

    1. Each gate now sees 0 and 0, so both try to output 1.
    2. Then each gate sees a 1 coming back from the other, so both try to output 0.
    3. The outputs can flicker like this, and the latch settles only when one gate happens to be a little faster than the other. This is called a race condition.
    4. Which gate wins depends on tiny differences in the real components, so the final value of Q cannot be predicted.

    If the two inputs are let go one at a time, the result is predictable: whichever input is still 1 at the end wins. That is why designers simply say S = 1, R = 1 is not allowed for an SR latch. Try it 1 lets you release both together. The lab below lets you compare all three ways of letting go, and keeps count:

    Try it 3The forbidden state lab

    Step 1: put the latch into S = 1, R = 1. Step 2: choose how to let go. Do it several times and watch the tally.

    Now: S = 0, R = 0
    Q
    Q̄

      Tally of final Q values

      How you let goQ ended 0Q ended 1
      Both together00
      R first, then S00
      S first, then R00

      About this simulator: real gates are never exactly the same speed, but we cannot know which one is faster. The simulator stands in for that with a coin toss, which is why "both together" gives a different answer from run to run.

      The NAND version (active-low inputs)

      You can also build a latch from two NAND gates. The NAND rule is the mirror image of the NOR rule: any 0 into a NAND gate forces its output to 1. So in a NAND latch it is a 0 on an input that does the work. We say the inputs are active-low, and we write them with a bar: S and R.

      • G1 has inputs S and Q. Its output is Q, so Q = NAND(S, Q).
      • G2 has inputs R and Q. Its output is Q, so Q = NAND(R, Q).
      SRQ (next)Q (next)What it does
      11Q (no change)Q (no change)Hold (memory)
      0110Set
      1001Reset
      0011Forbidden (not allowed)

      Compare this with the NOR latch. The resting inputs are now 1 and 1, not 0 and 0. The forbidden inputs are 0 and 0, and they make both outputs 1 (not 0). Also, the Set input goes into the gate that makes Q, which is the opposite of the NOR latch.

      The simulator below works just like Try it 1, but with NAND gates. It writes the inputs as S’ and R’ (S-bar and R-bar). First choose the wiring, then test whether your Set input really sets.

      Try it 4Wire and test the NAND latch

      The same simulator, now built from two NAND gates. The inputs are active-low: S’ (read "S-bar") and R’ ("R-bar") rest at 1 and do their job when you pull them down to 0.

      Step 1: wire it. Choose which input goes into G1, the top gate whose output is Q. Step 2: test it. Pulse each input (switch it to 0 and back to 1), or press Test my wiring.

      Into G1 (makes Q):

      Key: wire = 1 (high)   wire = 0 (low)

      SR latch made from two cross-coupled NAND gates G1NAND G2NAND S’ R’ 1 1 0 1 S’ Q’ Q R’ Q = 0 Q’ = 1 Q Q’ Feedback: Q goes back into G2, Q’ goes back into G1
      Mode:
      NAND gate reference
      ABA NAND BUsed by
      001
      011
      101
      110

      G1: A = S’, B = Q’
      G2: A = R’, B = Q

      What the signals are doing:
        Current state

        Hold

        SR latch truth table (NAND version)
        S’R’Q (next)Q’ (next)State
        11Q (no change)Q’ (no change)Hold (memory)
        0110Set
        1001Reset
        0011Invalid (forbidden)

        The highlighted row matches the switches right now (with the correct wiring).

        Timing diagram

        Every time the switches change, a new time slot is added. Drag the slider (or tap a slot) to move the cursor: the circuit above jumps to that moment.

        Where it leads

        The SR latch is the starting point for nearly every memory circuit in a computer. These are the ideas that come next in this course (posts to follow):

        • Gated latches and the D (Data) flip-flop. An extra input, usually a clock or enable signal, decides when the latch is allowed to change. The D flip-flop also has a single data input D, so S and R can never both be 1 and the forbidden state cannot happen.
        • The JK flip-flop. It is built so that the input combination J = 1, K = 1 is useful instead of forbidden: the output toggles (changes to the opposite value).
        • Registers. A register is a group of flip-flops, one for each bit, that store a binary word together. An 8-bit register uses 8 flip-flops.
        • Counters. Flip-flops connected in a chain can count. See The Ripple Counter Explained (Animation), which uses clocked JK flip-flops.
        • Memory. Thousands or millions of 1-bit storage cells arranged in rows and columns give you memory that the processor can read and write.

        The same idea in C: a variable holds a value

        When you write C programs you use the same idea all the time. A variable keeps its value until your program changes it, just as a latch keeps Q until S or R changes it. (If you have not met variables in C yet, see Variables and Format Specifiers: Printing Values with %d and Adding 2 numbers – Declaring integer variables, Watching Variables.)

        #include <stdio.h>
        
        int main()
        {
            int q = 0;          /* like a latch that starts reset   */
        
            q = 1;              /* like a pulse on S: set q to 1    */
                                /* nothing else changes q here...   */
        
            printf("%d\n", q);  /* ...so it still prints 1 (hold)   */
            return 0;
        }
        

        The comparison is only a picture to help you remember. The C language does not tell you what kind of circuit stores q. What you can say is that each bit of a stored value has to be kept by some storage element, and a latch is the simplest example of one.

        Review questions

        Try it 5Review questions

        Tap an answer. You get feedback straight away, and you can try again, but only your first try counts towards the score.

        Now try these in your notebook before you open the answers.

        1. Explain the difference between a combinational circuit and a sequential circuit. Give one example of each.

        Show answer

        In a combinational circuit the output depends only on the present inputs (for example a single AND gate). In a sequential circuit the output depends on the present inputs and on the previous output (for example an SR latch or a flip-flop).

        2. What does "cross-coupled" mean, and why is it needed for memory?

        Show answer

        The output of each gate is fed back into an input of the other gate. This feedback lets the circuit keep its output when the inputs return to their resting values, so it can store a bit.

        3. Write Boolean expressions for Q and Q in the NOR latch.

        Show answer

        Q = NOR(R, Q) = NOT(R OR Q). Q = NOR(S, Q) = NOT(S OR Q).

        4. A NOR latch starts with Q = 0. The inputs then go through these values in order: (S, R) = (1, 0), (0, 0), (0, 1), (0, 0). Write down Q after each step.

        Show answer

        1 (set), 1 (hold), 0 (reset), 0 (hold).

        5. A flip-flop is often called a storage element. Give two features of a flip-flop that explain why.

        Show answer

        For example: it always settles in one of two stable states (it is bistable), so each state can stand for 0 or 1; it keeps that state after the input that set it is removed, so the bit is remembered. That is why flip-flops are used to build registers, memory cells and counters.

        6. A CPU has 16-bit registers. How many flip-flops does one register need, and why?

        Show answer

        16. Each flip-flop stores one bit, so a 16-bit register is a group of 16 flip-flops that hold the 16 bits of a word side by side and are loaded together.

        Self-check: S = 1, R = 1 and the NAND wiring

        7. For a NOR latch, describe what happens to Q and Q when S = 1 and R = 1, and then what happens when (a) both inputs return to 0 at the same time, (b) R returns to 0 before S.

        Show answer

        With S = 1 and R = 1 both NOR gates output 0, so Q = 0 and Q = 0 (they are no longer opposites). (a) Both gates try to switch to 1 at the same moment and race; the final Q could be 0 or 1 and cannot be predicted. (b) With S still 1 and R = 0 the latch is set (Q = 1), and when S returns to 0 it holds Q = 1.

        8. Describe how to draw an SR latch using NAND gates. Label every input and output.

        Show answer

        Draw two NAND gates. The top gate has inputs S and Q and its output is Q. The bottom gate has inputs R and Q and its output is Q. Draw the two feedback wires: Q goes back into the bottom gate and Q goes back into the top gate. Mark the inputs as active-low (S and R): 1 and 1 holds, S = 0 sets, R = 0 resets, and 0 and 0 is forbidden (Q = Q = 1).

        Homework

        1. Explain, using the NOR truth table, what happens for each output of the SR latch when S = 1 and R = 1. Then explain what can happen when both inputs return to 0.
        2. Draw an SR latch using NAND gates. Label the inputs (active-low) and both outputs, and write its truth table underneath.

        The half adder (circuit and truth table) has its own lesson later in this course.

        Mastery quiz: SR Latch

        Your course badges: loading saved progress…

        View badges

          No course badges earned yet. Score 8/10 in a lesson quiz to earn its badge.

          Saved in this browser on this device. Clearing browser data may remove your badges.

          Answer all 10 questions. Earn this lesson’s badge at 8/10 or higher. Read the explanations, revisit the Try it activities and retry as often as you need. These are self-study badges, not formal grades.

          1. What allows an SR latch to remember a bit after a Set pulse ends?
          2. For a NOR SR latch, S = 1 and R = 0. What is Q after settling?
          3. A NOR SR latch stores Q = 1. Both S and R are now 0. What happens?
          4. For a NOR SR latch, S = 0 and R = 1. Which output pair is correct?
          5. Why is S = 1, R = 1 forbidden in the NOR SR latch?
          6. After the forbidden NOR state, S and R are released together. What should you conclude?
          7. A correctly wired NAND SR latch has active-low inputs S-bar = 1 and R-bar = 1. What is its action?
          8. For that NAND latch, S-bar = 0 and R-bar = 1. What happens?
          9. Which input combination is forbidden for the active-low NAND SR latch?
          10. How does a sequential circuit differ from a combinational circuit?

          Exam tips

          • Specimen Unit 1 Paper 01 (2021), Item 11. A multiple-choice item about what flip-flops are and what they are used for (syllabus reference 1.3, Module 1). It tests whether you know that a flip-flop is bistable and stores one bit, and how flip-flops are used inside the CPU. When an item asks which statements are true, judge each statement on its own first: one false statement rules out every option that contains it. Open the specimen paper and try the item before you check the answer key.
          • 2013 Unit 1 Paper 02, Question 1(a)(iii). This part is about the characteristics of a flip-flop. It tests whether you can say, in a few short sentences, how a flip-flop behaves and what it is used for. Give each characteristic as its own sentence (two stable states, keeps its state so it stores a bit) and add a use, such as memory or counters. Try the question yourself first, then compare with the solution on this site: 2013 U1 Q1.
          • 2009 Unit 1 Paper 02, Question 1. This question has no latch part, but it brings together gate truth tables, building one gate from others, a multiplexer and binary numbers in one long question. It shows that the building blocks are examined together, so you need the gate truth tables you use to explain a latch at your fingertips. Try it, then check the solution on this site: 2009 U1 Q1.
          • More worked answers are on the CS Solutions page.

          General advice for latch questions (from the lesson content, not from a particular paper): always give both outputs, Q and Q; say which input combination is forbidden and why; for a NAND latch say clearly that the inputs are active-low; and label every wire on a diagram.

          Previous: Logic Gates – Formal Introduction. Background: Flip Flops and The SR Flip-Flop – Practical Introduction. Next: D and JK flip-flops (coming soon in this course).

          Syllabus link: CAPE Computer Science (CXC A19/U2/21), Unit 1, Module 1: Computer Architecture. Specific Objective 2: describe the basic building blocks of a computer (flip flops: Data, JK and SR; registers; counters). Specific Objective 3: interpret the interaction among the basic building blocks of a computer (Data flip flops, registers).

          Updates

          7 Nov 2026: Added the shared course badge summary and lesson mastery quiz, with feedback, retries and browser-saved progress.

          26 Oct 2026

          - Draft created.

          27 Oct 2026

          - Reused the original SR flip-flop simulator for the Try-it circuits.

          28 Oct 2026

          - Exam references reworded and quiz questions rewritten.

          © 2026 Vedesh Kungebeharry. All rights reserved.

          Leave a Reply