☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

Logic circuits and the AND gate

الأسبوع 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.

ABA∧B
000
010
100
111
Worked examples
ABCA∧B∧C
0000
0010
0100
0110
1000
1010
1100
1111
Three inputs make 2³ = 8 rows. Only the row 111 has output 1.
Php
1for ($a = 0; $a <= 1; $a++) {
2    for ($b = 0; $b <= 1; $b++) {
3        echo $a, " ", $b, "   ", $a & $b, "\n";
4    }
5}
Output
0 0   0
0 1   0
1 0   0
1 1   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.
InputsRows
12
24
38
416
532
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?
2
In the table of a two-input AND gate, how many rows have the output 1?
3
Read Y = A·B in words.
4
Why is AND called logical multiplication?