ViewWiki

Lesson 2 of 4

Truth tables.

About 25 minutes · 6 practice questions

A table that describes a gate completely: a row for every combination of inputs, the columns of AND, OR and XOR, gates built from gates, and how many different gates there are at all.

Step 1 of 6 · A row for every combination

Step 1 of 6

A row for every combination

A gate is a rule, and a truth table writes the rule out in full: a row for every possible combination of the inputs, and on each row what comes out. A gate with two inputs has four rows, usually written in the order of the binary numbers, 00, 01, 10, 11:

A B A AND B
00⁠ 00⁠ 00⁠
00⁠ 11⁠ 00⁠
11⁠ 00⁠ 00⁠
11⁠ 11⁠ 11⁠

The four settings of Input bits are exactly the four rows.

To the question

Step 2 of 6

The OR column

To fill in a column, go through the rows one by one. On the board you can do it by experiment: set Input bits to each row in turn, and read the light.

To the question

Step 3 of 6

OR but not AND

The columns of OR and AND differ on two rows. Find one of them on the board.

To the question

Step 4 of 6

XOR

The rows you found define a fourth gate, XOR, “exclusive or”: 1 when exactly one input is 1. It is the “or” of everyday speech, tea or coffee but not both. XOR asks whether its two inputs differ, and in the next Lesson it will add numbers.

To the question

Step 5 of 6

Gates from gates

Gates can be joined: the output of one goes into another. That is how you write an expression like

(A OR B) AND NOT (A AND B)(A \text{ OR } B) \text{ AND NOT } (A \text{ AND } B)⁠

and fill in its table in stages, a working column for each gate. To work it out, start from the brackets, as in arithmetic.

To the question

Step 6 of 6

Every gate

A two-input gate is decided entirely by its output column, so there are only so many such gates. The wonder is that you do not need them all: AND, OR and NOT alone can build any of them, and NAND alone, NOT(A AND B)\text{NOT}(A \text{ AND } B)⁠, can build all the rest. So a whole processor can be made from one kind of gate.

To the question

Interactive scene

Loading the interactive version…

Each step sets up the Scene for you, and a control marked “fixed” stays put for that step.

To the experiment

Practice · Calculate

A truth table has a row for every combination of the inputs. How many rows does the truth table of a gate with three inputs have?

To the experiment

Practice · Choose

A truth table lists the rows in the order 00, 01, 10, 11 (A then B). What is the column of A OR B, from top to bottom? Step through the four Input bits and check.

To the experiment

Practice · Reach the target

Find inputs at which the A OR B light is on and the A AND B light is dark, and press Check.

To the experiment

Practice · Choose

XOR, “exclusive or”, gives 1 when exactly one input is 1. What is its column in the order 00, 01, 10, 11?

To the experiment

Practice · Choose

The expression (A OR B) AND NOT (A AND B)(A \text{ OR } B) \text{ AND NOT } (A \text{ AND } B)⁠ is built from the board’s three kinds of gate. At which inputs is it 1? Mark them all.

To the experiment

Practice · Calculate

A two-input gate is decided entirely by its output column in the truth table. How many different two-input gates can be defined?