Digital logic

advertisement
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Lecture 11
Digital logic
• 
• 
• 
• 
• 
• 
From analog to digital: families
Logic operations and gates
The logic design problem
Laws of Boolean algebra
Canonical forms
Karnaugh maps
Robert R. McLeod, University of Colorado
http://en.wikipedia.org/wiki/Logic_gate
109
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Mapping analog voltage
to binary high/low levels
…depends on the logic family e.g. CMOS, TTL, etc.
Logic high:
Logic low:
VT
VIH < V < VOH
VIL < V < VOL
The voltage applied to a device which cause the device to switch.
Most integrated circuits are level sensitive and not threshold sensitive.
Robert R. McLeod, University of Colorado
http://www.interfacebus.com/voltage_threshold.html
110
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Boolean algebra
Primary
Inverted
AND
NAND
A⋅ B
A⋅ B
OR
NOR
A+ B
=
A+B
A+ B =
A⋅B
XOR
XNOR
A⊕ B
A⊕ B
Venn diagram view
X ⋅Y
Robert R. McLeod, University of Colorado
DeMorgan’s
equivalent
http://en.wikipedia.org/wiki/Logic_gate
X +Y
X
http://en.wikipedia.org/wiki/Boolean_algebra
111
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Laws of Boolean algebra
Basic rules:
A⋅ A = A
A+ A= A
A ⋅1 = A
A +1 =1
A⋅0 = 0
A+0 = A
A⋅ A = 0
A+ A =1
A=A
A+ A⋅B = A+ B
Association: Order of like operations doesn’t matter
A ⋅ (B ⋅ C ) = ( A ⋅ B ) ⋅ C
A + (B + C ) = ( A + B ) + C
Distribution: Operation can be applied across brackets
A ⋅ (B + C ) = ( A ⋅ B ) + ( A ⋅ C )
A + (B ⋅ C ) = ( A + B ) ⋅ ( A + C )
Commutation: Order of terms doesn’t matter
A⋅ B = B ⋅ A
A+ B = B+ A
De Morgan’s Law: Or “how to distribute the inversion operator”
A⋅ B = A + B
A+ B = A⋅B
Robert R. McLeod, University of Colorado
http://en.wikibooks.org/wiki/Electronics/Boolean_Algebra
112
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
The logic design problem
•  Examples:
–  What is the 3rd bit in
the addition of two
binary numbers?
–  Which states of a
traffic light have a
particular red light on?
–  Which combinations of
security procedures
allow the lock to be
opened?
•  Purpose: To simplify
the implementation of
a logical function, e.g.
minimize # of gates
or number of gate
delays
•  Starting point =
capture requirement
in truth table:
Robert R. McLeod, University of Colorado
http://en.wikipedia.org/wiki/Karnaugh_map
113
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Canonical forms
Complete but inefficient
Minterm: Product (AND) of every input or its inverse appears once.
E.g. m9 = A ⋅ B ⋅ C ⋅ D
TRUE only for one combination (1001 for example given)
There are 2n minterms of n variables:
Decimal
Binary
Minterm = product of
Maxterm = sum of
0
0
0
0
A
B
C
A
B
C
1
0
0
1
A
B
C
A
B
C
2
0
1
0
A
B
C
A
B
C
3
0
1
1
A
B
C
A
B
C
4
1
0
0
A
B
C
A
B
C
5
1
0
1
6
1
1
0
A
A
B
B
C
C
A
A
B
B
C
C
7
1
1
1
A
B
C
A
B
C
Maxterm: Sum (OR) of every input or its inverse appears once.
E.g. M 9 = A + B. + C + D
FALSE only for one combination (1001 for example given)
By DeMorgan’s rule: The inverse of a minterm is its maxterm
E.g. m9 = M 9
Sum of products canonical form for truth-table example
f = (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D ) +
(A ⋅ B ⋅ C ⋅ D) + (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D) + (A ⋅ B ⋅ C ⋅ D )
Product of sums canonical form for truth-table example
f = (A + B + C + D ) ⋅ (A + B + C + D ) ⋅ (A + B + C + D )⋅ (A + B + C + D )⋅
(A + B + C + D)⋅ (A + B + C + D )⋅ (A + B + C + D )⋅ (A + B + C + D )
Robert R. McLeod, University of Colorado
114
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Karnaugh maps
How to find minimal implementation
Concept: Truth table is arranged to show logical groupings.
Adjacent squares change by only one bit = Gray code.
Large rectangular areas represent simpler forms
Rectangles contain either only
1 or X (don’t care) or
0 or X (don’t care)
Number of cells in rectangle must be power of 2
Rectangles can wrap around edges
Rectangles can overlap
Example maps for 2, 3, 4 and 5 variables
Robert R. McLeod, University of Colorado
115
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Karnaugh maps
Why they work
Truth table
ABCD ABCD ABCD ABCD
Set up of the Karnaugh map
• 
ABCD ABCD ABCD ABCD
• 
ABCD ABCD ABCD ABCD
• 
ABCD ABCD ABCD ABCD
Every space in the map corresponds
to one line of the truth table.
The rows and columns of the map are
arranged such that only on variable
changes (from 0 to 1 or 1 to 0)
between adjacent rows or columns.
This includes wrapping around the
edges!
Terms where f=1 are shaded
f can be written, from the truth table as:
f = ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD + ABCD
Consider any two adjacent squares (circled in blue) that are both “1”.
This corresponds to entries in the formula for f that differ only by one
variable flipping from inverted to not inverted, in this case B. Grouping
those two terms and factoring, we find:
(
)
ABCD + ABCD = B +B ACD = ACD
Now consider any four adjacent squares (circled in red) that are all “1”.
This corresponds to entries in the formula for f with two variables that are
the same (A and B not), while all the rest of the terms differ. Again, factor:
(
)
(
)(
)
ABCD + ABCD + ABCD + ABCD = AB CD +CD +CD +CD = AB C +C D +D = AB
K-maps do Boolean algebra for you, making it easy to find reduced terms.
Robert R. McLeod, University of Colorado
116
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Example Karnaugh map
Step 1: Truth table
Step 4: Write expressions for blocks
Step 2: Transfer to K-map
0
0
1
1
0
0
1
1
0
0
0
1
0
1
1
1
Step 3: Circle minimal blocks
A⋅C
A⋅ B
B ⋅C ⋅ D
Step 5: Write final expression
f = A⋅C + A⋅ B + B ⋅C ⋅ D
Compare this to the canonical forms.
This form is much simpler to implement.
Robert R. McLeod, University of Colorado
http://en.wikipedia.org/wiki/Karnaugh_map
117
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Karnaugh maps: 0 and X
We could instead group the zeros:
f = A⋅B +
A ⋅C +
B ⋅C ⋅ D
Using De Morgan’s rule gives the
product of sums form:
f = ( A + B )( A + C )(B + C + D )
Don’t care states
Often there are states that we don’t intend to use, such as values beyond 9 in BCD.
For example, what if ABCD=1111 was “don’t care” in the previous example.
It is marked with an “X”.
We can make a larger grouping now:
f = A + B ⋅C ⋅ D
Robert R. McLeod, University of Colorado
http://en.wikipedia.org/wiki/Karnaugh_map
118
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Another example
Correct, but not minimal:
f = W ⋅ X ⋅Y ⋅ Z
+ W ⋅ X ⋅Y
+ W ⋅Y ⋅ Z
+ W ⋅ X ⋅Y ⋅ Z
+ W ⋅ X ⋅Y ⋅ Z
Much better
f = X ⋅Z
+ W ⋅ X ⋅Y
+Y ⋅Z
Rules of thumb
•  Remember wrap-around edges
•  Always use largest possible area
Robert R. McLeod, University of Colorado
http://www.facstaff.bucknell.edu/
mastascu/elessonshtml/logic/logic3.html
119
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Quiz 11.1
f = (A ⋅ B) + (A ⋅ B )
Q: Use Boolean algebra to simplify
this expression to its simplest form.
Remember that association and
distribution work just like regular
algebra so you can “factor out”
common terms.
A: f = A.(B+NOT(B))
B: f = A.(B.NOT(B))
C: f = A
D: f = 0
E: No simplification possible
f = (A ⋅ B) + (A ⋅ B )
= A ⋅ (B + B )
= A ⋅1
Robert R. McLeod, University of Colorado
=A
120
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Quiz 11.2
0
1
0
0
0
0
0
1
Q: The Karnaugh map above corresponds
to which minterms?
A:
B:
C:
D:
E:
A.B.NOT(C) + NOT(A).NOT(B).C
NOT(A).NOT(B).C + A.B.NOT(C)
A.NOT(B).C + NOT(A).B.NOT(C)
NOT(A).B.C + A. NOT(B).NOT(C)
A.NOT(B).C + A.B.NOT(C)
Robert R. McLeod, University of Colorado
121
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Quiz 11.3
0
0
0
0
0
0
0
0
0
0
1
1
0
0
1
1
Q: What is the simplest logical
expression for the Karnaugh map
shown?
A: A . NOT(D)
B: A.C.D + A.C.NOT(D)
C: A.B.C + A.NOT(B).C
B and C are correct, but not minimal.
D: A.D
Note that, for the “1” states,
•  A = 1
E: A .C
•  B is both 0 and 1, so doesn’t matter
Robert R. McLeod, University of Colorado
• 
• 
C=1
D is both 0 and 1, so doesn’t matter
122
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Bonus quiz 11.1
f = (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D )
Q: Use Boolean algebra to simplify this
expression to its simplest form. Remember
that association and distribution work just
like regular algebra so you can “factor out”
common terms.
) (
( )[ (
f = (A ⋅ C ⋅ D ) + (A ⋅ C ⋅ D )
A: f = A ⋅ C D ⋅ B + B + D ⋅ B + B
B:
C: f = 0
D: f = A ⋅ C
)]
f = (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D )
+ (A ⋅ B ⋅ C ⋅ D ) + (A ⋅ B ⋅ C ⋅ D )
= (A ⋅ C ⋅ D )(B + B ) + (A ⋅ C ⋅ D )(B + B )
= (A ⋅ C ⋅ D ) + (A ⋅ C ⋅ D )
= (A ⋅ C )(D + D )
= A⋅C
E: No simplification possible
Robert R. McLeod, University of Colorado
123
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Bonus quiz 11.2
0
0
0
1
0
0
0
1
Q: What is the simplest expression
for the Karnaugh map shown?
A:
B:
C:
D:
E:
f
f
f
f
f
= B⋅ C
= B⋅C
= A ⋅B⋅ C + A ⋅B⋅ C
= A⋅B+ A⋅B
= A⋅C
C is correct, but not minimal.
Note that, for the “1” states,
•  A = is both 0 and 1, so doesn’t matter
•  B =1
•  C = 0
Robert R. McLeod, University of Colorado
124
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Bonus quiz 11.3
0
0
0
0
1
0
0
1
1
0
0
1
0
0
0
0
Q: What is the simplest logical
expression for the Karnaugh map
shown?
A: f = A ⋅ B ⋅ D + A ⋅ B ⋅ D
B: f = B ⋅ D
A is correct, but not minimal.
Note that, for the “1” states,
C: f = B ⋅ C
•  A = is both 0 and 1, so doesn’t matter
•  B =0
D: f = B ⋅ D
•  C is both 0 and 1, so doesn’t matter
•  D = 1
E: f = A ⋅ D
Robert R. McLeod, University of Colorado
125
• Lecture 11: Digital logic
ECEN 1400 Introduction to Analog and Digital Electronics
Bonus quiz 11.4
Q: Which of the following Boolean
algebra expressions is equivalent to
X = A . NOT(B) where “.” represents
the “and” operation, “+” represents
the “or” operation, and “NOT()”
represents an inversion function.
A:
B:
C:
D:
E:
X = NOT(A) + B
X = NOT[NOT(A) + B]
X = NOT[NOT(A) . B]
X = NOT[A + NOT(B)]
X = A + NOT(B)
By DeMorgan’s rule, C . D is equivalent to NOT[NOT(C) + NOT(D)]
Robert R. McLeod, University of Colorado
126
Download