Course 10.3Lesson 2 of 3
With three inputs a truth table has eight rows. You fill them in binary order, add working columns for the gates inside the circuit, and check the output column. This is the most common logic question on the examination paper.
Try the code and the simulations beside the lesson.
Each input can be 0 or 1. With three inputs there are combinations. The syllabus prints the table like this, and you should use the same order every time.
| A B C | Output |
|---|---|
| 0 0 0 | |
| 0 0 1 | |
| 0 1 0 | |
| 0 1 1 | |
| 1 0 0 | |
| 1 0 1 | |
| 1 1 0 | |
| 1 1 1 |
Look at the pattern. A is 0 in the top four rows and 1 in the bottom four. B changes every two rows. C changes every row. The rows are the binary numbers from 0 to 7.
For a circuit with gates inside, add a column for the output of each inner gate. Then the output gate only has to look at those columns.
Let us complete the table for the circuit of the last lesson, X = (A NAND B) XOR (B OR C).
P = A NAND B is 0 only when A and B are both 1.Q = B OR C is 0 only when B and C are both 0.X = P XOR Q is 1 when P and Q differ.| A B C | P Q | X = P XOR Q |
|---|---|---|
| 0 0 0 | 1 0 | 1 |
| 0 0 1 | 1 1 | 0 |
| 0 1 0 | 1 1 | 0 |
| 0 1 1 | 1 1 | 0 |
| 1 0 0 | 1 0 | 1 |
| 1 0 1 | 1 1 | 0 |
| 1 1 0 | 0 1 | 1 |
| 1 1 1 | 0 1 | 1 |
The output column is 1, 0, 0, 0, 1, 0, 1, 1. It has 4 ones.
Check one row by hand. Take 1 1 0. P = 1 NAND 1 = 0. Q = 1 OR 0 = 1. X = 0 XOR 1 = 1. That matches the table.
The method is the same whether the question gives an expression or a drawing. With a drawing, first write the expression from the output back, as in the last lesson. Then name the inner gates P and Q and fill their columns.
The program uses three loops inside each other, so the rows come out in binary order. It prints P, Q and X, and counts the ones.
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
X = (A NAND B) XOR (B OR C), find X in the row 0 0 0.X = (A AND B) OR C, how many rows give X = 1?Every lesson is open to read. Enrolling also lets you:
Log in to join the discussion.
Loading…
This lesson is free to read. Enroll free to keep your place and take the tests.