05 BA2 Page 1 ECEn/CS 224 Boolean Algebra – Part 2.
-
Upload
roger-mathews -
Category
Documents
-
view
215 -
download
1
Transcript of 05 BA2 Page 1 ECEn/CS 224 Boolean Algebra – Part 2.
05 BA2 Page 1
ECEn/CS 224
Boolean Algebra – Part 2
05 BA2 Page 2
ECEn/CS 224
InversionInversion or Complement of a Function means
all 0 outputs become 1 and all 1 outputs become 0
A B F F'
0 0 0 10 1 1 01 0 1 01 1 0 1
05 BA2 Page 3
ECEn/CS 224
Inversion
DeMorgan’s Laws
( X + Y )’ = X’ Y’ . ( X Y )’ = X’ + Y’
Proof:
X Y X' Y' X + Y (X + Y)' X'Y' X Y (XY)' X' + Y'
0 0 1 1 0 1 1 0 1 10 1 1 0 1 0 0 0 1 11 0 0 1 1 0 0 0 1 11 1 0 0 1 0 0 1 0 0
05 BA2 Page 4
ECEn/CS 224
DeMorgan’s Laws
For N variables:
(X1 + X2 + X3 + …+ Xn)’ = X1’ X2’ X3’ … Xn’
( X1 X2 X3 … Xn )’ = X1’ + X2’ + X3’ + …+ Xn’
05 BA2 Page 5
ECEn/CS 224
DeMorgan’s Laws
For complex expressions, apply DeMorgan’s Laws successively
Example:
A B F F'
0 0 0 10 1 1 01 0 1 01 1 0 1
F = A’B + AB’
F’ = (A’B + AB’)’ = (A’B)’•(AB’)’ = (A+B’)•(A’+B)
= AA’+AB+A’B’+BB’= AB+A’B’
05 BA2 Page 6
ECEn/CS 224
DeMorgan’s Laws
Another Example:
[ ( 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
05 BA2 Page 7
ECEn/CS 224
DeMorgan’s Laws - One Step Rule
[ f ( X1, X2, … XN, 0, 1, +, •) ]’ =
f ( X1 ’, X2 ’, … XN ’, 1, 0, •, +)
1. Replace all variables with the inverse2. Replace + with • and • with +3. Replace 0 with 1 and 1 with 0
Be careful of hierarchy…This is biggest source of errorsBefore beginning, surround all AND terms with parens
05 BA2 Page 8
ECEn/CS 224
Canonical Forms
05 BA2 Page 9
ECEn/CS 224
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
05 BA2 Page 10
ECEn/CS 224
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?
05 BA2 Page 11
ECEn/CS 224
Truth Tables Canonical?
A B C D f
0 0 0 0 10 0 0 1 00 0 1 0 10 0 1 1 10 1 0 0 10 1 0 1 00 1 1 0 10 1 1 1 11 0 0 0 01 0 0 1 11 0 1 0 01 0 1 1 11 1 0 0 01 1 0 1 11 1 1 0 01 1 1 1 1
f = AD + A’D’ + CD f = AD + A’D’ + A’CA B C D f
0 0 0 0 10 0 0 1 00 0 1 0 10 0 1 1 10 1 0 0 10 1 0 1 00 1 1 0 10 1 1 1 11 0 0 0 01 0 0 1 11 0 1 0 01 0 1 1 11 1 0 0 01 1 0 1 11 1 1 0 01 1 1 1 1
Same truth table -two different minimal expressions.
Are truth tables canonical forms?
05 BA2 Page 12
ECEn/CS 224
Minterm Expansions
• Truth table is unique if rows in set order
• Each row can be numbered
• Call each row’s AND term a minterm
A B C D f
0 0 0 0 1 m0
0 0 0 1 0 m1
0 0 1 0 1 m2
0 0 1 1 1 m3
0 1 0 0 1 m4
0 1 0 1 0 m5
0 1 1 0 1 m6
0 1 1 1 1 m7
1 0 0 0 0 m8
1 0 0 1 1 m9
1 0 1 0 0 m10
1 0 1 1 1 m11
1 1 0 0 0 m12
1 1 0 1 1 m13
1 1 1 0 0 m14
1 1 1 1 1 m15
f = AD + A’D’ + A’C
f (A,B,C,D) = m0 + m2 + m3 + m4 + m6 + m7 + m9 + m11 + m13 + m15
f (A,B,C,D) = m(0,2,3,4,6,7,9,11,13,15)
05 BA2 Page 13
ECEn/CS 224
Minterms
• Are these minterms of 4 variables?
abcd yesab’cd’ yesab’c no, only 3 literalsa’bc’bd no, b more than once
05 BA2 Page 14
ECEn/CS 224
Minterms have names
Note: the order of the variables is significant.
A B C f
0 0 0 1 m0 = A'B'C'
0 0 1 0 m1 = A'B'C
0 1 0 1 m2 = A'BC'
0 1 1 1 m3 = A'BC
1 0 0 1 m4 = AB'C'
1 0 1 0 m5 = AB'C
1 1 0 1 m6 = ABC'
1 1 1 1 m7 = ABC
05 BA2 Page 15
ECEn/CS 224
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
05 BA2 Page 16
ECEn/CS 224
Maxterms are POS Equivalents to Minterms
Note that maxterms are the inverse of minterms
A B C f Minterms Maxterms
0 0 0 1 m0 = A'B'C' M0 = m0' = A+B+C
0 0 1 0 m1 = A'B'C M1 = m1' = A+B+C'
0 1 0 1 m2 = A'BC' M2 = m2' = A+B'+C
0 1 1 1 m3 = A'BC M3 = m3' = A+B'+C'
1 0 0 1 m4 = AB'C' M4 = m4' = A'+B+C
1 0 1 0 m5 = AB'C M5 = m5' = A'+B+C'
1 1 0 1 m6 = ABC' M6 = m6' = A'+B'+C
1 1 1 1 m7 = ABC M7 = m7' = A'+B'+C'
05 BA2 Page 17
ECEn/CS 224
Maxterm Expansion
• Are these maxterms of 4 variables?
a + b + c + d yesa + b’ + c + d’ yesa + b’ + d’ no, only 3 literalsa’ + b + c’ + a’ + d no, a’ more than once
05 BA2 Page 18
ECEn/CS 224
Maxterm Expansion
Any function can be written as a product of maxterms. This is called a:
Standard Product of Sums (Standard POS)
Use the 0’s for f to write the POS:
f (A,B,C) =M0 M2 M3 M4
f (A,B,C) = M(0, 2, 3, 4 )
f = (A+B+C)(A+B’+C)(A+B’+C’)(A’+B+C)
A B C f
0 0 0 0 M0
0 0 1 1 M1
0 1 0 0 M2
0 1 1 0 M3
1 0 0 0 M4
1 0 1 1 M5
1 1 0 1 M6
1 1 1 1 M7
05 BA2 Page 19
ECEn/CS 224
Maxterm Expansion
• Maxterm expansions are useful– For the same things as minterm expansions
• We will use them when we want POS instead of SOP representations
05 BA2 Page 20
ECEn/CS 224
Minterm / Maxterm Relationships
f (A,B,C) = m1 + m5 + m6 + m7
f (A,B,C) = M0 M2 M3M4
For any function, if a minterm is in the Minterm Expansion,the corresponding maxterm is not in the Maxterm Expansion.
Makes it easy to convert between SOP and POS
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1
05 BA2 Page 21
ECEn/CS 224
Minterm Example
• Is this equation true?
AD + A’D’ + CD = AD + A’D’ + A’C
1. Write each side as a truth table2. Compare which minterms each contains
Minterm expansions shorthand truth tables…
05 BA2 Page 22
ECEn/CS 224
Minterm Example• Minimize the following:
f (A,B,C) = m1 + m5 + m7
1. Write out as SOPf = A’B’C + AB’C + ABC
2. Minimizef = B’C + AC
minterm expansions shorthand expressions…
05 BA2 Page 23
ECEn/CS 224
Maxterm ExampleMinimize the following:
f (A,B,C) = M1M5M7
1. Write out as SOPf = (A+B+C’)(A’+B+C’)(A’+B’+C’)
2. Minimizef = (B+C’)(A’+C’)
maxterm expansions shorthand expressions…
05 BA2 Page 24
ECEn/CS 224
Minterm/Maxterm Example
Convert the following to POS:
F = AB + C
1. Write minterm expansionF = m1+m3+m5+m6+m7 (use truth table if it helps)
2. Convert to maxterm expansionF = M0 • M2 • M4
3. Write POS from maxterm expansionF = (A+B+C)(A+B’+C)(A’+B+C)
4. Simplify if desiredF = (B+C)(A+C)
05 BA2 Page 25
ECEn/CS 224
Algebraic Simplification
05 BA2 Page 26
ECEn/CS 224
Algebraic SimplificationObjectives
• Why Simplify?– Simpler equations less hardware to
implement, faster, cheaper, less power
By inspection: f = A’B’C + AB’C + ABC’ + ABC
Simplifying:
f = A’B’C + AB’C + ABC’ + ABC
f = B’C + AB
XY’+XY=X
4 3-input AND gates1 4-input OR gate
2 2-input AND gates1 2-input OR gate
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1
05 BA2 Page 27
ECEn/CS 224
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
05 BA2 Page 28
ECEn/CS 224
Algebraic Simplification: Which Theorems To Use?
1. Essential Identities:X + 0 = X X • 1 = XX + 1 = 1 X • 0 = 0X + X = X X • X = X( X' ) ' = XX + X' = 1 X • X' = 0
X + Y = Y + X X • Y = Y • X(X + Y) + Z = X + (Y + Z) =X + Y + Z
(XY)Z = X(YZ) = XYZ
X( Y + Z ) = XY + XZ X + YZ = ( X + Y ) ( X + Z )
3. Essential:X Y + X Y' = X ( X + Y ) ( X + Y' ) = XX + XY = X X ( X + Y ) = X
( X + Y' ) Y = XY XY' + Y = X + Y4. Useful, hard to remember, easy to re-derive:
[ f ( X1, X2, … XN, 0, 1, +, • ) ]' = f ( X1', X2', … XN', 1, 0, •, + )
2. Essential Commutative, Associative, Distributive, and DeMorgan's Laws:
Suggestions:1. Focus on yellow ones2. Create duals on
right as needed3. Be familiar with 4
05 BA2 Page 29
ECEn/CS 224
4 Methods of Algebraic Simplification
1. Combine terms2. Eliminate terms3. Eliminate literals4. Add redundant terms
05 BA2 Page 30
ECEn/CS 224
Methods of Algebraic Simplification
• Combine termsUse X Y + X Y’ = X
ABC’ + A’B’C + A’BC’ =
BC’ + A’B’C
• Eliminate terms• Eliminate literals• Add redundant terms
05 BA2 Page 31
ECEn/CS 224
Methods of Algebraic Simplification
• Combine terms• Eliminate terms
A’B + B ( A’D + C)
A’B + A’BD + BC
Use X + X Y = X
A’B + BC
• Eliminate literals• Add redundant terms
05 BA2 Page 32
ECEn/CS 224
Methods of Algebraic Simplification• Combine terms• Eliminate terms• Eliminate literals
Use X + X’ Y = X + YA’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’
• Add redundant terms
05 BA2 Page 33
ECEn/CS 224
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 + AC
05 BA2 Page 34
ECEn/CS 224
Proving an Equation is True
1. Construct a truth table for both sidesi. Tedious, not very elegantii. Computers love this method
2. Convert Both Sides to minterm/maxterm expansion
3. Manipulate one side algebraically to equal the other
4. Perform the same operation on both sides
05 BA2 Page 35
ECEn/CS 224
Perform the same operation on both sides
• Valid Operations– Complement – Construct the duals
• Invalid Operations– Add a term to both sides (not reversible)– Multiply (AND) both sides by a term (not reversible)– Subtract a term from both sides (subtraction?)
05 BA2 Page 36
ECEn/CS 224
Proving an Equation Add a term to both sides
Prove y = zAdd 1 to both sides
y + 1 = z + 1Use X + 1 = 1
1 = 1Therefore y = z
But not really, you cannot add an arbitrary term to both sides.
This does not prevent you from duplicating an existing term:
Y = Z Y+Y = Z
05 BA2 Page 37
ECEn/CS 224
Proving an Equation Multiply (AND) both sides by a term
Prove y = zMultiply both sides by 0
y • 0 = z • 0Use X • 0 = 0
0 = 0Therefore y = z
But not really, you cannot multiply both sides by an arbitrary term
But, you can multiply by a redundant existing term:
y • z = y • y • z
05 BA2 Page 38
ECEn/CS 224
Proving an Equation is False
• Show one combination of values which is false (counter example)
• Use Boolean algebra manipulation– Reduce to sum of products form– Minimize– Compare the 2 sides– Be careful – some expressions have >1
minimal forms…
05 BA2 Page 39
ECEn/CS 224
Converting English to Boolean Expressions
05 BA2 Page 40
ECEn/CS 224
The air conditioner should be turned on if and only if: - the temperature is greater than 75, - the time is between 8a.m. and 5 p.m., - and it is not a holiday.
05 BA2 Page 41
ECEn/CS 224
1. Identify phrases
F = air conditioner should be turned onA = temperature is greater than 75B = time is between 8a.m. and 5 p.mC = it is not a holiday
The air conditioner should be turned on if and only if: - the temperature is greater than 75, - the time is between 8a.m. and 5 p.m., - and it is not a holiday.
05 BA2 Page 42
ECEn/CS 224
2. Identify connective words
impliedand
=
The air conditioner should be turned on if and only if: - the temperature is greater than 75, - the time is between 8a.m. and 5 p.m., - and it is not a holiday.
05 BA2 Page 43
ECEn/CS 224
3. Construct a Boolean Expression
F = air conditioner should be turned onA = temperature is greater than 75B = time is between 8a.m. and 5 p.mC = it is not a holiday
F = A • B • C’
The air conditioner should be turned on if and only if: - the temperature is greater than 75, - the time is between 8a.m. and 5 p.m., - and it is not a holiday.
05 BA2 Page 44
ECEn/CS 224
4. Draw the Network
F = A • B • C’
The air conditioner should be turned on if and only if: - the temperature is greater than 75, - the time is between 8a.m. and 5 p.m., - and it is not a holiday.
BA
CF
05 BA2 Page 45
ECEn/CS 224
Converting English to Boolean
1. Identify phrases2. Identify connective words3. Construct a Boolean Expression4. Draw the Network
05 BA2 Page 46
ECEn/CS 224
Converting English to Boolean
• Be careful: Boolean algebra is precise, English is not.
The roads will be very slippery if it snows or rains and there is oil on the road.
F = A + BC
or
F = (A + B) C
AB C
Which is it?
05 BA2 Page 47
ECEn/CS 224
AND/OR vs. OR/AND Logic Forms
05 BA2 Page 48
ECEn/CS 224
AND/OR Logic from Truth Table
1. Write the SOP by inspection from f
A
B
C
f
f = A’B’C +AB’C + ABC’ + ABC
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1
05 BA2 Page 49
ECEn/CS 224
AND/OR Logic from Truth Table
2. Simplify the equation
f = A’B’C +AB’C + ABC’ + ABC
f = (A + A’) B’C + AB ( C + C’)
f = AB + B’C
05 BA2 Page 50
ECEn/CS 224
AND/OR Logic from Truth Table
3. Draw the logic network
f = AB + B’C
A
B
C
f
05 BA2 Page 51
ECEn/CS 224
OR/AND Logic from Truth Table
A
B
C
f
f ‘ = A’B’C’ + A’BC’ + AB’C’f = (A + B + C)(A + B’ + C)(A’ + B + C)
1. Write a POS by inspection from f
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 11 0 0 01 0 1 11 1 0 11 1 1 1
05 BA2 Page 52
ECEn/CS 224
OR/AND Logic from Truth Table
3. Simplify the equation: f = (B+C)(A+C)4. Draw the logic network
AC
BC
f
05 BA2 Page 53
ECEn/CS 224
Incompletely Specified Functions
05 BA2 Page 54
ECEn/CS 224
Incompletely Specified Functions
w
x
y
z
A
B
CFN1 N2
Known: N1 does not generateoutputs A B C with valuesof 101 or 111
The X’s represent don’t care – since those input combos never occur, you don’t care what the output is.
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 X1 1 0 11 1 1 X
05 BA2 Page 55
ECEn/CS 224
Incompletely Specified Functions
f1 = A’B’C + AB’C’ + ABC’f1 = A’B’C + AC’
f2 = A’B’C + AB’C’ + ABC’ + ABCf2 = A’B’C + AC’(B’ + B) + AB(C’ + C)f2 = A’B’C + AC’ + AB Worse than f1
Multiple ways to choose those X’s when minimizing. Cost of minimal solution will depend on which one chosen.
A B C f f1 f2 f3 f4
0 0 0 0 0 0 0 00 0 1 1 1 1 1 10 1 0 0 0 0 0 00 1 1 0 0 0 0 01 0 0 1 1 1 1 11 0 1 X 0 0 1 11 1 0 1 1 1 1 11 1 1 X 0 1 0 1
05 BA2 Page 56
ECEn/CS 224
Incompletely Specified Functions
f1 = A’B’C + AC’
f3 = A’B’C + AB’C’ + AB’C + ABC’f3 = A’C( B + B’) + AB’( C’ + C)f3= A’C + AB’ Better than f1
f4 = A’B’C + AB’C’ + AB’C + ABC’ + ABCf4 = (A’ + A)B’C+ AB’(C’ + ’C) + AB(C’ + C)f4 = B’C+ AB’ + AB = B’C + A Best
A B C f f1 f2 f3 f4
0 0 0 0 0 0 0 00 0 1 1 1 1 1 10 1 0 0 0 0 0 00 1 1 0 0 0 0 01 0 0 1 1 1 1 11 0 1 X 0 0 1 11 1 0 1 1 1 1 11 1 1 X 0 1 0 1
05 BA2 Page 57
ECEn/CS 224
Incompletely Specified Functions
• If the function has n don’t cares– Must solve 2n truth tables– Ouch
• A better way will be shown in a later chapter…
05 BA2 Page 58
ECEn/CS 224
Don’t Cares - Minterm Representation
Use d0 … d7 to represent don’t care minterms
F = m1 + m4 + m6 + d5 + d7
F = m( 1, 4, 6) + d( 5, 7)
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 X1 1 0 11 1 1 X
05 BA2 Page 59
ECEn/CS 224
Don’t Cares - Maxterm Representation
Use D0 … D7 to represent don’t care maxterms
F = M0 M2 M3 D5 D7
F = M(0, 2, 3) D(5, 7)
A B C f
0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 X1 1 0 11 1 1 X