28
Lecture 4: Simplification using Boolean Algebra, K Maps, Incompletely Specified Functions CSE 140: Components and Design Techniques for Digital Systems Diba Mirza Dept. of Computer Science and Engineering University of California, San Diego 1

Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

  • Upload
    others

  • View
    24

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Lecture 4: Simplification using Boolean Algebra, K Maps,

Incompletely Specified Functions

CSE 140: Components and Design Techniques for Digital Systems

Diba Mirza

Dept. of Computer Science and Engineering University of California, San Diego

1

Page 2: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

What you should know at the end of this lecture….

1.  How to simplify combinational circuits using Boolean Algebra axioms and theorems

2.  How to simplify combinational circuits using Karnaugh maps

3.  Why Karnaugh maps are preferred in simplifying circuits

2

Page 3: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<3>

Shannon’s Expansion

•  Shannon’s expansion assumes a switching algebra system

•  Divide a switching function into smaller functions •  Pick a variable x, partition the switching function

into two cases: x=1 and x=0 –  f(x,y,z,…)= xf(x=1,y,z,…) + x’f(x=0,y,z,…)

Page 4: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<4>

Shannon’s expansion

•  Shannon’s expansion: –  f(x)=xf(1)+x’f(0) = (x+f(0)). (x’+f(1))

–  f(x,y)=xf(1,y)+x’f(0,y) –  f(x,y,z,…)=xf(1,y,z,…)+x’f(0,y,z,…)

Page 5: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<5>

Proof of Shannon’s Expansion

f(x,y)=(x+f(0,y))(x’+f(1,y)) {Enumerative induction}

Page 6: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<6>

Shannon’s Expansion: Example

f(x,y,z)=xf(0,y,z) + x’f(1,y,z) Is the above equation correct? A. Yes B. No

Page 7: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<7>

Shannon’s Expansion Decompose the switching function into min terms f(x,y)=xf(1,y)+x’f(0,y)

Page 8: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

<8>

Shannon’s Expansion Decompose the switching function into max terms f(x,y)=(x+f(0,y)). (x’+ f(1,y))

Page 9: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Reduction of Boolean Expression •  AB+AC+B’C =AB+B’C

•  (A+B)(A+C)(B’+C) =(A+B)(B’+C)

1-<9>

Prove the reduction using (1)  Boolean algebra, (2)  Logic simulation and (3)  Shannon’s expansion (exercise)

Page 10: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

10

We are in a position to build a circuit to do n-bit Binary Addition

5 + 7

1 2 Carry Sum

1 1 1 1 0 1 + 1 1 1

1 1 0 0

Carryout Sums

Carry bits 5 7 12

Page 11: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Binary Addition: Hardware

•  Half Adder: Two inputs (a,b) and two outputs (carry, sum).

•  Full Adder: Three inputs (a,b,c) and two outputs (carry, sum).

11

Page 12: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

12

Full Adder

Id a b cin carry sum

0 0 0 0 0 0 1 0 0 1 0 1 2 0 1 0 0 1 3 0 1 1 1 0 4 1 0 0 0 1 5 1 0 1 1 0 6 1 1 0 1 0 7 1 1 1 1 1

Truth Table

a

b

Sum

Carry

Cin

Page 13: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

13

Minterm and Maxterm

Id a b cin carryout

0 0 0 0 0 a+b+c 1 0 0 1 0 a+b+c’ 2 0 1 0 0 a+b’+c 3 0 1 1 1 a’ b c 4 1 0 0 0 a’+b+c 5 1 0 1 1 a b’c 6 1 1 0 1 a b c’ 7 1 1 1 1 a b c minterm

maxterm

Page 14: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

14

Minterm and Maxterm

Id a b cin carryout

0 0 0 0 0 a+b+c 1 0 0 1 0 a+b+c’ 2 0 1 0 0 a+b’+c 3 0 1 1 1 a’ b c 4 1 0 0 0 a’+b+c 5 1 0 1 1 a b’c 6 1 1 0 1 a b c’ 7 1 1 1 1 a b c f1(a,b,c) = a’bc + ab’c + abc’ + abc

f2(a,b,c) = (a+b+c)(a+b+c’)(a+b’+c)(a’+b+c)

f1(a, b, c) = m3 + m5 + m6 + m7 = Sm(3,5,6,7) f2(a, b, c) = M0M1M2M4 = PM(0, 1, 2, 4)

