CIE AS & A Level Computer Science, section 15.2 (Boolean algebra and logic circuits)
What a flip-flop is
A flip-flop is a circuit with two stable states that stores one bit. It is a memory element, because its output depends on previous input, as well as the current one. Flip-flops are used to build registers and cache memory (SRAM).
SR flip-flop
Two inputs, S (set) and R (reset), and an output Q. It is built from two cross-coupled NOR (or NAND) gates.
| S | R | Q (next) |
|---|---|---|
| 0 | 0 | no change (holds its value) |
| 1 | 0 | 1 (set) |
| 0 | 1 | 0 (reset) |
| 1 | 1 | not allowed (invalid) |
JK flip-flop
Adds a clock input, and the invalid state is replaced with toggle.
| J | K | Q (next) |
|---|---|---|
| 0 | 0 | no change |
| 0 | 1 | 0 (reset) |
| 1 | 0 | 1 (set) |
| 1 | 1 | toggles (opposite of the current Q) |
The state only changes when the clock pulse arrives, which keeps different parts of the computer in step.
Why they store data
Because the output feeds back to the input, the circuit keeps its value when both inputs are 0 until an input changes it.
Common mistake: forgetting that with S = R = 1 an SR flip-flop is invalid, whereas for a JK flip-flop J = K = 1 makes the output toggle. Also, the "no change" row means Q keeps its previous value, not 0.
Exam tip: when completing a table, fill in the Q after each row, using the previous Q for no change and toggle rows. State that a flip-flop stores one bit.
Check yourself
What does a flip-flop store?
One bit of data.
What happens to a JK flip-flop when J = 1 and K = 1?
The output toggles to the opposite of its current value.
Why is S = 1, R = 1 not allowed in an SR flip-flop?
It gives an invalid, unpredictable state.