Study Guide
Designing Logic Circuits
Turning a problem into a working logic circuit: choosing the inputs and gates from a description, writing the expression, drawing the circuit, working backwards from a truth table, and testing a design to find its mistakes.
Lesson 2.4 Boolean Logic
For: Cambridge IGCSE Computer Science (ages 14 to 16), after Lessons 1 to 3; useful for AS level revision
Stage: Think
What is the problem asking?
So far you have been given a logic circuit and worked out what it does. Now it is the other way round: you are told what a circuit must do, and you design it. Every design starts by reading the description for its inputs.
A school greenhouse has a sprinkler. It should water the plants when the soil is dry and it is not raining, or when the gardener switches it on by hand. The situation is fictional.
Think it through
What are the inputs, and which words in the description tell you how they combine?
- Hint 1: Each input is a yes-or-no fact the sprinkler could detect.
- Hint 2: Look for and, or and not.
Show what happens
Three inputs: soil dry (A), raining (B) and manual switch on (C). “And” joins soil dry with not raining; “not” turns raining round; “or” adds the manual switch.
Descriptions do not always use the words AND, OR and NOT. “While” and “but” usually mean AND; “unless” means AND NOT (“the light comes on when someone moves, unless it is daytime”: movement AND NOT daytime); “either … or” may mean OR or XOR, so read whether both together are allowed.
Stage: Apply
From a description to an expression
Before drawing anything, write the description as a logic expression: each condition becomes an input or a gate, and brackets keep together what the description keeps together.
Apply it
Show the answer
Answer: C. Q = (A AND NOT B) OR C
NOT goes on the input it describes, and brackets keep “dry and not raining” together before the OR.
A school corridor light comes on (Q) when someone moves (A) or a door opens (B), unless it is daytime (C). The situation is fictional.
- Find the inputs. Movement, the door and daytime are yes-or-no facts the light can detect: A, B and C. The light is the output, Q.
- Find the joining words. “Or” joins movement and the door. “Unless” means AND NOT, and it applies to the whole of “someone moves or a door opens”.
- Bracket what belongs together. A OR B must be worked out before the AND NOT, so it goes in brackets: Q = (A OR B) AND NOT C.
- Check one row. Someone moves in daytime: A = 1, B = 0, C = 1. A OR B is 1, NOT C is 0, so Q = 0, and the light stays off, as the description says.
Change one fact, C to 0 (it is dark): NOT C becomes 1, so Q = 1 and the light comes on.
Think it through
A school laptop charges (Q) when it is plugged in (A) and its battery is not full (B). Write the expression.
- Hint 1: Which input needs NOT?
Show what happens
Q = A AND NOT B.
Stage: Experiment
From an expression to a circuit
Think it through
You are drawing the circuit for Q = (A AND NOT B) OR C. Which gate do you draw first, and why?
- Hint 1: Which gate needs only inputs, and no other gate’s output?
The method: start with the gates nearest the inputs (inside the brackets, and any NOT on a single input), draw each gate’s output wire into the gate that uses it, and label every input on the left and the output on the right. If you cannot draw, describe the circuit gate by gate instead: which inputs or gate outputs go into each gate, and where its output goes.
Think it through
Sketch the circuit for Q = (A AND NOT B) OR C on paper or the whiteboard, then reveal the drawing to compare.
Work this out on paper or the board first. Nothing here is marked: compare yours with the model answer.
Show a model answer
Check yours: NOT on B only; A and NOT B into AND; the AND output and C into OR.
Check your understanding
Show the answer
Answer: A. Three: OR, NOT and AND.
One gate for each gate name in the expression.
Stage: Apply
From a description straight to a circuit
The science preparation room’s door is upgraded. It now opens if a staff card is valid (A), and either the PIN is correct (B) or a teacher in the room presses the release button (C).
Think it through
Sketch the circuit for the new door directly from the description. Write its expression underneath.
Work this out on paper or the board first. Nothing here is marked: compare yours with the model answer.
- Hint 1: Which two inputs are joined by “either … or”?
- Hint 2: What must be true together with that?
Show a model answer
B OR C first, then AND with A. A valid card is always needed; then either the PIN or the release.
Stage: Discover
Working backwards from a truth table
Sometimes you are given only what a circuit must do, as a truth table, and you have to find the expression.
| A | B | C | Q |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Think it through
Look only at the rows where Q = 1. What is A in every one of them?
- Hint 1: There are three rows with Q = 1.
Show what happens
A is 1 in all three. So A must be 1 for Q to be 1.
Check your understanding
Show the answer
Answer: B. At least one of B and C must be 1.
So Q = A AND (B OR C): the upgraded door’s circuit, found from its table.
Check your understanding
Show the answer
Answer: C. Q = A AND NOT B
When only one row gives 1, describe that row with AND, putting NOT on each input that is 0.
Go deeper When no pattern is clear: one term for each row with Q = 1
Describe each row where Q = 1 as the inputs joined by AND, with NOT on each input that is 0 in that row, then join those descriptions with OR. For the table above: (A AND NOT B AND C) OR (A AND B AND NOT C) OR (A AND B AND C). Because each gate has two inputs, a three-input description is written with brackets, such as ((A AND NOT B) AND C). The result is always correct, but longer than an expression found from a pattern, so look for a pattern first.
Stage: Apply
From a truth table to a circuit
A circuit must give this table: Q is 1 only in the rows 001, 011 and 101, and 0 in every other row.
Think it through
Find the pattern, write the expression, then sketch the circuit.
Work this out on paper or the board first. Nothing here is marked: compare yours with the model answer.
- Hint 1: What is C in every row with Q = 1?
- Hint 2: Which row has C = 1 but Q = 0?
Show a model answer
C is 1 in every row with Q = 1; the only row with C = 1 and Q = 0 is 111, where A and B are both 1. So Q = NOT (A AND B) AND C.
Check a design by completing its truth table, with a working column for each gate before the last, and comparing it with the one you were given.
| A | B | C | A AND B (working) | NOT (A AND B) (working) | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | |||
| 0 | 0 | 1 | |||
| 0 | 1 | 0 | |||
| 0 | 1 | 1 | |||
| 1 | 0 | 0 | |||
| 1 | 0 | 1 | |||
| 1 | 1 | 0 | |||
| 1 | 1 | 1 |
Show the completed table
| A | B | C | A AND B | NOT (A AND B) | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Stage: Check
Find the mistake
Kai designed a circuit for the school alarm: it should sound if a door is opened (D) while the alarm is set (S), or if the panic button (P) is pressed. Kai’s circuit is below.
Check your understanding
Show the answer
Answer: A. The panic button is pressed with every door shut.
A single row where the design and the description disagree proves a design wrong. The correct circuit is (D AND S) OR P.
Stage: Consolidate
Design challenge
A school minibus has a safety system that decides whether the engine may start. The situation is fictional.
Think it through
A minibus starts (Q) if the key is in (A) and the seat belt is fastened (B), but not if the fuel cap is open (C). Write the expression, sketch the circuit, and check one row of your choice.
Work this out on paper or the board first. Nothing here is marked: compare yours with the model answer.
Show a model answer
Q = (A AND B) AND NOT C. For example, the row A = 1, B = 1, C = 1: A AND B is 1, NOT C is 0, so Q is 0, and the bus does not start with the fuel cap open.
| A | B | C | A AND B (working) | NOT C (working) | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | |||
| 0 | 0 | 1 | |||
| 0 | 1 | 0 | |||
| 0 | 1 | 1 | |||
| 1 | 0 | 0 | |||
| 1 | 0 | 1 | |||
| 1 | 1 | 0 | |||
| 1 | 1 | 1 |
Show the completed table
| A | B | C | A AND B | NOT C | Q |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 0 |
| 0 | 0 | 1 | 0 | 0 | 0 |
| 0 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 1 | 0 | 0 |
Think it through
Which of today’s conversions do you find hardest: description to expression, expression to circuit, or table to expression? What would help?
Show a model answer
There is no wrong answer. If it is table to expression, look at the rows with Q = 1 and ask what they share; if nothing, use one term per row. If it is drawing, write the expression first and draw the innermost gate first.
- From a description: find the inputs, then the joining words (and, or, not, unless, while), then write the expression.
- From an expression to a circuit: draw the innermost gates first and feed each output on.
- From a table: look at the rows with Q = 1 and find what they share; if nothing is clear, write one term per row.
- Test every design by completing its truth table and comparing it with the description or table.
Sources and scope
- What this lesson is. The fourth of four draft lessons on Boolean logic, written for this site, awaiting the site owner’s editorial review. Its curriculum links are provisional: the wording of each linked specification point has been checked against the published specification, but no link has yet been verified by the site owner. The links show where the lesson may help with a course; they do not imply that any examination board has reviewed or endorsed it.
- Original material. The sprinkler, the corridor light, the laptop, the upgraded door, Kai’s design and the minibus are fictional examples written for this lesson.
- Method from a truth table. Finding a pattern, and one term for each row with an output of 1, are standard methods; the lesson uses tables whose patterns can be found, as introductory examples do.
A logic gate whose output is 1 only when both of its inputs are 1.
Reasoning with values that are either true or false (1 or 0), combined with operations such as AND, OR and NOT.
A closed path that electricity flows around, made of connected components. A logic gate is a very small circuit, made of transistors.
A piece of information that goes into a system for it to use, such as whether a card is valid. In a logic gate each input is 0 or 1.
Logic gates joined together, so that the output of one gate becomes an input of another.
A written description of a logic circuit using gate names and brackets, such as Q = (A AND B) OR C.
A logic gate with one input, whose output is the opposite of its input: 1 becomes 0 and 0 becomes 1.
A logic gate whose output is 1 when at least one of its inputs is 1, including when both are.
What a system produces from its inputs, such as whether a door unlocks. A logic gate has one output, 0 or 1.
A table listing every possible combination of a logic gate’s or circuit’s inputs, with the output for each.
An extra column in a truth table for the output of one gate inside a circuit, worked out before the gates that use it.
Your progress on this lesson
Saved in this browser only. It is not sent anywhere, does not follow you to another device, and is lost if you clear this site’s data.
This browser is not allowing the site to save progress, so it will be forgotten when you leave the page.