Demo 6.1: Latches

Every circuit in this module so far has had one property in common, and I want to name it before this demonstration removes it. Give the circuit a set of inputs, wait long enough, and the outputs are determined. The same inputs always produce the same outputs. An adder given 5 and 3 produces 8 today and it produced 8 yesterday, and there is nothing else to know.
This demonstration removes that property with two gates.
The circuit here has a stretch of behaviour where the outputs are not a function of the inputs at all. Two identical circuits with identical inputs can show different outputs, and both of them are correct. What separates them is what happened earlier, and a circuit whose present depends on its past is a circuit that remembers.
Analysing a latch for the first time
Section titled “Analysing a latch for the first time”There is a specific difficulty in analysing a latch for the first time, and it helps to know about it in advance.
Look at the cross-coupled pair with both inputs idle and try to work out the outputs. The top gate’s output depends on the bottom gate’s output. The bottom gate’s output depends on the top gate’s output. Neither can be worked out first, and a student who assumes they have missed something will spend a long time looking for it.
Nothing has been missed. The question has no answer from that starting point. So the demonstration opens there, with both outputs drawn as dashed lines with question marks in them, and it does not resolve them until you assert an input. This is a property of the circuit, not a limitation of the drawing.
The way in is a property of the NOR gate you have known since the first week. A NOR gate with a 1 on any input produces 0, whatever its other input is. So assert Set or Reset, and one gate in the loop can be worked out on its own. Once that one is settled the other has both its inputs, and the rest of the loop follows in three steps.
How to use it
Section titled “How to use it”The SR latch starts unknown and stays that way until you assert an input. Then use Step to walk the resolution one gate at a time. Do this at least once, then release the input and watch it hold. The Forget the state button puts it back to unknown so you can start again from a different direction. The toggle at the top switches between the NOR version, whose inputs are active high, and the NAND version, whose inputs are active low.
Gated SR latch is the same two NOR gates with two AND gates in front, so the latch only responds to S and R while the enable is high.
The D latch is the gated latch with an inverter, which removes the input combination that is not allowed. It also carries a timing diagram whose D and enable traces you can draw yourself by clicking on them.
Latches: SR, Gated SR and D
Two gates arguing with each other, and why that counts as remembering something.
Walkthrough
Section titled “Walkthrough”Step 1: Examine the unknown state
Section titled “Step 1: Examine the unknown state”Open the first tab and read the drawing before touching anything. Both inputs are at 0, both outputs are dashed, and both terminals show a question mark.
Try to work out Q. You cannot, and you should satisfy yourself about why rather than taking it on trust: each gate’s output depends on the other’s. This is the first circuit in the module where “wait long enough and read the answer” does not work.
Step 2: Force one gate, then follow the rest
Section titled “Step 2: Force one gate, then follow the rest”Assert Set and press Step three times, reading what each step says.
Step 1 is the important one. The gate with Set on its input produces 0 because it is a NOR gate with a 1 on an input, and that conclusion needs no information about the feedback conductor. That is the starting point. Notice that only one output stops being dashed.
Step 2 is ordinary combinational work. The other gate now has one input from outside and one arriving on the feedback conductor, both known, so its output follows.
Step 3 is the one people skip. Take the second gate’s answer, feed it back into the first gate, and work the first gate out again. It gives the same value it gave before. That is what stable means for a loop, and without checking it you have not shown the circuit will stay where you put it.
Step 3: Take the input away
Section titled “Step 3: Take the input away”Return Set to 0 and watch the outputs.
Both inputs are now idle, as they were in Step 1, and yet the outputs are no longer unknown. Nothing is forcing either gate from outside any more. The top gate’s output is set by the bottom gate’s output, and the bottom gate’s output is set by the top gate’s output. Each holds the other in place.
That feedback loop is the memory. There is no separate storage component: the two gates hold a consistent pair of outputs until an input forces a change. Assert Reset and watch the outputs change, then release it and watch the new state persist.
Step 4: Ask for both at once
Section titled “Step 4: Ask for both at once”Assert Set and Reset together.
Both gates are now forced from outside independently, and neither needs the feedback at all. Both outputs go to 0. Nothing is damaged, and the circuit is stable.
The trouble is what the outputs now mean. The second output is supposed to be the complement of the first, and it is not, so the labels have stopped being true. Anything downstream reading both of them reads an invalid pair. That is why this combination is ruled out: it does not damage the part, but it asks for two contradictory things and produces outputs that cannot be interpreted.
The bigger problem is what happens on release. Release both inputs at the same instant and the latch settles into one state or the other, and which one depends on which of the two gates is slightly faster in that particular part and at that temperature. You cannot design around that. You will see it for yourself when you build one of these in the laboratory, and different benches will not agree.
Step 5: The same circuit with inverted polarity
Section titled “Step 5: The same circuit with inverted polarity”Switch to the NAND version.
It is the same topology with the gate changed. Where the NOR latch is asserted by putting a 1 on an input and idles at 0, the NAND latch is asserted by putting a 0 and idles at 1. Its inputs are active low, and the bars over the names indicate this: a bar means the pin is asserted when it is low.
Now look at which input arrives at the gate that produces Q. In the NOR version it is Reset, because asserting Reset forces that gate to 0 and 0 is what Q should become. In the NAND version it is Set, because asserting Set forces that gate to 1. The wiring had to change because the polarity did.
Active low is common. Most of the parts you will meet use it for at least some of their pins, for the electrical reason met in the decoder demonstration, and mistaking an active-low pin for an active-high one is one of the most common ways to misread a data sheet. Get used to the bar.
Step 6: Add an enable input
Section titled “Step 6: Add an enable input”Open Gated SR latch. Set S to 1 with the enable at 0 and watch the outputs stay as they are.
I want to state the mechanism precisely, because it is not what students usually assume. Disabling the latch does not switch anything off or disconnect anything. With the enable at 0 both AND gates produce 0, and 0 on both inputs of an SR latch is the hold case. So disabling the latch applies the one input combination that means “hold the current state”.
Now raise the enable and watch the pending S take effect immediately. Lower it again and change S and R as much as you like; nothing gets through.
What has not been fixed is the disallowed combination. S and R both high with the enable high still arrives at the latch as both inputs asserted, and it is still not allowed. The enable controls when the latch responds to S and R, not what values they carry.
Step 7: Design the fault out
Section titled “Step 7: Design the fault out”Open The D latch.
The gated latch has a combination that must never be applied, which means every designer who uses one has to remember a rule, and a rule that is only written down can be missed. The D latch removes the possibility instead. One input, called D, goes to Set directly and to Reset through an inverter, so the two can never be asserted together because one of them is always the complement of the other.
This is a general technique. Given a part with a combination that must be avoided, you can write the rule in the documentation, or you can wire the part so the combination cannot occur. The second is more reliable, and it usually costs one gate.
Step 8: Read it over time
Section titled “Step 8: Read it over time”The timing diagram on that tab shows the same latch with time running left to right, and the shaded stretches are where the enable is high.
Look at what Q does inside a shaded stretch. It copies D, following every change D makes for as long as the enable stays high, as though the latch were not in the circuit. That is what transparent means. When the enable returns to 0, Q keeps the value D had at that moment and ignores further changes.
Click on the D and enable traces to draw your own. Try two things. Make D change several times inside one long enable stretch, and watch Q change with it: anything reading Q during that window sees every change, so the stored value is not stable while it is being read. Then make the enable high for one slot only and see that the extra changes disappear.
Notice also that Q is drawn as unknown until the first time the enable goes high. Until then no input has set the latch’s state, which is the same point the first tab opened on.
Check your understanding
Section titled “Check your understanding”A NOR-based SR latch has both inputs at 0 and you are asked what Q is. What is the correct answer?
Working out the state of a cross-coupled NOR pair has to start somewhere. What makes it possible to begin?
Match each situation to what the latch does
A gated SR latch has its enable at 0. Why do S and R have no effect?
Why does a D latch have no combination of inputs that is disallowed?
Wrap-up
Section titled “Wrap-up”Five things to take from this.
- A latch has a set of inputs for which the outputs are not determined. This is the property that makes it useful, and it is what separates this half of the subject from everything before it.
- Two gates in a loop are worked out by finding the one that its own input forces, settling that one, then following the loop round, then checking that going round again changes nothing.
- Holding is not a separate mode. It is the state the circuit stays in when no input forces either gate and each one is kept in place by the other.
- Both inputs asserted is stable but uninterpretable, and how it resolves when you release it is a matter of which gate happens to be faster. Take a note of this for the laboratory.
- Active low is a wiring convention with a bar over the name, and inverting the polarity changes which pin goes where in the drawing.
The D latch solved one of the two problems with an SR latch. It has no contradictory input combination, and it stores a bit.
What it has not solved is the one the timing diagram makes obvious. While the enable is high the latch is transparent, and the value it holds keeps changing for as long as the enable is high. If the rest of the system reads that output during the same period, it reads the input’s value at that instant rather than a settled stored value, and the circuit that writes the latch and the circuit that reads it interfere with each other.
The fix uses the same kind of memory, with much tighter control over when the latch responds to its input, and that is the subject of the next demonstration.
© 2026 Derek Molloy, Dublin City University. All rights reserved.