CSE4: Components and Design Techniques for Digital Systems Specifying logic functions Instructor: Mohsen Imani Slides from: Prof.Tajana Simunic and Dr.Pietro Mercati
We have seen various concepts: Last lecture - Logic function (as a mathematical formula): some,,, with Boolean variables - Truth table: a table that reports all possible combination of inputs and the corresponding output - Logic circuit (made of gates): allows you to give a graphical representation of the circuit implementing a logic function - They all are possible ways of representing the same thing - Today: we will use these concepts and see how to jump between them - We are going to need more definitions and more formalism! 2
Sum-of-products Canonical Form Also known as disjunctive normal form Minterm expansion: F = F = A B C + A BC + AB C + ABC + ABC A B C F F F = A B C + A BC + AB C 3
Sum-of-products canonical form (cont d) Product minterm ANDed product of literals input combination for which output is each variable appears exactly once, true or inverted (but not both) You can write a canonical form in multiple ways A B C minterms A B C m A B C m A BC m2 A BC m3 AB C m4 AB C m5 ABC m6 ABC m7 short-hand notation for minterms of 3 variables F F in canonical form: F(A, B, C) = m(,3,5,6,7) = m + m3 + m5 + m6 + m7 = A B C + A BC + AB C + ABC + ABC canonical form minimal form F(A, B, C) = A B C + A BC + AB C + ABC + ABC = (A B + A B + AB + AB)C + ABC = ((A + A)(B + B))C + ABC = C + ABC = ABC + C = AB + C 4
Product-of-sums canonical form (cont d) Sum term (or maxterm) ORed sum of literals input combination for which output is false each variable appears exactly once, true or inverted (but not both) A B C maxterms A+B+C M A+B+C M A+B +C M2 A+B +C M3 A +B+C M4 A +B+C M5 A +B +C M6 A +B +C M7 F F in canonical form: F(A, B, C) = M(,2,4) = M M2 M4 = (A + B + C) (A + B + C) (A + B + C) canonical form minimal form F(A, B, C) = (A + B + C) (A + B + C) (A + B + C) = (A + B + C) (A + B + C) (A + B + C) (A + B + C) = (A + C) (B + C) short-hand notation for maxterms of 3 variables 5
Product of Sum Canonical Form Carry(A,B)= Maxterm A B Carry Sum 6
When would you use the SOP instead of the POS to express the switching function? A. When the output of the function is TRUE for most input combinations B. When the output of the function is FALSE for most input combinations C. We always prefer the SOP form because it s more compact D. None of the above 7
Mapping between canonical forms Minterm to maxterm conversion use maxterms whose indices do not appear in minterm expansion e.g., F(A,B,C) = m(,3,5,6,7) = M(,2,4) Maxterm to minterm conversion use minterms whose indices do not appear in maxterm expansion e.g., F(A,B,C) = M(,2,4) = m(,3,5,6,7) Minterm expansion of F to minterm expansion of F use minterms whose indices do not appear e.g., F(A,B,C) = m(,3,5,6,7) F (A,B,C) = m(,2,4) Maxterm expansion of F to maxterm expansion of F use maxterms whose indices do not appear e.g., F(A,B,C) = M(,2,4) F (A,B,C) = M(,3,5,6,7) 8
The SOP and POS forms don t usually give the optimal circuit or the simplest Boolean expression of the switching function To optimize the circuit, we need to simplify using:. Boolean algebra axioms and theorems 2. Karnaugh Maps (K-Maps) 9
CSE4: Components and Design Techniques for Digital Systems Logic Simplification with K-maps Slides from Prof.Tajana Simunic Rosing Sources:
Two-level minimization Let s look at a SOP canonical form: A B C F SOP F = A B C +A B C+A BC +A BC+AB C +ABC To easily get there, we need a tool called k-map, which allows to easily apply the minimization algorithm Equivalent minimum 2-level form: F = A +C
Key to simplification: the uniting theorem Uniting theorem: X (Y + Y) = X Essence of simplification of two-level logic find two element subsets of the ON-set where only one variable changes its value this single varying variable can be eliminated and a single product term used to represent both elements A B F F = A B +A B = A (B+B ) = A A has the same value in both on-set rows A remains B has a different value in the two rows B is eliminated 2
Mapping truth tables onto Boolean cubes Uniting theorem combines two faces" of a cube into a larger face" Example: A B F B F two faces of size (nodes) combine into a face of size (line) A A varies within face, B does not this face represents the literal B' ON-set = solid nodes OFF-set = empty nodes DC-set = 'd nodes 3
Flat map of Boolean cube wrap around at edges Karnaugh maps hard to draw and visualize for more than 4 variables Alternative to truth-tables to help visualize adjacencies guide to applying the uniting theorem on-set elements with only one variable changing value are adjacent unlike the linear truth-table ID A B f(a,b) f(,) f(,) 2 f(,) 3 f(,) A= A= B= A B AB B= A B AB A B F B A 2 3 4
2-Variable K-Map Example ID A B f(a,b) 2 3 B = B = A = A = 2 3 5
2-Variable K-Map Example Cont. ID A B f(a,b) B = A = A = 2 AB 2 3 B = 3 A B AB f(a,b) = A + B 6
Question What s the simplified function of the following K-map? A. A B. A B C. AB D. B E. A A = A = B = 2 B = 3 7
Boolean cubes Visual technique for applying the uniting theorem n input variables = n-dimensional "cube RULE: adjacent points should differ by only bit -cube X Y X 2-cube 3-cube Y Z X Y Z X W 4-cube 8
2-Variable K-Map Id a b c f (a,b,c) 2 3 4 5 6 7 (a,b) c = c = (,) (,) (,) (,) 2 4 6 3 5 7 Wrong K-map Table!!! Neighbor cells don t have bit similarity 9
Truth Table Reduction in three variable K-maps Id a b c f (a,b,c) 2 3 4 5 6 7 (a,b) c = c = (,) (,) (,) (,) 2 6 4 3 7 5 2
Karnaugh Maps with 3 Variables Numbering scheme is based on Gray code e.g.,,,, only a single bit changes in code for adjacent map cells AB C 2
Karnaugh Maps with 3 Variables Numbering scheme is based on Gray code e.g.,,,, only a single bit changes in code for adjacent map cells ABC F AB C 22
Three Variable K-map Is this K-map correct? A. Yes B. No (a,b) c = c = (,) (,) (,) (,) 2 4 6 3 5 7
Truth Table Reduction in three variable K-maps Id a b c f (a,b,c) 2 3 4 5 6 7 (a,b) c = c = (,) (,) (,) (,) 2 6 4 3 7 5 24
(a,b) c = (,) (,) (,) (,) 2 6 4 c = 3 7 5 (a,b) c = (,) (,) (,) (,) 2 6 4 c = 3 7 5 25
Minimum number of SOP terms to cover the following function? A. B. 2 C. 3 D. 4 (a,b) (,) (,) (,) (,) E. 5 2 6 4 c = c = 3 7 5 26
4-input K-Mmap: Alternative Representation AB CD A C B D Place a bold bar where the value of a variable is and label it. Outside of the bar, the value of the variable is 27
Examples AB CD AB CD A. B C + A B B. B C D + A B + B C D C. A B CD +B C D. AB +A B + A B D 28
Examples AB CD AB CD 29
CSE4: Components and Design Techniques for Digital Systems Don t cares Tajana Simunic Rosing 3
Incompletely Specified Functions Situations where the output of a function can be either or for a particular combination of inputs This is specified by a don t care in the truth table Id a b f (a, b) 2 3 X: don t care This happens when ) The input does not occur. E.g. Decimal numbers 9 use 4 bits, so (,,,) does not occur. 2) The input may happen but we don t care about the output. E.g. The output driving a seven segment display we don t care about illegal inputs (greater than 9) 3
Don t care! Does it help to simplify? Do we get a smaller circuit implementation if we assume f(,)= instead of f(,)=? A. Yes B. No ID a b f (a, b) 2 3 X 32
Completely Specifying Boolean Functions Onset Σm (set of minterms where the function is ): All the input conditions for which the output is Offset M(set of maxterms where the function is ): All the input conditions for which the output is Don t cares DC: All the input conditions for which the output is a don t care ID a b g(a,b) X 2 3 We need two of the three sets to represent any function: on-set, off-set, and dc-set Σm(2); M (,3); DC() g(a,b) = Σm(2) + DC() 33
Truth Table K-map with Don t Cares Id a b c f (a,b,c) 2 3 4 5 6 X 7 c = c = (,) (,) (,) (,) 2 6 4 X 3 7 5 34
4-input K-Maps with Don t Cares f(a,b,c,d) = m(,3,5,7,9) + d(6,2,3) without don't cares with don t cares f = B C D + A D f = C D + A D AB CD x x x AB CD x x x don't cares can be treated as s or s depending on which is more advantageous 35
4-input K-Maps with Don t Cares f(a,b,c,d) = m(,3,5,7,9) + d(6,2,3) f = (D ) * (C +A ) AB CD x x x 36
Another Example F = m(, 2, 7, 8, 4, 5) + d(3, 6, 9, 2, 3) 37
Design example: two-bit comparator N N2 A B C D LT EQ GT block diagram and truth table A B < C D A B = C D A B > C D A B C D LT EQ GT we'll need a 4-variable Karnaugh map for each of the 3 output functions 38
Design example: two-bit comparator (cont d) A A A D D D C B C B C B K-map for LT K-map for EQ K-map for GT LT = EQ = GT = A' B' D + A' C + B' C D A' B' C' D' + A' B C' D + A B C D + A B' C D = (A xnor C) (B xnor D) B C' D' + A C' + A B D' LT and GT are similar (flip A/C and B/D) 39
Design example: 2x2-bit multiplier A A2 B B2 block diagram and truth table P P2 P4 P8 A2 A B2 B P8 P4 P2 P 4-variable K-map for each of the 4 output functions 4
Design example: 2x2-bit multiplier (cont d) A2 K-map for P8 K-map for P4 A2 B B B2 B2 A A A2 K-map for P2 K-map for P A2 B B B2 B2 A A 4
Design example: BCD + I I2 I4 I8 block diagram and truth table O O2 O4 O8 I8 I4 I2 I O8 O4 O2 O X X X X X X X X X X X X X X X X X X X X X X X X 4-variable K-map for each of the 4 output functions 42
Design example: BCD + (cont d) I8 X O8 O4 I8 X X I X I I2 X X I4 X X I2 X X I4 X X I8 X O2 O I8 X X I X I I2 X X I4 X X I2 X X I4 X X 43
Examples to illustrate terms A X D C B A D C B 44
Examples to illustrate terms X A D 6 prime implicants: A'B'D, BC', AC, A'C'D, AB, B'CD essential C minimum cover: AC + BC' + A'B'D B A 5 prime implicants: BD, ABC', ACD, A'BC, A'C'D D essential minimum cover: 4 essential implicants C B 45
Algorithm for two-level simplification Algorithm: minimum sum-of-products expression from a Karnaugh map Step : choose an element of the ON-set Step 2: find "maximal" groupings of s and Xs adjacent to that element consider top/bottom row, left/right column, and corner adjacencies this forms prime implicants (number of elements always a power of 2) Repeat Steps and 2 to find all prime implicants Step 3: revisit the s in the K-map if covered by single prime implicant, it is essential, and participates in final cover s covered by essential prime implicant do not need to be revisited Step 4: if there remain s not covered by essential prime implicants select the smallest number of prime implicants that cover the remaining s 46
Algorithm for two-level simplification (example) X A X A X A C X B X A D D X X C B 2 primes around A'BC'D' A D X X C B 2 primes around ABC'D A X X X D D D X X C B 3 primes around AB'C'D' C X X B 2 essential primes X X C B minimum cover (3 primes) 47
Essential primes A Which are the essential prime implicants? A. CD B. BD C. AC D D. All of the above E. None of the above C X X X B X X X D For more practice: think about essential prime implicates! 48