C75 of 57
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

C7 · Lesson 5 · Canonical forms and NAND logic

Minterms, maxterms, and building everything from one gate

Any Boolean function can be written straight from its truth table, with no cleverness at all: OR together one AND term for every row where it's 1. That canonical form is usually far from the simplest, but it always exists, it's unique, and it's the starting point for every simplification method. Turn it over with De Morgan's laws and the same function becomes a network of nothing but NAND gates, which is why a chip can be built from a single kind of gate.

  • Two circuits for the same function: F written as a sum of products, AB+A¯C, and G built from NAND gates only.
  • Flip the inputs, or read the truth table: F and G agree in every row.
  • The NAND version is two levels of NAND where the sum of products had AND then OR: De Morgan's laws turn one into the other.

Predict

How many different Boolean functions of three inputs are there?

Name it

Minterms and maxterms

For n inputs, each row of the truth table has a minterm: the AND of every input, inverted where the row has a 0. Row 5 of a three-input table (A = 1, B = 0, C = 1) has minterm m5=AB¯C, which is 1 only in that row. Every function is the OR of the minterms of its 1 rows, its canonical sum of products:

f=∑m(1,3,6,7)=A¯B¯C+A¯BC+ABC¯+ABC

Each row also has a maxterm: the OR of every input, inverted where the row has a 1, which is 0 only in that row: M5=A¯+B+C¯. Every function is the AND of the maxterms of its 0 rows, its canonical product of sums: f=∏M(0,2,4,5). The two lists always split the rows between them.

Useful theorems

  • De Morgan: A+B¯=A¯B¯ and AB¯=A¯+B¯.
  • Consensus: AB+A¯C+BC=AB+A¯C; the term BC is covered by the other two.
  • Duality: swap AND with OR and 0 with 1, and any true identity stays true.

One gate is enough

A sum of products is two levels, AND then OR. By De Morgan, XY+ZW=XY¯⋅ZW¯¯: NAND then NAND. So any function in SOP form becomes NAND–NAND logic with the same structure, and a product of sums becomes NOR–NOR. NAND alone (or NOR alone) is functionally complete: NOT is a NAND with its inputs tied, AND is a NAND followed by a NOT, and OR is a NAND of inverted inputs. CMOS builds NAND and NOR more cheaply than AND and OR (lesson 8), so real logic is full of them.

Worked example

A function of A, B, C is 1 in rows 1, 3, 6 and 7. Write its canonical SOP and POS, then simplify.

Show the solution
  1. Canonical SOP. A¯B¯C+A¯BC+ABC¯+ABC
  2. Canonical POS. ∏M(0,2,4,5)
  3. Simplify. Rows 1 and 3 share A¯C, rows 6 and 7 share AB, so f=A¯C+AB the function in the sim.

Answer the SOP is A¯B¯C+A¯BC+ABC¯+ABC, the POS is ∏M(0,2,4,5), and both simplify to f=A¯C+AB.

Worked example

Build f=AB+A¯C from two-input NAND gates only. How many?

Show the solution
  1. Make A¯. One NAND with both inputs tied to A makes A¯.
  2. Make the two products, inverted. Two more NANDs make AB¯ and A¯C¯.
  3. Combine them. A final NAND of those two gives AB+A¯C.

Answer four two-input NAND gates.

Worked example

Write A⊕B⊕C in canonical sum-of-products form. Can it be simplified?

Show the solution
  1. Find the rows. The three-input XOR is 1 when an odd number of inputs are 1: rows 1, 2, 4 and 7.
  2. Write the canonical SOP. A⊕B⊕C=∑m(1,2,4,7)=A¯B¯C+A¯BC¯+AB¯C¯+ABC
  3. Try to combine terms. No two of those minterms differ in just one variable, so no pair combines: the sum of products stays at four three-literal terms.
  4. Use XOR gates. Two XOR gates do the same job, which is why parity and adder circuits use XOR rather than AND–OR logic.

Answer A¯B¯C+A¯BC¯+AB¯C¯+ABC, which can't be simplified as a sum of products.

Check

Write a function of A, B, C equal to ∑m(1,2,7) (rows counted from 0 with A as the top bit).

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

Write a function of A, B, C equal to ∏M(0,5).

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

Simplify AB+A¯C+BC.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

Write A+BC¯ using inversions only on single variables.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

How many different Boolean functions of 3 inputs are there?

Check

A function of 4 inputs has 3 minterms. How many maxterms does its canonical product of sums have?

Check

Which single gate type can build any Boolean function on its own?

Check

Write ∑m(1,2,4,7) using only XOR.

Write AND as · or & (or just AB), OR as +, XOR as ⊕, and NOT as ¬ or a trailing ': A·B + C' works.

Check

A function has n inputs.

Step 1

How many rows does its truth table have?

Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.

Explain why

Why can any truth table be built as a sum of products?

Practice

Keep practicing

5 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.