Skip to content
digiwleea Tools
Learn Open the lab →

5 and 6 variable K-map solver

A 5-variable Karnaugh map is two 4-variable maps side by side, one for A = 0 and one for A = 1, and a 6-variable map is four, one for each value of A B. Groups follow the usual rules inside each map, and a group can also cover the same cells on neighbouring maps. Click the cells below (or type minterms) and the solver groups across the maps for you, giving the minimized SOP and POS.

How a 5-variable K-map is laid out

Five variables have 32 combinations, too many for one square map whose neighbours all differ in a single bit. So the map is split in two: the left map holds every cell with A = 0 (minterms 0 to 15) and the right map every cell with A = 1 (minterms 16 to 31). Inside each map the rows are B C and the columns D E, both in Gray-code order (00, 01, 11, 10), exactly like an ordinary 4-variable map. A cell's minterm number is 16A + 8B + 4C + 2D + E, which the small label in each cell shows.

The one new rule: a cell is also adjacent to the cell in the same position on the other map, because the two differ only in A. Picture the maps stacked one on top of the other. A group of 1s may therefore be a rectangle on one map, or the same rectangle on both maps, which doubles its size and removes A from the term. Groups still have to hold 1, 2, 4, 8 or 16 cells.

Worked example: 5 variables

The solver above opens on F(A,B,C,D,E) = Σm(0, 1, 4, 5, 16, 17, 20, 21, 23, 29, 31). Eight of those 1s form the same 2 by 2 square in the top-left corner of both maps: rows BC = 00, 01 and columns DE = 00, 01. Inside the square C and E change, and across the two maps A changes, so only B = 0 and D = 0 stay fixed. That group of eight is B'D'.

The other three 1s (23, 29 and 31) sit only on the A = 1 map, in the middle square of rows BC = 01, 11 and columns DE = 01, 11; minterm 21 completes that square even though it is already in the first group. Here A, C and E stay at 1 while B and D change, so the group is ACE. Every 1 is now covered, and the minimized result is F = B'D' + ACE: two terms and five literals in place of eleven 5-literal minterms.

How a 6-variable K-map is laid out

Six variables need 64 cells, so four 4-variable maps, one for each value of A B. The solver draws them two by two: AB = 00 and 01 on top, 10 and 11 below (on a phone they stack in that order), with rows C D and columns E F in each. Maps side by side differ only in B and maps one above the other only in A, so the same cell on two such neighbours is adjacent. Diagonal maps (00 and 11, or 01 and 10) differ in two bits, so they are not neighbours, although a group of 32, or one that covers the same cells on all four maps, includes them.

Example: choose 6 variables and enter the minterms 0, 2, 8, 10, 16, 18, 24, 26, 32, 34, 40, 42, 48, 50, 56, 58, 59, 62, 63. The four corner cells of every map are 1. The corners of one map are already a group (rows and columns wrap around), and the same corners on all four maps make a group of 16 in which A, B, C and E all change: that is D'F'. The remaining 1s, 59, 62 and 63, sit with 58 in the bottom-right square of the AB = 11 map, which is ABCE. The result is F = D'F' + ABCE.

The mirror layout some textbooks use

Some books draw a 5-variable map as one 4 by 8 grid instead, with the columns C D E in a reflected Gray code (000, 001, 011, 010, 110, 111, 101, 100). The adjacencies are the same: besides ordinary neighbours, each cell is adjacent to its mirror image across the vertical centre line. The side-by-side layout used here shows that extra adjacency more plainly: the cells that differ only in the extra variable sit in the same place on two maps.

How the solver finds the minimum

By hand, the risk with five and six variables is missing a group that spans maps. The solver does not look at the picture at all: it combines minterms that differ in one bit, over and over, to list every prime implicant (the Quine-McCluskey method), then searches for the cover with the fewest terms and, among those, the fewest literals. It branches on the 1 with the fewest possible groups and drops any branch that cannot beat the best cover found so far, which settles a 64-cell map in a fraction of a second. Don't-cares (X) join groups when that helps and never need covering. For seven or more variables, type the expression into the Boolean algebra calculator, which handles up to eight.

Frequently asked

How do you solve a 5-variable K-map?

Draw two 4-variable maps, one for A = 0 and one for A = 1, with rows BC and columns DE in Gray-code order. Group 1s as usual within each map, and also group the same rectangle on both maps when both hold 1s; that group drops A. Cover every 1 with as few, and as large, groups as possible, then read each group as a product term.

Which cells are adjacent in a 5-variable K-map?

Within one map, the usual neighbours, including wrap-around from the top row to the bottom row and from the left column to the right. Across the two maps, the cell in the same position, since it differs only in A. For example, minterms 5 and 21 are adjacent.

How many cells does a 6-variable K-map have?

64, drawn as four 4 by 4 maps, one for each value of A B. The same cell on two maps that differ in one of A or B is adjacent, so a group can span two maps or all four.

What is the largest group in a 5 or 6 variable K-map?

Any power of two up to the whole map: 32 cells for 5 variables and 64 for 6. A group of 2 to the k cells removes k variables from its term, so a group of 16 on a 6-variable map leaves a two-literal term.

Why not use K-maps for 7 or more variables?

Seven variables would need eight 4-variable maps, and spotting groups across them by eye is error-prone. Past five or six variables people switch to the Quine-McCluskey method or software that runs it, such as the Boolean algebra calculator here.

For 2, 3 and 4 variables the same solver draws a single map: see the Karnaugh map solver. The theory is in the lessons on Karnaugh maps and Quine-McCluskey minimization.

Related tools: truth table generator, Boolean algebra calculator and logic circuit generator (up to 6 variables, as a live gate circuit).

Open the lab →