Logic circuits can be described in three equivalent ways: a diagram, a Boolean expression, and a truth table. This lesson shows how to move between them and how to build a truth table for a larger problem.
Writing Boolean expressions
Boolean expressions use these symbols:
- AND: A AND B (also written A . B or AB)
- OR: A OR B (also written A + B)
- NOT: NOT A (also written A with a bar over it, or !A)
- XOR: A XOR B
Operator precedence: NOT first, then AND, then OR. Brackets override this. So A OR B AND C means A OR (B AND C).
Example: a car warning light comes on if the door is open (D) or the seatbelt is unfastened (S) while the engine is running (E). That is:
W = (D OR S) AND E
Building a truth table
A truth table lists every combination of inputs and the resulting output. With n inputs there are 2^n rows.
Steps:
- List all input combinations in binary counting order.
- Add a column for each sub-expression.
- Fill in the final output column.
Truth table for Q = (A AND B) OR NOT C:
A B C | A AND B | NOT C | Q
0 0 0 | 0 | 1 | 1
0 0 1 | 0 | 0 | 0
0 1 0 | 0 | 1 | 1
0 1 1 | 0 | 0 | 0
1 0 0 | 0 | 1 | 1
1 0 1 | 0 | 0 | 0
1 1 0 | 1 | 1 | 1
1 1 1 | 1 | 0 | 1
From truth table to expression
Look at the rows where the output is 1. For each such row, write an AND term of the inputs (using NOT for inputs that are 0), then OR those terms together. This is called the sum of products form.
For a table where Q = 1 only on rows A=0,B=1 and A=1,B=0, the result is:
Q = (NOT A AND B) OR (A AND NOT B)
which is the XOR function.
From expression to diagram
Build the circuit by working from the innermost brackets outward: each operator becomes a gate and its operands feed its inputs. The diagram for (D OR S) AND E has an OR gate whose output feeds an AND gate along with E.
Check your understanding
How many rows does a truth table with 4 inputs have?
- 4
- 8
- 16
- 32
Answer: 16. There are 2 to the power 4 combinations.
Evaluate A OR B AND C for A=1, B=0, C=0.
- 0
- 1
- Undefined
- 2
Answer: 1. AND is done first (0 AND 0 = 0), then 1 OR 0 = 1.
What is Q = (A AND B) OR NOT C when A=0, B=1, C=1?
- 0
- 1
- 2
- Undefined
Answer: 0. A AND B is 0 and NOT C is 0.
In sum of products form, which rows do you use?
- Rows where the output is 0
- Rows where the output is 1
- Only the first row
- All rows
Answer: Rows where the output is 1. Each becomes an AND term, joined with OR.
