GoalDraw a two-gate logic circuit from a Boolean expression by dealing with the brackets first, and read an expression back from a circuit.
New words
brackets · show the part of an expression that is drawn and worked out firstlabel · the letter written on an input or on the output, so that the drawing can be matched to the expressionmiddle output · the output of an early gate that becomes the input of a later gate
Explanation
To draw a circuit from an expression, follow the same steps each time. First find the brackets and draw the gate inside them. Then add the second gate: one of its inputs is the output of the first gate, and the other input is the next letter of the expression. Last, label every input and the output X. A NOT in front of a single letter goes on that input’s wire, before the gate that uses it. A NOT can also come after a bracket, as in NOT (A OR B): the OR gate is drawn first and its output goes into the NOT gate. Brackets matter. If you move them, you draw a different circuit, and it can give different outputs.
Step
What you do for X = A OR (B AND C)
1
draw the AND gate in the brackets, with inputs B and C
2
add the OR gate: its inputs are A and the output of the AND gate
3
label the inputs A, B, C and the output X
Worked examples
Gate
Type
Takes
Gives
Gate 1
AND
B and C
P
Gate 2
OR
A and P
X
Draw X = A OR (B AND C). The AND gate in the brackets comes first. Its output P goes into the OR gate, which also takes A.
A
B
C
X1
X2
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
1
0
1
1
0
0
0
1
1
0
1
1
1
1
1
0
1
1
1
1
1
1
1
Same letters and the same two gates, but different brackets. X1 = A AND (B OR C) and X2 = A OR (B AND C) are different circuits. They give the same output in six rows and a different output in two rows, the ones with a shaded X. For example, with A = 1, B = 0 and C = 0, X1 is 0 but X2 is 1.
A
B
P = A OR B
X = NOT P
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
0
A NOT after a bracket: X = NOT (A OR B). The OR gate comes first, and the NOT gate reverses its output. The final output is 1 only when both inputs are 0.
Class activity
Draw and swap (no computer). You need a pen and paper. The usual symbols are: AND has a flat back and a rounded front; OR has a curved back and a pointed front; NOT is a small triangle with a circle on its tip. Draw the circuit for X = A OR (B AND C) with the three steps, and label every input and the output. Swap drawings with a partner. Your partner writes the Boolean expression that your drawing shows, and counts the gates. Do you both get the expression you started with? Does the number of gates match the number of operators? Then both of you draw X = A AND (B OR C) and compare it with your first drawing. Which gate is first in each?
Practice
1
Complete the wiring list for X = NOT (A AND B).
Gate
Type
Takes
Gives
Gate 1
?
A and B
P
Gate 2
NOT
?
X
Gate 1 is AND and takes A and B; it gives P. Gate 2 is NOT and takes P; it gives X.
2
Complete the truth table for X = NOT (A AND B).
A
B
P = A AND B
X = NOT P
0
0
?
?
0
1
?
?
1
0
?
?
1
1
?
?
P: 0, 0, 0, 1. X: 1, 1, 1, 0. X is 0 only when both inputs are 1.
3
Predict what this program prints.
Python
1a = False2b = True3c = True4print(a and (b or c))
5print(a or (b and c))
False, then True. First line: b or c is True, and False and True is False. Second line: b and c is True, and False or True is True.
4
A learner draws X = A AND (B OR C) like this: an AND gate first, with inputs A and B, and then an OR gate with the AND output and C. What mistake did the learner make?
The learner ignored the brackets. That drawing is (A AND B) OR C. The brackets say that the OR gate must be drawn first, with inputs B and C, and its output goes into the AND gate with A.