Presentation is loading. Please wait.

Presentation is loading. Please wait.

EECS 465: Digital Systems Lecture Notes # 2

Similar presentations


Presentation on theme: "EECS 465: Digital Systems Lecture Notes # 2"— Presentation transcript:

1 EECS 465: Digital Systems Lecture Notes # 2
Two-Level Minimization Using Karnaugh Maps SHANTANU DUTT Department of Electrical & Computer Engineering University of Illinois, Chicago Phone: (312) : URL:

2 Concepts in 2-Level Minimization
Defn: An implicant g of a function is a product term (e.g., g=xyz) s.t. when g=1  f=1 Defn: A minterm is an implicant whose product term representation consists of all n variables of an n-var. function (each in either compl.or uncompl. form) Defn: Let g, and h be 2 implicants of a function f. g is said to cover h if h=1  g=1 (e.g., g = xz, h = xyz) Defn: Let G = {g1, .., gk} be a set of implicants of func f, and let h be another implicant of f. Then G covers h if h=1  g gk =1 (generalized covering).

3 3 Defn: An SOP or POS expression is also called a 2-level expression Defn: A 2-level AND-OR (OR-AND) gate realization of an SOP (POS) expression is one in which all product terms (OR terms in POS) in the SOP (POS) expression are implementedby multiple input AND (OR) gates & the ORing (ANDing) of the product (OR) terms is realized by a multiple input OR (AND) gate. AB + BC + ACD A B C D f1 Level 2 Level 1

4 4 An OR-AND 2-level circuit implementing a POS expression Level 2 Level 1 (B + C)(A + D)(C + D) B C A D f2

5 3 A multi-level circuit implementing a multi-level expression E.g. f1 = AB + BC + ACD level. (SOP) f2 = ( B+C )( A+D )( C+D ) level (POS) f3 =AB + AC( B+D ) not SOP or POS level 1 I/Ps not 2-level level ( can be realized directly by 3 levels of gates) A B A f3 C B level 2 I/Ps D level 2 gates level 3 gate level 0 I/Ps level 1 gates

6 6 Defn. A gate in a logic circuit is a level-1 gate if all its inputs are primary inputs (i.e., literals, A, A, B, B, etc.) A gate is a level-i gate g, i > 1, if the highest-level gate whose output feeds g is a level-(i-1) gate. NOTE: If a given expr. is not 2-level, we can convert it to a 2-level one using the distributive law. The traditional goal of 2-level minimization is to minimize the number of literals (a literal is a var. in complemented or uncompl. form) in a 2-level logic expr. This approx. reduces the total # of inputs over all level-1 gates (AND gates in an SOP expr. , OR gates in a POS expr.) in the circuit in a 2-level gate realization. Cost of a circuit = total # of gate inputs across all its gates (approx. = (number of MOS transistors)/2; exact for nand/nor/and/or/not gates) Cost of a 2-level expr. f = cost of a 2-level circuit implementing f A better 2-level minimization goal is to minimize the number of literals plus number of product terms as this corresponds exactly to total # of gate inputs across all its gates in a 2-level implementation

7 E.g. f = ABC + ABC + ABC (non-minimized 9 literals) A B (12 gate I/Ps)
7 E.g. f = ABC + ABC + ABC (non-minimized 9 literals) A B (12 gate I/Ps) = Circuit complexity C A f B C A B C f = AB + AC (minimized 4 literals) A f B (6 gate I/Ps) = Circuit complexity A C Note: Minimizing # of literals + # of product terms  minimizing total # of gate inputs in a 2-level impl.  approx. min. total # of gate i/ps of a multi-level impl. (reqd. when gates of certain sizes reqd. by the minimized expression is not available)

