Flip-flops and logic circuits in the computer
A-Level Computer Science · Logic Gates and Boolean Algebra
From combinational to sequential
Everything so far has been combinational: the output depends only on the current inputs. A flip-flop is sequential: it has feedback, so the output depends on the inputs and on what was stored before. That is how a circuit remembers a bit.
The SR flip-flop
Two cross-coupled NOR (or NAND) gates. $S=1,R=0$ sets $Q$ to 1; $S=0,R=1$ resets $Q$ to 0; $S=0,R=0$ holds the previous value. $S=1,R=1$ is invalid, because both outputs would go to the same value and the result on returning to $00$ depends on which gate switches first — an unpredictable state, which is exactly why the JK flip-flop was designed.
The JK flip-flop
Clocked, and the $J=K=1$ case toggles instead of being forbidden. A clock input means state changes only on an edge, so a whole register of flip-flops changes together — the basis of registers, counters and, in bulk, static RAM.
Adders
A half adder (XOR for sum, AND for carry) adds two bits but has nowhere to put an incoming carry. A full adder takes three inputs ($A$, $B$, carry-in) and produces sum and carry-out; chaining $n$ full adders gives an $n$-bit adder. This is the concrete link between Boolean logic and binary arithmetic.
Why this matters in the syllabus
Questions ask you to complete a characteristic table, explain why $S=R=1$ is invalid, or describe how flip-flops store data in a register. Answer with the feedback idea, not with a memorised diagram.
Worked example: why S = R = 1 is forbidden
An SR flip-flop is built from two cross-coupled NOR gates. Explain what happens when $S=1$ and $R=1$, and why that state is considered invalid.
Solution
Step 1: recall the structure. Output $Q$ is the output of the first NOR gate, which receives $R$ and $\overline{Q}$; output $\overline{Q}$ is the output of the second NOR gate, which receives $S$ and $Q$. Each output is an input to the other gate; that is the feedback.
Step 2: set $S=R=1$. A NOR gate gives $0$ if any input is $1$. Because $R=1$, $Q=0$; because $S=1$, $\overline{Q}=0$.
Step 3: the first problem. Now $Q=0$ AND $\overline{Q}=0$. The two outputs should always be the negation of each other, but now they are equal; the circuit violates its own definition, so it no longer represents any data bit at all.
Step 4: the second, more serious problem. When both inputs return to $S=R=0$, each gate sees the other's input at $0$, so both "want" to push their output up to $1$. Whichever gate switches faster (because of tiny manufacturing and temperature differences) locks out the other. The final result, $Q=1$ or $Q=0$, is unpredictable and may differ between two runs; this is called a race condition.
Conclusion. It is invalid not because the circuit burns out, but because the circuit loses determinism: the same sequence of inputs can give two different results. The JK flip-flop fixes this by defining $J=K=1$ as TOGGLE the state, and by using a clock pulse so that every change happens only at the clock edge.