Lec02

Lecture 2
Two Level Minimization
Hai Zhou
ECE 303
Advanced Digital Design
Spring 2002
ECE C03 Lecture 2
1
Outline
•
•
•
•
Boolean algebra review
Two-level minimization
Karnaugh maps
READING: Katz 1.3, 1.4, 2.1, 2.2, 2.3, Dewey
1.3, 1.4, 4.2, 4.3, 4.4
ECE C03 Lecture 2
2
Boolean Algebra
Algebraic structure consisting of:
set of elements B
binary operations {+, •}
unary operation {'}
such that the following axioms hold:
1. B contains at least two elements, a, b, such that a• b
2. Closure a,b in B,
(i) a + b in B
(ii) a • b in B
5. Distributive Laws:
(i) a + (b • c) = (a + b) • (a + c)
(ii) a • (b + c) = a • b + a • c
3. Commutative Laws: a,b in B,
(i) a + b = b + a
(ii) a • b = b • a
6. Complement:
(i) a + a' = 1
(ii) a • a' = 0
4. Identities: 0, 1 in B
(i) a + 0 = a
(ii) a • 1 = a
ECE C03 Lecture 2
3
Boolean Functions
B = {0,1}, + = OR, • = AND, ' = NOT is a Boolean Algebra
must verify that the axioms hold:
E.g., Commutative Law:
0 + 1 = 1 + 0?
0 • 1 = 1 • 0?
1=1
0=0
Theorem: any Boolean function that can be expressed as a truth table
can be written as an expression in Boolean Algebra using ', +, •
Desc ription
If X = 0 then X ' = 1
If X = 1 then X ' = 0
Gates
X
Truth Table
X
X
0
1
X
1
0
Sw itc hes
True
X
NOT
Fals e
X
Review
from
Chapter 1
Description
Z = 1 if X and Y
are both 1
Gates
X
Y
Z
Truth Table
X Y Z
0 0 0
0 1 0
1 0 0
1 1 1
ECE C03 Lecture 2
Switches
false
X•Y
AND
true
X
Y
4
Logic Functions: Expressions to Gates
More than one way to map an expression to gates
T2
E.g., Z = A' • B' • (C + D) = (A' • (B' • (C + D)))
T1
use of 3-input gate
A
A
Z
B
B
T
D
C
T1
C
Z
D
2
Literal: each appearance of a variable or its complement in an expression
E.g., Z = A B' C + A' B + A' B C' + B' C
3 variables, 10 literals
ECE C03 Lecture 2
5
Logic Functions: NAND and NOR
NAND, NOR gates far outnumber AND, OR in typical designs
easier to construct in the underlying transistor technologies
Any Boolean expression can be implemented by NAND, NOR, NOT gates
In fact, NOT is superfluous
(NOT = NAND or NOR with both inputs tied together)
X
0
Y
0
X NOR Y
1
X
0
Y
0
X NAND Y
1
1
1
0
1
1
0
ECE C03 Lecture 2
6
Simplifying Logic Functions
Logic Minimization: reduce complexity of the gate level implementation
• reduce number of literals (gate inputs)
• reduce number of gates
• reduce number of levels of gates
fewer inputs implies faster gates in some technologies
fan-ins (number of gate inputs) are limited in some technologies
fewer levels of gates implies reduced signal propagation delays
minimum delay configuration typically requires more gates
number of gates (or gate packages) influences manufacturing costs
Traditional methods:
reduce delay at expense of adding gates
New
ECE
C03methods:
Lecture 2
7
trade off between increased circuit delay and reduced gate count
Alternative Logic Implementations
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
Z
0
1
0
1
0
1
1
0
0 1 0 1 0 1
A
B
C
0
Two-Level Realization
(inverters don't count)
Z1
0
Multi-Level Realization
Advantage: Reduced Gate
Fan-ins
Z2
0
Complex Gate: XOR
Advantage: Fewest Gates
Z3
TTL Package Counts:
Z1 - three packages (1x 6-inverters, 1x 3-input AND, 1x 3-input OR)
Z2 - three packages (1x 6-inverters,
1x 2-input
AND, 1x 2-input OR)
ECE C03 Lecture
2
Z3 - two packages (1x 2-input AND, 1x 2-input XOR)
8
Laws of Boolean Algebra
Duality: a dual of a Boolean expression is derived by replacing AND
operations by ORs, OR operations by ANDs, constant 0s by 1s, and
1s by 0s (literals are left unchanged).
Any statement that is true for an expression is also true for its dual!
Useful Laws/Theorems of Boolean Algebra:
Operations with 0 and 1:
1D. X • 1 = X
1. X + 0 = X
2D. X • 0 = 0
2. X + 1 = 1
Idempotent Law:
3. X + X = X
3D. X • X = X
Involution Law:
4. (X')' = X
Laws of Complementarity:
5. X + X' = 1
5D. X • X' = 0
Commutative Law:
6. X + Y = Y + X
6D. X • Y = Y • X
ECE C03 Lecture 2
9
Laws of Boolean Algebra
Associative Laws:
7. (X + Y) + Z = X + (Y + Z)
=X+Y+Z
Distributive Laws:
8. X • (Y+ Z) = (X • Y) + (X ••Z)
Simplification Theorems:
9. X • Y + X • Y' = X
10. X + X • Y = X
11. (X + Y') • Y = X • Y
7D. (X • Y) • Z = X • (Y • Z)
=X•Y•Z
8D. X + (Y• Z) = (X + Y) • (X + Z)
9D. (X + Y) • (X + Y') = X
10D. X • (X + Y) = X
11D. (X • Y') + Y = X + Y
DeMorgan's Law:
12. (X + Y + Z + ...)' = X' • Y' • Z' • ... 12D. (X • Y • Z • ...) ' = X' + Y' + Z' + ...
13. {F(X1,X2,...,Xn,0,1,+,•)}' = {F(X1',X2',...,Xn',1,0,•,+)}
Duality:
14. (X + Y + Z + ...) D = X • Y • Z • ...
14D. (X •FY • Z • ...)D = X + Y + Z + ...
15. {F(X1,X2,...,Xn,0,1,+,•)}D = {F(X1,X2,...,Xn,1,0,•,+)}
Theorems for Multiplying and Factoring:
16. (X + Y) • (X' + Z) = X • Z + X' • Y 16D. X • Y + X' • Z = (X + Z) • (X' + Y)
Consensus Theorem:
ECE C03 Lecture17D.
2
(X + Y) • (Y + Z) • (X' + Z)10=
(X + Y) • (X' + Z)
Proving Theorems via Boolean Algebra
Proving theorems via axioms of Boolean Algebra:
E.g., prove the theorem: X • Y + X • Y' = X
distributive law (8)
X • Y + X •Y' = X • (Y + Y')
complementary law (5)
X • (Y + Y')
= X • (1)
identity (1D)
X • (1)
=X
E.g., prove the theorem: X + X • Y
= X
identity (1D)
X + X•Y
distributive law (8)
X • 1 + X • Y = X • (1 + Y)
identity (2)
X • (1 + Y)
= X • (1)
identity (1)
X • (1)
= X
ECE C03 Lecture 2
= X•1 + X•Y
11
Two Level Logic: Canonical Forms
Sum of Products
A
B
C
Minterms
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
A
A
A
A
A
A
A
A
B
B
B
B
B
B
B
B
C = m0
C = m1
C = m2
C = m3
C = m4
C = m5
C = m6
C = m7
Shorthand Notation for
Minterms of 3 Variables
F in canonical form:
F(A,B,C) = Sm(3,4,5,6,7)
= m3 + m4 + m5 + m6 + m7
= A' B C + A B' C' + A B' C
+ A B C' + A B C
canonical form/minimal form
F = A B' (C + C') + A' B C + A B (C' + C)
= A B' + A' B C + A B
= A (B' + B) + A' B C
B
C
product term / minterm:
ANDed product of literals in which each
variable appears exactly once, in true or
complemented form (but not both!)
F
A
= A + A' B C
=A + BC
2-Level AND/OR
Realization
F = (A + B C)' = A' (B' + C') = A' B' + A' C'
ECE C03 Lecture 2
12
Product of Sums
A
0
0
0
0
1
1
1
1
B
0
0
1
1
0
0
1
1
C
0
1
0
1
0
1
0
1
Maxterms
A + B + C = M0
A + B + C = M1
A + B + C = M2
A + B + C = M3
A + B + C = M4
A + B + C = M5
A + B + C = M6
A + B + C = M7
Maxterm:
ORed sum of literals in which each
variable appears exactly once in either
true or complemented form, but not both!
Maxterm form:
Find truth table rows where F is 0
0 in input column implies true literal
1 in input column implies complemented
literal
Maxterm Shorthand Notation
for a Function of Three Variables
F(A,B,C) = PM(0,1,2)
= (A + B + C) (A + B + C') (A + B' + C)
F’(A,B,C) = PM(3,4,5,6,7)
= (A + B' + C') (A' + B + C) (A' + B + C') (A' + B' + C) (A' + B' + C')
ECE C03 Lecture 2
13
Two Level Simplification
Key Tool: The Uniting Theorem — A (B' + B) = A
A
0
0
1
1
B
0
1
0
1
F
0
0
1
1
F = A B' + A B = A (B' + B) = A
B's values change within the on-set rows
B is eliminated, A remains
A's values don't change within the on-set rows
A
0
0
1
1
B
0
1
0
1
G
1
0
1
0
G = A' B' + A B' = (A' + A) B' = B'
B's values stay the same within the on-set rows
A is eliminated, B remains
A's values change within the on-set rows
Essence of Simplification:
find two element subsets of the ON-set where only one variable
ECE C03
Lecture
2
14
changes its value. This
single
varying
variable can be eliminated!
Visualizing Boolean Cubes
0
1
XYZ
011
X
111
Just another way to
represent the truth table
1-cube
010
XY
11
01
110
Y
Y
00
001
Z
101
000
10
100
X
X
2-cube
n input variables =
n dimensional "cube"
3-cube
WXYZ
1011
1111
0111
0011
1010
1110
0010
0110
Y
0001
1001
0101
1101
Z
1100
W
0000
X
1000
0100
4-cube
ECE C03 Lecture 2
15
Two Level Simplication
Three variable example: Full Adder Carry Out
(A' + A) B Cin
011
A B Cin
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
Cout
0
0
0
1
0
1
1
1
111
010
The ON-set is covered
by the OR of the subcubes
of lower dimensionality
110
001
B
A B (Cin' + Cin)
101
Cin
000
100
A
C03 Lecture
Cout = ECE
B Cin
+ A B2 + A Cin
A (B + B') Cin
16
Karnaugh Map Method
hard to draw cubes of more than 4 dimensions
K-map is an alternative method of representing the truth table that
helps visualize adjacencies in up to 6 dimensions
Beyond that, computer-based methods are needed
A
0
B
2-variable
K-map
1
CD
0
0
1
1
A
AB
2
00
00
01
11
00
0
4
12
8
1
5
13
9
3
7
15
11
2
6
14
10
3
01
A
AB
C
3-variable
K-map
00
01
11
11
10
10
0
1
C
0
2
6
4
1
3
7
5
B
D
4-variable
K-map
B
Numbering Scheme: 00, 01, 11, 10
Gray Code — only a single bit changes from code
word
to next
ECE
C03 Lecture
2 code word
17
Karnaugh Map Method
Karnaugh Map Method
Adjacencies in the K-Map
00
C
01
111
011
A
AB
11
10
010
0
000
010
110
100
1
001
011
111
101
110
B
001
101
C
000
B
100
A
Wrap from first to last column
Top row to bottom row
ECE C03 Lecture 2
18
Karnaugh Map Examples
A
0
1
0
0
1
1
0
1
B
A
A asserted, unchanged
B varies
0
1
0
1
1
1
0
0
B
B complemented, unchanged
A varies
F=A
G = B'
A
AB
00
01
11
10
0
0
0
1
0
1
0
1
1
1
Cin
AB
C
B
Cout = A B + B Cin + A Cin
ECE C03
A
00
01
11
10
0
0
0
1
1
1
0
0
1
1
F(A,B,C) = A
19
B
Lecture 2
More Karnaugh Map Examples
A
AB
C
0
00
01
11
10
1
0
0
1
F(A,B,C) = Sm(0,4,5,7)
F = B' C' + A C
1
0
0
1
1
In the K-map, adjacency wraps from left to right
and from top to bottom
B
A
AB
C
0
00
01
11
10
0
1
1
0
F' simply replace 1's with 0's and vice versa
F'(A,B,C) = Sm(1,2,3,6)
1
1
1
0
0
F' = B C' + A' C
B
Compare with
the
ECE
C03method
Lecture 2 of using DeMorgan's Theorem
20
and Boolean Algebra to reduce the complement!
Karnaugh Map Examples (4 variables)
A
AB
00
CD
01
11
10
00
1
0
0
1
01
0
1
0
0
F(A,B,C,D) = Sm(0,2,3,5,6,7,8,10,11,14,15)
F = C + A' B D + B' D'
Find the smallest number
of the largest possible
subcubes that cover the
ON-set
D
11
1
1
1
1
10
1
1
1
1
C
B
1011
1111
0111
0011
1010
1110
0010
0110
1001
0001
C
D
0000
1100
A
B
1101
0101
K-map Corner Adjacency
Illustrated in the 4-Cube
1000
0100
ECE C03 Lecture 2
21
Karnaugh Maps: Circling zeros
AB
00
CD
A
01
11
10
00
1
0
0
1
01
0
1
0
0
F = (B + C + D) (A + C + D) (B + C + D)
D
11
1
1
1
1
10
1
1
1
1
C
B
Replace F by F, 0’s become 1’s and vice versa
F=BCD+ACD+BCD
F=BCD+ACD+BCD
ECE C03
F = Lecture
(B + C2
+ D) (A + C + D) (B + C + D)22
Karnaugh Map Don’t Cares
Don't Cares can be treated as 1's or 0's if it is advantageous to do so
AB
00
CD
A
01
11
10
F(A,B,C,D) = Sm(1,3,5,7,9) + Sd(6,12,13)
F = A'D + B' C' D w/o don't cares
00
0
0
X
0
01
1
1
X
1
D
11
1
1
0
0
10
0
X
0
0
C
B
F = C' D + A' D w/ don't cares
By treating this DC as a "1", a 2-cube
can be formed rather than one 0-cube
A
AB
CD
00
01
11
10
00
0
0
X
0
01
1
1
X
1
In PoS form: F = D (A' + C')
Same answer as above,
but fewer literals
D
11
1
1
0
0
10
0
X
0
0
C
ECE C03 Lecture 2
B
23
Algorithm: Minimum
SOP from K-Map
Step 1:
Choose an element of ON-set not already covered by an implicant
Step 2:
Find "maximal" groupings of 1's and X's adjacent to that element.
Remember to consider top/bottom row, left/right column, and
corner adjacencies. This forms prime implicants (always a power
of 2 number of elements).
Repeat Steps 1 and 2 to find all prime implicants
Step 3:
Revisit the 1's elements in the K-map. If covered by single prime
implicant, it is essential, and participates in final cover. The 1's it
covers do not need to be revisited
Step 4:
If there remain 1's not covered by essential prime implicants, then
select the smallest number of prime implicants that cover the
remaining 1's
ECE C03 Lecture 2
24
Gate Logic: Two Level Simplification
Example: ƒ(A,B,C,D) = •
m(4,5,6,8,9,10,13) + d(0,7,15)
A
AB
CD
00
01
11
10
00
X
1
0
1
00
01
0
1
1
1
01
A
01
11
10
AB
CD
X
1
0
1
0
1
1
1
AB
00
CD
D
11
0
X
X
0
10
0
1
0
1
C
Initial K-map
00
01
11
10
00
X
1
0
1
01
0
1
1
1
D
D
11
0
X
X
0
10
0
1
0
1
11
0
X
X
0
10
0
1
0
1
C
C
B
A
B
Primes around
A' B C' D'
ECE C03 Lecture 2
B
Primes around
A B C' D
25
Gate Logic: Two-Level Simplification
Example Continued
AB
00
CD
A
01
11
10
00
X
1
0
1
01
0
1
1
1
AB
00
CD
A
01
11
10
00
X
1
0
1
01
0
1
1
1
D
11
0
X
X
0
10
0
1
0
1
C
Primes around
A B C' D
A
01
11
10
00
X
1
0
1
01
0
1
1
1
D
11
0
X
X
0
10
0
1
0
1
C
B
AB
00
CD
D
11
0
X
X
0
10
0
1
0
1
C
B
Primes around
A B' C' D'
ECE C03 Lecture 2
B
Essential Primes
with Min Cover
26
Gate Logic: Two-Level Simplification
5-Variable K-maps
BC
BC
DE
00
00
0
A =0
01
11
10
4
12
8
5
13
DE
00
A=0
3
7
2
6
15
14
11
A =1
00
01
11
10
18
10
1
1
1
1
1
BC
00
01
11
16
20
28
17
19
11
1
10
10
01
1
BC
DE
00
01
9
11
11
10
1
01
21
23
22
29
31
30
DE
00
10
24
A=1
11
27
1
01
11
10
1
1
01 1
25
26
00
1
1
1
10
ƒ(A,B,C,D,E) = Sm(2,5,7,8,10,
13,15,17,19,21,23,24,29 31)
ECE C03 Lecture=2 C
E + A B' E + B C' D' E' 27
+ A' C' D E'
Gate Logic: Two Level
6- Variable K-Maps
Simplification
EF
00
AB=00
01
10
00
01
11
10
0
4
12
8
1
11
5
3
7
2
6
13
15
14
AB =01 00
10 1
10
01
11
10
11
16
20
28
17
19
18
21
23
22
11
10
49
51
50
31
30
CD
EF
00
00
AB =11
48
01
29
60
55
54
61
63
62
10
56
ƒ(A,B,C,D,E,F) =
Sm(2,8,10,18,24,
26,34,37,42,45,50,
53,58,61)
= D' E F' + A D E' F
+ A' C D' F'
57
59
10 1
CD
EF
00
00
AB=11
01
AB =10
00
01
11
11
32
36
44
33
35
10 34
37
39
38
45
47
46
11
10
1
11
10
1
1
CD
10
01
40
43
00
01
11
10
00
AB=10
1
1
11
41
42
01
1
EF
01
10
1
1
58
00
11
11
CD
EF
01
01
24
26
52
53
10
27
11
10
1
1
CD
EF
00
00
AB=01
25
01
11
11
11
01
01
01
9
00
00
00
AB=00
CD
EF
CD
EF
CD
10
ECE C03 Lecture 2
1
1
28
Summary
•
•
•
•
•
Representations of digital design
Boolean algebra review
Two-level minimization
Karnaugh maps
NEXT LECTURE: Two-level Logic Minimization
Algorithms
• READING: Katz 2.4.1, 2.4.2, Dewey 4.5
ECE C03 Lecture 2
29