1 00:00:00,880 --> 00:00:05,421 When trying to minimize a sum-of-products expression using the reduction identity, our 2 00:00:05,421 --> 00:00:10,520 goal is to find two product terms that can be written as one smaller product term, eliminating 3 00:00:10,520 --> 00:00:12,760 the "don't-care" variable. 4 00:00:12,760 --> 00:00:17,640 This is easy to do when two the product terms come from adjacent rows in the truth table. 5 00:00:17,640 --> 00:00:21,619 For example, look at the bottom two rows in this truth table. 6 00:00:21,619 --> 00:00:26,570 Since the Y output is 1 in both cases, both rows will be represented in the sum-of-products 7 00:00:26,570 --> 00:00:29,029 expression for this function. 8 00:00:29,029 --> 00:00:35,230 It's easy to spot the don't care variable: when C and B are both 1, the value of A isn't 9 00:00:35,230 --> 00:00:36,821 needed to determine the value of Y. 10 00:00:36,821 --> 00:00:42,431 Thus, the last two rows of the truth table can be represented by the single product term 11 00:00:42,431 --> 00:00:45,780 (B AND C). 12 00:00:45,780 --> 00:00:49,820 Finding these opportunities would be easier if we reorganized the truth table so that 13 00:00:49,820 --> 00:00:54,030 the appropriate product terms were on adjacent rows. 14 00:00:54,030 --> 00:00:58,560 That's what we've done in the Karnaugh map, K-map for short, shown on the right. 15 00:00:58,560 --> 00:01:04,080 The K-map organizes the truth table as a two-dimensional table with its rows and columns labeled with 16 00:01:04,080 --> 00:01:06,969 the possible values for the inputs. 17 00:01:06,969 --> 00:01:12,420 In this K-map, the first row contains entries for when C is 0 and the second row contains 18 00:01:12,420 --> 00:01:14,700 entries for when C is 1. 19 00:01:14,700 --> 00:01:19,408 Similarly, the first column contains entries for when A is 0 and B is 0. 20 00:01:19,408 --> 00:01:21,259 And so on. 21 00:01:21,259 --> 00:01:25,180 The entries in the K-map are exactly the same as the entries in the truth table, they're 22 00:01:25,180 --> 00:01:28,219 just formatted differently. 23 00:01:28,219 --> 00:01:31,658 Note that the columns have been listed in a special sequence that's different from the 24 00:01:31,658 --> 00:01:34,270 usual binary counting sequence. 25 00:01:34,270 --> 00:01:40,259 In this sequence, called a Gray Code, adjacent labels differ in exactly one of their bits. 26 00:01:40,259 --> 00:01:44,820 In other words, for any two adjacent columns, either the value of the A label changed, or 27 00:01:44,820 --> 00:01:47,950 the value of the B label changed. 28 00:01:47,950 --> 00:01:52,869 In this sense, the leftmost and rightmost columns are also adjacent. 29 00:01:52,869 --> 00:01:56,729 We write the table as a two-dimensional matrix, but you should think of it as cylinder with 30 00:01:56,729 --> 00:01:59,319 its left and right edges touching. 31 00:01:59,319 --> 00:02:04,049 If it helps you visualize which entries are adjacent, the edges of the cube shows which 32 00:02:04,049 --> 00:02:08,119 3-bit input values differ by only one bit. 33 00:02:08,119 --> 00:02:12,960 As shown by the red arrows, if two entries are adjacent in the cube, they are also adjacent 34 00:02:12,960 --> 00:02:15,260 in the table. 35 00:02:15,260 --> 00:02:19,510 It's easy to extend the K-map notation to truth tables for functions with 4 inputs, 36 00:02:19,510 --> 00:02:21,220 as shown here. 37 00:02:21,220 --> 00:02:25,540 We've used a Gray code sequencing for the rows as well as the columns. 38 00:02:25,540 --> 00:02:31,670 As before, the leftmost and rightmost columns are adjacent, as are the top and bottom rows. 39 00:02:31,670 --> 00:02:36,829 Again, as we move to an adjacent column or an adjacent row, only one of the four input 40 00:02:36,829 --> 00:02:39,270 labels will have changed. 41 00:02:39,270 --> 00:02:45,120 To build a K-map for functions of 6 variables we'd need a 4x4x4 matrix of values. 42 00:02:45,120 --> 00:02:49,680 That's hard to draw on the 2D page and it would be a challenge to tell which cells in 43 00:02:49,680 --> 00:02:52,180 the 3D matrix were adjacent. 44 00:02:52,180 --> 00:02:55,900 For more than 6 variables we'd need additional dimensions. 45 00:02:55,900 --> 00:03:00,680 Something we can handle with computers, but hard for those of us who live in only a three-dimensional 46 00:03:00,680 --> 00:03:02,760 space! 47 00:03:02,760 --> 00:03:08,400 As a practical matter, K-maps work well for up to 4 variables, and we'll stick with that. 48 00:03:08,400 --> 00:03:14,530 But keep in mind that you can generalize the K-map technique to higher dimensions. 49 00:03:14,530 --> 00:03:16,890 So why talk about K-maps? 50 00:03:16,890 --> 00:03:22,050 Because patterns of adjacent K-map entries that contain 1's will reveal opportunities 51 00:03:22,050 --> 00:03:26,690 for using simpler product terms in our sum-of-products expression. 52 00:03:26,690 --> 00:03:31,840 Let's introduce the notion of an implicant, a fancy name for a rectangular region of the 53 00:03:31,840 --> 00:03:34,220 K-map where the entries are all 1's. 54 00:03:34,220 --> 00:03:38,910 Remember when an entry is a 1, we'll want the sum-of-products expression to evaluate 55 00:03:38,910 --> 00:03:43,700 to TRUE for that particular combination of input values. 56 00:03:43,700 --> 00:03:48,910 We require the width and length of the implicant to be a power of 2, i.e., the region should 57 00:03:48,910 --> 00:03:55,060 have 1, 2, or 4 rows, and 1, 2, or 4 columns. 58 00:03:55,060 --> 00:03:57,720 It's okay for implicants to overlap. 59 00:03:57,720 --> 00:04:02,710 We say that an implicant is a prime implicant if it is not completely contained in any other 60 00:04:02,710 --> 00:04:03,710 implicant. 61 00:04:03,710 --> 00:04:09,490 Each product term in our final minimized sum-of-products expression will be related to some prime implicant 62 00:04:09,490 --> 00:04:12,010 in the K-map. 63 00:04:12,010 --> 00:04:17,160 Let's see how these rules work in practice using these two example K-maps. 64 00:04:17,160 --> 00:04:21,750 As we identify prime implicants, we'll circle them in red. 65 00:04:21,750 --> 00:04:26,320 Starting with the K-map on the left, the first implicant contains the singleton 1-cell that's 66 00:04:26,320 --> 00:04:30,160 not adjacent to any other cell containing 1's. 67 00:04:30,160 --> 00:04:34,240 The second prime implicant is the pair of adjacent 1's in the upper right hand corner 68 00:04:34,240 --> 00:04:35,840 of the K-map. 69 00:04:35,840 --> 00:04:40,280 This implicant is has one row and two columns, meeting our constraints on an implicant's 70 00:04:40,280 --> 00:04:42,900 dimensions. 71 00:04:42,900 --> 00:04:46,860 Finding the prime implicants in the right-hand K-map is a bit trickier. 72 00:04:46,860 --> 00:04:53,270 Recalling that the left and right columns are adjacent, we can spot a 2x2 prime implicant. 73 00:04:53,270 --> 00:04:59,720 Note that this prime implicant contains many smaller 1x2, 2x1 and 1x1 implicants, but none 74 00:04:59,720 --> 00:05:05,000 of those would be prime implicants since they are completely contained in the 2x2 implicant. 75 00:05:05,000 --> 00:05:10,680 It's tempting draw a 1x1 implicant around the remaining 1, but actually we want to find 76 00:05:10,680 --> 00:05:14,370 the largest implicant that contains this particular cell. 77 00:05:14,370 --> 00:05:18,650 In this case, that's the 1x2 prime implicant shown here. 78 00:05:18,650 --> 00:05:21,400 Why do we want to find the largest possible prime implicants? 79 00:05:21,400 --> 00:05:25,180 We'll answer that question in a minuteā€¦ 80 00:05:25,180 --> 00:05:29,790 Each implicant can be uniquely identified by a product term, a Boolean expression that 81 00:05:29,790 --> 00:05:34,590 evaluates to TRUE for every cell contained within the implicant and FALSE for all other 82 00:05:34,590 --> 00:05:35,669 cells. 83 00:05:35,669 --> 00:05:39,290 Just as we did for the truth table rows at the beginning of this chapter, we can use 84 00:05:39,290 --> 00:05:44,940 the row and column labels to help us build the correct product term. 85 00:05:44,940 --> 00:05:50,370 The first implicant we circled corresponds to the product term (not A) AND (not B) 86 00:05:50,370 --> 00:05:57,960 AND C, an expression that evaluates to TRUE when A is 0, B is 0, and C is 1. 87 00:05:57,960 --> 00:06:02,210 How about the 1x2 implicant in the upper-right hand corner? 88 00:06:02,210 --> 00:06:07,139 We don't want to include the input variables that change as we move around in the implicant. 89 00:06:07,139 --> 00:06:12,590 In this case the two input values that remain constant are C (which has the value 0) and 90 00:06:12,590 --> 00:06:19,350 A (which has the value 1), so the corresponding product term is A AND (not C). 91 00:06:19,350 --> 00:06:25,650 Here are the two product terms for the two prime implicants in the right-hand K-map. 92 00:06:25,650 --> 00:06:30,370 Notice that the larger the prime implicant, the smaller the product term! 93 00:06:30,370 --> 00:06:34,270 That makes sense: as we move around inside a large implicant, the number of inputs that 94 00:06:34,270 --> 00:06:37,730 remain constant across the entire implicant is smaller. 95 00:06:37,730 --> 00:06:42,400 Now we see why we want to find the largest possible prime implicants: they give us the 96 00:06:42,400 --> 00:06:45,190 smallest product terms! 97 00:06:45,190 --> 00:06:47,250 Let's try another example. 98 00:06:47,250 --> 00:06:50,560 Remember that we're looking for the largest possible prime implicants. 99 00:06:50,560 --> 00:06:55,860 A good way to proceed is to find some un-circled 1, and then identify the largest implicant 100 00:06:55,860 --> 00:06:59,110 we can find that incorporates that cell. 101 00:06:59,110 --> 00:07:03,720 There's a 2x4 implicant that covers the middle two rows of the table. 102 00:07:03,720 --> 00:07:09,100 Looking at the 1's in the top row, we can identify two 2x2 implicants that include those 103 00:07:09,100 --> 00:07:10,770 cells. 104 00:07:10,770 --> 00:07:15,949 There's a 4x1 implicant that covers the right column, leaving the lonely 1 in the lower 105 00:07:15,949 --> 00:07:18,979 left-hand corner of the table. 106 00:07:18,979 --> 00:07:24,770 Looking for adjacent 1's and remembering the table is cyclic, we can find a 2x2 implicant 107 00:07:24,770 --> 00:07:29,370 that incorporates this last un-circled 1. 108 00:07:29,370 --> 00:07:33,460 Notice that we're always looking for the largest possible implicant, subject to constraint 109 00:07:33,460 --> 00:07:37,470 that each dimension has to be either 1, 2 or 4. 110 00:07:37,470 --> 00:07:42,030 It's these largest implicants that will turn out to be prime implicants. 111 00:07:42,030 --> 00:07:46,630 Now that we've identified the prime implicants, we're ready to build the minimal sum-of-products 112 00:07:46,630 --> 00:07:48,290 expression. 113 00:07:48,290 --> 00:07:52,600 Here are two example K-maps where we've shown only the prime implicants needed to cover 114 00:07:52,600 --> 00:07:54,630 all the 1's in the map. 115 00:07:54,630 --> 00:08:00,430 This means, for example, that in the 4-variable map, we didn't include the 4x1 implicant covering 116 00:08:00,430 --> 00:08:02,360 the right column. 117 00:08:02,360 --> 00:08:06,570 That implicant was a prime implicant since it wasn't completely contained by any other 118 00:08:06,570 --> 00:08:12,550 implicant, but it wasn't needed to provide a cover for all the ones in the table. 119 00:08:12,550 --> 00:08:16,820 Looking at the top table, we'll assemble the minimal sum-of-products expression by including 120 00:08:16,820 --> 00:08:20,210 the product terms for each of the shown implicants. 121 00:08:20,210 --> 00:08:25,650 The top implicant has the product term A AND (not C), and the bottom implicant has the 122 00:08:25,650 --> 00:08:28,340 product term (B AND C). 123 00:08:28,340 --> 00:08:30,460 And we're done! 124 00:08:30,460 --> 00:08:33,140 Why is the resulting equation minimal? 125 00:08:33,140 --> 00:08:37,789 If there was some further reduction that could be applied, to produce a yet smaller product 126 00:08:37,789 --> 00:08:41,960 term, that would mean there was a larger prime implicant that could have been circled in 127 00:08:41,960 --> 00:08:44,470 the K-map. 128 00:08:44,470 --> 00:08:50,110 Looking the bottom table, we can assemble the sum-of-products expression term-by-term. 129 00:08:50,110 --> 00:08:56,170 There were 4 prime implicants, so there are 4 product terms in the expression. 130 00:08:56,170 --> 00:08:58,180 And we're done. 131 00:08:58,180 --> 00:09:02,640 Finding prime implicants in a K-map is faster and less error-prone that fooling around with 132 00:09:02,640 --> 00:09:06,130 Boolean algebra identities. 133 00:09:06,130 --> 00:09:10,550 Note that the minimal sum-of-products expression isn't necessarily unique. 134 00:09:10,550 --> 00:09:14,950 If we had used a different mix of the prime implicants when building our cover, we would 135 00:09:14,950 --> 00:09:17,480 have come up with different sum-of-products expression. 136 00:09:17,480 --> 00:09:22,140 Of course, the two expressions are equivalent in the sense that they produce the same value 137 00:09:22,140 --> 00:09:27,180 of Y for any particular combination of input values - they were built from the same truth 138 00:09:27,180 --> 00:09:28,280 table after all. 139 00:09:28,280 --> 00:09:32,690 And the two expressions will have the same number of operations. 140 00:09:32,690 --> 00:09:36,240 So when you need to come with up a minimal sum-of-products expression for functions of 141 00:09:36,240 --> 00:09:40,070 up to 4 variables, K-maps are the way to go! 142 00:09:40,070 --> 00:09:44,240 We can also use K-maps to help us remove glitches from output signals. 143 00:09:44,240 --> 00:09:48,890 Earlier in the chapter we saw this circuit and observed that when A was 1 and B was 1, 144 00:09:48,890 --> 00:09:55,020 then a 1-to-0 transition on C might produce a glitch on the Y output as the bottom product 145 00:09:55,020 --> 00:09:59,980 term turned off and the top product term turned on. 146 00:09:59,980 --> 00:10:04,810 That particular situation is shown by the yellow arrow on the K-map, where we're transitioning 147 00:10:04,810 --> 00:10:10,600 from the cell on the bottom row of the 1-1 column to the cell on the top row. 148 00:10:10,600 --> 00:10:15,130 It's easy to see that we're leaving one implicant and moving to another. 149 00:10:15,130 --> 00:10:21,160 It's the gap between the two implicants that leads to the potential glitch on Y. 150 00:10:21,160 --> 00:10:25,250 It turns out there's a prime implicant that covers the cells involved in this transition 151 00:10:25,250 --> 00:10:28,480 - shown here with a dotted red outline. 152 00:10:28,480 --> 00:10:33,339 We didn't include it when building the original sum-of-products implementation since the other 153 00:10:33,339 --> 00:10:37,770 two product terms provided the necessary functionality. 154 00:10:37,770 --> 00:10:43,670 But if we do include that implicant as a third product term in the sum-of products, no glitch 155 00:10:43,670 --> 00:10:46,560 can occur on the Y output. 156 00:10:46,560 --> 00:10:51,250 To make an implementation lenient, simply include all the prime implicants in the sum-of-products 157 00:10:51,250 --> 00:10:52,330 expression. 158 00:10:52,330 --> 00:10:56,580 That will bridge the gaps between product terms that lead to potential output glitches.