Topic 10 · Boolean logic
The six logic gates
What is a logic gate?
A logic gate is a tiny electronic circuit that takes one or two binary inputs (0 or 1) and produces one binary output. Processors are built from billions of them.
In the exam you need six gates. NOT has one input; all the others have two inputs.
The six gates
| Gate | Output is 1 when… | Expression |
|---|---|---|
| NOT | the input is 0 (it flips the input) | X = NOT A |
| AND | both inputs are 1 | X = A AND B |
| OR | at least one input is 1 | X = A OR B |
| NAND | not both inputs are 1 (opposite of AND) | X = A NAND B |
| NOR | neither input is 1 (opposite of OR) | X = A NOR B |
| XOR | the inputs are different | X = A XOR B |
Try every gate in the simulator below before you look at the tables.
Truth tables for each gate
A truth table lists every possible combination of inputs and the output for each one. With two inputs there are 2 × 2 = 4 rows.
| A | B | AND | OR | NAND | NOR | XOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
| A | NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
Memory tricks
- AND is strict: everyone has to agree.
- OR is relaxed: anyone will do.
- N in front (NAND, NOR) means "then flip the answer". In the drawn symbol, that's the little circle on the output.
- XOR is "one or the other, but not both".
Drawing the symbols
In the exam you must use the standard symbols (the ones in the syllabus). The key shapes: AND has a flat back and a round front (like a D); OR has a curved back and a pointed front; NOT is a triangle with a small circle; NAND and NOR are AND and OR with a small circle on the output; XOR is OR with an extra curved line behind it.
Key terms
| Term | Meaning |
|---|---|
| Logic gate | A circuit that performs a logical operation on one or more binary inputs to give one binary output |
| Truth table | A table showing the output for every possible combination of inputs |
| Logic expression | A written statement of a circuit, e.g. X = (A AND B) OR NOT C |
Quiz
Quick check: logic gates
4 questions