Lecture 4: Simplification using Boolean Algebra, K Maps

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
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
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
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,…)
<4>
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,…))
<5>
Proof of Shannon’s Expansion
f(x,y)=(x+f(0,y))(x’+f(1,y)) {Enumerative induction}
<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
<7>
Shannon’s Expansion
Decompose the switching function into min terms
f(x,y)=xf(1,y)+x’f(0,y)
<8>
Shannon’s Expansion
Decompose the switching function into max terms
f(x,y)=(x+f(0,y)). (x’+ f(1,y))
<9>
Reduction of Boolean Expression
•  AB+AC+B’C
=AB+B’C
•  (A+B)(A+C)(B’+C)
=(A+B)(B’+C)
Prove the reduction using
(1)  Boolean algebra,
(2)  Logic simulation and
(3)  Shannon’s expansion (exercise)
1-<10>
We are in a position to build a circuit to do
n-bit Binary Addition
5
+ 7
12
Carry
Sum
1
+
1
1 1
1 0 1
1 1 1
1
Carryout
0 0
Carry bits
5
7
12
Sums
11
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
Full Adder
Truth Table
Cin
a
Sum
b
Carry
Id
a b cin
0
1
2
3
4
5
6
7
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
carry
sum
0
0
0
1
0
1
1
1
0
1
1
0
1
0
0
1
13
Minterm and Maxterm
Id
a b cin
0
1
2
3
4
5
6
7
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
carryout
0
0
0
1
0
1
1
1
a+b+c
a+b+c’
a+b’+c
a’ b c
a’+b+c
a b’c
a b c’
abc
maxterm
minterm
14
Minterm and Maxterm
Id
a b cin
0
1
2
3
4
5
6
7
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
carryout
0
0
0
1
0
1
1
1
a+b+c
a+b+c’
a+b’+c
a’ b c
a’+b+c
a b’c
a b c’
abc
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)
PI Q: Is f1 = f2?
A. Yes
B. No
15
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
A’BC+AB’C+ABC’+ABC
17
Circuit for Full Adder Carry out
f1(a,b,c) = a’bc + ab’c + abc’ + abc
= ab +c(b +a)
18
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>
Implementation: Specification => Logic Diagram
Karnaugh Map: A 2-dimensional truth table
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
20
Truth Table vs. Karnaugh Map
2-variable function, f(A,B)
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
f(0,0)
f(1,0)
B=1
f(0,1)
f(1,1)
21
Truth Table vs. Karnaugh Map
2-variable function, f(A,B)
ID A B f(A,B)
0
0
0 0
1
0
1 1
2
1
0 1
3
1
1 1
A=0
A=1
B=0
0
1
B=1
1
1
Boolean expr:
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.
Try minimizing using Boolean algebra
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
24
How can we guarantee the most reduced
expression was reached?
•  Boolean expressions can be minimized by combining terms
•  K-maps minimize equations graphically
ID A B f(A,B)
A=0
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=1
B=0
A’B’
AB’
B=1
A’B
AB
25
K-Map: Truth Table in 2 Dimensions
ID A
B
f(A,B)
0
0
0
0
1
0
1
1
2
1
0
1
3
1
1
1
A=0
B=0
B=1
0
1
0
1
A=1
2
3
1
1
26
K-Map: Truth Table in 2 Dimensions
ID A
B
A=0
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?
B=0
B=1
0
1
0
1
A’B
A=1
2
3
AB’
1
1
AB
f(A,B) = A + B
27
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
Next Lecture…
•  Quiz (multiple choice based on material
covered so far)
•  Bring your clickers for the quiz, paper
submissions will not be accepted
29