Chapter 2
Chapter 2
DIGITAL SYSTEM I
Lectures:
Tuesday, 14:30 – 16:00 room: CBY-B205
Friday, 16: 00 –17:30 room: CBY-B205
TUTORIAL: Wednesday 11:30 - 13:00 LMX 360
LAB
LAB 1 Tuesday 19:00 - 22:00 CBY B302
LAB 2 Monday 11:30 - 14:30 CBY B302
Professor : Dr. A. Karmouch, office CBY A508
Mid-term exam date: Sunday March 4, 2012
(9:00-10:30)
Chapter 2
Boolean Algebra and Logic Gates
2
Boolean expressions (functions)
• We can use the basic operations to form more
complex expressions:
f(x,y,z) = x y’+ z x’
• Some terminology and notation:
– f is the name of the function.
- Term is an implementation with a gate: in this example f
has two terms x y’ and z x
– ( x,y,z ) are the input variables, each representing 1 or 0.
– A literal is any occurrence of an input variable or its
complement. The function above has four literals: x, y’, z,
and x’.
3
Precedence for Evaluation of Boolean Expression
4
Truth Table
•A truth table shows all possible inputs and outputs of a
function. Each input variable represents either 1 or 0.
•A function with n variables has 2 power n possible
combinations of inputs.
•Inputs are listed in binary order-example, from 000 to 111.
f(x,y,z) = (x + y’)z + x’
x y z f(x,y,z)
0 0 0 1
f(0,0,0) = (0 + 1)0 + 1 =1 0 0 1 1
f(0,0,1) = (0 + 1)1 + 1 =1 0 1 0 1
f(0,1,0) = (0 + 0)0 + 1 =1 0 1 1 1
f(0,1,1) = (0 + 0)1 + 1 =1
1 0 0 0
f(1,0,0) = (1 + 1)0 + 0 =0
f(1,0,1) = (1 + 1)1 + 0 =1 1 0 1 1
f(1,1,0) = (1 + 0)0 + 0 =0 1 1 0 0
f(1,1,1) = (1 + 0)1 + 0 =1 1 1 1 1
5
Boolean Expression and Logic Circuits
• A Boolean expression (function) can be converted into a circuit
by combining basic gates.
• Example:
- The diagram below shows the inputs and outputs of each
gate.
- The precedences are explicit in a circuit.
f(x,y,z) = (x + y’)z + x’
6
Obtaining Boolean Expressions
7
Obtaining Boolean Expressions
•• The Boolean expression (un-simplified) can be obtained
from the truth table:Consider the following arbitrary Truth Table
A B C F1
We can also write the function as:
0 0 0 0 F1 (A,B,C) = A’BC’+ A’BC+ AB’C’+
0 0 1 0 AB’C+ ABC’+ ABC
0 1 0 1 A’BC’
0 1 1 1
A’BC
1 0 0 1 AB’C’
1 0 1 1 AB’C
1 1 0 1 ABC’
1 1 1 1 ABC
8
Obtaining Boolean Expressions
11
Truth table
C D M Q Alarm
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 0
0 1 0 1 0
0 1 1 0 0 Alarm= CD’M’Q’ + CD’MQ’ + CDMQ’
0 1 1 1 0
1 0 0 0 1 Door should not be open
1 0 0 1 0
1 0 1 0 1 room is closed to the public door open + motion
1 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 1 room is closed to the public + door closed motion
1 1 1 1 0
12
Boolean Identities
13
Boolean Identities
1. x+0=x
2. x·1=x
3. x+x =1
4. x·x =0
5. x+x=x Basic to Boolean algebra
6. x·x=x
7. x+1=1
8. x·0=0
9. (x ) = x
10. x+y=y+x Commutative
11. xy = yx Commutative
12. x + (y + z) = (x + y) + z Associative
13. x(yz) = (xy)z Associative
14. x(y + z) = xy + xz Distributive
15. x + yz = (x+y)(x+z) Associative
16. (x + y) = x y’ DeMorgan
17. (xy) = x + y DeMorgan
18. x + xy = x Absorption
19. x(x + y) = x Absorption 14
Verifying Boolean Identities-Examples
Theorem : x+x = x
x y x +y ( x + y) ‘ x ‘ y‘ x ‘ y’
0 0 0 1 1 1 1
0 1 1 0 1 0 0
1 0 1 0 0 1 0
1 1 1 0 0 0 0
16
Verifying Boolean Identities-Examples
• Theorem x + xy = x
17
Simplifying Boolean Expressions
18
Simplifying Boolean Expressions
Function with four variables
• Giving the following function:
F2a (A,B,C,D) = ( AB’ (C + BD) + A’B’ ) C
= ( AB’C + AB’BD + A’B’ ) C
= ( AB’C + A0D + A’B’ ) C
= (AB’C + 0 + A’B’ ) C
= (AB’C + A’B’ ) C
= AB’CC + A’B’C
= AB’C + A’B’C
= (A+A’)B’C
= B’C
F2b (A,B,C,D) = B’C
•AND
•OR These are called “fundamental logic gates” as all other
gates and digital Circuits can be created from these gates.
•NOT
•XOR
•XNOR
20
The NAND & NOR Gates
• We can use a NAND and NOR gates to implement all three of
the basic operations (AND,OR,NOT).
A A B F
F= A.B = A+B
B 0 0 1
0 1 1
1 0 1
1 1 0
22
The NAND Gate
a NAND gate with both of its inputs driven by the same signal is
equivalent to a NOT gate
A
F= A
NOT Gate
a NAND gate whose output is complemented is equivalent to an
AND gate ((AB)’(AB)’)’= (AB)’’+(AB)’’=
(AB)’ AB +AB = AB
A
B F=AB
AND Gate
23
The NAND Gate
F= A+B
B
OR Gate
24
Universality of NAND
25
The NOR Gate
•This is a NOR gate. It is a combination of an OR
gate followed by an inverter.
•like the NAND gate, the NOR gate is functionally
complete any logic function can be implemented
using just NOR gates.
A B F
0 0 1
A
F= A+B 0 1 0
B
1 0 0
1 1 0 26
NOR Gate Equivalence
27
NOR Gates-functionally complete
A
F= A
NOT Gate
A
B F= A+B
OR Gate
A
F= A.B
B
AND Gate
28
Universality of NOR gate
29
The XOR Gate (Exclusive-OR)
31
Standard Forms
33
The standard Sum of Products-Function
• SOP are expressions of the form:
F (A,B,C, …) = ( …) + ( … ) + ( … ) + …
34
The standard Sum of Product-Function
35
The standard Sum of Product-Function
• We Can obtain SOP from truth table (below)
F(A,B,C) = A’BC’ + A’BC + AB’C’ + AB’C + ABC’ + ABC
A simpler notation is to write as
F (A,B,C) = m2 + m3 + m4 + m5 + m6 + m7
= mi (2, 3, 4, 5, 6, 7)
Decimal value A B C F Minterm
0 0 0 0 0 m
0
A’B’C’
1 0 0 1 0 m A’B’C
1
2 0 1 0 1 m A’BC’
2
3 0 1 1 1 m
3 A’BC
4 1 0 0 1 m AB’C’
4
5 1 0 1 1 m
5 AB’C
6 1 1 0 1 m ABC’
6
7 1 1 1 1 m ABC
7
36
Product of Sums: Function
•From truth table we have F(A,B,C) = (A’B’C’ + A’B’C)
•Therefore we obtain F from F:
F (A,B,C) = [F(A,B,C)] = (A’B’C’ + A’B’C)
= (A’ + B’’ + C’’) (A’’ + B’’ + C’) = (A + B + C) (A + B + C’)
Form Compact F = M0 M1 = Mi (0, 1)
Truth Table
Decimal value A B C F Minterm Maxterm Mi = mi
0 0 0 0 0 m0 M0 A+B+C
1 0 0 1 0 m1 M1 A+B+C’
2 0 1 0 1 m2 M2 A+B’+C
3 0 1 1 1 m3 M3 A+B’+C’
4 1 0 0 1 m4 M4 A’+B+C
5 1 0 1 1 m5 M5 A’+B+C’
6 1 1 0 1 m6 M6 A’+B’+C
7 1 1 1 1 m7 M7 A’+B’+C’
37
Obtain SOP and POS from a given expression
• Two-level implementation
• Multi-level implementation
39
Examples
1- Half Adder
2- Full Adder
3- Deriving SOP and POS from a truth table
4- Simplifying SOP & POS using Boolean
identities
40
Half Adder
The half-adder accepts two binary digits on its inputs
and produces two binary digits on its outputs: a sum bit
and a carry bit.
Truth Table
A B C S A S
0 0 0 0 1/2 Adder
B C
0 1 0 1
1 0 0 1 1
1 1 1 0 1
10
C S
41
Half-Adder
A S
1/2 Adder
B C
Truth Table
A B C S
0 0 0 0 Logic Function
0 1 0 1 S = A’B + AB’
1 0 0 1 S=A B
1 1 1 0 C = A.B
A S = A B
B
LOGIC CIRCUIT
C = A.B
42
Full Adder
Logic circuit
Cin = C
Cout = Co C0 = C(A B)+AB
A FULL S
B Adder Co
C 45
Two bit parallel adder
1 0 0
46
Two bit parallel adder
A2 B2 A1 B1 0
A B Cin A B Cin
S3 S2 S1
A2A1
+ B2B1
S3 S2 S1
47
Four bit parallel adder
A4 B4 A3 B3 A2 B2 A1 B1 C0
C4 s4 C3 s3 C2 s2 C1 s1
48
Overflow Examples (review from chapter 1)
• In a 6-bit register
+ 17 = 010001
+ 16 = +010000
=100001 Overflow
• 100001 = 2’s : - (11111) = -(31)10 instead of + (33)10
• Same with a 7-bit register
+ 17 = 0 010001
+ 16 = +0 010000
= 0 100001
0100001 = + 33 No Overflow
49
Four bit parallel adder
0 1 1 0
=0
0 1 1 0
0
50
Four bit parallel adder
0 1 1 0
=1
1 0 0 1
1
51
Four bit parallel adder: more examples
Sign bit 0 1 1 0
0 1 1 0
=0
0 0 1 1 1 1 0 0
0 1 1 0 0
1 1 0 0
0
1 1
Overflow
52
Four bit parallel adder: more examples
Sign bit 0 1 1 0
0 1 1 0
=1
1 0 0 1 0 1 1 0
1 1 1 1 1
0 0 0 0
1
0 1
NO Overflow
53
SOP & POS Standard Forms- Example
From an arbitrary Truth table (next slide)
• Part one
1- obtain SOP representation for F
2- obtain the two level implementation for F without simplification
3- simplify F using Boolean identities
4- obtain two level-implementation for F
5- compare the design obtained in question 4 with the one of
question 2
• Part two
Repeat part one using POS
54
Deriving SOP and POS from a truth table
Consider the following arbitrary Truth Table
i) SOP i A B C F Minterms
ii) POS
0 0 0 0 0
1 0 0 1 0
2 0 1 0 1 m2 = A’BC’
3 0 1 1 1 m3 = A’BC
4 1 0 0 0
5 1 0 1 1 m5 = AB’C
6 1 1 0 0
7 1 1 1 1 m7 = ABC
55
Deriving SOP from a truth table
1- Expression sum of products
a) F = m2 + m3 + m5 + m7
= A’BC’ + A’BC + AB’C + ABC
b) Implementation with logic gates (unsimplified )
A’
B
C'
A’
B F
C
A
B’
C
A
B
C
Two level-Implementation
56
Simplifying SOP using Boolean identities
c) Simplification
Using the Boolean identity absorption xy + xy’= x
We can simplify m2 with m3 and m5 with m7
m2 + m3 = (A’B) C’ + (A’B) C = A’B
m5 + m7 = (AC)B’ + (AC)B = AC
Therefore F = A’B + AC
A’ Two level-Implementation
B
F
A
C
Circuit with 3 gates instead of 5
57
Deriving POS from a truth table
2- Expression Product of sums
i A B C F Maxterms
0 0 0 0 0 M0 = A+B+C
1 0 0 1 0 M1 = A+B+C’
2 0 1 0 1
3 0 1 1 1
4 1 0 0 0 M4 = A’+B+C
5 1 0 1 1
6 1 1 0 0 M6 = A’+B’+C
7 1 1 1 1
58
Deriving SOP from a truth table
a) Function
F = M0 . M1 . M 4 . M6
= (A+B+C) (A+B+C’)(A’+B+C)(A’+B’+C)
Logic circuit
A
B
C
A
B F
C’
A’
B
C
A’
B’
C
Two level-Implementation
59
Simplifying POS using Boolean identities
b) Simplification
Using (X + Y) (X+Y’) = X Verification
X Y Y’ X + Y X + Y’ (X + Y) (X+Y’)
0 0 1 0 1 0
0 1 0 1 0 0
1 0 1 1 1 1
1 1 0 1 1 1
60
Simplifying POS using Boolean identities
C) Two level Implementation
A
B
F
A’
C
61