AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Gates joined together

Week 28 · 4.5 Logic circuits · 3 lessons
2

Brackets first

Computing 9: Topic 4.5, pp. 341–347
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.

StepWhat you do for X = A OR (B AND C)
1draw the AND gate in the brackets, with inputs B and C
2add the OR gate: its inputs are A and the output of the AND gate
3label the inputs A, B, C and the output X
Worked examples
GateTypeTakesGives
Gate 1ANDB and CP
Gate 2ORA and PX
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.
ABCX1X2
00000
00100
01000
01101
10001
10111
11011
11111
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.
ABP = A OR BX = NOT P
0001
0110
1010
1110
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).
GateTypeTakesGives
Gate 1?A and BP
Gate 2NOT?X
2
Complete the truth table for X = NOT (A AND B).
ABP = A AND BX = NOT P
00??
01??
10??
11??
3
Predict what this program prints.
Python
1a = False
2b = True
3c = True
4print(a and (b or c))
5print(a or (b and c))
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?