الأسبوع 8 · الوحدة ٢ «البوابات المنطقية» (١): الدوائر المنطقية وقائمة البوابات وبوابة AND: المفاتيح والرمز وعدد الاحتمالات وجدول الحقيقة والصيغة البولية · 3 دروس
3
Truth table, number of rows and the AND formula
ICT Secondary 3 Term 1, Unit 2, Topic 1: pp. 6–18
GoalWrite the truth table of the AND gate, say how many rows n inputs need, and read the formula Y = A·B.
New words
truth table · a table with one row for each combination of inputs and the output for eachrow · one combination of input values together with its outputBoolean formula · a short way of writing the rule of a gate, such as Y = A·Blogical multiplication · another name for AND, because 0·0, 0·1 and 1·0 are 0 and 1·1 is 1
Explanation
A truth table lists every combination of the inputs and the output for each one. Inputs A and B can each be 0 or 1, so there are 2 × 2 = 4 rows. With n inputs there are 2ⁿ rows: 8 for three inputs, 16 for four. This is the same count as the bit patterns of Week 2. We write the columns A, B and then the output, and the rows in counting order: 00, 01, 10, 11. For AND only the last row has the output 1. The formula is Y = A·B, read “Y equals A AND B”. It is called logical multiplication because the product of 0s and 1s gives the same outputs: 0·0 = 0, 0·1 = 0, 1·0 = 0 and 1·1 = 1. The dot does not mean a big number; the values are only 0 and 1. For three inputs the formula is Y = A·B·C, and only the row 111 gives 1.
A
B
A∧B
0
0
0
0
1
0
1
0
0
1
1
1
Worked examples
A
B
C
A∧B∧C
0
0
0
0
0
0
1
0
0
1
0
0
0
1
1
0
1
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
Three inputs make 2³ = 8 rows. Only the row 111 has output 1.
A program can print the same table. The operator & works on 0 and 1 like AND (the better PHP operator && comes in Week 10). The output lines come from running it.
Inputs
Rows
1
2
2
4
3
8
4
16
5
32
The number of rows doubles with each extra input, just as the number of patterns doubles with each extra bit.
Class activity
Work out on paper the truth table of an AND gate with four inputs. How many rows does it have? Write the first six rows in counting order and say which row has the output 1.
Practice
1
How many rows does a truth table with five inputs have?
32 rows, because 2⁵ = 32.
2
In the table of a two-input AND gate, how many rows have the output 1?
One: the row 11.
3
Read Y = A·B in words.
Y equals A AND B.
4
Why is AND called logical multiplication?
Its outputs match the products of 0s and 1s: only 1·1 gives 1.