f (A,B,C) - ECEn 224

advertisement
Boolean Algebra – Part 2
ECEn 224
05 BA2
Page 1
© 2003-2008
BYU
Inversion
Inversion or Complement of a Function means
all 0 outputs become 1 and all 1 outputs become 0
A
B
F
F'
0
0
1
1
0
1
0
1
0
1
1
0
1
0
0
1
ECEn 224
05 BA2
Page 2
© 2003-2008
BYU
Inversion
DeMorgan’s Laws
( X + Y )’ = X’ Y’
( X Y )’ = X’ + Y’
Proof:
X
Y
X'
Y'
X+Y
(X + Y)'
X'Y'
XY
(XY)'
X' + Y'
0
0
1
1
0
1
0
1
1
1
0
0
1
0
1
0
0
1
1
1
1
0
0
0
1
0
0
0
0
0
0
1
1
1
1
0
1
1
1
0
ECEn 224
05 BA2
Page 3
© 2003-2008
BYU
DeMorgan’s Laws
For complex expressions,
apply DeMorgan’s Laws successively
DeMorgan’s Laws:
(X+Y)’ = X’Y’
(XY)’ = X’ + Y’
Example:
F
= A’B + AB’
F’
= (A’B + AB’)’
(X+Y)’ = X’Y’
= (A’B)’•(AB’)’
(XY)’ = X’ + Y’
= (A+B’)•(A’+B)
= AA’+AB+A’B’+BB’
= AB+A’B’
ECEn 224
A
B
F
F'
0
0
1
1
0
1
0
1
0
1
1
0
1
0
0
1
05 BA2
Page 5
© 2003-2008
BYU
DeMorgan’s Laws
Another Example:
F’ = [ ( a’b + 1)(cd + e’ + 0) ]’
= (a’b + 1)’ + (cd + e’ + 0)’
= [(a’b)’ • 1’] + (cd)’ • (e’)’ • 0’
= (a + b’) • 0 + (c’ + d’) • e • 1
Note: Expression is not simplified
ECEn 224
05 BA2
Page 6
© 2003-2008
BYU
DeMorgan’s Laws - One Step Rule
[ f ( X1, X2, … XN, 0, 1, +, •) ]’ = f ( X1 ’, X2 ’, … XN ’, 1, 0, •, +)
1. Replace + with • and • with +
Like taking the dual
2. Replace 0 with 1 and 1 with 0
3. Replace all variables with the inverse
Be careful of hierarchy…
This is biggest source of errors
Before beginning, surround all AND terms with parentheses
ECEn 224
05 BA2
Page 7
© 2003-2008
BYU
DeMorgan’s Laws
Another Example:
F = ( a’b + 1)(cd + e’ + 0)
F = ( (a’ • b) + 1) • ( (c • d) + e’ + 0)
F’ = ( (a + b’) • 0) + ( (c’ + d’) • e • 1)
Variables and
constants
inverted!
Note: Expression is not simplified
ECEn 224
05 BA2
Page 8
© 2003-2008
BYU
Canonical Forms
ECEn 224
05 BA2
Page 9
© 2003-2008
BYU
Canonical Forms
• Is this equality true?
– AD + A’D’ + CD ?=? AD + A’D’ + A’C
• Hard to tell
– Both look minimized…
– But they look different…
• For many expressions there are multiple minimal forms
• Miminimizing is not a good way to determine equality
ECEn 224
05 BA2
Page 10
© 2003-2008
BYU
Canonical Forms
• A canonical form is something written in the
standard way
– Two expressions which are equal will have
identical canonical forms
• Is there a standard (canonical) way of
representing boolean expressions?
– Yes…
ECEn 224
05 BA2
Page 11
© 2003-2008
BYU
Truth Tables  Canonical?
f = AD + A’D’ + CD
f = AD + A’D’ + A’C
A
B
C
D
f
A
B
C
D
f
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
0
1
0
1
0
1
0
1
ECEn 224
Same truth table, two
different minimal
expressions.
So, are truth tables
canonical forms?
Yes, if we agree on a
fixed column order.
05 BA2
Page 12
© 2003-2008
BYU
Minterm Expansion
• Each row in the truth table
can be numbered
• Each row corresponds to an
AND term in the SOP
expression
• Call each row’s AND term a
minterm
(e.g., m0 = A’B’C’, m5 = AB’C)
• Combine minterms into SOP
expressions
• Called minterm expansion or
standard sum of products
(standard SOP )
f = AB + AC + B’C
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
1
1
m0
m1
m2
m3
m4
m5
m6
m7
f = m1 + m5 + m6 + m 7
f = m(1,5,6,7)
f = A’B’C + AB’C + ABC’ + ABC
ECEn 224
05 BA2
Page 13
© 2003-2008
BYU
Minterms have names
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
1
0
1
1
1
0
1
1
m0 = A'B'C'
m1 = A'B'C
m2 = A'BC'
m3 = A'BC
m4 = AB'C'
m5 = AB'C
m6 = ABC'
m7 = ABC
• The order of the variables is significant!
• Given a minterm expression we can easily tell which minterm number it
corresponds to
A’B’C’  000  m0
AB’C’  100  m4
AB’C  101  m5
• Given the minterm number we can derive the minterm expression.
m1  001  A’B’C
m3  011  A’BC
ECEn 224
m6  110  ABC’
05 BA2
Page 14
© 2003-2008
BYU
Minterms
• Are these minterms of 4 variables?
abcd
ab’cd’
ab’c
a’bc’bd
Yes
Yes
no, only 3 variables
no, b more than once
ECEn 224
05 BA2
Page 15
© 2003-2008
BYU
Minterm Expansion
• A minterm expansion is unique
f (A,B,C,D) =
m(0,2,3,7)
• Useful for:
– Proving equality
– Shorthand for representing boolean expressions
ECEn 224
05 BA2
Page 16
© 2003-2008
BYU
Maxterms are POS Equivalents to
Minterms
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
m0 = A'B'C'
m1 = A'B'C
M0 = m0' = A+B+C
M1 = m1' = A+B+C'
m2 = A'BC'
m3 = A'BC
m4 = AB'C'
M2 = m2' = A+B'+C
M3 = m3' = A+B'+C'
M4 = m4' = A'+B+C
m5 = AB'C
M5 = m5' = A'+B+C'
m6 = ABC'
m7 = ABC
M6 = m6' = A'+B'+C
M7 = m7' = A'+B'+C'
Maxterms
Note that maxterms are the inverse of minterms
ECEn 224
05 BA2
Page 17
© 2003-2008
BYU
Maxterm Expansion
Any function can be written as a product of maxterms.
This is called the maxterm expansion or standard product of
sums (standard POS )
f = AB + AC + B’C
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
1
1
M0
M1
M2
M3
M4
Use the 0’s for the function to
write the POS:
f (A,B,C) = M0 M2 M3 M4
f (A,B,C) = M(0, 2, 3, 4)
M5
M6
M7
f = (A+B+C)(A+B’+C)(A+B’+C’)(A’+B+C)
ECEn 224
05 BA2
Page 18
© 2003-2008
BYU
Maxterm Expansion
• Are these maxterms of 4 variables?
a+b+c+d
a + b’ + c + d’
a + b’ + d’
a’ + b + c’ + a’ + d
yes
yes
no, only 3 variables
no, a’ more than once
ECEn 224
05 BA2
Page 19
© 2003-2008
BYU
Identifying Maxterms
• A little different from minterms
• Given a maxterm expression we can easily tell
which maxterm number it corresponds to
A+B+C  000  M0
A’+B+C  100  M4
A’+B+C’  101  M5
• Given the maxterm number we can derive the
maxterm expression
M1  001  A+B+C’
M3  011  A+B’+C’
ECEn 224
M6  110  A’+B’+C
05 BA2
Page 20
© 2003-2008
BYU
Maxterm Expansion
• Maxterm expansions are useful for the same
things as minterm expansions
– Proving equality
– Shorthand for representing boolean
expressions
• We will use the them when we want POS
instead of SOP representations
ECEn 224
05 BA2
Page 21
© 2003-2008
BYU
Minterm / Maxterm Relationships
For any function, if a minterm is in the Minterm Expansion,
the corresponding maxterm is not in the Maxterm Expansion.
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
1
1
f (A,B,C) = m1 + m5 + m6 + m7
f (A,B,C) = M0 M2 M3 M4
Makes it easy to convert between SOP and POS
ECEn 224
05 BA2
Page 22
© 2003-2008
BYU
Minterm Example
•
Is this equation true?
AD + A’D’ + CD = AD + A’D’ + A’C
•
One method
1. Draw truth table for each side
2. Compare which minterms each side contains
Minterm expansions  shorthand truth tables…
ECEn 224
05 BA2
Page 23
© 2003-2008
BYU
Minterm Example
•
Is this equation true?
AD + A’D’ + CD = AD + A’D’ + A’C
•
Another method
1. Expand each term into its minterms (X = XY’ + XY)
2. Compare which minterms each side contains
AD = AC’D + ACD
A’D’ = A’C’D’ + A’CD’
CD = A’CD + ACD
ECEn 224
AD = AC’D + ACD
A’D’ = A’C’D’ + A’CD’
A’C = A’CD’ + A’CD
05 BA2
Page 24
© 2003-2008
BYU
Minterm Example
Minimize the following:
f(A,B,C) = m1 + m5 + m7
1. Write out as SOP
F = A’B’C + AB’C + ABC
2. Minimize
F = B’C + AC
minterm expansions  shorthand expressions…
ECEn 224
05 BA2
Page 25
© 2003-2008
BYU
Maxterm Example
Minimize the following:
f (A,B,C) = M1M5M7
1. Write out as POS
F = (A + B + C’)(A’ + B + C’)(A’ + B’ + C’)
2. Minimize
F = (B + C’)(A’ + C’)
maxterm expansions  shorthand expressions…
ECEn 224
05 BA2
Page 26
© 2003-2008
BYU
Minterm/Maxterm Example
Convert the following function of A, B, C to POS:
F = AB + C
1. Write the minterm expansion
F = m1 + m3 + m5 + m6 + m7 (use truth table if it helps)
2. Convert to maxterm expansion
F = M0 • M2 • M4
3. Write POS from maxterm expansion
F = (A + B + C)(A + B’ + C)(A’ + B + C)
4. Simplify if desired
F = (B + C)(A + C)
ECEn 224
05 BA2
Page 27
© 2003-2008
BYU
Algebraic Simplification
ECEn 224
05 BA2
Page 28
© 2003-2008
BYU
Algebraic Simplification
Objectives
• Why Simplify?
– Simpler equations  less hardware to
implement, faster, cheaper, less power
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
0
1
1
1
By inspection:
f = A’B’C + AB’C + ABC’ + ABC
4 3-input AND gates
1 4-input OR gate
Simplifying:
f = A’B’C + AB’C + ABC’ + ABC
f=
B’C
ECEn 224
+
AB
XY’+XY=X
2 2-input AND gates
1 2-input OR gate
05 BA2
Page 29
© 2003-2008
BYU
Hardware Cost
• Exact cost depends on technology
– nMOS, CMOS, TTL, I2L, GaAs, FPGA, …
• In general:
– Fewer literals 
smaller/faster/lower power circuit
– Inverters don’t count
• Free in some technologies
• Insignificant difference in others
ECEn 224
05 BA2
Page 30
© 2003-2008
BYU
Algebraic Simplification
Which theorems to use?
Essential Identities
X+0=X
X•1=X
X+1=1
X•0=0
X+X=X
X•X=X
X + X’ = 1
X • X’ = 0
(X’)’ = X
Basic Laws: Commutative, Associative, Distributive
X+Y=Y+X
XY = YX
(X + Y) + Z = X + (Y + Z)
(XY)Z = X(YZ)
X + YZ = (X + Y)(X + Z)
X(Y + Z) = XY + XZ
Essential Theorems
XY + XY’ = X
(X + Y) (X + Y’) = X
X + XY = X
X(X + Y) = X
X + YX’ = X + Y
X(Y + X’) = X Y
XY + X’Z + YZ = XY + X’Z
(X + Y)(X’ + Z)(Y + Z) = (X + Y)(X’ + Z)
Suggestions:
1. Know the identities
and basic laws
2. Memorize left side of
essential theorems
3. Create duals on
right as needed
[ f ( X1, X2, … XN, 0, 1, +, • ) ] ’ = f ( X1’, X2’, … XN’, 1, 0, • , + )
ECEn 224
05 BA2
Page 31
© 2003-2008
BYU
Four Methods of Algebraic Simplification
1.
2.
3.
4.
Combine terms
Eliminate terms
Eliminate literals
Add redundant terms
ECEn 224
05 BA2
Page 32
© 2003-2008
BYU
Methods of Algebraic Simplification
• Combine terms
ABC’ + A’B’C + A’BC’
Use X Y + X Y’ = X
BC’ + A’B’C
• Eliminate terms
• Eliminate literals
• Add redundant terms
ECEn 224
05 BA2
Page 33
© 2003-2008
BYU
Methods of Algebraic Simplification
• Combine terms
• Eliminate terms
A’B + B(A’D + C)
Use X + X Y = X
A’B + A’BD + BC
A’B + BC
• Eliminate literals
• Add redundant terms
ECEn 224
05 BA2
Page 34
© 2003-2008
BYU
Methods of Algebraic Simplification
• Combine terms
• Eliminate terms
• Eliminate literals
A’B + A’B’C’D’ + ABCD’
A’(B + B’C’D’) + ABCD’
A’(B + C’D’) + ABCD’
A’B + A’C’D’ + ABCD’
A’C’D’ + B(A’ + ACD’)
A’C’D’ + B(A’ + CD’)
A’B + BCD’ + A’C’D’
Use X + X’ Y = X + Y
• Add redundant terms
ECEn 224
05 BA2
Page 35
© 2003-2008
BYU
Methods of Algebraic Simplification
•
•
•
•
Combine terms
Eliminate terms
Eliminate literals
Add redundant terms
A’B’C + AB’C + ABC
A’B’C + AB’C + AB’C + ABC
B’C
+
ECEn 224
AC
05 BA2
Page 36
© 2003-2008
BYU
Proving an Equation is True
1. Construct a truth table for both sides
i. Tedious, not very elegant
ii. Computers love this method
2. Convert Both Sides to minterm/maxterm expansion
3. Manipulate one side algebraically to equal the other
• Perform the same operation on both sides
ECEn 224
05 BA2
Page 37
© 2003-2008
BYU
Perform the same operation on both sides
• Valid Operations
– Complement
– Construct the dual
• Invalid Operations
– Add (OR) a term to both sides (not reversible)
– Multiply (AND) both sides by a term (not reversible)
– Subtract a term from both sides (subtraction?)
ECEn 224
05 BA2
Page 38
© 2003-2008
BYU
Proving an Equation
Add a term to both sides
Prove Y = Z
Y=Z
Add 1 to both sides
Y+1=Z+1
Use X + 1 = 1
1=1
Therefore Y = Z
NO! You cannot OR an arbitrary term with both sides.
However, you can duplicate an existing term:
Y=Z  Y+Y=Z
ECEn 224
05 BA2
Page 39
© 2003-2008
BYU
Proving an Equation
Multiply (AND) both sides by a term
Prove Y = Z
Y=Z
Multiply both sides by 0
Y•0=Y•0
Therefore Y = Z
Use X • 0 = 0
0=0
NO! You cannot AND an arbitrary term to both sides.
However, you can duplicate an existing term:
Y=Z  Y•Y=Z
ECEn 224
05 BA2
Page 40
© 2003-2008
BYU
Proving an Equation is False
• Show one combination of values for which
the equation is false (counter example)
• Use Boolean algebra manipulation
–
–
–
–
Reduce to sum of products form
Minimize
Compare the two sides
Be careful! Some expressions have more
than one minimal forms.
ECEn 224
05 BA2
Page 41
© 2003-2008
BYU
Incompletely Specified Functions
ECEn 224
05 BA2
Page 42
© 2003-2008
BYU
Incompletely Specified Functions
w
x
y
A
N1
B
N2
C
f
Known: N1 does not generate
outputs A B C with values
of 101 or 111
z
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
1
X
1
X
ECEn 224
The X’s represent “don’t cares” –
since those input combinations
never occur, we don’t care what
the output is.
05 BA2
Page 43
© 2003-2008
BYU
Incompletely Specified Functions
A
B
C
f
f1 f2 f3 f4
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
1
X
1
X
0
1
0
0
1
0
1
0
0
1
0
0
1
0
1
1
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
Multiple ways to choose those X’s when minimizing.
Cost of minimal solution will depend on values chosen.
f1 = A’B’C + AB’C’ + ABC’
f1 = A’B’C + AC’
f2 = A’B’C + AB’C’ + ABC’ + ABC
f2 = A’B’C + AC’(B’ + B) + AB(C’ + C)
f2 = A’B’C + AC’ + AB
ECEn 224
Worse than f1
05 BA2
Page 44
© 2003-2008
BYU
Incompletely Specified Functions
f1 = A’B’C + AC’
A
B
C
f
f1 f2 f3 f4
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
1
X
1
X
0
1
0
0
1
0
1
0
f3 = A’B’C + AB’C’ + AB’C + ABC’
f3 = A’C( B + B’) + AB’( C’ + C)
f3= A’C + AB’
0
1
0
0
1
0
1
1
0
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
Better than f1
f4 = A’B’C + AB’C’ + AB’C + ABC’ + ABC
f4 = (A’ + A)B’C+ AB’(C’ + ’C) + AB(C’ + C)
f4 = B’C+ AB’ + AB = B’C + A
Best
ECEn 224
05 BA2
Page 45
© 2003-2008
BYU
Incompletely Specified Functions
• If the function has n don’t cares
– Must solve 2n truth tables to use this method
– Ouch!
• A better way will be shown in a later chapter…
ECEn 224
05 BA2
Page 46
© 2003-2008
BYU
Don’t Cares - Minterm Representation
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
1
X
1
X
Use d0 … d7 to represent don’t care
minterms
F = m1 + m4 + m6 + d5 + d7
F=

m( 1, 4, 6) +
ECEn 224

d( 5, 7)
05 BA2
Page 47
© 2003-2008
BYU
Don’t Cares - Maxterm Representation
A
B
C
f
0
0
0
0
1
1
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
0
1
X
1
X
Use D0 … D7 to represent don’t care
maxterms
F = M0 M2 M3 D5 D7
F =  M(0, 2, 3)  D(5, 7)
ECEn 224
05 BA2
Page 48
© 2003-2008
BYU
Download