CSE 2317 W4 · Class 1 Latches: circuits that remember
Sakeef Sani ↗ ↓ PDF

CSE 2317Week 4Class 1Saturday · 11:00 AM – 12:20 PM80 min

Latches: circuits that remember

Every gate so far forgets its inputs the moment they change. Today we close a loop, and two gates start to remember.

S present · L lecturer notes · → next step · F full screen · P presenter window
01 Cold open 0–4 min

The lift button that stays lit

Press the call button of a lift and take your finger off. The light stays on until the lift arrives.

Every circuit we have built so far (DRL, DTL, TTL, CMOS gates) is combinational: its output depends only on its inputs right now. Remove your finger, and the output forgets.

Today's question: what is the smallest circuit that remembers one bit?

Pop culture

Every bit of cache memory in your phone's processor is a 6-transistor cell: two cross-coupled CMOS inverters plus two access switches. Billions of today's latch, on one chip.

02 Concept 4–8 min

Feedback: the one idea behind all memory

  • Combinational: output = f(present inputs). Sequential: output = f(present inputs, stored state).
  • Two inverters in a ring: if v₁ is high, v₂ is low, which keeps v₁ high. Two self-consistent states, Q = 0 and Q = 1: a bistable circuit.
  • There is a third consistent point, v₁ = v₂ = VM, but it is unstable: any imbalance is amplified round the loop (gain A > 1) until the circuit falls into one of the two stable states.
  • A loop of inverters can hold a bit but has no way to be told a new one. Replace the inverters by NOR (or NAND) gates and the spare inputs become Set and Reset.
v₂ (Q̄)v₁ (Q)
Pro tip

Gain is the whole story: the loop is bistable only if the inverters amplify (|slope| > 1 near VM). Two resistors in a ring remember nothing.

03 Live lab 8–13 min

Live lab: the hilltop and the two valleys

Two inverters in a loop: two valleys and a hilltop Release the loop slightly off balance. The smaller the imbalance, the longer it hesitates on the hilltop.
012345012345stablestablemetastablev₁ (V)v₂ (V)
v₂ = f(v₁)v₁ = f(v₂)
Q = 0Q = 1top: v₁ = v₂ = 2.5 V
0123450123456time (units of τ)V
Loop gain A6.9
Settles in—
Theory0.50 τ
04 Worked example 13–20 min

Worked example: a transistor latch

Given

The fixed-bias binary in the figure. VCC = 12 V, VBB = 12 V, RC = 2.2 kΩ, R1 = 15 kΩ (collector to the other base), R2 = 100 kΩ (base to −VBB), hFE(min) = 30, VBE(sat) = 0.7 V, VCE(sat) = 0.2 V.

Find

Show that the state Q1 ON, Q2 OFF is self-consistent. Find VB2, VC2, IB1, IC1 and check that Q1 saturates.

+VCC= 12 V−VBB= −12 VRC 2.2kRC 2.2kQ1Q2R1 15kR1 15kR2 100kR2 100k0.2 V10.55 V−1.39 V

Method: assume a state, then verify every transistor (Millman & Taub, the fixed-bias binary)

Solution

Predict the answer first. Then reveal one step at a time.

05 Concept 20–25 min

The SR latch: give the loop two handles

SRQ nextQ̄ next
00QQ̄hold (memory)
0101reset
1010set
1100forbidden
Q+=S+Rˉ Q(SR=0)Q^{+} = S + \bar{R}\,Q\qquad (SR = 0)

Two NOR gates, each output feeding the other's spare input. A 1 on any NOR input forces its output to 0: that is how S and R take control.

Active-low twin: the NAND S̄R̄ latch

A 0 on a NAND input forces its output to 1. So the inputs are active-low: S̄ = 0 sets, R̄ = 0 resets, S̄ = R̄ = 1 holds, and S̄ = R̄ = 0 is forbidden (Q = Q̄ = 1).

Gotcha

"Forbidden" is not about damage. With S = R = 1, Q and Q̄ stop being complements, and if both inputs are released together the next state is a race nobody can predict.

Pro tip

A set or reset pulse must last at least 2 tpd: one gate delay for the first gate to change, one for the second to answer and close the loop.

06 Live lab 25–31 min

Live lab: set, reset, hold, and the race

Latches: two gates that remember Flip the inputs and watch the change travel round the loop, one gate delay at a time. Then try the forbidden input and release it.
QQ̄01R0S0
SRQ next
00Qhold
010reset
101set
110*forbidden
OutputsQ = 0, Q̄ = 1
SRQQ̄
07 Worked example 31–36 min

Worked example: reading a NOR latch timing diagram

Given

A NOR SR latch, initially Q = 0. Gate delays are neglected (each slot is long compared with tpd). The S and R waveforms are in the figure.

Find

Q and Q̄ for all 12 slots. Mark any slot where the latch is not in a valid state.

S = R = 1123456789101112SRQ?Q̄?

