Draft preview. Lessons are being written and reviewed.

Digital Design / Module 1: Numbers and logic

4. Karnaugh maps

Find minimal two-level logic visually.

Lecture coming soon

See it move

The idea

A Karnaugh map redraws a so that neighbouring cells differ by exactly one variable. When two neighbouring cells are both 1, the variable that differs doesn't matter, and it drops out. Simplifying becomes a matter of drawing rectangles.

Rules for grouping

  • Rows and columns run in Gray order: 00, 01, 11, 10. This is what makes neighbours differ by one bit.
  • Groups must be rectangles of 1, 2, 4, 8 or 16 cells.
  • Make each group as large as possible, since larger groups mean fewer literals.
  • Groups may overlap, and they may wrap around the edges of the map.
  • Every 1 must be covered, using as few groups as you can.

Don't-cares

An X marks an input combination that can't occur, or whose output doesn't matter. Use an X if it lets a group grow, and ignore it otherwise. For example, a BCD circuit never sees the values 10 to 15, and that freedom can shrink the logic considerably.

Reading a group

A variable stays in the term only if it has the same value across the whole group. Suppose a group of four has A = 1 throughout, D = 1 throughout, and B and C taking both values. Its term is AD.

Common mistake

Using the ordinary order 00, 01, 10, 11 on the axes. Cells for 01 and 10 differ by two bits, so they aren't true neighbours, and any group across them gives a wrong answer. Another frequent slip is forgetting that the top and bottom edges touch, as do the left and right.

Where this stops

K-maps work well up to about four inputs, so treat them as a way to build intuition and to answer interview questions. Synthesis tools use other algorithms for real designs. The animation above does use an exact method behind the scenes, so you can compare your own grouping against the minimal answer.

Key ideas

  • Rows and columns follow Gray order, so neighbours differ by one bit.
  • Group in powers of two, as large as possible, and wrap around edges.
  • Don't-cares can join a group whenever that helps.

Your exercise

Minimise a 4-input function with two don't-cares.

Interview questions

coreWhy Gray order on the axes?

basicA 4-variable K-map has how many cells, and how many literals does a group of four cells give?

basicWhy can't a K-map group contain three cells?

coreMinimise F(A, B, C) = sum of minterms 0, 2, 4 and 6.

coreOn a 4-variable map with A, B down the side and C, D across the top, only the four corner cells are 1. What is the minimal expression?

coreF(A, B, C) is 1 for minterms 1, 3 and 7, and minterm 5 is a don't-care. Minimise it with and without the don't-care.

coreYou fill a 4-variable map and get a perfect checkerboard of 1s. What does that tell you?

advancedA colleague labels the BC columns of a 3-variable map 00, 01, 10, 11. Row A = 0 has 1s in the two middle columns, and they circle them as one pair. What is wrong, and what is the correct expression?

advancedA flag for 'BCD digit is 5 or more' was minimised with codes 10 to 15 as don't-cares, giving F = A + BD + BC. A reset fault leaves 1100 on the bus. What does the flag show, and what is the lesson?

Practise these 9 questions with animations