CIE AS & A Level Computer Science, section 3.2 (Logic gates and logic circuits)
Converting between forms
A logic problem can be described in four ways: a problem statement, a logic expression, a logic circuit and a truth table. You must be able to move between them.
From a problem statement to an expression
Identify the conditions and join them with AND, OR and NOT.
Example: a safe opens () when the key is turned () and either the code is correct () or the fingerprint matches ().
From an expression to a truth table
Write all input combinations ( rows for inputs), work out each part of the expression, then the output.
| OR | ||||
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 1 | 1 |
From an expression to a circuit
Draw one gate for each operator, working from the inside of the brackets outwards, and join the outputs to the next gate's inputs. is an OR gate (inputs , ) whose output feeds an AND gate with .
From a circuit to an expression
Label the output of each gate with an intermediate letter, then combine them step by step from the inputs to the output.
From a truth table to an expression
For each row where the output is 1, write an AND term of the inputs (using NOT for inputs that are 0). Join the terms with OR. For the table has outputs 1, 0, 1, 0, 1, 0, 1, 1 for to .
Common mistake: missing rows in a truth table. Three inputs need rows. Write them in counting order (000, 001, 010, ...). Also, work through brackets first: is not the same as .
Exam tip: add a column for each intermediate result in a truth table. When drawing a circuit, label the inputs and the output, and check each wire is connected.
Check yourself
How many rows has a truth table with 4 inputs?
.
Write the expression for a circuit with and into an AND gate, whose output goes into a NOT gate.
, which is the NAND function.
Give the output of for , , .
.