Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Logical Gates
Keep in mind that computers work on an electrical flow where a high voltage is considered a 1 and a low voltage is considered a 0. Using these highs and lows, data are represented. Electronic circuits must be designed to manipulate these positive and negative pulses into meaningful logic. Logic gates are the building blocks of digital circuits. Combinations of logic gates form circuits designed with specific tasks in mind. For example, logic gates are combined to form circuits to add binary numbers (adders), set and reset bits of memory (flip flops), multiplex multiple inputs, etc.
2
Binary Variables
Recall that the two binary values have different names:
True/False On/Off Yes/No 1/0
Logical Operations
The three basic logical operations are:
AND OR NOT
AND is denoted by a dot (). OR is denoted by a plus (+). NOT is denoted by an overbar ( ), a single quote mark (') after, or (~) before the variable.
AND
x out y
x 0 0 1
y 0 1 0 1
out = xy 0 0 0 1
OR
x y out = x+y
0
0 1 1
0
1 0 1
0
1 1 1
x out y
Output is 1 if at least one input is 1. More than two values can be or-ed together. For example x+y+z = 1 if at least one of the three values is 1.
NOT
x x'
x x'
0
1
1
0
This function operates on a single Boolean value. Its output is the complement of its input. An input of 1 produces an output of 0 and an input of 0 produces an output of 1
NAND
x y out = x NAND y
x out y
0
0 1 1
0
1 0 1
1
1 1 0
NOR
x 0 0 1 1 y 0 1 0 1 out = x NOR y 1 0 0 0
x out y
10
y
x out y
0 0 1
1
amplitude 0 1 0 1
0 1 0
1
0 1 1
0
0 0 1
1 X(t)
0 1 1
General rule: the output is equal to 1 if an odd number of input values are 1 and 0 if an even number of input values are 1.
11
XNOR
x 0 0 1 y 0 1 0 out =x xnor y 1 0 0
x out y
1
amplitude 0 1 0 1
1 X(t)
1 0 0
SUMMARY ON GATES
Inputs A 0 0 1 1 B 0 1 0 1 AND 0 0 0 1 Truth Table Outputs for each Gate NAND 1 1 1 0 OR 0 1 1 1 NOR 1 0 0 0 EX-OR EX-NOR 0 1 1 0 1 0 0 1
Boolean Notation A.B A+B A (A.B) (A+B) (A.B) + (A.B) or AB (A.B) + (AB) or (A B)
13
Truth Tables
Used to evaluate any logic function Consider F(X, Y, Z) = X Y + Y Z
X
0 0 0 0 1 1 1 1
Y
0 0 1 1 0 0 1 1
Z
0 1 0 1 0 1 0 1
XY
0 0 0 0 0 0 1 1
Y
1 1 0 0 1 1 0 0
YZ
0 1 0 0 0 1 0 0
F=XY+YZ
0 1 0 0 0 1 1 1
14
Logic Equation
F = X +Y Z
Logic Diagram
Boolean equations, truth tables and logic diagrams describe the same function! Truth tables are unique, but expressions and logic diagrams are not. This gives flexibility in implementing functions.
15
16
One NAND input pin is connected to the input signal A while all other input pins are connected to logic 1. The output will be A.
17
18
19
One NOR input pin is connected to the input signal A while all other input pins are connected to logic 0. The output will be A.
20
21
22
Boolean Algebra
A useful mathematical system for specifying and transforming logic functions. We study Boolean algebra as a foundation for designing and analyzing digital systems! 1854: Logical algebra was published by George Boole known today as Boolean Algebra Its a convenient way and systematic way of expressing and analyzing the operation of logic circuits. 1938: Claude Shannon was the first to apply Booles work to the analysis and design of logic circuits.
23
Commutative Laws
The commutative law of addition for two variables is written as: A+B = B+A
A B
A+B
B A
B+A
B A
B+A
24
Associative Laws
The associative law of addition for 3 variables is written as:
A+(B+C) = (A+B)+C
A B C B+C A+(B+C)
A
B C
A+B
(A+B)+C
The associative law of multiplication for 3 variables is written as: A(BC) = (AB)C
A B C BC
A(BC)
A
B C
AB
(AB)C
25
Distributive Laws
The distributive law is written for 3 variables as follows:
A(B+C) = AB + AC
B C A B+C X A AB X
B A C
AC
X=A(B+C)
X=AB+AC
26
deMorgans theoreMs
DeMorgans theorems provide mathematical verification of:
the equivalency of the NAND and negative-OR gates
28
deMorgans theoreMs
The complement of two or more ANDed variables is equivalent to the OR of the complements of the individual variables.
NAND
X Y = X + Y
NOR
Negative-OR
The complement of two or more ORed variables is equivalent to the AND of the complements of the individual variables.
Negative-AND
X + Y = X Y
29
CD
B+CD
B
A(B+CD)
31
Boolean Algebra
An algebraic structure defined by a set B = {0, 1}, together with two binary operators (+ and ) and a unary operator ( )
1. 3. 5. 7. 9. 10.
2. 4. 6. 8.
X .1=X X .0=0 X .X = X X .X = 0
XY = YX
(XY) Z = X(Y Z) X + YZ = (X + Y) (X + Z) X .Y = X + Y
DeMorgans
32
The identities appear in dual pairs. When there is only one identity on a line the identity is self-dual, i. e., the dual expression = the original expression.
Sometimes, the dot symbol (AND operator) is not written when the meaning is clear
33
34
1+B=1
Identity element
Useful Theorems
Minimization XY+XY=Y Minimization (dual) (X+Y)(X+Y) = Y
X+Y=XY
0 0 1 1 0 1 0 1 0 0 0 1 0 1 1 1 1 1 0 0 1 0 1 0
XY=X+Y
1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0
Expression Simplification
An application of Boolean algebra Simplify to contain the smallest number of literals (variables that may or may not be complemented)
A B + A C D + A BD + A C D + A BC D
= AB + ABCD + A C D + A C D + A B D = AB + AB(CD) + A C (D + D) + A B D = AB + A C + A B D = B(A + AD) +AC = B (A + D) + A C (has only 5 literals)
40
Complementing Functions
Use DeMorgan's Theorem:
1. Interchange AND and OR operators 2. Complement each constant and literal
F = (x + y + z)(x + y + z)
Example: Complement G = (a + bc)d + e
G = (a (b + c) + d) e
41
Canonical Forms
Minterms and Maxterms
42
Minterms
Minterms are AND terms with every variable present in either true or complemented form. Given that each binary variable may appear normal (e.g., x) or complemented (e.g. x ), there are 2n minterms for n variables. Example: Two variables (X and Y) produce 2 x 2 = 4 combinations:
xy xy xy xy (both normal) (X normal, Y complemented) (X complemented, Y normal) (both complemented)
43
Maxterms
Maxterms are OR terms with every variable in true or complemented form. Given that each binary variable may appear normal (e.g., x) or complemented (e.g., x), there are 2n maxterms for n variables. Example: Two variables (X and Y) produce 2 x 2 = 4 combinations: X + Y (both normal) X + Y (x normal, y complemented) X + Y (x complemented, y normal) X + Y (both complemented)
44
Index
Minterm
Maxterm
0
0 1 1
0
1 0 1
0
1 2 3
m0 = x y
m1 = x y m2 = x y m3 = x y
M0 = x + y
M1 = x + y M2 = x + y M3 = x + y
The minterm mi should evaluate to 1 for each combination of x and y. The maxterm is the complement of the minterm
45
For Maxterms:
0 means the variable is Not Complemented and
1 means the variable is Complemented.
47
Standard Order
All variables should be present in a minterm or maxterm and should be listed in the same order (usually alphabetically) Example: For variables a, b, c:
Maxterms (a + b + c), (a + b + c) are in standard order However, (b + a + c) is NOT in standard order (a + c) does NOT contain all variables Minterms (a b c) and (a b c) are in standard order However, (b a c) is not in standard order (a c) does not contain all variables
48
Sum-Of-Minterm (SOM)
Sum-Of-Minterm (SOM) canonical form: Sum of minterms of entries that evaluate to 1
x
0 0 0 0 1 1 1 1
y
0 0 1 1 0 0 1 1
z
0 1 0 1 0 1 0 1
F
0 1 0 0 0 0 1 1
Minterm
m1 = x y z
m6 = x y z m7 = x y z
F = m1 + m6 + m7 = (1, 6, 7) = x y z + x y z + x y z
49
Sum-Of-Minterm Examples
50
Product-Of-Maxterm (POM)
Product-Of-Maxterm (POM) canonical form: Product of maxterms of entries that evaluate to 0
x
0 0 0 0 1 1 1 1
y
0 0 1 1 0 0 1 1
z
0 1 0 1 0 1 0 1
F
1 1 0 1 0 1 0 1
Maxterm
M2 = (x + y + z)
M4 = (x + y + z)
M6 = (x + y + z)
Product-Of-Maxterm Examples
F(a, b, c, d) = (1, 3, 6, 11)
F(a, b, c, d) = M1 M3 M6 M11
(a+b+c+d)(a+b+c+d) (a+b+c+d)(a+b+c+d)
52
Observations
We can implement any function by "ORing" the minterms corresponding to the 1 entries in the function table. A minterm evaluates to 1 for its corresponding entry. We can implement any function by "ANDing" the maxterms corresponding to 0 entries in the function table. A maxterm evaluates to 0 for its corresponding entry. The same Boolean function can be expressed in two canonical ways: Sum-of-Minterms (SOM) and Product-of-Maxterms (POM). If a Boolean function has fewer 1 entries then the SOM canonical form will contain fewer literals than POM. However, if it has fewer 0 entries then the POM form will have fewer literals than SOM.
53
Consider F = y + x z
x y z
0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1
F
1 1 1 0 1 1 0 0
Minterm
m0 = x y z m1 = x y z m2 = x y z
m4 = x y z m5 = x y z
x y z
0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1
F
1 1 1 0 1 1 0 0
Minterm
F = (3, 6, 7) = M3 M6 M7 =
M3 = (x+y+z)
M6 = (x+y+z) M7 = (x+y+z)
55
x
0 0 0 0 1 1 1 1
y
0 0 1 1 0 0 1 1
z
0 1 0 1 0 1 0 1
F
0 1 1 1 0 1 0 1
Minterm
m1 = x y z m2 = x y z m3 = x y z
Maxterm
M0 = (x + y + z)
M4 = (x + y + z) m5 = x y z M6 = (x + y + z) m7 = x y z
Algebraic Conversion to Sum-of-Minterms Expand all terms first to explicitly list all minterms AND any term missing a variable v with (v + v) Example 1: f = x + x y (2 variables) f = x (y + y) + x y f=xy+xy+xy f = m3 + m2 + m0 = (0, 2, 3) Example 2: g = a + b c (3 variables) g = a (b + b)(c + c) + (a + a) b c g=abc+abc+abc+abc+abc+abc g=abc+abc+abc+abc+abc g = m2 + m4 + m5 + m6 + m7 = (2, 4, 5, 6, 7)
57
Expand all terms first to explicitly list all maxterms OR any term missing a variable v with v v Example 1: f = x + x y (2 variables) Apply 2nd distributive law: f = ( x + x ) ( x + y ) = 1 ( x + y ) = ( x + y ) = M1 Example 2: g = a c + b c + a b (3 variables) g = (a c + b c + a) (a c + b c + b) (distributive) g = (c + b c + a) (a c + c + b) (x + x y = x + y) g = (c + b + a) (a + c + b) (x + x y = x + y) g = (a + b + c) (a + b + c) = M5 . M2 = (2, 5)
58
Function Complements
The complement of a function expressed as a sum of minterms is constructed by selecting the minterms missing in the sum-of-minterms canonical form Alternatively, the complement of a function expressed by a Sum of Minterms form is simply the Product of Maxterms with the same indices Example: Given F(x, y, z) = (1, 3, 5, 7)
59
A Simplification Example:
60
Example
Minimize the following Boolean function using sum of products (SOP): f(a,b,c,d) = m(3,7,11,12,13,14,15)
f(a,b,c,d) = m(3,7,11,12,13,14,15)
=a`b`cd + a`bcd + ab`cd + abc`d`+ abc`d + abcd` + abcd =cd(a`b` + a`b + ab`) + ab(c`d` + c`d + cd` + cd ) =cd(a`[b` + b] + ab`) + ab(c`[d` + d] + c[d` + d]) =cd(a`[1] + ab`) + ab(c`[1] + c[1]) =ab+ab`cd + a`cd =ab+cd(ab` + a`) =ab+ cd(a + a`)(a`+b`) = ab + a`cd + b`cd = ab +cd(a` + b`) 62
Example
f(a,b,c,d) = M(0,1,2,4,5,6,8,9,10) =m(3,7,11,12,13,14,15)
=[(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`)]
63
Karnaugh maps
A graphical technique for simplifying an expression into a minimal sum of products (MSP) form: There are a minimal number of product terms in the expression. Each term has a minimal number of literals. Circuit-wise, this leads to a minimal two-level implementation.
64
65
2-Variable k-MAP
A two-variable function has four possible minterms. We can re-arrange these minterms into a Karnaugh map.
x 0 0 1 1 y 0 1 0 1 minterm xy xy xy xy
Y 0 1 0 xy xy 1 xy xy
Now we can easily see which minterms contain common literals. Minterms on the left and right sides contain y and y respectively. Minterms in the top and bottom rows contain x and x respectively.
Y 0 1 0 xy xy 1 xy xy
X X Y xy xy Y xy xy
66
Both of these minterms appear in the top row of a Karnaugh map, which means that they both contain the literal x.
Both minterms appear in the right side, where y is uncomplemented. Thus, we can reduce xy + xy to just y.
How about xy + xy + xy
X xy xy
Y xy xy
We have xy + xy in the top row, corresponding to x. Theres also xy + xy in the right side, corresponding to y. This whole expression can be reduced to x + y.
68
0 1
0 1
Y X m0 m4 m1 m5 Z m3 m7 m2 m6
69
= = = =
xyz + xyz + xyz + xyz z(xy + xy + xy + xy) z(y(x + x) + y(x + x)) z(y+y) z
f(x,y,z)
71
Unsimplifying expressions
You can also convert the expression to a sum of minterms with Boolean algebra. Apply the distributive law in reverse to add in missing variables. Very few people actually do this, but its occasionally useful.
xy + yz + xz = (xy 1) + (yz 1) + (xz 1) = (xy (z + z)) + (yz (x + x)) + (xz (y + y)) = (xyz + xyz) + (xyz + xyz) + (xyz + xyz) = xyz + xyz + xyz + xyz
In both cases, were actually unsimplifying our example expression. The resulting expression is larger than the original one! But having all the individual minterms makes it easy to combine them together with the K-map.
72
f(x,y,z) = m1 + m5 + m6 + m7
Y X m0 m4 m1 m5 Z m3 m7 m2 m6
0 1
0 1
Y X
Y X 0 0 1 1 Z 0 1 0 1
m0 m4
m1 m5 Z
m3 m7
m2 m6
1 1 1 1
0 0 1 1
0 1 0 1
0 1 1 1
74
Each group corresponds to one product term. For the simplest result: Make as few rectangles as possible, to minimize the number of products in the final expression. Make each rectangle as large as possible, to minimize the number of literals in each term. Its all right for rectangles to overlap, if that makes them larger.
75
For our example, we find that xy + yz + xz = yz + xy. (This is one of the additional algebraic laws from last time.)
76
Practice K-map 1
Simplify the sum of minterms m1 + m3 + m5 + m6.
Y X Z
Y X m0 m4 m1 m5 Z m3 m7 m2 m6
77
78
Four-variable K-maps
We can do four-variable expressions too! The minterms in the third and fourth columns, and in the third and fourth rows, are switched around. Again, this ensures that adjacent squares have common literals.
Y
Y
m0 m4 m12 m8
m1 m5 m13 m9 Z
m3 m7 m15 m11
m2 m6 X m14 m10
Grouping minterms is similar to the three-variable case, but: You can have rectangular groups of 1, 2, 4, 8 or 16 minterms. You can wrap around all four sides.
79
0 0 0 0
1 0 0 1
X
W
m0 m4 m12 m8
m1 m5 m13 m9 Z
m3 m7 m15 m11
m2 m6 m14 m10 Y
Y X 0 0 1 1 Z 0 1 1 1
X 0 0 1 1 Z 0 1
Y 1 1
yz + yz + xy
yz + yz + xz
81
Examples
Two variable K-map f(A,B)=m(0,1,3)=A`B`+A`B+AB
A 0
B 0 1
1 1
0 1
82
A B 1 1
A B` 1 0
1
A`B`C`
1
A`BC
1
AB`C
83
Universal set A BC
Example
BC 00
2
A 11
6 4
AB 10 C
0
A 00
2
01 1
01
6
11
4
10 0
0
1 3
1
7 5
0
1
0
3 7 5
C 1 B (b)
1 AB
C 1
B (c)
Maxterm example
(A+B) (A+B`) (A`+B`) (A`+B) A`B` A`B AB AB` C
C` 0
0
0
C` C
f(A,B,C) = M(1,2,4,6,7)
=(A+B+C`)(A+B`+C)(A`+B+C) )(A`+B`+C) (A`+B`+C`) Note that the complements are (0,3,5) which are the minterms of the previous example
85
86
Example Simplify
f(A,B,C,D) = m(2,3,4,5,7,8,10,13,15)
AB CD
0
A 00
4
AB 10 CD
0
A 00
4
01
12
11
8
01
12
11
8
10 1
00
1 5
1
13 9
1 1
15 11
00
1 5
1
13 9
01
3 7
1 1
2 6
01 D 11
10 3 7
1
15
1
11
11 C 10
1
14
1 C 1
1
2 6
1
14
1
10
10
B (a) AB CD
0
B (b) A AB 10
8
A 00
0 4
00
4
01
12
11
CD 00
1
01
12
11
8
10 1
00
1 5
1
13 9
1 1
15 11
1
5 13 9
01
3 7
1 1
2 6
01 D 11
10 3 7
1
15
1
11
11 C 10
1
14
1 C 1
1
2 6
1
14
1
10
10
B (c)
B (d)
87
AB CD
0
A 00
4
AB 10 CD
0
A 00
4
AB 10 CD
0
A 00
4
01
12
11
8
01
12
11
8
01
12
11
8
10 1
00
1 5
1
13 9
1 1
15 11
00
1 5
1
13 9
1 1
15 11
00
1 5
1
13 9
01
3 7
1 1
2 6
01 D 11
10 3 7
1 1
2 6
01 D 11
10 3 7
1
15
1
11
11 C 10
1
14
1 C 1
1
14
1 C 1
1
2 6
1
14
1
10
10
10
B (a)
B (b)
B (c)
88
A 00
4
AB 10 CD
0
A 00
4
01
12
11
8
01
12
11
8
10 1
9
00
1
1
5 13
1
9
00
1
1
5 13
1 1
01
3 7
1
15 11
01 D 11
10 3 7
15
11
11 C 10
2 6
1
14
1 C 1 1
1
2 6 14
1
10
10
B (a) AB CD
0
B (b) A AB 10
8
A 00
0 4
00
4
01
12
11 1
CD 00
1
01
12
11
8
10 1
9
00
1
1
5 13
1
9
1
5 13
1 1
01
3 7
1
15 11
01 D 11
10 3 7
15
11
11 C 10
2 6
1
14
1 C 1 1
1
2 6 14
1
10
10
B (c)
B (d)
89
Example
90
Example
f(A,B,C,D) = m(1,2,4,6,9)
Step 2 AB CD
0
A 00
4
01
12
11
8
10 Step 1
00
1 5
1
13 9
01
3
1
7 15 11
1 D
11 C 10
2 6 14 10
Step 3
91
S
0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1
T
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
U
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
F3
0 1 0 1 0 1 1 1 0 1 0 0 1 0 1 1
92
Solution:
S
0 0 0 0 1 1
T
0 0 1 1 0 0
U
0 1 0 1 0 1
F3
0 1 0 1 0 1
TU
RS RS
TU
TU
TU
0 0 1 0
1 1 0 1
1 1 1 0
0 1
0
0 1 1 1 1
1
1 0 0 0 0
1
1 0 0 1 1
0
1 0 1 0 1
1
1 0 1 0 0
ST
RS
RSU
RS
1
1 1 1
1
1 1 1
0
0 1 1
0
1 0 1
1
0 1 1
STU
F3 = R S U + S T U + R U + S T
93
Treating a dont care as a (0) means that you do not need to group it.
Treating a dont care as a (1) allows you to make a grouping larger, resulting in a simpler term in the SOP equation.
94
VC 0 0
AB
X 1
This dont care condition was treated as a (1). This allowed the grouping of a single one to become a grouping of two, resulting in a simpler term.
AC
AB
AB
AB
0
X
0
0
There was no advantage in treating this dont care condition as a (1), thus it was treated as a (0) and not grouped.
95
S
0 0 0 0 1 1
T
0 0 1 1 0 0
U
0 1 0 1 0 1
F4
X 0 1 X 0 X
0
0 1 1 1 1
1
1 0 0 0 0
1
1 0 0 1 1
0
1 0 1 0 1
X
1 1 1 1 X
1
1 1 1
1
1 1 1
0
0 1 1
0
1 0 1
X
0 0 0
96
Solution:
S
0 0 0 0 1 1
T
0 0 1 1 0 0
U
0 1 0 1 0 1
F4
X 0 1 X 0 X
TU
RS RS
TU
TU
TU
X 0 X 1
0 X 0 1
X 1 0 X
1 X 0 1
0
0 1 1 1 1
1
1 0 0 0 0
1
1 0 0 1 1
0
1 0 1 0 1
X
1 1 1 1 X
RS
RS
RS
1
1 1 1
1
1 1 1
0
0 1 1
0
1 0 1
X
0 0 0
F4 = R T + R S
97