HOME

TheInfoList



OR:

The Karnaugh map (KM or K-map) is a method of simplifying
Boolean algebra In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas in e ...
expressions.
Maurice Karnaugh Maurice Karnaugh (; October 4, 1924 – November 8, 2022) was an American physicist, mathematician, computer scientist, and inventor known for the Karnaugh map used in Boolean algebra. Career Karnaugh studied mathematics and physics at City Co ...
introduced it in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which was a rediscovery of
Allan Marquand Allan Marquand (; December 10, 1853 – September 24, 1924) was an art historian at Princeton University and a curator of the Princeton University Art Museum. Early life Marquand was born on December 10, 1853 in New York City. He was a son of ...
's 1881 ''logical diagram'' aka Marquand diagram but with a focus now set on its utility for switching circuits. Veitch charts are also known as Marquand–Veitch diagrams or, rarely, as Svoboda charts, and Karnaugh maps as Karnaugh–Veitch maps (KV maps). The Karnaugh map reduces the need for extensive calculations by taking advantage of humans' pattern-recognition capability. It also permits the rapid identification and elimination of potential
race condition A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when one or more of t ...
s. The required Boolean results are transferred from a
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional argumen ...
onto a two-dimensional grid where, in Karnaugh maps, the cells are ordered in
Gray code The reflected binary code (RBC), also known as reflected binary (RB) or Gray code after Frank Gray, is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit). For example, the representati ...
, and each cell position represents one combination of input conditions. Cells are also known as minterms, while each cell value represents the corresponding output value of the boolean function. Optimal groups of 1s or 0s are identified, which represent the terms of a
canonical form In mathematics and computer science, a canonical, normal, or standard form of a mathematical object is a standard way of presenting that object as a mathematical expression. Often, it is one which provides the simplest representation of an obje ...
of the logic in the original truth table. These terms can be used to write a minimal Boolean expression representing the required logic. Karnaugh maps are used to simplify real-world logic requirements so that they can be implemented using a minimum number of logic gates. A sum-of-products expression (SOP) can always be implemented using
AND gate The AND gate is a basic digital logic gate that implements logical conjunction (∧) from mathematical logic AND gate behaves according to the truth table. A HIGH output (1) results only if all the inputs to the AND gate are HIGH (1). If not all ...
s feeding into an
OR gate The OR gate is a digital logic gate that implements logical disjunction. The OR gate returns true if either or both of its inputs are true; otherwise it returns false. The input and output states are normally represented by different voltage le ...
, and a product-of-sums expression (POS) leads to OR gates feeding an AND gate. The POS expression gives a complement of the function (if F is the function so its complement will be F'). Karnaugh maps can also be used to simplify logic expressions in software design. Boolean conditions, as used for example in conditional statements, can get very complicated, which makes the code difficult to read and to maintain. Once minimised, canonical sum-of-products and product-of-sums expressions can be implemented directly using AND and OR logic operators.


Example

Karnaugh maps are used to facilitate the simplification of
Boolean algebra In mathematics and mathematical logic, Boolean algebra is a branch of algebra. It differs from elementary algebra in two ways. First, the values of the variables are the truth values ''true'' and ''false'', usually denoted 1 and 0, whereas in e ...
functions. For example, consider the Boolean function described by the following
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional argumen ...
. Following are two different notations describing the same function in unsimplified Boolean algebra, using the Boolean variables , , , and their inverses. * f(A, B, C, D) = \sum_m_i, i \in \ where m_i are the
minterms In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF) or minterm canonical form and its dual canonical conjunctive normal form ( CCNF) or maxterm canonical form. Other canonical forms include ...
to map (i.e., rows that have output 1 in the truth table). * f(A, B, C, D) = \prod_M_i, i \in \ where M_i are the
maxterms In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF) or minterm canonical form and its dual canonical conjunctive normal form ( CCNF) or maxterm canonical form. Other canonical forms include ...
to map (i.e., rows that have output 0 in the truth table).


Construction

