Logic gates and truth tables
Logic gates are the building blocks of a processor. Each one takes inputs that are 0 or 1 and gives an output by a fixed rule, and a truth table lists the output for every possible input.
Part 1 of 3: Learn it
In short
- AND outputs 1 only if both inputs are 1; OR outputs 1 if at least one input is 1; NOT flips its input.
- A truth table with n inputs has 2ⁿ rows: 2 inputs give 4 rows, 3 inputs give 8.
- Work through a circuit one gate at a time, adding a column for each gate's output.
Where this is in your specification
Spec points: AQA 3.4.2, OCR 2.4.1, Edexcel Topic 3
| Board | Topic: Boolean logic |
|---|---|
| AQA 8525 | 3.4.2 |
| Edexcel 1CP2 | Topic 3 (logic) |
| OCR J277 | 2.4.1 |
The gates
| Gate | Rule | Expression |
|---|---|---|
| NOT | output is the opposite of the input | NOT A (also written ¬A or A with a bar over it) |
| AND | output is 1 only when both inputs are 1 | A AND B (A ∧ B, or A.B) |
| OR | output is 1 when either or both inputs are 1 | A OR B (A ∨ B, or A + B) |
| XOR | output is 1 when exactly one input is 1 | A XOR B (A ⊕ B) |
OCR's GCSE uses NOT, AND and OR; AQA and Edexcel add XOR. The gate symbols and the way expressions are written differ a little between boards, so use the ones in your own specification.
Truth tables for AND and OR
| A | B | A AND B | A OR B |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 |
List the inputs in binary counting order (00, 01, 10, 11) so you never miss a row.
Circuits with more than one gate
Label the output of each gate (for example D and then Q), add a column for each, and fill them in left to right. The expression follows the wiring: if A and B go into an AND gate whose output goes into a NOT gate, the circuit is Q = NOT (A AND B).
What is 1 AND 0?
Show the answer
0.
Part 2 of 3: See it worked
Worked examples
Example 1
Complete the truth table for Q = (A AND B) OR (NOT C).
- 3 inputs, so 8 rows: A, B, C from 000 to 111
- Column D = A AND B: 1 only in rows 110 and 111
- Column E = NOT C: 1 when C = 0
- Q = D OR E: 1 when either column is 1
Answer: Q is 1 for inputs 000, 010, 100, 110 and 111, and 0 for 001, 011 and 101.
Example 2
A security light comes on (L = 1) when it is dark (D = 1) and either movement is detected (M = 1) or the override switch is on (S = 1). Write the expression.
- 'Either ... or' joins M and S with OR
- 'and' joins that with D
Answer: L = D AND (M OR S).
Common mistakes
- Missing rows: a 3-input table needs all 8 combinations.
- Treating OR as 'one or the other but not both'. That is XOR; OR is also 1 when both are 1.
- Dropping brackets when writing the expression from a diagram.
- Drawing an OR gate when the question uses the AND symbol, or mixing the curved and flat shapes.
What is NOT (0 OR 0)?
Show the answer
NOT 0 = 1.
Part 3 of 3: Test yourself
Check yourself
Answer each one in your head or on paper first, then open it to check.
What is 1 AND 0?
0.
What is NOT (0 OR 0)?
NOT 0 = 1.
How many rows does a truth table with 4 inputs need?
2⁴ = 16.
Jobs that use this
- Electrical engineer (opens a new tab)
- Software developer (opens a new tab)
- IT security co-ordinator (opens a new tab)
Each link opens the job profile on the National Careers Service (England). In the rest of the UK: My World of Work (Scotland), Careers Wales, nidirect careers (Northern Ireland).
Full lessons and marked practice for this course are coming soon to Brainlag Learn. See courses