Karnaugh Maps
What are karnaugh maps? Boolean algebra can be represented in a variety of ways. These include: Boolean expressions Truth tables Circuit diagrams Another method is the Karnaugh Map (also known as the K-map) K-maps are particularly useful for simplfying boolean expressions
2 variable K-Map Starting with the Expression: A ∧ B As a Truth Table this would be: As a Circuit Diagram this would be: A K-Map, will be a small grid with 4 boxes, one for each combination of A and B. Each grid square has a value for A and a value for B. To complete the K-Map for the expression, you find the box in the row where A is true and the column where B is true, put a 1 in the box that is in both rows. AB A ∧ B
2 variable K-Map One way to view a K-Map is to figure out what the ‘address’ is for each box: what its A and B values are for each position These have been written in the format (A, B) (0,0) (0,1) (1,0) (1,1)
2 variable K-Map To create a K-map for the expression: A Place 1s in all the boxes in the row where A is true 1
2 variable K-Map To create a K-Map for the expression B Place 1s in all the boxes in the column where B is true 1
2 variable K-Map Expression: ~A ∧ B Find the row where A is false and the column where B is true Place a 1 in the overlapping position 1
2 variable K-Map Try working backwards! Starting with the K-Map, interpret the results and write an expression Highlight the row that contains the 1 Is it A or ~A? Highlight the column that contains the 1 Is it B or ~B? Write down your two variables and join them with an AND ( ∧ ) 1
2 variable K-Map Try working backwards! Starting with the K-Map, interpret the results and write an expression Highlight the row that contains the 1 Is it A or ~A? Highlight the column that contains the 1 Is it B or ~B? Write down your two variables and join them with an AND ( ∧ ) 1
3 variable K-Map In a 3 variable K-Map, we need to accommodate 8 possible combinations of A, B and C We’ll start by figuring out the ‘address’ for each position (A, B, C) (0,0,0)(0,0,1) (0,1,0)(0,1,1) (1,1,0)(1,1,1) (1,0,0)(1,0,1)
3 variable K-Map If we had a K-Map where the expression was B We would place 1s in every box where B is true We ignore the values of A and C, because they are not written in our expression
3 variable K-Map Create a K-map for the expression: ~A ∧ C Highlight rows where A is false Highlight columns where C is true Place 1s in all the overlapping boxes Note: We can ignore the values of B, because they are not mentioned in the expression
3 variable K-Map To create the K-Map for the expression A ∧ B ∧ ~C Highlight rows where A is true Highlight rows where B is false Highlight columns where C is false Place 1s in all the overlapping boxes 1
3 variable K-Map This time we’ll start with a K-map and find the expression. Identify any groupings (in this case we have a pair) What is the value of A for both items in the pair? What is the value of B for both items in the pair? What is the value of C for both items in the pair? 1111
3 variable K-Map This time we’ll start with a K-map and find the expression. Identify any groupings (in this case we have a pair) What is the value of A for both items in the pair? What is the value of B for both items in the pair? What is the value of C for both items in the pair? Because B is both true and false, it does not affect the answer and can be ignored 1111 ~A ∧ C
3 variable K-Map Determine the expression represented by this K-map Identify any groupings What is the value of A for both items in the pair? What is the value of B for both items in the pair? What is the value of C for both items in the pair? 1111
3 variable K-Map Working backwards to build an expression Identify any groupings (I see a pair) What is the value of A for both items in the pair? What is the value of B for both items in the pair? What is the value of C for both items in the pair? Because A is both true and false, it does not affect the answer and can be ignored This leaves: 1111 B ∧ ~C
3 variable K-Map Determine the expression represented by this K-map Identify any groupings (I see two pairs) What is the value of A for both items in the first pair? What is the value of B for both items in the first pair? What is the value of C for both items in the first pair? First Pair: What is the value of A for both items in the second pair? What is the value of B for both items in the second pair? What is the value of C for both items in the second pair? Second Pair: Put brackets around each pair and combine them with an OR
3 variable K-Map Determine the expression represented by this K-map Identify any groupings (I see two pairs) What is the value of A for both items in the first pair? What is the value of B for both items in the first pair? What is the value of C for both items in the first pair? First Pair: ~A ∧ ~B What is the value of A for both items in the second pair? What is the value of B for both items in the second pair? What is the value of C for both items in the second pair? Second Pair: A ∧ ~C Put brackets around each pair and combine them with an OR (~A ∧ ~B) ∨ (A ∧ ~C)
3 variable K-Map Working backwards to build an expression Identify any groupings (I see two pairs) What are the value of A, B, C values for the first pair? What are the value of A, B, C values for the second pair? First Pair: Second Pair: Put brackets around each pair and combine them with an OR
3 variable K-Map Working backwards to build an expression Identify any groupings (I see two pairs) What are the value of A, B, C values for the first pair? What are the value of A, B, C values for the second pair? First Pair: ~A ∧ ~C Second Pair: C ∧ B Put brackets around each pair and combine them with an OR (~A ∧ ~C) ∨ (C ∧ B)
3 variable K-Map Working backwards to build an expression Identify any groupings (I see two pairs) When I look more closely, I can see they are both ~B, so perhaps I can view it as a group of 4 What are the value of A, B, C values for the group? 1
3 variable K-Map Working backwards to build an expression Identify any groupings (I see two pairs) When I look more closely, I can see they are both ~B, so perhaps I can view it as a group of 4 What are the value of A, B, C values for the group? A is both true and false, so it can be ignored B is false C is both true and false, so it can be ignored This leaves: ~B 1
K-Map Notes Some notes to add at this point: Groupings can only be exact binary values: 1, 2, 4, 8 You cannot have a groupings of 3 Groups can overlap The bigger the groupings, the simpler the resulting expression/circuit When converting from a truth table to a K-Map, simply use the values in the TT to find the position values within the K-Map
4 variable K-Map In a 4 variable K-Map, we need to accommodate 16 possible combinations of A, B, C and D We’ll start by figuring out what the ‘address’ for each position (A, B, C, D) (0,0,0,0) (0,0,0,1) (0,0,1,1) (0,0,1,0) (0,1,0,0) (0,1,0,1) (0,1,1,1) (0,1,1,0) (1,1,0,0) (1,1,0,1) (1,1,1,1) (1,1,1,0) (1,0,0,0) (1,0,0,1) (1,0,1,1) (1,0,1,0)
4 variable K-Map If we had a K-Map where the expression was D We would place 1s in every box where D is true We ignore the values of A, B and C, because they are not written in our expression 1
4 variable K-Map If we had a K-Map where the expression was: A ∧ ~B ∧ ~C ∧ ~D We would highlight the Rows where A is true Rows where B is false Columns where C is false Columns where D is false place 1s in all the overlapping boxes (When you have all 4 variables in your expression, it will only result in a single value in the K-Map) 1
4 variable K-Map If we had a K-Map where the expression was: (A ∧ D) We highlight the: Rows where A is true Columns where D is true Put 1s in all overlapping boxes 1
4 variable K-Map If we had a K-Map where the expression was: (A ∧ B) ∨ (B ∧ C ∧ ~D) We would work with one pair at a time. For each part of the expression: Identify the overlapping boxes Place 1s in them We have resulted in a: Group of 4 Pair 1 1 1
4 variable K-Map Working backwards Identify any groupings (I see a group of 4) What is the value of A for the items in the group? What is the value of B for the items in the group? What is the value of C for the items in the group? What is the value of D for the items in the group? 1 1
4 variable K-Map Working backwards Identify any groupings (I see a group of 4) What is the value of A for the items in the group? False What is the value of B for the items in the group? False What is the value of C for the items in the group? True/False What is the value of D for the items in the group? True/False ~A ∧ ~B 1 1
4 variable K-Map Working backwards Identify any groupings (I see a group of 4 and a pair) What are the values of A, B, C and D for the group? What are the values of A, B, C and D for the pair? Solution
4 variable K-Map Working backwards Identify any groupings (I see a group of 4 and a pair) What are the values of A, B, C and D for the group? (C ∧ ~D) What are the values of A, B, C and D for the pair? (A ∧ B ∧ ~C) Solution: (C ∧ ~D) ∨ (A ∧ B ∧ ~C)
K-Maps & Truth Tables Often we are asked to write an expression based on a truth table, this can result in pretty complicated expressions that require simplification using logic laws Using a K-Map can aid the simplification process
K-Maps & Truth Tables Let’s start with a Truth Table To build an expression we would normally write an expression (using AND’s) for each row resulting in true and combine those with ORs This produces a really big expression that will be difficult to simplify using the logic laws ABCSolution (~A ∧ ~B ∧ C) ∨ (~A ∧ B ∧ C) ∨ (A ∧ ~B ∧ C) ∨ (A ∧ B ∧ ~C) ∨ (A ∧ B ∧ C)
K-Maps & Truth Tables Rather than converting straight to an expression, let’s try placing the values in a Karnaugh Map. Place 1s in the appropriate positions, according to the Truth Table This highlights a group of 4 and a pair From this we can write a simpler expression ABCSolution
K-Maps & Truth Tables Rather than converting straight to an expression, let’s try placing the values in a Karnaugh Map. Place 1s in the appropriate positions, according to the Truth Table This highlights a group of 4 and a pair From this we can write a simpler expression ABCSolution C ∨ (A ∧ B)
Practise, Practise, Practise The best way to learn how to work with K-Maps, is to apply your new knowledge to some Karnaugh Maps worksheets