In the example above, the four input variables can be combined in 16 different ways, so the truth table has 16 rows, and the Karnaugh map has 16 positions. The Karnaugh map is therefore arranged in a 4 × 4 grid. The row and column indices (shown across the top and down the left side of the Karnaugh map) are ordered in
Gray code The reflected binary code (RBC), also known as reflected binary (RB) or Gray code after Frank Gray, is an ordering of the binary numeral system such that two successive values differ in only one bit (binary digit). For example, the representati ...
rather than binary numerical order. Gray code ensures that only one variable changes between each pair of adjacent cells. Each cell of the completed Karnaugh map contains a binary digit representing the function's output for that combination of inputs.


Grouping

After the Karnaugh map has been constructed, it is used to find one of the simplest possible forms — a
canonical form In mathematics and computer science, a canonical, normal, or standard form of a mathematical object is a standard way of presenting that object as a mathematical expression. Often, it is one which provides the simplest representation of an obje ...
— for the information in the truth table. Adjacent 1s in the Karnaugh map represent opportunities to simplify the expression. The minterms ('minimal terms') for the final expression are found by encircling groups of 1s in the map. Minterm groups must be rectangular and must have an area that is a power of two (i.e., 1, 2, 4, 8...). Minterm rectangles should be as large as possible without containing any 0s. Groups may overlap in order to make each one larger. The optimal groupings in the example below are marked by the green, red and blue lines, and the red and green groups overlap. The red group is a 2 × 2 square, the green group is a 4 × 1 rectangle, and the overlap area is indicated in brown. The cells are often denoted by a shorthand which describes the logical value of the inputs that the cell covers. For example, would mean a cell which covers the 2x2 area where and are true, i.e. the cells numbered 13, 9, 15, 11 in the diagram above. On the other hand, would mean the cells where is true and is false (that is, is true). The grid is toroidally connected, which means that rectangular groups can wrap across the edges (see picture). Cells on the extreme right are actually 'adjacent' to those on the far left, in the sense that the corresponding input values only differ by one bit; similarly, so are those at the very top and those at the bottom. Therefore, can be a valid term—it includes cells 12 and 8 at the top, and wraps to the bottom to include cells 10 and 14—as is , which includes the four corners.


Solution

Once the Karnaugh map has been constructed and the adjacent 1s linked by rectangular and square boxes, the algebraic minterms can be found by examining which variables stay the same within each box. For the red grouping: * ''A'' is the same and is equal to 1 throughout the box, therefore it should be included in the algebraic representation of the red minterm. * ''B'' does not maintain the same state (it shifts from 1 to 0), and should therefore be excluded. * ''C'' does not change. It is always 0, so its complement, NOT-C, should be included. Thus, should be included. * ''D'' changes, so it is excluded. Thus the first minterm in the Boolean sum-of-products expression is . For the green grouping, ''A'' and ''B'' maintain the same state, while ''C'' and ''D'' change. ''B'' is 0 and has to be negated before it can be included. The second term is therefore . Note that it is acceptable that the green grouping overlaps with the red one. In the same way, the blue grouping gives the term . The solutions of each grouping are combined: the normal form of the circuit is A\overline + A\overline + BC\overline. Thus the Karnaugh map has guided a simplification of :\begin f(A, B, C, D) = &\overlineBC\overline + A\overline\,\overline\,\overline + A\overline\,\overlineD + A\overlineC\overline + \\ &A\overlineCD + AB\overline\,\overline + AB\overlineD + ABC\overline\\ = &A\overline + A\overline + BC\overline \end It would also have been possible to derive this simplification by carefully applying the axioms of Boolean algebra, but the time it takes to do that grows exponentially with the number of terms.


Inverse

