lecture 4: simplification using boolean algebra k maps · pdf file ·...

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

Upload: trankhuong

Post on 22-Mar-2018

228 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

Lecture 4: Simplification using Boolean Algebra, K Maps

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 · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

Announcements

•  HW 1 posted on TED and on the website, due Wed (Jan 21 at 5pm)

•  Paperless quiz on Friday (multiple choice based on lecture material) – Don’t forget to bring your clickers, answers on

paper will not be accepted.

2

Page 3: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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

3

Page 4: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<4>

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 5: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<5>

Shannon’s expansion

Two flavors of the expansion – f(x)=xf(1)+x’f(0) – f(x)= (x+f(0)). (x’+f(1)) – f(x,y)=xf(1,y)+x’f(0,y) – f(x,y)=(x+f(0,y)).(x’+f(1,y))

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

Page 6: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<6>

Proof of Shannon’s Expansion

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

Page 7: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<7>

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 8: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<8>

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

Page 9: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

<9>

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

Page 10: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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

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

1-<10>

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

Page 11: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

11

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 12: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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).

12

Page 13: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

13

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 14: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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 minterm

maxterm

Page 15: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

15

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

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

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

f1(a, b, c) = m3 + m5 + m6 + m7 = Sm(3,5,6,7)

f2(a,b,c) = (a+b+c)(a+b+c’)(a+b’+c)(a’+b+c) f2(a, b, c) = M0M1M2M4 = PM(0, 1, 2, 4)

Page 16: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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+BC D. ABC E.  Cannot be reduced further

16

Page 17: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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

17

Page 18: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

18

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

Circuit for Full Adder Carry out

Page 19: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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-<19>

Page 20: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

20

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 or Boolean function 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 21: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

21

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 22: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

22

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 23: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

23

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.

Try minimizing using Boolean algebra

Page 24: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

24

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 25: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

How can we guarantee the most reduced expression was reached?

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

25

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 26: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

26

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 27: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

27

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

Why Karnaugh maps are preferred in simplifying circuits?

Page 28: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

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) 28

Page 29: Lecture 4: Simplification using Boolean Algebra K Maps · PDF file · 2015-01-15Lecture 4: Simplification using Boolean Algebra K Maps CSE 140: ... 2.Truth table or Canonical POS/SOP

Next Lecture…

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

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

29