← ME-5 · DIGITAL LOGIC

Flip-flops & registers

YOU WILL BE ABLE TO
  • Explain how cross-coupled gates store a bit.
  • Describe the SR latch and its forbidden input.
  • Distinguish level-triggered latches from edge-triggered flip-flops.
  • Describe a register as a group of flip-flops.

Combinational logic has no memory: remove the inputs and the outputs forget. Feed an output back to an input, however, and the circuit can hold a state — the same feedback idea that stabilised bias points in ME-2 and set gains in ME-4, now applied to keep a value rather than to control one. Two cross-coupled NAND gates are the simplest memory in existence.

/SN1QN2/R/Q
The NAND-based SR latch: each gate's output feeds the other's input, so the pair has two stable states.

The inputs are active-low, written S‾\overline{S} and R‾\overline{R} — pulling one low commands an action. Hold both high and the latch simply remembers: whichever output was high stays high, because each gate's output is sustaining the other's input. Pull S‾\overline{S} low and QQ is forced high — set. Pull R‾\overline{R} low and QQ is forced low — reset. Pull both low and both outputs go high, which contradicts the whole premise that they are complements, and when you release them the final state depends on which input rises last: a race. That combination is forbidden.

S‾\overline{S}R‾\overline{R}QQQ‾\overline{Q}meaning
11holdholdremember
0110set
1001reset
0011forbidden
The NAND SR latch. The both-low row is forbidden because the outputs stop being complementary.

The D flip-flop is the workhorse: one data input, one clock, one output, and a single rule — on each active clock edge, QQ takes the value DD had at that instant. Everything else it does follows from that. Group nn of them sharing one clock and you have an nn-bit register, which is what holds a variable in a processor; chain them so each one's output feeds the next one's input and you have a shift register, which is how serial data becomes parallel and how the WS2812 strip from ME-2's capstone accepts its colour bytes.

CLKDDQnextQ_{next}
rising edge00
rising edge11
0 or 1 (steady)XQQ (unchanged)
falling edgeXQQ (unchanged)
The D flip-flop: the output changes only on the rising clock edge.
WORKED EXAMPLE

Walking the latch through a sequence

  1. Start with S‾=R‾=1\overline{S} = \overline{R} = 1 and Q=0Q = 0.
  2. Pull S‾\overline{S} low: QQ goes high. Release it back to 1: QQ stays high — the latch remembers.
  3. Pull S‾\overline{S} low again: nothing changes, because QQ is already set. Setting an already-set latch is harmless.
  4. Pull R‾\overline{R} low: QQ returns to 0, and stays there when released.
Two inputs, four operations, one stored bit.
WORKED EXAMPLE

A shift register moves data

  1. Four D flip-flops in a chain share a clock; the first one's DD is the serial input.
  2. Present the bit sequence 1,0,1,11, 0, 1, 1, one bit per clock edge.
  3. After four edges the four flip-flops hold 1,1,0,11, 1, 0, 1 — the sequence, in parallel, in reverse arrival order.
  4. This is exactly how a microcontroller's SPI peripheral transmits and receives, and why one clock plus one data wire can carry arbitrarily many bits.
Serial in, parallel out, one bit per clock edge.

PRACTICE

Q1

A NAND SR latch has S‾=1\overline{S} = 1 and R‾=1\overline{R} = 1. What does QQ do?

Q2

Why is S‾=R‾=0\overline{S} = \overline{R} = 0 forbidden?

Q3

State the difference between a D latch and a D flip-flop in one sentence each.

Q4

An 8-bit register is built from D flip-flops sharing one clock. How many flip-flops, and what happens to all eight bits on a clock edge?

Flip-flops & registers · ME-5 · iLearnSTEM Electronics