8 Multilevel Minimization Example
8 Multilevel Minimization Example f = x1x2x3 + x2x3x4 + x1x5 + x4x (2-level minimized) Applying the distributive law (factoring) f = x2x3(x1 + x4) + x5(x1 + x4) = (x2x3 + x5)(x1 + x4) -- Multilevel expr. See gate impl. below Cost = 14 (# of gate i/ps in a 2-level impl.) Cost = 8 (# of gate i/ps). Can increase delay though due to more levels of gates & more interconnects that the critical path has to go through Simple gate delay model: delay prop. to # of inputs Critical path goes through 3 2-i/p gates (6 units of delay) and 2 interconn. delays (not counting i/p and o/p interconnects). The critical path in a 2-level impl. of the above SOP expr. will go through a total of 7 gate units of delay but only 1 interconnect delay. An interconnect’s delay is generally much more than a single gate i/p delay So mostly, and esp. for large ckts, cost decrease via multi-level min. can cause delay increase. x2 x3 x5 x1 x4 f Multilevel circuit

9 Two implicants (or product terms) of a function f are said to
9 Defn. Two implicants (or product terms) of a function f are said to be logically adjacent if they have the same literals except in one variable xi which occurs in uncomplemented form (xi) in one implicant and in complemented form (xi) in the other. The 2 implicants are said to differ in xi. E.g. ABC, ABC (adjacent implicants, differ in B) ABD, ABC (not adjacent) Adjacent implicants can be combined into one implicant by the combining theorem (ABC + ABC = AC) C 1 A’B’ AC AB ABC AB’C A’B’C’ A’B’C AC’ A

10 Another ordering of inputs ( Gray-code ordering) A B Z1 0 0 0 0 1 1
10 Karnaugh Maps 2-variable TT outputs A B Z1 Z2 Binary place-value ordering (Binary ordering) Physically adjacent but not logically adjacent. logically adjacent but not physically adjacent AB + AB B Another ordering of inputs ( Gray-code ordering) A B Z1 Z1 = B Physically as well as logically adjacent.

11 n-variable Gray-code ordering
11 n-variable Gray-code ordering Defn. Gi = i-bit Gray-code ordering rev(Gi) = reverse order of Gi Gn = 0 Gn-1 1 rev(Gn-1) G1 = Base. 1 G2 = 0 G1 1 rev(G1) 0 0 0 1 1 1 1 0 A B C = G3 = 0 G2 1 rev(G2) = Convert to a 2-dimensional Gray-code ordered TT AB x 110 C y 1 Throw away variable (A) changing across the 2 squares. We thus obtain BC. 1 1 001

12 12 Example ( 3-var. K-Map) Consensus = BC Function f:
Gray code ordering Consensus = BC AB C 1 A’B’ AC’ B’C’ Function f: f = AB + AB + AC + BC Note: 1) The consensus theorem is an example of generalized covering discussed earlier—the consensus is covered by the sum of the 2 implicants whose consensus it is. 2) AC’ is also a consensus, this time of AB and B’C’. Can’t discard both A’C’ and B’C’ simultaneously! Need to apply gen. covering (incl. consensus) one at a time. Defn. A Prime Implicant (PI) of a function f is an implicant of f that is not covered by any other implicant of f. Defn. An Essential PI is a PI that covers/includes at least one minterm that is not covered by any other PI. In the above K-map, four PIs AB, BC, AC, AB formed. Not all these PIs are needed in the expression. Only a minimum set that covers all minterms is needed. In the above example, AB & AB are essential PIs. These will need to be present in any SOP expr. of the function. To form a minimal set, the PI BC can be used. Thus f = AB + AB + BC is a minimized expression.

13 Larger than 2-minterm PIs can also exist: E.g.,
13 Larger than 2-minterm PIs can also exist: AB AB E.g., C C 1 1 AB AB B C B 2-minterm implicants (AB, AB in the 1st example above) can be merged if they are logically adjacent to form a 4-minterm implicant and so on.

14 When an implicant can not be “grown” any further, then it is a PI.
14 When an implicant can not be “grown” any further, then it is a PI. Defn. In a K-map, 2 implicants can be logically adjacent if they are symmetric, i.e., if : (1) They are disjoint (no common minterms). (2) They cover the same # of minterms. (3) Each minterm in one implicant is adjacent to a unique minterm in the other implicant. AB More Examples: Both PIs (A, BC) are essential. C AB Redrawn 1 C 1 Not symmetric Thus, f = A + BC is minimized. Symmetric ( logically adjacent) 2-minterm implicants : Can be “merged” to form a 4-minterm implicant, which will be a PI.

15 15 4-variable K-Map: Gray code ordering AB CD Gray code ordering
00 01 11 10 CD Gray code ordering

16 Instead of starting with 2-minterm implicants & growing them, you
16 Example: f = AC + D Instead of starting with 2-minterm implicants & growing them, you can form larger implicants directly by grouping power of 2 (2, 4, 8, etc.) # of minterms so as to form a rectangle or square ( a convex region). AB CD 00 01 AC 11 10 Convex D Concave AB CD Invalid grouping (region formed is concave) f = AB + AC + BCD 00 01 11 10 Valid groupings 1

17 17 Another Example: AB CD BD ABD C f = C + BD + ABD TT: 00 01 11 10
A B C D Z 00 01 ABD 1 C 11 10 Binary order f = C + BD + ABD

18 Many times certain input combinations are invalid for a function
18 Don’t Cares in K-Maps Many times certain input combinations are invalid for a function (E.g. BCD to 7-segment display functions; see pp in Katz text ) For such combinations, we do not care what the output is, and we put an ‘x’ in the o/p column for the TT AB CD A B C f x x x 1 x x f = BC + AB by considering all x’s as 0s f = B The x’s can, however, be profitably used to make larger PIs & thus further simplify the function. by selectively considering the 010 cell’s x as 1

19 In a K-map, the ‘x’s can be profitably used to form larger
implicants (which have fewer literals) 19 However, when we need to form a minimal PI cover, we need to worry only about covering the minterms ( the 1s), and not the Xs. • Thus as far as x’s are concerned, we can have the cake and eat it too! Example: f(A,B,C,D) = m(1,3,5,7,9) + d(2,6,12,13) AB CD 00 01 11 10 x x 2 x x LSBs MSBs AC AD A B C D f = CD + AD or CD + AC If input comb. 2,6 occur o/p is 0. If inputs 2,6 occur o/p = 1. Which to use for lower dynamic power (consumed on a 0  1 transition at the o/p)?

