AQA GCSE Computer Science (8525), section 3.4.2 (Boolean logic)
Logic gates
A logic gate is a tiny electronic component that takes one or more inputs (each 0 or 1) and gives one output. 1 means true (on) and 0 means false (off). At GCSE you use four gates: NOT, AND, OR and XOR. (NAND and NOR are not needed.)
Truth tables
A truth table shows the output for every possible combination of inputs. With inputs, there are rows.
NOT gate
Gives the opposite of the input.
| A | Q = NOT A |
|---|---|
| 0 | 1 |
| 1 | 0 |
AND gate
Output is 1 only if both inputs are 1.
| A | B | Q = A AND B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
OR gate
Output is 1 if at least one input is 1.
| A | B | Q = A OR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
XOR gate (exclusive OR)
Output is 1 if the inputs are different: one or the other, but not both.
| A | B | Q = A XOR B |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Gate symbols
| Gate | Shape of the symbol |
|---|---|
| NOT | a triangle with a small circle at the output |
| AND | a flat back with a rounded front (a "D" shape) |
| OR | a curved back, with a pointed front |
| XOR | like OR, with an extra curved line at the back |
Boolean expression notation
| Gate | Written as |
|---|---|
| AND | |
| OR | |
| XOR | |
| NOT | (a bar over the top) |
Common mistake: mixing up OR and XOR. For the inputs 1 and 1, OR gives 1 but XOR gives 0. XOR means "one or the other, not both". Also, remember that the NOT gate has only one input.
Exam tip: list the input rows in the standard binary counting order (00, 01, 10, 11) so that none are missed. With 3 inputs there are 8 rows.