AQA GCSE Computer Science (8525), section 3.4.2 (Boolean logic)
Logic circuits
A logic circuit joins several gates together, so that the output of one gate is the input of another. At GCSE circuits have up to three inputs and use NOT, AND, OR and XOR gates.
From a circuit to a Boolean expression
Work through the circuit from the inputs to the output, writing the expression for each gate.
Example circuit: A and B go into an AND gate. C goes into a NOT gate. The outputs of the AND and NOT gates go into an OR gate, which gives Q.
The expression is
In words: Q = (A AND B) OR (NOT C).
From an expression to a circuit
Break the expression into parts, innermost first. For :
- A and B go into an XOR gate.
- The output of the XOR gate and C go into an AND gate.
- The AND output is Q.
Truth table for a circuit
Add a column for each intermediate step to make it easier.
Q = (A AND B) OR (NOT C)
| A | B | C | A AND B | NOT C | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 1 |
P = (A XOR B) AND C
| A | B | C | A XOR B | P |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 | 0 |
| 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 0 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 |
Interpreting a truth table
You may be asked when the output is 1. For P above, it is 1 only when C is 1 and A and B are different.
Real uses
Logic circuits are used inside processors to add numbers and make decisions, and in alarms: for example an alarm sounds if (the door is open AND the system is on) OR the panic button is pressed.
Common mistake: working out the whole circuit in one go and making mistakes. Add a column for each gate in the truth table, working left to right. Also, take care with brackets in an expression: is not the same as .
Exam tip: start from the inputs and follow the wires. For a three-input table, write the inputs in the order 000, 001, 010... up to 111. Label each gate output before combining.
Check yourself
Write the Boolean expression: A and B go into an OR gate, and the output goes into a NOT gate.
Q = NOT (A OR B), written .
For Q = A AND (NOT B), what is Q when A = 1 and B = 0?
In the table for P = (A XOR B) AND C, when is P equal to 1?
When C is 1 and A and B are different (inputs 011 and 101).