20 STEPS IN K-MAP MINIMIZATION (sop EXPR.)
20 STEPS IN K-MAP MINIMIZATION (sop EXPR.) STEP1: Form all PIs by including the Xs with the 1s to form larger PIs. (Do not form PIs covering only Xs !) STEP2: Identify all essential PIs by visiting each minterm (1s) & checking if it is covered by only one PI. If so, then that PI is an essential PI. STEP3: Identify all 1s not covered by essential PIs. Select a minimal- cost set S of PIs to cover them. This requires some trial-and error (in fact, this is a hard computational problem). STEP4: Minimal SOP Expr. for function f: f = essential PIs + Pi Pi S PI Pi is in set S

21 Minimal POS Expr. from a K-Map : 21
METHOD 1: Obtain minimal SOP expression for the complement function f, and complement this SOP expression to get a minimal POS expr. for f (using De-Morgan’s Law) Big M notation Example: F (A,B,C,D) = M(0,2,4,8,10,11,14,15) D(6,12,13) Xs of F 0s of F AB F F AB CD CD D x x 00 01 11 10 x x x 00 01 11 10 Complement x AC F =D + AC F = D + AC = D(A +C)

22 Example: (Method2: Direct Method)
22 Example: (Method2: Direct Method) AB (OR terms) CD x x x 00 01 11 10 An implicate of f is an OR term which when 0  f = 0. An implicate g covers implicate h if h = 0  g = 0 Prime implicate is an implicate not covered by any other implicate. (groups of 0s that cannot be grown any further). A prime implicate that covers at least one 0 [or maxterm] not covered by any other prime implicate is an essential prime implicate. Both D and A + C are essential prime implicates. D (A + C) F = D( A + C ) ( Product of Prime Implicates )

23 METHOD2 : Direct Method : 23
(1) Obtain all prime implicates (PTs) (largest groups of 0s & Xs of size 2 , i 0, forming a convex region, that can not be “grown” any further). (2) Identify all essential PTs (those that cover at least one 0 not covered by any other PT). (3) Choose a minimal set T of PTs to cover the 0s not covered by the set of essential PTs. (4) The expression for a PT is an OR term obtained by discarding all changing variables, & keeping variables complemented if they are constant at 1 or uncomplemented if they are constant at 0 & taking the OR (sum) of these literals. (5) Minimal POS Expr.: f = (essential PTs) qi qi T

24 5-variable K-map: f(A,B,C,D,E): Juxtapose two 4-var. K-submaps
24 5-variable K-map: f(A,B,C,D,E): Juxtapose two 4-var. K-submaps one for the MSB A=0 and the other for A=1: BC BC DE DE 00 01 11 10 00 01 11 10 A=0 A=1 4-var. K-submap 4-var. K-submap Adjacencies of a square: Adjacent squares of the 4-var. K-submap plus the “corresponding” or “mirror” square in the other 4-var. K-submap. Example: BC BC DE DE 00 01 11 10 00 01 11 10 x 24 19 x x 27 x 11 x 10 A=0 A=1

25 6-variable K-map: f(A,B,C,D,E,F)--Juxtapose two 5-var. K-submaps
25 6-variable K-map: f(A,B,C,D,E,F)--Juxtapose two 5-var. K-submaps one for the MSB A=0 and other for A=1 CD CD EF EF 00 01 11 10 00 01 11 10 5-var. K-submap A=0 B=0 B=1 CD CD EF EF 00 01 11 10 00 01 11 10 5-var. K-submap A=1 B=1 B=0 Adjacencies of a square: Adjacent squares of the 5-var. K-submap plus the “corresponding” or “mirror” square in the other 5-var. K-submap.

26 6-variable K-map: f(A,B,C,D,E,F,)---Example:
26 6-variable K-map: f(A,B,C,D,E,F,)---Example: CD CD EF EF 00 01 11 10 00 01 11 10 A=0 B=0 B=1 CD CD EF EF 00 01 11 10 00 01 11 10 A=1 B=1 B=0

27 f = (C’+D’)(B’+C’)(C+B)(A’+C+D)
f = A’BC’ + BC’D + B’CD’ AB 00 01 11 10 CD 1 1 1 1 1 f = (C’+D’)(B’+C’)(C+B)(A’+C+D)

28 f = (C’+D’)(A’+B)(A’+C’)(C+B)(A’+D)
f = A’BC’ + BC’D + A’CD’ AB 00 01 11 10 CD 1 1 1 1 1 f = (C’+D’)(A’+B)(A’+C’)(C+B)(A’+D)

29 f = (C’+D’)(A’+B)(C+B)
f = BC’ + A’CD’ + BCD’ AB 00 01 11 10 CD 1 1 1 1 1 1 1 f = (C’+D’)(A’+B)(C+B)


Download ppt "EECS 465: Digital Systems Lecture Notes # 2"

Similar presentations


Ads by Google