Lesson 2 of 3
Boolean Logic: Lesson 2

NAND, NOR and XOR Gates

The extended gate set used in real hardware. Learn NAND as the universal gate, NOR as its complement, XOR for arithmetic: and complete truth tables for all three with confidence.

~35 minutes GCSE Logic Gate Builder

If you could only have one type of logic gate: just one: which would you choose? The engineers who designed the first integrated circuits faced exactly this question. They chose NAND. Not AND, not OR: NAND.

Why? Because every other gate: AND, OR, NOT, XOR, everything: can be built entirely from NAND gates. This property is called universality, and it makes mass-manufacturing chips dramatically simpler. One gate type to rule them all.
NAND gate
NOT AND. Output is 0 only when all inputs are 1. The inverse of AND.
NOR gate
NOT OR. Output is 1 only when all inputs are 0. The inverse of OR.
XOR gate
Exclusive OR. Output is 1 when inputs are different. Output is 0 when inputs are the same.
Universal gate
A gate that can replicate any other logic gate. NAND is universal; NOR is also universal.
Inversion bubble
The small circle shown on a gate symbol's output indicating that the output is inverted (NOT applied).
NAND, NOR and XOR: click each to expand

Each of these gates either inverts a familiar gate (NAND, NOR) or introduces new behaviour (XOR). In circuit diagrams, NAND and NOR are drawn with an inversion bubble on the output.

NAND Gate
NOT AND: output is 0 only when ALL inputs are 1
Gate symbol (ANSI)
A B Q
Notation
Q = NOT (A AND B)
Drawn as an AND gate symbol with an inversion bubble (small circle) on the output. All GCSE boards use this symbol.

NAND is an AND gate with its output inverted. The only time NAND outputs 0 is when all inputs are 1. Every other combination gives output 1. This is the exact opposite of AND.

Q = NOT (A AND B)
ABA AND BQ = NAND
0001
0101
1001
1110

Memory tip: NAND is the opposite of AND. Where AND has a single 1 in the output column, NAND has a single 0. In the circuit diagram symbol, it looks like an AND gate but with a small circle (inversion bubble) on the output.

Exam angle

A common question shows a NAND gate symbol and asks for the truth table. Many students write the AND table by mistake. Remember: the circle on the output means NOT is applied. Flip every AND output and you have NAND.

NOR Gate
NOT OR: output is 1 only when ALL inputs are 0
Gate symbol (ANSI)
A B Q
Notation
Q = NOT (A OR B)
Drawn as an OR gate symbol with an inversion bubble on the output. All GCSE boards use this symbol.

NOR is an OR gate with its output inverted. The only time NOR outputs 1 is when all inputs are 0. Every other combination gives output 0. This is the exact opposite of OR.

Q = NOT (A OR B)
ABA OR BQ = NOR
0001
0110
1010
1110

Memory tip: NOR is the opposite of OR. Where OR has a single 0 in the output column, NOR has a single 1. In the circuit symbol, it looks like an OR gate with an inversion bubble on the output.

Exam angle

NOR is also a universal gate: any circuit can be built from NOR gates alone. This is unlikely to be tested at GCSE level but may appear in a "describe one advantage" style question about NOR or NAND gates.

XOR Gate (Exclusive OR)
Output is 1 only when inputs are DIFFERENT
Gate symbol (ANSI)
A B Q
Notation
Q = A XOR B
Drawn as an OR gate with an extra arc on the input side. Written XOR in full at GCSE level.

XOR stands for Exclusive OR. Unlike OR, XOR outputs 1 when exactly one input is 1: not both. When both inputs are the same (00 or 11), XOR outputs 0. It is used in binary addition circuits.

Q = A XOR B
ABQ (A XOR B)
000
011
101
110

Memory tip: XOR outputs 1 when inputs are different, 0 when the same. You can think of it as "one or the other, but not both." Compare with OR which outputs 1 when A=1, B=1: XOR does not.

Real-world use: XOR is the core of a half adder: the circuit that adds two binary digits. When you add 1 + 1 in binary, the sum digit is 0 (XOR gives 0 when both inputs are 1) and the carry digit is 1 (AND gives 1). XOR and AND together form the simplest building block of CPU arithmetic.

Exam angle

XOR is the most commonly confused gate in the exam. Students write the OR truth table instead. The key difference: OR outputs 1 when A=1, B=1; XOR outputs 0 when A=1, B=1. The symbol for XOR is an OR gate shape with an extra curved line on the input side.

All six gates side by side

This table shows the output of every gate for every input combination. Use it to check your recall: cover the columns and test yourself.

ABANDORNANDNORXOR
0000110
0101101
1001101
1111000
Key patterns to remember

AND and NAND are opposites. OR and NOR are opposites. XOR is unique: it outputs 1 only when exactly one input is 1. NAND and NOR both have all-1 and all-0 runs in their output: exactly inverted from AND and OR.

Why NAND is the most important gate in hardware

A universal gate is one that can replicate every other logic gate by combining copies of itself. Both NAND and NOR are universal gates. In practice, NAND is preferred in manufacturing.

NOT from NAND: Connect both inputs of a NAND gate to the same signal (A = B). The output is NOT A, because NAND(A, A) = NOT(A AND A) = NOT A.

