Cambridge IGCSE Computer Science · 0478
Topic 10: Boolean Logic
Logic Gates, Truth Tables & Logic Circuits
What is Boolean logic?
Boolean logic is a branch of algebra that works with values that can only be true or false. In computer hardware, these are represented as the binary digits 0 (off / false) and 1 (on / true).
Computers are built from millions of tiny electronic switches. Each switch is either on or off. By combining these switches using logic gates, a processor can perform calculations, make decisions, and control devices such as security barriers, traffic lights, and sensors.
Boolean logic in hardware (Topic 10) is closely related to the logical operators AND, OR, and NOT used in pseudocode (Topic 8) — but in this topic you work with logic gate symbols, truth tables, and logic circuit diagrams.
Logic gate symbols
A logic gate is an electronic component that takes one or more binary inputs and produces a single binary output according to a fixed rule. Cambridge IGCSE 0478 requires you to recognise and draw the standard symbols for six gates:
| Gate | Inputs | Function |
|---|---|---|
| NOT | 1 | Inverts the input (0 → 1, 1 → 0) |
| AND | 2 | Output is 1 only if both inputs are 1 |
| OR | 2 | Output is 1 if at least one input is 1 |
| NAND | 2 | NOT AND — output is the inverse of AND |
| NOR | 2 | NOT OR — output is the inverse of OR |
| XOR (EOR) | 2 | Exclusive OR — output is 1 if inputs are different |
Truth tables
A truth table lists every possible combination of inputs and shows the resulting output. For a gate with two inputs (A and B), there are four rows (2² = 4 combinations). For three inputs, there are eight rows (2³ = 8).
Inputs are usually labelled A, B, C on the left of a circuit; the output is labelled X (or sometimes W, Y, or Z).
NOT gate
| A | X |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND gate
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR gate
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
NAND, NOR, and XOR in detail
NAND gate (NOT AND)
The NAND gate produces the opposite output to an AND gate. Its output is 0 only when both inputs are 1; otherwise the output is 1.
| A | B | X |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NOR gate (NOT OR)
The NOR gate produces the opposite output to an OR gate. Its output is 1 only when both inputs are 0.
| A | B | X |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
XOR gate (exclusive OR / EOR)
The XOR gate outputs 1 when the inputs are different (one is 0 and the other is 1). When both inputs are the same (both 0 or both 1), the output is 0.
| A | B | X |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Boolean expressions and logic circuits
A Boolean expression describes the logic of a circuit using operators: NOT, AND, OR, and sometimes XOR. Brackets show which operations are performed first.
Example expression: X = (NOT P AND Q) OR R
To draw a logic circuit from an expression:
- Identify the inputs (P, Q, R) on the left.
- Work from the innermost brackets outward — draw NOT P first, then feed it and Q into an AND gate.
- Feed the AND output and R into an OR gate to produce X.
- Label the final output X on the right.
Completing truth tables for expressions
To complete a truth table for a complex expression such as X = (NOT P AND Q) OR R:
- List every combination of the input columns (P, Q, R) — 8 rows for three inputs.
- Add intermediate columns for each sub-expression, working from inside the brackets outward: first NOT P, then (NOT P AND Q), then the final X.
- Fill each column by applying the gate rule row by row.
Shortcut for OR: once you have the (NOT P AND Q) column, X is 1 on any row where that column is 1 or R is 1.
Boolean algebra rules
These identities help you understand and check circuits (you will not usually be asked to simplify expressions in Paper 2, but they help with truth tables):
| Rule | Example |
|---|---|
| NOT NOT A = A | Inverting twice returns the original value |
| A AND 1 = A · A AND 0 = 0 | AND with 1 leaves A unchanged; AND with 0 forces 0 |
| A OR 0 = A · A OR 1 = 1 | OR with 0 leaves A unchanged; OR with 1 forces 1 |
| De Morgan's: NOT (A AND B) = (NOT A) OR (NOT B) | NOT distributes over AND by becoming OR with inverted inputs |
| De Morgan's: NOT (A OR B) = (NOT A) AND (NOT B) | NOT distributes over OR by becoming AND with inverted inputs |
Real-world applications
Logic gates are found throughout digital systems:
- CPU — millions of gates perform arithmetic and comparisons.
- Security systems — a barrier may open only when a valid ticket AND a clear sensor signal are both present.
- Memory — solid-state flash storage uses NAND gate technology (see Topic 3).
NAND and NOR are called universal gates because any other gate can be built using only NAND gates (or only NOR gates). For example, connecting both inputs of a NAND gate together creates a NOT gate.
0/15