PI Q: Is f1 = f2? A. Yes B. No

Page 15: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

PIQ: Reduce using Boolean algebra theorems Carry(A,B,C)=A’BC+AB’C+ABC’+ABC

A. A’BC+AB’C+AB B. A’BC+AC+AB C. AB+AC+CA D. ABC E.  Cannot be reduced further

15

Page 16: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

A’BC+AB’C+ABC’+ABC

16

Page 17: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

17

f1(a,b,c) = a’bc + ab’c + abc’ + abc = ab +c(b +a)

Circuit for Full Adder Carry out

Page 18: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Building the simplest possible circuit

We can get the simplest circuit in two ways: 1. Truth table –> Canonical POS/SOP –> Most simplified switching function -> Simplest Circuit

•  This can get difficult when we have many inputs variables

2. Truth table or Canonical POS/SOP ->Karnaugh map-> Simplest Circuit

1-<18>

Page 19: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

19

Implementation: Specification => Logic Diagram

Flow 1: 1.  Specification 2.  Truth Table 3.  Sum of Products or Product of Sums

canonical form 4.  Reduced expression using Boolean

Algebra 5.  Schematic Diagram of Two Level Logic

Flow 2: 1. Specification 2. Truth Table 3. Karnaugh Map (truth table in two dimensional space) 4. Reduce using K’Maps 5. Reduced expression (SOP or POS) 6. Schematic Diagram of Two Level Logic

Karnaugh Map: A 2-dimensional truth table

Page 20: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

20

Truth Table vs. Karnaugh Map

ID A B f(A,B)

0 0 0 f(0,0)

1 0 1 f(0,1)

2 1 0 f(1,0)

3 1 1 f(1,1)

2-variable function, f(A,B)

A=0 A=1

B=0 f(0,0) f(1,0)

B=1 f(0,1) f(1,1)

Page 21: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

21

Truth Table vs. Karnaugh Map

ID A B f(A,B)

0 0 0 0

1 0 1 1

2 1 0 1

3 1 1 1

2-variable function, f(A,B)

A=0 A=1

B=0 0 1

B=1 1 1

Boolean expr:

Page 22: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

22

Function can be represented by sum of minterms: f(A,B) = A’B+AB’+AB

This is not optimal however! We want to minimize the number of literals and terms.

Page 23: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

23

To minimize the number of literals and terms. We factor out common terms – A’B+AB’+AB= A’B+AB’+AB+AB =(A’+A)B+A(B’+B)=B+A Hence, we have

f(A,B) = A+B

Page 24: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

How can we guarantee the most reduced expression was reached?

•  Boolean expressions can be minimized by combining terms •  K-maps minimize equations graphically

24

ID A B f(A,B)

0 0 0 f(0,0)

1 0 1 f(0,1)

2 1 0 f(1,0)

3 1 1 f(1,1)

A=0 A=1

B=0 A’B’ AB’

B=1 A’B AB

Page 25: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

25

K-Map: Truth Table in 2 Dimensions

A = 0 A = 1

B = 0 B = 1

0 2

1 3

0 1 1 1

ID A B f(A,B)

0 0 0 0

1 0 1 1

2 1 0 1

3 1 1 1

Page 26: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

26

K-Map: Truth Table in 2 Dimensions

A = 0 A = 1

B = 0 B = 1

0 2

1 3

0 1 1 1

A’B

AB’

AB

f(A,B) = A + B

ID A B f(A,B)

0 0 0 0

1 0 1 1

2 1 0 1

3 1 1 1

Page 27: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Review Some Definitions •  Complement: variable with a bar over it A, B, C •  Literal: variable or its complement A, A, B, B, C, C •  Implicant: product of literals ABC, AC, BC •  Implicate: sum of literals (A+B+C), (A+C), (B+C) •  Minterm: product that includes all input variables ABC, ABC, ABC •  Maxterm: sum that includes all input variables (A+B+C), (A+B+C), (A+B+C) 27

Page 28: Lecture 4: Simplification using Boolean Algebra K Maps ...€¦ · Lecture 4: Simplification using Boolean Algebra K Maps Incompletely Specified Functions CSE 140: Components and

Next Lecture…

•  Quiz (multiple choice based on material covered so far)

•  Bring your clickers for the quiz, paper submissions will not be accepted

28