AND from NAND: Add a NOT gate (made from NAND) to the output of a NAND gate. NOT(NAND) = NOT(NOT(AND)) = AND.

OR from NAND: Invert both inputs using two NAND-as-NOT gates, then feed into a NAND gate. By De Morgan's theorem, this produces OR.

Why does this matter? A chip manufacturer only needs to make one type of transistor arrangement. All logic can be achieved by wiring NAND gates differently. This simplifies fabrication enormously.

Exam angle

If asked "What is a universal gate?", define it precisely: a gate from which any other logic gate can be constructed using only that gate type. State that NAND is an example. You may be asked to show how NOT is constructed from NAND: this is the most likely specific requirement.

Build NAND, NOR and XOR circuits

Use the Logic Gate Builder to place NAND, NOR and XOR gates and verify their truth tables. Then try building a NOT gate using only NAND gates.

Logic Gate Builder
Place NAND, NOR, XOR gates. Connect inputs. Verify truth tables live. Opens in a new tab.

Challenge tasks: (1) Place a NAND gate, connect both inputs to the same signal: verify it acts as NOT. (2) Build XOR from NAND gates only (advanced: takes 4 NAND gates). (3) Verify the full XOR truth table by toggling all four input combinations.

Quick quiz: NAND, NOR and XOR

Q1. What is the output of a NAND gate when A = 1 and B = 1?

1
0
NAND = NOT AND. AND(1,1) = 1. NOT(1) = 0. The only time NAND outputs 0 is when all inputs are 1. This is the key distinguishing row from AND.

Q2. A NOR gate has inputs A = 0 and B = 0. What is the output?

1
0
NOR = NOT OR. OR(0,0) = 0. NOT(0) = 1. The only time NOR outputs 1 is when all inputs are 0: the single 1 in the NOR truth table.

Q3. XOR gate: A = 1, B = 1. What is the output?

1
0
XOR outputs 1 only when inputs are DIFFERENT. A = 1 and B = 1 are the same, so XOR outputs 0. This is the most common exam trap: students confuse XOR with OR (which gives 1 when both are 1).

Q4. Which gate is described as "universal"?

XOR
NAND
OR
NAND is the universal gate: any logic circuit can be built from NAND gates alone. NOR is also universal, but NAND is the more commonly cited example at GCSE level.

Q5. A NAND gate has inputs A = 0 and B = 1. What is the output?

1
0
AND(0,1) = 0. NAND = NOT AND, so NOT(0) = 1. NAND outputs 0 in only one case: when ALL inputs are 1. In all other cases it outputs 1.
Think deeper

XOR outputs 1 when inputs are different and 0 when inputs are the same. In binary addition, 1 + 1 = 10 (sum = 0, carry = 1). How do XOR and AND together create a circuit that adds two single bits?

This is called a half adder. For inputs A and B: the sum bit is A XOR B (because in binary, 1+1 gives a sum digit of 0 and 0+1 gives 1: exactly what XOR produces). The carry bit is A AND B (because a carry of 1 only happens when both inputs are 1). So a half adder is just one XOR gate and one AND gate wired in parallel with the same inputs. This is the fundamental arithmetic circuit inside every processor: billions of half adders (and full adders) working together.
Lesson 2: Boolean Logic
NAND, NOR and XOR Gates
Starter activity
Display the six-gate comparison table without the output columns filled in. Give students 3 minutes to complete the NAND, NOR and XOR columns from memory using what they know from Lesson 1 (AND and OR are already known, NAND/NOR are just inverted). Reveal and discuss: which column did students find hardest? Usually XOR, because the A=1,B=1 output catches people out.
Lesson objectives
1
State the rule for NAND, NOR and XOR in plain English.
2
Complete truth tables for NAND, NOR and XOR from memory.
3
Explain what is meant by a universal gate and state which gate(s) are universal.
4
Identify the circuit symbol for NAND and NOR (standard AND/OR shape with inversion bubble).
Key vocabulary
NAND
NOT AND. Output is 0 only when all inputs are 1. Outputs 1 in all other cases.
NOR
NOT OR. Output is 1 only when all inputs are 0. Outputs 0 in all other cases.
XOR
Exclusive OR. Output is 1 when inputs differ. Output is 0 when inputs are the same.
Universal gate
A gate from which any other gate can be constructed. NAND and NOR are both universal.
Inversion bubble
The circle on the output of a gate symbol indicating that the output is inverted.
Discussion questions
If NAND can make every other gate, why do we bother learning AND, OR, NOT separately?
XOR is used in binary arithmetic. Can you think of any everyday situation where you want exactly one of two things to be true, but not both?
NOR is also universal: could a computer be built using only NOR gates? What would be the practical advantage of that?
Exit tickets
State the output of a NAND gate when A = 1 and B = 1. [1 mark]
Complete the truth table for a NOR gate with inputs A and B. [2 marks]
Explain what is meant by a universal gate. State one example. [2 marks]
Homework suggestion
Complete truth tables for all six gates (AND, OR, NOT, NAND, NOR, XOR) without referring to notes. Then: describe XOR in one sentence and explain why it is different from OR. Explain what "universal gate" means and give one reason why hardware designers prefer to use NAND gates.