Skip to main content
Logo image

Section 3.1 Truth tables, again

What we know, so far (Section 1.4):
  • A logical variable \(x\) is either 0 (FALSE) or 1 (TRUE).
  • Logical variables are combined into logical expressions with AND (\(\cdot\)), OR (\(+\)), and NOT (\(', \overline{\hspace{1em}}\)) operations, e.g., \(x \cdot y \cdot \overline{z}\text{.}\) The "\(\cdot\)" symbol in the AND of two variables may be omitted, e.g., \(xy\) is equivalent to \(x \cdot y\text{.}\)
  • An OR of ANDs, e.g., \(w \cdot x + \overline{y} \cdot z \text{,}\) is called a sum of products. Each row of a truth table is represented by a product term (AND), and the logic equation for a truth table is a sum (OR) of products.
A truth table with \(N\) inputs has \(2^N\) rows, and logic expression with \(N\) variables can become quite lengthy, up to \(2^N\) product terms. We saw in Section 1.3 that sometimes, a long truth table can be simplified by merging rows with “don’t care” entries. This also leads to simpler logic equations. The process of simplifying a logic equation is called logic minimization.
To illustrate, we will revisit Checkpoint 1.3.6, the two-input multiplexer. The full truth table is
\(S\) \(A\) \(B\) \(y\)
\(0\) \(0\) \(0\) \(0\)
\(0\) \(0\) \(1\) \(0\)
\(0\) \(1\) \(0\) \(1\)
\(0\) \(1\) \(1\) \(1\)
\(1\) \(0\) \(0\) \(0\)
\(1\) \(0\) \(1\) \(1\)
\(1\) \(1\) \(0\) \(0\)
\(1\) \(1\) \(1\) \(1\)
and using don’t care entries, the truth table simplifies to four rows.
\(S\) \(A\) \(B\) \(y\)
\(0\) \(0\) — \(0\)
\(0\) \(1\) — \(1\)
\(1\) — \(0\) \(0\)
\(1\) — \(1\) \(1\)
The logic equations for the full and simplified truth tables are, respectively,
\begin{align*} y \amp = \overline{S} A \overline{B} + \overline{S} A B + S \overline{A} B + S A B\\ y \amp = \overline{S} A + S B \end{align*}
The first equation requires four three-input AND gates, a four-input OR gate, three NOTs, and all the wiring to connect them together. The second equation requires only two two-input AND gates, two-input OR gate, and one NOT. That is quite a simplification!

Logical adjacency.

Two binary codes are called logically adjacent if they differ in only one bit. In the multiplexer example, the binary codes for the third and fourth rows of the full truth table, "010" and "011" are logically adjacent. Two product terms are logically adjacent if they differ only by inverting one variable, e.g., \(\overline{S} A \overline{B}\) and \(\overline{S} A B\text{.}\) The value of \(B\) is irrelevant, since \(y\) is TRUE whether \(B\) is 0 or 1, and the sum \(\overline{S} A \overline{B} + \overline{S} A B\) simplifies to \(\overline{S}A\text{.}\) Likewise, the binary codes for the sixth and eight rows, "101" and "111", are logically adjacent, differing only in the \(A\) bit. Their sum of products simplifies, \(S \overline{A} B + SAB = SB\text{.}\)

Checkpoint 3.1.1.

Identify all the pairs of rows in the multiplexer truth table that are logically adjacent and have the same output. Write simplified logical expressions for each pair.
Answer.
Producing output \(y=0\text{:}\) "000" and "001", \(\overline{S} \overline{A}\text{;}\) "000" and "100", \(\overline{A} \overline{B}\text{;}\) "010" and "110", \(A \overline{B}\text{;}\) "100" and "110", \(S \overline{B}\text{.}\)
Producing output \(y=1\text{:}\) "010" and "011", \(\overline{S} A\text{;}\) "011" and "111", \(AB\text{;}\) "101" and "111", \(SB\text{.}\)
Discovering and exploiting logical adjacency is the key to logic minimization. However, it rapidly becomes unwieldy for even moderate-sized truth tables, as this next example shows. In the \(x > y\) function you designed in Checkpoint 1.3.4, the truth table was:
\(x_1\) \(x_0\) \(y_1\) \(y_0\) \(g\) \(x_1\) \(x_0\) \(y_1\) \(y_0\) \(g\)
\(0\) \(0\) \(0\) \(0\) \(0\) \(1\) \(0\) \(0\) \(0\) \(1\)
\(0\) \(0\) \(0\) \(1\) \(0\) \(1\) \(0\) \(0\) \(1\) \(1\)
\(0\) \(0\) \(1\) \(0\) \(0\) \(1\) \(0\) \(1\) \(0\) \(0\)
\(0\) \(0\) \(1\) \(1\) \(0\) \(1\) \(0\) \(1\) \(1\) \(0\)
\(0\) \(1\) \(0\) \(0\) \(1\) \(1\) \(1\) \(0\) \(0\) \(1\)
\(0\) \(1\) \(0\) \(1\) \(0\) \(1\) \(1\) \(0\) \(1\) \(1\)
\(0\) \(1\) \(1\) \(0\) \(0\) \(1\) \(1\) \(1\) \(0\) \(1\)
\(0\) \(1\) \(1\) \(1\) \(0\) \(1\) \(1\) \(1\) \(1\) \(0\)
Figure 3.1.2. Truth table for a two-bit comparison function, \(x > y\text{.}\)
Observe that if \(x = 00\text{,}\) then \(g\) will be zero regardless of the value of \(y\text{.}\) We may compress all of the rows with \(x = 00\text{,}\) as shown below. Again, the dashes indicate that we don’t care what the values of those inputs are.
\(x_1\) \(x_0\) \(y_1\) \(y_0\) \(g\)
\(0\) \(0\) — — \(0\)
\(0\) \(1\) \(0\) \(0\) \(1\)
\(\vdots\)
Likewise, if \(x=01\) and \(y_1=1\text{,}\) then \(g\) will be zero regardless of \(y_0\text{,}\) and another pair of rows can be compressed:
\(x_1\) \(x_0\) \(y_1\) \(y_0\) \(g\)
\(0\) \(0\) — — \(0\)
\(0\) \(1\) \(0\) \(0\) \(1\)
\(0\) \(1\) \(0\) \(1\) \(0\)
\(0\) \(1\) \(1\) — \(0\)
\(\vdots\)
Compressing the remainder of the rows is left as an exercise.

Checkpoint 3.1.3.

Complete the compression of the truth table for the two-bit comparison by pairing rows and using “don’t care” entries. Then write a logic equation.
Answer.
There are a few ways to do this. Here is one.
\(x_1\) \(x_0\) \(y_1\) \(y_0\) \(g\)
\(0\) \(0\) — — \(0\)
\(0\) \(1\) \(0\) \(0\) \(1\)
\(0\) \(1\) \(0\) \(1\) \(0\)
\(0\) \(1\) \(1\) — \(0\)
\(1\) \(0\) \(0\) — \(1\)
\(1\) \(0\) \(1\) — \(0\)
\(1\) \(1\) \(0\) — \(1\)
\(1\) \(1\) \(1\) \(0\) \(1\)
\(1\) \(1\) \(1\) \(1\) \(0\)
The logic equation is
\begin{equation*} g = x_1' x_0 y_1' y_0' + x_1 x_0' y_1' + x_1 x_0 y_1' + x_1 x_0 y_1 y_0' . \end{equation*}
As the exercise showed, some logical adjacencies are harder to spot from a truth table than others. It gets even harder as the number of variables increases. There is a better way.