A Level · Topic 15.2
A-Level Computer Science 9618 / Topic 15 / A2

Circuits that add and remember.

Two families of logic circuit sit inside every processor. Adders do binary arithmetic in the ALU; flip-flops store single bits in registers and static RAM. This lesson builds the half adder and full adder, then the SR and JK flip-flops, with their truth tables.

The key idea

A half adder adds two bits A and B, giving a sum S = A XOR B and a carry C = A AND B. A full adder also adds a carry in, so it can be chained: S = A XOR B XOR Cin and Cout = A.B + Cin.(A XOR B); it can be built from two half adders and an OR gate. A flip-flop is a circuit whose outputs are fed back into its inputs, so it has two stable states and stores one bit. An SR flip-flop is set by S = 1, reset by R = 1, holds its value when S = R = 0, and must not have S = R = 1. A JK flip-flop changes only on a clock pulse and removes the invalid state: J = K = 1 makes it toggle. Flip-flops are the data storage elements of registers and static RAM.

a full adder built from two half adders and an OR gate half adder 1 S = XOR C = AND half adder 2 S = XOR C = AND A B S1 Cin C1 C2 S Cout S = A XOR B XOR Cin; Cout = A.B + Cin.(A XOR B)
Fig. 1: a full adder. The first half adder adds A and B; the second adds the carry in to their sum; either half adder can produce the carry out
Section 01

Half adders and full adders.

Adding two single bits gives a two-bit answer: 1 + 1 = 10 in binary, a sum of 0 and a carry of 1. Switch the inputs in the lab to see the half adder, the full adder and a 4-bit adder made of full adders.

Half adder (two inputs):

ABSC
0000
0110
1010
1101

Full adder (three inputs, including the carry from the column to the right):

ABCinSCout
00000
00110
01010
01101
10010
10101
11001
11111
Worked example A chain of four full adders
A 4-bit ripple-carry adder adds 0110 and 0111. Give the sum and carry out of each full adder, starting from the least significant bit.
  1. Bit 0: 0 + 1 + carry in 0 = 1, so S = 1, Cout = 0.
  2. Bit 1: 1 + 1 + 0 = 10, so S = 0, Cout = 1.
  3. Bit 2: 1 + 1 + 1 = 11, so S = 1, Cout = 1.
  4. Bit 3: 0 + 0 + 1 = 1, so S = 1, Cout = 0: no overflow.
Answer: 1101 (6 + 7 = 13)
Examiner trap

Do not write the full adder carry as A.B only: a carry in of 1 plus one other 1 also produces a carry. Cout = 1 for rows 011, 101, 110 and 111.

Section 02

The SR flip-flop.

Feed the output of each NOR gate back into the other and the circuit can remember. Toggle S and R in the lab and notice that when both return to 0, Q stays as it was.

an SR flip-flop made from two NOR gates R S Q Q each output is fed back to an input of the other gate
SRQ beforeQ afterQ afterEffect
00001no change (memory)
00110no change (memory)
10010set
10110set
01001reset
01101reset
11000not allowed: Q = Q = 0
11100not allowed: Q = Q = 0
Worked example Tracing an SR flip-flop
An SR flip-flop made of NOR gates starts with Q = 0. The inputs (S, R) are changed to (1, 0), (0, 0), (0, 1), (0, 0), (1, 0) in turn. Give Q after each change.
  1. StepSRQ
    1101
    2001
    3010
    4000
    5101
  2. Steps 2 and 4 (S = R = 0) keep the value set by the step before: that is the stored bit.
Answer: Q = 1, 1, 0, 0, 1
Examiner trap

Saying S = R = 1 "gives Q = 1" loses the mark. For NOR gates both outputs go to 0, which breaks the rule that Q and Q are opposite, so the state is invalid.

Stage 1 · Learn

Check what the sim just showed you

Four quick checks. Each correct answer earns XP and records this skill on your profile.

Quick check+10 XP

What are the outputs of a half adder when A = 1 and B = 1?

Quick check+10 XP

A full adder has A = 1, B = 0 and carry in = 1. What are its outputs?

Quick check+10 XP

An SR flip-flop made of NOR gates has S = 0 and R = 0. What happens to Q?

Quick check+10 XP

In the lab, what does a JK flip-flop do on a clock pulse when J = 1 and K = 1?

Section 03

JK flip-flops and data storage.

The JK flip-flop fixes the two weaknesses of the SR flip-flop: it has no invalid input combination, and it only changes when a clock pulse arrives, so many flip-flops can change together in step.

JKQ before pulseQ after pulseEffect
0000no change
0011no change
0100reset
0110reset
1001set
1011set
1101toggle
1110toggle
Worked example Tracing a JK flip-flop
A JK flip-flop starts with Q = 0. Six clock pulses arrive with (J, K) = (1, 0), (0, 0), (1, 1), (1, 1), (0, 1), (0, 0). Give Q after each pulse.
  1. Pulse 1: J = 1, K = 0 sets Q to 1. Pulse 2: no change, Q stays 1.
  2. Pulses 3 and 4: J = K = 1 toggles Q, to 0 and then back to 1.
  3. Pulse 5: K = 1, J = 0 resets Q to 0. Pulse 6: no change.
  4. PulseJKQ
    1101
    2001
    3110
    4111
    5010
    6000
Answer: Q = 1, 1, 0, 1, 0, 0
Your turn
Give two advantages of a JK flip-flop over an SR flip-flop.
Examiner trap

"A flip-flop stores data" is too vague. Say it stores one bit, and name a use: registers, static RAM or cache.

Stage 2 · Exam

Exam-style questions

Unlocks once the four checks above are done. Worth more XP, written to A Level Paper 3 and Paper 4 standard.

Finish the four checks above to unlock the exam questions
Exam style+20 XP

Which pair of expressions describes a full adder?

Exam style+20 XP

Why are flip-flops used in registers?

Exam style+20 XP

Which input combination must NOT be used on an SR flip-flop made of NOR gates?

Exam style+20 XP

Why can a half adder not be used for every column of a multi-bit addition?

Skill unlocked

Adders and flip-flops, mastered.

This skill is now recorded on your profile. Keep the chain going.

-Rank -Level -Score -Topics
Go deeper · practice
Six original Cambridge-style questions
Half adders, full adders, SR and JK flip-flops and their truth tables.