Method: hold / set / reset / forbidden, one slot at a time (Mano, SR latch)

Solution

Predict the answer first. Then reveal one step at a time.

08 Your turn 36–40 min

Your turn · 1: the active-low latch

04:00
1 Exam CQ

A NAND S̄R̄ latch starts with Q = 0. Draw Q and Q̄.

12345678910S̄R̄Q?Q̄?

Work it out first.
Press Solve when the class has an answer.

09 Think deeper 40–43 min

Critical thinking · why is S = R = 1 really forbidden?

Think deeper

S = R = 1 just gives Q = Q̄ = 0, which is a perfectly definite output. So what exactly goes wrong?

Argue it in pairs for two minutes. There may be more than one defensible answer.

Think deeper

In the lab the race always ended. Could a real latch stay undecided for, say, a whole microsecond?

Argue it in pairs for two minutes. There may be more than one defensible answer.

10 Concept 43–47 min

Gated latches: listen only when enabled

  • Put two NAND gates in front of an S̄R̄ latch, both driven by an enable C (often called the clock). C = 0: both front gates output 1, the latch holds. C = 1: S and R pass through.
  • The gated SR latch still has a forbidden input (C = 1, S = R = 1).
  • The D latch: feed S = D and R = D̄ through an inverter. S and R can never both be 1, so the forbidden input disappears.
D latch:Q+=D  (C=1),Q+=Q  (C=0)\text{D latch:}\quad Q^{+} = D \ \ (C = 1),\qquad Q^{+} = Q \ \ (C = 0)

Transparent

While C = 1 the D latch is a wire: Q follows D (one or two gate delays later). When C falls, Q freezes at the last value of D. That is what "latching" means.

Pro tip

The 74LS75 holds four D latches; two enables each control a pair. Processors used them to hold an address steady on the bus while the data moved.

11 Live lab 47–52 min

Live lab: the transparent D latch

Latches: two gates that remember Flip the inputs and watch the change travel round the loop, one gate delay at a time. Then try the forbidden input and release it.
QQ̄01D0C0
CDQ next
0xQhold (latched)
100transparent
111transparent
OutputsQ = 0, Q̄ = 1
CDQQ̄
12 Worked example 52–57 min

Worked example: D latch timing

Given

A gated D latch, initially Q = 0. C and D as shown (gate delays neglected).

Find

Q for all 16 slots.

12345678910111213141516CDQ?

Method: C = 1 → copy D; C = 0 → hold

Solution

Predict the answer first. Then reveal one step at a time.

13 Your turn 57–63 min

Your turn · 2: debounce a switch with a latch

05:00
2 Design

A push button is an SPDT switch: contact A (normally closed) drives R̄, contact B drives S̄, both lines pulled up to 5 V. When pressed, the arm leaves A and bounces on B for a few ms.

12345678910111213141516S̄ (B)R̄ (A)

(a) How many presses would a counter driven by the B line count? (b) Draw Q of an S̄R̄ latch. (c) Why does the latch remove the bounce? (d) Would it work with a two-terminal (SPST) button?

Work it out first.
Press Solve when the class has an answer.

14 Real world 63–68 min

Real world: alarms that must not forget

A pulse oximeter on a sleeping patient sees SpO₂ fall to 82 % for 20 seconds at 3 AM, then recover. The nurse was in another ward.

Medical alarm standards (IEC 60601-1-8) define a latching alarm: once triggered it keeps sounding after the cause has gone, until a person acknowledges it. In hardware, that is an SR latch: the comparator output drives S, the Acknowledge button drives R.

SpO₂ < 90 %?SR latchSRQAcknowledgeALARM
BME corner

The same pattern appears in defibrillators ("shock advised" stays lit), infusion pumps (occlusion alarms) and ventilators. Memory turns a brief event into something a human can notice.

Think deeper

What should happen if the SpO₂ is still low when the nurse presses Acknowledge?

Argue it in pairs for two minutes. There may be more than one defensible answer.

15 Pop quiz 68–74 min

Pop quiz

Score 0

Question 1 / 5

A NOR SR latch has S = 0 and R = 0. Its output is…

16 Recap 74–80 min

Three things to remember

01

Feedback with gain makes a bistable: two stable states and one metastable balance point. A transistor latch: assume one ON, one OFF, then verify.

02

SR latch (NOR, active-high) and S̄R̄ (NAND, active-low): hold, set, reset, forbidden. Q⁺ = S + R̄Q, SR = 0.

03

Gated D latch: C = 1 transparent (Q follows D), C = 0 holds. No forbidden input, but every glitch on D gets through while C = 1.

HW Before next class

A gated SR latch (built from NAND gates) starts with Q = 0. Draw Q.

123456789101112CSR

Class Test 1 is in Week 5, Class 1 (Weeks 1–4, including next class's flip-flops). Assignment 1 is due the same day.

Work it out first.
Press Solve when the class has an answer.