Layout of a 2-Input K-Map
In a 2‑input Karnaugh map, one variable is assigned to the rows and the other to the columns, creating a fixed \(\mathsf{2\times{}2}\) matrix of four cells. The Gray codes themselves serve as the row and column labels, representing the specific combinations of variable values along each axis. This structured labeling is essential for identifying valid groupings during simplification, with each cell corresponding to a unique input combination in the 2‑variable K‑map shown here.
Alternative Labeling
In some K-map layouts, the row and column labels are presented not as Gray codes, but directly as complemented and uncomplemented variables. However, Gray code ordering still governs the cell arrangement to preserve adjacency. These variable-based labels may offer a more intuitive bridge between the map and the original Boolean function, and may appeal more to some readers. A 2-variable K-map with alternative labels and input combinations is shown here:
Minterms in a 2-Variable K-map
In the figure, each cell is annotated with its corresponding minterm, determined by the input combination specified by the variables’ row and column labels.
Example 1: Construct a K-map
Construct a K-map for the function \(\mathsf{Z=\sum\left(0,2\right)}\)
Example 2: Construct a K-map
Construct a K-map for the function \(\mathsf{Z=\sum\left(0,2\right)}\). \(\mathsf{m_3}\) is a Don’t Care, \(\mathsf{X}\).
How to Solve a K-map?
This section outlines the general procedure for solving a K‑map, illustrated first with a simple 2‑input example. Starting with this basic case ensures that anyone can grasp the core concepts, regardless of which page they begin on. More complex examples—matching the number of inputs featured on the page—are introduced afterwards. To explore specific cases in detail, select the relevant page for 2‑, 3‑, 4‑, or 5‑input K‑maps. For an overall introduction to K‑maps, Gray codes, and minterms ordering, refer to their dedicated pages or sections.
The following steps are followed while solving a K-map.
- Identify Implicants: Identify groups of adjacent 1s that can be grouped in powers of 2 (1, 2, 4, 8, …).
- Make Prime Implicants: Form largest possible groups that collectively include all the relevant minterms.
- Determine the Product Term: For each group, determine the variable(s) that remain constant across it.
- Write Minimum Cost Solution: Combine terms using OR to generate the solution in SOP form.
In more precise terms, the process of grouping the largest possible sets of minterms in powers of two is essentially the search for prime implicants among all possible implicants. The resulting Sum of Products (SOP) expression is considered to be in its simplest form when it achieves the minimum cost—typically measured in terms of the fewest possible literals or logic gates required for implementation.
Step 1: Identify Implicants
An implicant is simply a product term that describes one or more specific input combinations where the function’s output is 1. The simplest implicants are the individual minterms. However, implicants aren’t limited to single minterms — by combining adjacent implicants in groups whose sizes are powers of two, we can form larger implicants that cover more minterms while still remaining valid.
Consider the following K‑map:
It contains a total of five implicants as highlighted in the figure. Of these, three are individual minterms, while the other two arise from grouping pairs of adjacent 1’s, \(\mathsf{m_0,m_2}\) and \(\mathsf{m_2,m_3}\), each forming a valid implicant.
Step 2: Make Prime Implicants
A prime implicant is an implicant that cannot be combined with any other implicant to form a larger valid group. In a K‑map, it represents the largest possible block of 1’s that contains no 0’s. It may or may not cover all the 1’s in the map, and in most cases, multiple prime implicants exist. In the above example, the two implicants which are formed by the groupings of \(\mathsf{m_0\textsf{ & }m_2}\), and \(\mathsf{m_2\textsf{ & }m_3}\), are the prime implicants.
Step 3: Determine the Product Term for Each Prime Implicant
To determine the product term for each prime implicant, identify the variables that remain constant across all 1’s in that group. Iteratively check each variable, and drop any literal that changes within the grouping. The remaining literals — whether in complemented or uncomplemented form — represent the constant variables for that largest valid block.
In the example, for the first prime implicant, covering minterms \(\mathsf{m_0}\) and \(\mathsf{m_2}\), input B is fixed at 0 across both minterms, while A changes from 0 in \(\mathsf{m_0}\) to 1 in \(\mathsf{m_2}\). Since A varies, it is dropped. The constant B = 0 corresponds to the literal \(\mathsf{B’}\).
For the second prime implicant, covering minterms \(\mathsf{m_2}\) and \(\mathsf{m_3}\), A remains fixed at 1 in both cases, while B changes. Thus, A = 1 is retained, giving the product term \(\mathsf{A}\).
Step 4: Write Minimum Cost Solution
Once all essential prime implicants have been selected, the final Boolean expression is obtained by combining their corresponding product terms using the OR operator (\(\mathsf{+}\)). If there are remaining prime implicants that can be included in multiple ways at equal minimal cost, any such combination may be chosen, as all yield functionally equivalent minimal solutions. The simplest function is:
\[\mathsf{Z=A+B’}\]
Example 3: Express in the simplest form \(\mathsf{Z=\sum\left(1,2\right)}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:
\[\mathsf{Z=A’B+AB’}\]
which is just the minterms. This is because we could not build larger groups of implicants and our prime implicants were just the minterms.
Example 4: Express in the simplest form \(\mathsf{Z=\sum\left(0,1,2\right)}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:
\[\mathsf{Z=A’+B’}\]
Example 5: Express in the simplest form \(\mathsf{Z=\sum\left(1,2\right)}\) with \(\mathsf{X}\) at \(\mathsf{m_0}\)
We draw the K-map, show the prime implicants (largest possible groupings of adjacent 1s in powers of 2) on it and then write the simplest function. The simplest function comes out to be:
\[\mathsf{Z=A’+B’}\]
Using \(\mathsf{X}\) as 1 helped us form bigger groups around minterms \(\mathsf{m_1}\) and \(\mathsf{m_2}\).
In this case, using \(\mathsf{X=0}\) would not have allowed the formation of larger groups for the prime implicants. Choosing \(\mathsf{X=1}\) with only a single minterm to expand the group would have increased the final cost, as the resulting implicant would still contain two literals for the other minterm. Therefore, we aim to ensure that each prime implicant in the K‑map is formed as the largest possible group to achieve minimal cost.
Frequently Asked Questions
Can we take the complement of a function using K-maps?
Yes, we can obtain the complement of a function using K‑maps. Instead of grouping 1s, we carry out the usual K‑map simplification process with the 0s. The largest possible groups of 0s, formed in sizes that are powers of two, will yield the complement of the function in sum‑of‑products form.
Example 6: Express the complement in the simplest form \(\mathsf{Z=\sum\left(0,1,2\right)}\)
There is just a single 0 at \(\mathsf{m_3}\). Consequently,
\[\mathsf{Z’ = AB}\]
Verifying against the truth table confirms the result. Like in previous example, if there was an \(\mathsf{X}\) at \(\mathsf{m_3}\), we could have taken \(\mathsf{X=1}\) to make the largest group of 1’s to leave behind just one 0.
Can we solve a function using maxterms in K-maps?
Yes — the function can also be solved using maxterms in K‑maps. The process mirrors that for minterms, but instead of grouping 1s, we identify the largest possible groupings of 0s. From these, we write the corresponding constant terms in sum form. Each prime implicant equivalent derived in this way is then combined using the AND gate (·) operator.
Example 7: Express in the simplest form using Maxterms \(\mathsf{Z=\sum\left(0,1,2\right)}\)
In this case, only a single 0 appears at \(\mathsf{M_3}\). Therefore, the corresponding full maxterm is \(\mathsf{A’+B’}\) — identical to the result we obtained earlier using minterms. Hence,
\[\mathsf{Z=A’+B’}\]
We can verify that there is a 0 in the truth table against \(\mathsf{A=1}\) and \(\mathsf{B=1}\).
Can we take the complement of a function using maxterms in K-maps?
Yes — we can find the complement of a function using maxterms in a K‑map. The approach is the same as the standard maxterm method, but instead of grouping 0s to get the original function, we group the 1s instead. The largest possible groups of 1s, formed in powers of two, give the complement in product‑of‑sums form, with each term representing the constant values across the group.
Example 8: Express the complement in the simplest form using Maxterms \(\mathsf{Z=\sum\left(0,1,2\right)}\)
In this case, we have two largest groups of 1s: one formed by combining \(\mathsf{M_0}\) with \(\mathsf{M_1}\), and another formed by combining \(\mathsf{M_0}\) with \(\mathsf{M_2}\). In the first group, A remains fixed at 0, giving the term A. In the second group, B stays fixed at 0, giving the term B. Since we’re working with maxterms, these terms are combined using the AND operation. Therefore, the complement of the function is:
\[\mathsf{Z’=A\cdot{}B}\]
This matches the result from the previous example and can also be confirmed directly from the truth table.