بهينه سازي با نقشة کارنو Karnaugh Map
Karnaugh Map Method of graphically representing the truth table that helps visualize adjacencies 2-variable K-map 3-variable K-map 2 3 2 3 6 7 4 5 D 3 2 4 5 7 6 2 3 5 4 8 9 4-variable K-map D 2
Karnaugh Map One map cell corresponds to a row in the truth table. lso, one map cell corresponds to a minterm (or a maxterm) in the boolean expression. Multiple-cell areas of the map correspond to standard terms. 2 3 2 3 6 7 4 5 D 3 2 4 5 7 6 2 3 5 4 8 9 D 3
Karnaugh Map f (,,) = m + m 2 + m 4 + m 6 = + + + 2 6 4 3 7 5 f m m m2 m3 m4 m5 m6 m7 4
Karnaugh Map Numbering Scheme:,,, Gray ode - only a single bit changes from code word to next code word. 2 3 D 3 4 5 7 2 3 5 8 9 D 2 6 4 2 6 4 3 7 5 5
Two-Variable Map (cont.) ny two adjacent cells in the map differ by ONLY one variable, which appears complemented in one cell and uncomplemented in the other. Example: m (= ) is adjacent to m (= ) and m 2 (= ) but NOT m 3 (=) 2 3 6
Karnaugh Map djacencies in the K-Map Wrap from first to last column Top row to bottom row 7
2-Variable Map -- Example f(x,x 2 ) = x x 2 + x x 2 + x x 2 = m + m + m 2 s placed in K-map for specified minterms m, m, m 2 Grouping (ORing) of s allows simplification What (simpler) function is represented by each dashed rectangle? m + m = x x 2 + x x 2 = x (x 2 + x 2 ) = x m + m 2 = x x 2 + x x 2 = x 2 (x + x ) = x 2 Note m covered twice x x 2 2 3 8
Minimization as SOP using K-map Enter s in the K-map for each product term in the function Group adjacent K-map cells containing s to obtain a product with fewer variables. Groups must be in power of 2 (2, 4, 8, ) Handle boundary wrap for K-maps of 3 or more variables. nswer may not be unique 9
Minimization as SOP asserted, unchanged varies F =? complemented, unchanged varies G =? in out =? F(,,) =?
Minimization as SOP asserted, unchanged varies F = complemented, unchanged varies G = ' in out = + cin + in F(,,) =
More Examples F(,,) = m(,4,5,7) F = F' : simply replace 's with 's and vice versa F'(,,) = m(,2,3,6) F' = 2
More Examples Why not group m4 and m5? F(,,) = m(,4,5,7) F = ' ' + F' simply replace 's with 's and vice versa F'(,,) = m(,2,3,6) F' = ' + ' ompare with the method of using DeMorgan's Theorem and oolean lgebra to reduce the complement! 3
Simplification Enter minterms of the oolean function into the map, then group terms Example: f(a,b,c) = bc + abc + ab Result: f(a,b,c) = bc + a c ab c ab 4
4-Variable Map D D F(,,,D) = m(,2,3,5,6,7,8,,,4,5) F = D m m 4 m 2 m 8 m m 5 m 3 m 9 m 3 m 7 m 5 m m 2 m 6 m 4 m 5
Four-variable Map Simplification One square represents a minterm of 4 literals. rectangle of 2 adjacent squares represents a product term of 3 literals. rectangle of 4 squares represents a product term of 2 literals. rectangle of 8 squares represents a product term of literal. rectangle of 6 squares produces a function that is equal to logic. 6
4-Variable Map D F(,,,D) = m(,2,3,5,6,7,8,,,4,5) F = + ' D + ' D' D Find the smallest number of the largest possible subcubes that cover the ON-set 7
Simplify for POS D K-map Method: ircling Zeros to get product of sums form F = ( + + D) ( + + D ) ( + + D ) D Replace F by F, s become s and vice versa F = D + D + D (F ) = ( D + D + D) F = ( + + D) ( + + D ) ( + + D ) 8
Don t ares Don't ares can be treated as 's or 's if it is advantageous to do so D X F(,,,D) = m(,3,5,7,9) + d(6,2,3) X X In Product of Sums form Same answer as above, but fewer literals D F = 'D + ' ' D w/o don't cares F = ' D + ' D w/ don't cares : F = D (' + ') D X X D X 9
2 Example: omparator Design Example: Two it omparator lock Diagram and Truth Table 4-Variable K-map for each of the 3 output functions F F 2 F 3 D F = D F 2 < D F 3 > D D N N 2
omparator K-Maps D D D D D D K-map for F K-map for F 2 K-map for F 3 F = F2 = F3 = ' ' ' D' + ' ' D + D + ' D' ' ' D + ' D + ' ' D' + ' + D' = ( xnor ) ( xnor D) much simpler, but not in sum of products form s on K-map diagonals make XOR or XNOR 2
22 Example: Two it dder lock Diagram and Truth Table 4-variable K-map for each of the 3 output functions + N 3 X Y Z D D N N 2 X Y Z out
dder K-Maps D D D D D D K-map for X K-map for Y K-map for Z X = + D + D 's on diagonal suggest XOR! Z = D' + ' D = xor D Y = ' ' + ' ' + ' ' D + ' D' + ' D' + D = ' ( xor ) + ' ( xor D) + ( xnor D) = ' ( xor ) + ( xor xor D) gate count reduced if XOR available 23
\ \ \ Implementations of Y \ D Two alternative implementations of Y with and without XOR D Y X Note: XOR typically requires 4 NND gates to implement! X XOR Y Y Y 2 24
xy + yx = xy + yx + xx + yy x(y +x ) + y(x +y ) x.(x.y) + y. (x.y) ((x.(x.y) ). (y. (x.y) ) ) XOR X Y X XOR Y تبديل مدارها به فقط :Nand بعد ا 25
26 D W X X X X X X X X X X X X X Y X X X X X X Z X X X X X X Example: D Incrementer
Example: D Incrementer D X D X W X X X X X D X X X X X X D D D X X Y X X X X X D Z X X X X X D W = D + D' X = ' + D' + ' D Y = ' ' D + D' Z = D' 27
Implicant: Definition of Terms single element of the ON-set or any group of elements that can be combined together in a K-map (= adjacency plane) Prime Implicant (PI): implicant (a circled set of -cells) satisfying the combining rule, such that if we try to make it larger (covering twice as many cells), it covers one or more s. Distinguished -cell: an input combination that is covered by only one PI. Essential Prime Implicant (EPI): a PI that covers one or more distinguished -cells. 28
Implicant, PI and EPI D 6 Prime Implicants: ' ' D, ',, ' ' D,, ' D D Essential Minimum cover = First: cover EPIs Then: minimum number of PIs = ' + + ' ' D 29
Implicant, PI and EPI D D 5 Prime Implicants: D, ', D, ', ' ' D essential Minimum cover = First: cover EPIs Then: minimum number of PIs = + D + ' + ' ' D 3
More Examples D Prime Implicants: D, D,, ' D essential = D + + ' 3
Example Example: f(,,,d) = m(4,5,6,8,9,,3) + d(,7,5) D D D X X X X X D X X D X X D Initial K-map Primes around ' ' D' Primes around ' D 32
Example: ontinued D D X X X X D X X D Primes around ' ' D' Essential Primes with Min over (each element covered once) 33
5-Variable K-Map 34
5-Variable K-Map DE = 4 2 8 5 3 9 3 7 5 2 6 4 DE = 6 2 28 24 7 2 29 25 9 23 3 27 8 22 3 26 35
= DE 5-Variable K-Map = DE DE = = DE f(,,,d,e) = m(2,5,7,8,, 3,5,7,9,2,23,24,29 3) = E + ' E + ' D' E' + ' ' D E' 36
6-Variable K-Map 37
7-Variable K-Map 38
8-Variable K-Map 39
ترکيب هاي XOR در جدول کارنو خانه هاي قطري نشان مي دهند يکي از فرم هاي XOR/XNOR که با دقت بيشتر معلوم مي شود کدام است. است b a b a ab + a b = a XOR b a b + ab = a XNOR b 4
ترکيب هاي XOR در جدول کارنو c ab c ab a b c + a bc + abc + ab c = a (boc) + + a(boc) + = ao(boc). + a b c + a bc + abc + ab c = a (boc) + + a(boc) + = ao(boc) + + 4
ترکيب هاي XOR در جدول کارنو با بررسي بيشتر داخل o معلوم مي شود. :a.(boc) c ab c ab a (b c + bc) = a (boc) + b(aoc) b(a c + ) = b (aoc). 42
ab cd ترکيب هاي XOR در جدول کارنو a c d c (aobod) ab cd a b bd(aoc) c d b 43
ترکيب هاي XOR در جدول کارنو c ab bc + b c =(boc) + c ab b c + bc 44
ترکيب هاي XOR در جدول کارنو c ab a c + ac c ab ac +a c 45
ترکيب هاي XOR در جدول کارنو قوت روش: به خصوص وقتي don t care داريم. 46
Implementing by Nands only Nand: Universal gate can replace gates by equivalent Nand circuit. ut Large circuit (many gates) 47
New Symbols for ND/OR DeMorgan s Law: (a + b) = a b (a b) = a + b a + b = (a b ) (a b) = (a + b ) = = = = 48
New Symbols for NOT (a. a) = a _ (a + a) = a 49
NND-Only Implementation Find Sum-of-Product form. Inventers can be added Equivalent NND-only 5
nother Example 5
NOR-Only Implementation Find Product-of-Sums form. Inventers can be added Equivalent NOR-only 52
NND-Only Implementation NND-only: nother method: Group s in K-Map Find F in SOP form dd an inverter at the end. 53
NND-Only Implementation Multi-Level ircuits onvert ND/OR gates to proper NND gates ND ND-NOT symbol OR NOT-OR symbol ubbles must cancel each other; otherwise, insert a NND inverter. Take care of appropriate input literals. 54
NND-Only Implementation Example: 55
NND-Only Implementation nother Example: 56
NND-Only Implementation e careful about branches: Gates with multi-fanouts D (a) X F X D X F D X F (b) (c) 57
NOR-Only Implementation NOR-Only: Use Duality for the last several slides. 58
nalysis of NND ircuits The functionality of a NND-only circuit is not clear. Must be converted to ND-OR circuit. 59
Example nalysis of NND ircuits 6
nalysis of NND/NOR ircuits 6
nalysis of NND/NOR ircuits 62
Variable-Entered Maps
Variable-Entered Maps Using a 3-variable K-Map for a 4-variable function Extract some variables out of the function: F(,,, D) ' ' ' ' ' D ' D dont care( ) F(,,, D) m m2. D m3 m7. D dont care( m5) Reminder: Shannon Theorem: F(x,x2,,xn) = x.f(,x2,,xn) + x.f(,x2,,xn) 64
Variable-Entered Maps To enter the variables in the K-map: Example: G(,,, D, E, F) m m2 m3 Em5 Em7 Fm9 m m5 ( don' t care terms) 65
Variable-Entered Maps To group map entries: an consider F as: F S P. S P2. S2... P i s are map-entered variables S : minimum sum obtained by P =P 2 = = S : minimum sum obtained by P =, P j = (j=/ ) and replacing all s on the map with don t cares (X) S 2 : minimum sum obtained by P 2 =, P j = (j=/ 2) and replacing all s on the map with don t cares (X) S s :. 66
6-variable function Variable-Entered Maps Example: G(,,, D, E, F) m m2 m3 Em5 Em7 Fm9 m m5 ( don' t care terms : m m m3) 67
68 Variable-Entered Maps oth and in the map-entered variables: F = ' ' + + ' + = ' (') + () + () F F
Variable-Entered Maps F = ' (') + () + X F = + 69