- by a truth table, listing each combination of inputs and the correponding outputs
- by a Boolean formula for each output
- by a circuit diagram, connecting a set of logic gates

x |
y |
sum |
carry |

0 |
0 |
0 |
0 |

0 |
1 |
1 |
0 |

1 |
0 |
1 |
0 |

1 |
1 |
0 |
1 |

The Boolean formulas are

sum
= (x AND (NOT y)) OR ((NOT x) AND y) = x EXCLUSIVE-OR y

carry = x AND y

carry = x AND y

We can verify these formulas by computing their value for each combination of inputs, and seeing if they match the listed outputs. But how can such a formula be systematically produced, starting from the truth table?

The simplest approach is to produce what is called a sum-of-products formula. The formula consists of a bunch of terms which are connected by ORs. Each term consists of a bunch of factors, one for each input. Each factor represents either an input, or a negated input. There will be one term for each row of the truth table with a "1" output.

In the simple case where there are two inputs, x and y, and one output, we generate the formula as follows:

look only at rows with output = 1

for each such row, build a term as follows:

if there is more than one row with output = 1, OR the corresponding
terms together.for each such row, build a term as follows:

if x = 0, include (NOT x) in the term

if x = 1, include x in the term

if y = 0, include (NOT y) in the term

if y = 1, include y in the term

AND these factors together to build the termif x = 1, include x in the term

if y = 0, include (NOT y) in the term

if y = 1, include y in the term

This simple procedure doesn't always produce the simplest formula, but it will always produce a correct formula corresponding to the truth table. The truth table can be used to represent any Boolean function, so this procedure shows that one can compute any Boolean function using only AND, OR, and NOT gates (P&P sec. 3.3.5: logical completeness).

The truth table and circuit diagram for a full adder are shown in P&P, page 62.

The design of an ALU is very simple: we build a separate circuit for each. Then we build a multiplexer which selects the output of the appropriate circuit.