Digital Logic Fundamentals
Senior 4 · ICT
Digital Logic Fundamentals
Lesson 4 of 5
25 min
A school's disciplinary committee has three prefects. Each presses a button: 1 for "yes", 0 for "no". A light on the patron's desk must come on when the majority, at least two of the three, say yes. Nobody gives you an expression for the light; you are given a rule in words. This lesson turns rules like this into a truth table and then into a Boolean expression that can be built as a circuit.
Definition
Minterm: an AND of all the input variables, each written plain or barred, that is 1 in exactly one row of the truth table. Example: is 1 only in the row .
Sum of products (SOP): an OR of AND terms, such as .
Maxterm: an OR of all the input variables, each plain or barred, that is 0 in exactly one row. Example: is 0 only in the row .
Product of sums (POS): an AND of OR terms, such as .
For XOR, the output is 1 in rows and . Their minterms are and , so Every SOP expression can be built as a two-level circuit: a layer of AND gates, one per term, all feeding one OR gate (plus NOT gates for the barred inputs).
Worked example 1: the majority voter
Inputs: (1 = yes). Output: when at least two inputs are 1.
| A | B | C | Y | Minterm (rows with Y = 1) |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | |
| 0 | 0 | 1 | 0 | |
| 0 | 1 | 0 | 0 | |
| 0 | 1 | 1 | 1 | |
| 1 | 0 | 0 | 0 | |
| 1 | 0 | 1 | 1 | |
| 1 | 1 | 0 | 1 | |
| 1 | 1 | 1 | 1 |
Built directly, this needs 3 NOT gates, 4 three-input AND gates and a four-input OR gate. In lesson 5 you will reduce it to .
Press Run. The program goes through the 8 rows, keeps the rows where \( Y = 1 \), and writes a minterm for each: plain for 1, primed (A') for 0. It prints Y = A'BC + AB'C + ABC' + ABC, the same as worked example 1. Change the rule on the Y = line, for example to A + B + C == 1 ("exactly one yes"), and run it again.
POS is shorter when the output has few 0s. Suppose only in rows and . Then Each bracket is 0 in exactly one of those rows, and the AND is 0 if any bracket is 0. (Here is 0 exactly when and , so it simplifies to .)
Worked example 2: straight from words
A security light () must come on when it is dark () and either a motion sensor detects movement () or the manual switch is on ().
Translate the words: "and" → AND, "either … or" → OR, and the brackets follow the meaning:
Check with the truth table method: in rows , giving . Factorising, , since the bracket is 1 whenever or is 1. Both methods agree, and the word method gave the shorter answer at once.
Computing Tutor: Deriving a Boolean expression from a truth table (sum of products). Watch how each row with output 1 becomes one AND term, then repeat the method on the majority-voter table above.
Warning
Plain for 1 in SOP, plain for 0 in POS. The rules are opposite. A minterm is written so that it equals 1 in its row; a maxterm so that it equals 0 in its row. Test one term in its own row to be sure.
Define every variable first. " = seat belt" is not enough: say whether means fastened or unfastened, or the expression will be the wrong way round.
Tip
Count before you choose. If the output column has fewer 1s than 0s, write the SOP; if it has fewer 0s, write the POS. Fewer terms means fewer gates before you even start simplifying.
Practice
Key points
Sources and credits
This lesson adapts CC BY-SA material and is shared under CC BY-SA 4.0.
# Build the sum of products of the majority voter automatically.
# A' means NOT A (a common way to type a bar).
names = ["A", "B", "C"]
terms = []
for A in (0, 1):
for B in (0, 1):
for C in (0, 1):
Y = int(A + B + C >= 2) # at least two yes votes
if Y == 1:
term = ""
for name, value in zip(names, (A, B, C)):
term += name if value == 1 else name + "'"
terms.append(term)
print("Y =", " + ".join(terms))Quick check
Which minterm is 1 only in the row A = 0, B = 1, C = 1?