The inverse of a function is solved in the same way by grouping the 0s instead. The three terms to cover the inverse are all shown with grey boxes with different colored borders: * : * : * : This yields the inverse: :\overline = \overline\,\overline + \overline\,\overline + BCD Through the use of
De Morgan's laws In propositional logic and Boolean algebra, De Morgan's laws, also known as De Morgan's theorem, are a pair of transformation rules that are both valid rules of inference. They are named after Augustus De Morgan, a 19th-century British mathem ...
, the
product of sums In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF) or minterm canonical form and its dual canonical conjunctive normal form ( CCNF) or maxterm canonical form. Other canonical forms include ...
can be determined: :\begin f(A,B,C,D) &= \overline \\ &= \overline \\ &= \left(\overline\right) \left(\overline\right) \left(\overline\right) \\ &= \left(A + B\right)\left(A + C\right)\left(\overline + \overline + \overline\right) \end


Don't cares

Karnaugh maps also allow easier minimizations of functions whose truth tables include "
don't care In digital logic, a don't-care term (abbreviated DC, historically also known as ''redundancies'', ''irrelevancies'', ''optional entries'', ''invalid combinations'', ''vacuous combinations'', ''forbidden combinations'', ''unused states'' or ''l ...
" conditions. A "don't care" condition is a combination of inputs for which the designer doesn't care what the output is. Therefore, "don't care" conditions can either be included in or excluded from any rectangular group, whichever makes it larger. They are usually indicated on the map with a dash or X. The example on the right is the same as the example above but with the value of ''f''(1,1,1,1) replaced by a "don't care". This allows the red term to expand all the way down and, thus, removes the green term completely. This yields the new minimum equation: :f(A,B,C,D) = A + BC\overline Note that the first term is just , not . In this case, the don't care has dropped a term (the green rectangle); simplified another (the red one); and removed the race hazard (removing the yellow term as shown in the following section on race hazards). The inverse case is simplified as follows: :\overline = \overline\,\overline + \overline\,\overline + \overlineD Through the use of
De Morgan's laws In propositional logic and Boolean algebra, De Morgan's laws, also known as De Morgan's theorem, are a pair of transformation rules that are both valid rules of inference. They are named after Augustus De Morgan, a 19th-century British mathem ...
, the
product of sums In Boolean algebra, any Boolean function can be expressed in the canonical disjunctive normal form ( CDNF) or minterm canonical form and its dual canonical conjunctive normal form ( CCNF) or maxterm canonical form. Other canonical forms include ...
can be determined: :\begin f(A,B,C,D) &= \overline \\ &= \overline \\ &= \left(\overline\right) \left(\overline\right) \left(\overline\right) \\ &= \left(A + B\right)\left(A + C\right)\left(A +\overline\right) \end


Race hazards


Elimination

Karnaugh maps are useful for detecting and eliminating
race condition A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when one or more of t ...
s. Race hazards are very easy to spot using a Karnaugh map, because a race condition may exist when moving between any pair of adjacent, but disjoint, regions circumscribed on the map. However, because of the nature of Gray coding, ''adjacent'' has a special definition explained above – we're in fact moving on a torus, rather than a rectangle, wrapping around the top, bottom, and the sides. * In the example above, a potential race condition exists when ''C'' is 1 and ''D'' is 0, ''A'' is 1, and ''B'' changes from 1 to 0 (moving from the blue state to the green state). For this case, the output is defined to remain unchanged at 1, but because this transition is not covered by a specific term in the equation, a potential for a ''glitch'' (a momentary transition of the output to 0) exists. * There is a second potential glitch in the same example that is more difficult to spot: when ''D'' is 0 and ''A'' and ''B'' are both 1, with C changing from 1 to 0 (moving from the blue state to the red state). In this case the glitch wraps around from the top of the map to the bottom. Whether glitches will actually occur depends on the physical nature of the implementation, and whether we need to worry about it depends on the application. In clocked logic, it is enough that the logic settles on the desired value in time to meet the timing deadline. In our example, we are not considering clocked logic. In our case, an additional term of A\overline would eliminate the potential race hazard, bridging between the green and blue output states or blue and red output states: this is shown as the yellow region (which wraps around from the bottom to the top of the right half) in the adjacent diagram. The term is redundant in terms of the static logic of the system, but such redundant, or consensus terms, are often needed to assure race-free dynamic performance. Similarly, an additional term of \overlineD must be added to the inverse to eliminate another potential race hazard. Applying De Morgan's laws creates another product of sums expression for ''f'', but with a new factor of \left(A + \overline\right).


2-variable map examples

The following are all the possible 2-variable, 2 × 2 Karnaugh maps. Listed with each is the minterms as a function of \sum m() and the race hazard free (''see previous section'') minimum equation. A minterm is defined as an expression that gives the most minimal form of expression of the mapped variables. All possible horizontal and vertical interconnected blocks can be formed. These blocks must be of the size of the powers of 2 (1, 2, 4, 8, 16, 32, ...). These expressions create a minimal logical mapping of the minimal logic variable expressions for the binary expressions to be mapped. Here are all the blocks with one field. A block can be continued across the bottom, top, left, or right of the chart. That can even wrap beyond the edge of the chart for variable minimization. This is because each logic variable corresponds to each vertical column and horizontal row. A visualization of the k-map can be considered cylindrical. The fields at edges on the left and right are adjacent, and the top and bottom are adjacent. K-Maps for four variables must be depicted as a donut or torus shape. The four corners of the square drawn by the k-map are adjacent. Still more complex maps are needed for 5 variables and more. File:K-map 2x2 none.svg , Σ''m''(0); ''K'' = 0 File:K-map 2x2 1.svg , Σ''m''(1); ''K'' = ''A''′''B''′ File:K-map 2x2 2.svg , Σ''m''(2); ''K'' = ''AB''′ File:K-map 2x2 3.svg , Σ''m''(3); ''K'' = ''A''′''B'' File:K-map 2x2 4.svg , Σ''m''(4); ''K'' = ''AB'' File:K-map 2x2 1,2.svg , Σ''m''(1,2); ''K'' = ''B''′ File:K-map 2x2 1,3.svg , Σ''m''(1,3); ''K'' = ''A''′ File:K-map 2x2 1,4.svg , Σ''m''(1,4); ''K'' = ''A''′''B''′ + ''AB'' File:K-map 2x2 2,3.svg , Σ''m''(2,3); ''K'' = ''AB''′ + ''A''′''B'' File:K-map 2x2 2,4.svg , Σ''m''(2,4); ''K'' = ''A'' File:K-map 2x2 3,4.svg , Σ''m''(3,4); ''K'' = ''B'' File:K-map 2x2 1,2,3.svg , Σ''m''(1,2,3); ''K'' = ''A + ''B''′ File:K-map 2x2 1,2,4.svg , Σ''m''(1,2,4); ''K'' = ''A'' + ''B''′ File:K-map 2x2 1,3,4.svg , Σ''m''(1,3,4); ''K'' = ''A''′ + ''B'' File:K-map 2x2 2,3,4.svg , Σ''m''(2,3,4); ''K'' = ''A'' + ''B'' File:K-map 2x2 1,2,3,4.svg , Σ''m''(1,2,3,4); ''K'' = 1


Related graphical methods

Related graphical minimization methods include: * ''Marquand diagram'' (1881) by
Allan Marquand Allan Marquand (; December 10, 1853 – September 24, 1924) was an art historian at Princeton University and a curator of the Princeton University Art Museum. Early life Marquand was born on December 10, 1853 in New York City. He was a son of ...
(1853–1924) * ''Veitch chart'' (1952) by Edward W. Veitch (1924–2013) * ''Svoboda chart'' (1956) by Antonín Svoboda (1907–1980) * ''
Mahoney map Logic optimization is a process of finding an equivalent representation of the specified logic circuit under one or more specified constraints. This process is a part of a logic synthesis applied in digital electronics and integrated circuit de ...
'' (''M-map'', ''designation numbers'', 1963) by Matthew V. Mahoney (a reflection-symmetrical extension of Karnaugh maps for larger numbers of inputs) * ''
Reduced Karnaugh map Logic optimization is a process of finding an equivalent representation of the specified logic circuit under one or more specified constraints. This process is a part of a logic synthesis applied in digital electronics and integrated circuit de ...
'' (RKM) techniques (from 1969) like ''infrequent variables'', ''map-entered variables'' (MEV), ''variable-entered map'' (VEM) or ''variable-entered Karnaugh map'' (VEKM) by G. W. Schultz, Thomas E. Osborne, Christopher R. Clare, J. Robert Burgoon, Larry L. Dornhoff, William I. Fletcher, Ali M. Rushdi and others (several successive Karnaugh map extensions based on variable inputs for a larger numbers of inputs) * ''
Minterm-ring map Logic optimization is a process of finding an equivalent representation of the specified logic circuit under one or more specified constraints. This process is a part of a logic synthesis applied in digital electronics and integrated circuit de ...
'' (MRM, 1990) by Thomas R. McCalla (a three-dimensional extension of Karnaugh maps for larger numbers of inputs)


See also

*
Algebraic normal form In Boolean algebra, the algebraic normal form (ANF), ring sum normal form (RSNF or RNF), '' Zhegalkin normal form'', or '' Reed–Muller expansion'' is a way of writing logical formulas in one of three subforms: * The entire formula is purely tr ...
(ANF) *
Binary decision diagram In computer science, a binary decision diagram (BDD) or branching program is a data structure that is used to represent a Boolean function. On a more abstract level, BDDs can be considered as a compressed representation of sets or relations. Un ...
(BDD), a data structure that is a compressed representation of a Boolean function *
Espresso heuristic logic minimizer The ESPRESSO logic minimizer is a computer program using heuristic and specific algorithms for efficiently reducing the complexity of digital logic gate circuits. ESPRESSO-I was originally developed at IBM by Robert K. Brayton et al. in 1982. ...
*
List of Boolean algebra topics This is a list of topics around Boolean algebra and propositional logic. Articles with a wide scope and introductions * Algebra of sets * Boolean algebra (structure) * Boolean algebra * Field of sets * Logical connective * Pro ...
*
Logic optimization Logic optimization is a process of finding an equivalent representation of the specified logic circuit under one or more specified constraints. This process is a part of a logic synthesis applied in digital electronics and integrated circuit de ...
*
Punnett square The Punnett square is a square diagram that is used to predict the genotypes of a particular cross or breeding experiment. It is named after Reginald C. Punnett, who devised the approach in 1905. The diagram is used by biologists to determine ...
(1905), a similar diagram in biology *
Quine–McCluskey algorithm The Quine–McCluskey algorithm (QMC), also known as the method of prime implicants, is a method used for minimization of Boolean functions that was developed by Willard V. Quine in 1952 and extended by Edward J. McCluskey in 1956. As a genera ...
*
Reed–Muller expansion In Boolean logic, a Reed–Muller expansion (or Davio expansion) is a decomposition of a Boolean function. For a Boolean function f(x_1,\ldots,x_n) : \mathbb^n \to \mathbb we call : \begin f_(x) & = f(x_1,\ldots,x_,1,x_,\ldots,x_n) \\ f_(x)& = ...
*
Venn diagram A Venn diagram is a widely used diagram style that shows the logical relation between set (mathematics), sets, popularized by John Venn (1834–1923) in the 1880s. The diagrams are used to teach elementary set theory, and to illustrate simple ...
(1880) *
Zhegalkin polynomial Zhegalkin (also Žegalkin, Gégalkine or Shegalkin) polynomials (russian: полиномы Жегалкина), also known as algebraic normal form, are a representation of functions in Boolean algebra. Introduced by the Russian mathematician Iva ...


Notes


References


Further reading

* * * * * (146 pages) *

* * *
https://web.archive.org/web/20221126095943/http://www.viademica.de/content/buchkatalog/detail.php?id=263 -->
(282 pages with 14 animations)


External links

{{sisterlinks
Detect Overlapping Rectangles
by Herbert Glarner.
Using Karnaugh maps in practical applications
Circuit design project to control traffic lights.




POCKET–PC BOOLEAN FUNCTION SIMPLIFICATION, Ledion Bitincka — George E. Antoniou

K-Map troubleshoot
Boolean algebra Diagrams Electronics optimization Logic in computer science