From a truth table to a real circuit
The recipe that turns a spec into gates
Any truth table becomes a circuit by writing one AND term for each row whose output is `1` and then OR-ing those terms together, the mechanical recipe that connects a specification to a buildable gate network.
A truth table tells you *what* a circuit must do; the canonical forms lesson showed the standard shapes an expression can take. This bridge joins them into a single, always-works procedure: given any table, produce gates. After this you never have to guess a circuit, you can derive one.
The gap that feels big: a truth table is a *list of desired answers*, but a circuit is *wires and gates*. How do you get from one to the other without cleverness or luck? The reassuring answer is that there is a recipe, and it works for every table, even one you have never seen. It may not give the smallest circuit (that is what Karnaugh maps are for), but it always gives a correct one.
The recipe
- Look only at the rows where the output is
1. Ignore the0rows entirely. - For each
1row, write one AND term that is true for exactly that input combination: use the variable if its value is1in that row, and its inverse (NOT) if its value is0. - OR all those AND terms together. The result is
1on precisely the rows you selected and0everywhere else. - Build it: an inverter for each NOTed input, an AND gate per term, and one OR gate combining them.
This is the sum of products you saw named in canonical forms, now used as a construction method. Each AND term is a product that fires on one exact input pattern; OR-ing them (the sum) lights the output for any of the patterns you wanted. Because every
1 row gets its own dedicated term, the circuit cannot be wrong: it outputs 1 on exactly those rows and nothing else.A worked example, the XOR function (output
1 when the inputs differ):| A | B | F |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Two
1 rows, so two AND terms. Row A=0, B=1 gives (NOT A) AND B. Row A=1, B=0 gives A AND (NOT B). OR them: F = ((NOT A) AND B) OR (A AND (NOT B)). That expression is exactly XOR, and it maps directly to two inverters, two AND gates, and one OR gate. You just built a circuit from nothing but the table.The recipe gives a *correct* circuit, not the *smallest* one. Its term count grows with the number of
1 rows, so a table with many ones yields a bulky network. Always run the result through simplification (Boolean algebra or a Karnaugh map) before building for real. Also watch the inversions: use NOT for an input that is 0 in that row, not 1, a very common sign error.Try it
A 2-input function outputs
1 only on the single row A=1, B=1. Apply the recipe. What expression and gate do you get?Answer
One
1 row means one AND term. Both inputs are 1 in that row, so no inversions: the term is A AND B. With a single term there is nothing to OR, so F = A AND B. The recipe hands you a plain AND gate, which is correct, that row is exactly where AND outputs 1.Frequently asked
How do you turn a truth table into a circuit?
Write one AND term for each row whose output is
1 (using NOT on any input that is 0 in that row), then OR all the terms together. This sum-of-products expression maps directly to inverters, AND gates, and one OR gate, and is correct for any table.Does this recipe give the smallest circuit?
No. It always gives a correct circuit, but the number of AND terms equals the number of
1 rows, so it can be large. Simplify the expression with Boolean algebra or a Karnaugh map before building to reduce the gate count.What is sum of products?
It is an expression written as an OR (the sum) of AND terms (the products), where each AND term is true for one specific input combination. It is the standard form the truth-table-to-circuit recipe produces.
You can now build a circuit for any specification. Next, minimize those circuits with the Karnaugh map so you build the fewest gates that still match the table.
Every lesson here builds toward one thing: a working CPU, from the transistor up.
Open the free lab →