EE421/621 Digital Circuits
EE421/621 Digital Circuits
1
EE421/621
Lecture #4 Overview
2
EE421/621
SYSTEM
MODULE
+
Boolean Logic
GATE
CIRCUIT
and Gate Network
DEVICE
G
S D
n+ n+
3
EE421/621
Boolean Algebra
4
EE421/621
Boolean Algebra (cont)
Two- and Three- Variable Properties
5
EE421/621
Boolean Algebra (cont)
6
EE421/621
Do Boolean Algebra to Learn
Boolean Algebra (cont)
Prove:
7
EE421/621
Do Boolean Algebra to Learn
Boolean Algebra
Prove:
8
EE421/621
Boolean Algebra (cont)
x y x y
x y
x x x x x y
z
z z
(a) x (d) x y
Verification of the
distributive property
x y x y x (y + z) = x y + x z
z z
(b) y + z (e) x z
x y x y
z z
(c) x ( y + z) (f) x y + x z
10
EE421/621
x y x y
z z
x y xy
x y x y
z z
xz xz
x y x y x y
z z z
yz x y + x z+ y z x y+ x z
11
EE421/621
Basic Gates for Boolean Algebra
x1
(a) AND gates x2
x1
x1 x2 x1 x2 xn
x2
xn
(b) OR gates
x1
x2
x1
x1 + x2 x1 + x2 + + xn
x2
xn
x x
12
EE421/621
Basic Gates for Boolean Algebra (cont)
1 1 0 0
x1 0 0 1 1
A
1 1 0 1 f
0 0 01 B
0 1 0 1
x2
(a) Network that implements f = x1 + x1 x2
x1 1
0
x x f (x , x )
1 2 1 2 A B x2 1
1 0
0
0 0 1
1
0 1 1 1 0 A
0
1 0 0 0 0 1
1 1 1 B
0 1 0
1
(b) Truth table f
0 Time
(c) Timing diagram
13
EE421/621
Basic Gates for Boolean Algebra (cont)
14
EE421/621
Basic Gates for Boolean Algebra (cont)
Minterm
For a function of n variables, a product term in which each of the n
variables appears once is called a minterm.
The variables may appear in a minterm either in uncomplemented or
complemented form.
For a given row of the truth table, the minterm is formed by including xi if
xi = 1 and by including xi if xi = 0.
SOP (Sum-of-Products)
A logic expression consisting of product ( AND) terms that are summed
(ORed) is said to be of the sum- of-products ( SOP) form.
If each product term is a minterm, then the expression is called a canonical
sum- of- products for the function f .
15
EE421/621
16
EE421/621
Basic Gates for Boolean Algebra (cont)
Maxterm
For a function of n variables, a sum term in which each of the n variables
appears once is called a maxterm.
The variables may appear in a maxterm either in uncomplemented or
complemented form.
For a given row of the truth table, the maxterm is formed by including xi if
xi = 0 and by including xi if xi = 1.
POS (Product-of-Sum)
A logic expression consisting of sum ( OR) terms that are the factors of a
logical product ( AND) is said to be of the product- of- sums ( POS) form.
If each sum term is a maxterm, then the expression is called a canonical
product- of- sums for the given function.
Any function f can be synthesized by finding its canonical product- of-
sums. This involves taking the maxterm for each row in the truth table for
which f = 0 and forming a product of these maxterms.
17
EE421/621
Gate implementation of the function
x1
x2
x3
(a) Sum-of-products realization
x3
x2
x1
X1X2
f
X1X2
f=X1X2+X1X2+X1X2
(a) Canonical sum-of-products
Minimized
x1
f=X1+X1X2 f
x2
xn
x1
x2
x1
x1 + x2 x1 + x2 + + xn
x2
xn
x x
3 3
x x
4 4
x x
5 5
x
x 1 x
1 1
x x x
2 x 2 1
2 x
2
x x = x +x x
3
12 1 2
x
4
x
5
x3 x3
x4 x4
x5 x5
x
x 1 x
1 1
x x x1
2 x 2
2
x2
x +x = x x x3
1 2 1 2
x4
x5
x3
x1
f
x2
x3
MODULE
+
Optimized
GATE
CIRCUIT
Implementation of
DEVICE
Logic Function
G
S D
n+ n+
24
EE421/621
Why to Optimize Implementation of
Logic Function
Optimization means low cost
Fewer gates or transistors
Smaller die area
Less power consumption
Lower costs
26
EE421/621
Karnaugh Map -Two Variables
x1
x2
1
0 1
0 1 0
f = x2 + x1
1 1 1
Example
27
EE421/621
Karnaugh Map -Three Variables
x1 x2 x3
x1 x2
0 0 0 m0 x3
00 01 11 10
0 0 1 m1
0 m0 m2 m6 m4
0 1 0 m2
0 1 1 m3 1 m1 m3 m7 m5
1 0 0 m4
1 0 1 m5 (b) Karnaugh map
1 1 0 m6
1 1 1 m7
00 m0 m4 m 12 m8
01 m1 m5 m 13 m9
x4
11 m3 m7 m 15 m 11
x3
10 m2 m6 m 14 m 10
x2
01 0 0 1 1 01 0 0 1 1
11 1 0 0 1 11 1 1 1 1
10 1 0 0 1 10 1 1 1 1
f 1 = x2 x3 + x1 x3 x4 f 2 = x3 + x1x4
x1 x2 x1x2
x3x4 x3 x4
00 01 11 10 00 01 11 10
00 1 0 0 1 00 1 1 1 0
01 0 0 0 0 01 1 1 1 0
11 1 1 1 0 11 0 0 1 1
10 1 1 0 1 10 0 0 1 1
x1x2
f 3 = x2 x4 + x1x3 + x2x3x4 f 4 = x1 x3 + x1x3 + or
x2x3
31
EE421/621
Strategy for Minimization (cont)
Incompletely Specified Functions
x1x2
x3x4
00 01 11 10
00 0 1 d 0
x2x3
01 0 1 d 0
11 0 0 d 0
10 1 1 d 1 x3x4
SOP implementation
MODULE
+
Number
GATE
CIRCUIT
Representation &
DEVICE
Arithmetic
G
S D
n+ n+
33
EE421/621
Number Representations &
Arithmetic in Digital Systems
Unsigned Integers
radix
Decimal (117)10=1×102+1×101+7×100
Binary (117)10=(1110101)2=1×26+1×25+1×24+0×23+1×22+0×21+1×20
Octal (117)10=(165)8=1×82+6×81+5×80
Hexadecimal (117)10=(75)16=7×161+5×160
34
EE421/621
Number Representations &
Arithmetic in Digital Systems
Unsigned Integers
Binary (117)10=(1110101)2=1×26+1×25+1×24+0×23+1×22+0×21+1×20
Octal (117)10=(165)8=1×82+6×81+5×80
Hexadecimal (117)10=(75)16=7×161+5×160
1 1 1 0 1 01
1 1 1 0 101
1 6 5
1 1 1 0 1 01
7 5
35
EE421/621
Number Representations &
Arithmetic in Digital Systems
36
EE421/621 Numbers in different systems
Carry Sum
x 0 0 1 1 x y c s
+y +0 +1 +0 +1
Number Representations & c s 0 0 0 1 0 1 1 0
0
0
0
1
0
0
0
1
x
cc ss 000 0 0 01 1 0 10 1 1 0 1 0 s
0 0 0 y 0
x
0 1 0 1
Carry
Carry Sum
Sum y
1 0 0 1
c
1 1 1 0
(a) The
(a) The four
fourpossible
possiblecases
cases
Carry Sum
Half-adder
(b) Truth table (c) Circuit (d) G
Carry Sum
x y c s
x y c s
x
0 0 0 0 s
0 0 0 y 0
0 1 0 1 x s
01 1
0 0
0 1
1 HA
y c
11 10 10 0 1 c
1 1 1 0
(b) Truth table (c) Circuit (d) Graphical symbol
(b) Truth table
x 37
EE421/621 s
x y x
Number Representations &
Arithmetic in Digital Systems
Addition of unsigned Integers
X = x4 x3 x2 x1 x0 01111 ( 15 ) 10
+ Y = y4 y3 y2 y1 y0 01010 ( 10 ) 10
(11001)2=1×24+1×23+0×22+0×21+1×20=(16+8+1)10=(25)10
An example of addition.
38
EE421/621
Number Representations &
Arithmetic in Digital Systems
Addition of unsigned Integers x i yi
ci 00 01 11 10
ci x i yi ci + 1 si 0 1 1
0 0 0 0 0 1 1 1
0 0 1 0 1
0 1 0 0 1 si = xi yi ci
0 1 1 1 0
1 0 0 0 1 x i yi
1 0 1 1 0 ci
1 1 0 1 0 00 01 11 10
1 1 1 1 1 0 1
Full-adder
ci +1
39
EE421/621
(c) Circuit
Number Representations &
Arithmetic in Digital Systems
A decomposed implementation of the full-adder circuit
ci s si
s HA c
xi
HA c ci + 1
yi
ci
si
xi
yi
ci + 1
c1
cn FA cn ” 1 c2 FA FA c0
sn– 1 s1 s0
MSB position LSB position
x8 x1 x0 y8 y7 y0
c8
s8 s0
41
EE421/621
Number Representations &
Arithmetic in Digital Systems
Examples A : a7 a0
P=3A
x7 x0 y7 y0
c7
s7 s0
x8 x7 x0 y8 y7 y0
c8
s8 s0
P = 3 A : P9 P8 P0
P=3A
0 0
x8 x1 x0 y8 y7 y0
c8
s8 s0
? P=4A P = 3 A : P9 P8 P0
43
EE421/621
Number Representations &
Arithmetic in Digital Systems
bn – 1 b1 b0
Signed Integers
sign- and- magnitude
+5 0101
Magnitude
bn – 1 bn – 2 b1 b0
+5 0101
-5 1101 Magnitude
Sign
0 denotes +
0 0010 1 denotes – MSB
2n-1=15 28-1=255
15-2=13 1101 255-2=253 11111101
Consider it as
unsigned integer 45
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e
•1’s complement
•2’s complement
An efficient way to get 1’s complement of a negative number:
(– 2) (– 2)
2n-1=15 28-1=255
15-2=13 1101 255-2=253 11111101
(2) 0010 (2) 00000010
1’scomplement
Examples of 1’s complement addition
47
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers (positive number) 2’s complement =itself
•s i g n - a n d - m a g n i t u d e
•1’s complement
•2’s complement
In the 2’s complement scheme, a negative number, K, is
obtained by subtracting its equivalent positive number, P,
from 2n; namely, K = 2n - P.
n=4 n=8
(– 2) (– 2)
24=16 28=256
16-2=14 1110 256-2=254 11111110
Consider it as
unsigned integer 48
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e
•1’s complement
•2’s complement
An efficient way to get 2’s complement of a negative number:
(– 2) (– 2)
24=16 28=256
16-2=14 1110 256-2=254 11111110
(2) 0010 (2) 00000010
(-12) (-12)
24=16 28=256
16-12=4 0100 256-12=244 1 1 1 1 0 1 0 0
(12) 1100 (12) 00001100
2n-1-1
(1X…X)2’s complement=1×2n-1+X×2n-2+…+X×21+X×20
K=-{2n-{1×2n-1+X×2n-2+…+X×21+X×20 }}=-1×2n-1+X×2n-2+…+X×21+X×20
-1×2n-1+1×2n-2+…+1×21+1×20
-2n-1 51
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e
•1’s complement
•2’s complement
An efficient way to get 2’s complement of a negative number:
(-12) (-12)
25=32
24=16 10100 28=256
32-12=20
16-12=4 0100 256-12=244 1 1 1 1 0 1 0 0
(12) 0 1 1 0 01 1 0 0 (12) 00001100
10011
Complementing 0011 11110011
Adding 1 1 1
1 0 1 0 00 1 0 0 11110100 52
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e In the 2’s complement scheme, a
•1’s complement negative number, K, is obtained by
•2’s complement subtracting its equivalent positive
number, P, from 2n; namely, K = 2n - P.
(1X…X)2’s complement=1×2n-1+X×2n-2+…+X×21+X×20
K=-{2n-{1×2n-1+X×2n-2+…+X×21+X×20 }}=-1×2n-1+X×2n-2+…+X×21+X×20
-(0X…X)=-{0×2n-1+X×2n-2+…+X×21+X×20 }
=-1×2n-1 +1×2n-1-{0×2n-1+X×2n-2+…+X×21+X×20 }
=-1×2n-1 + {1×2n-2+…+1×21+1×20 }+1 -{0×2n-1+X×2n-2+
{1×2n-2+…+1×21+1×20 }=2n-1-1
…+X×21+X×20 }
={-1×2n-1+(1-X)×2n-2+…+(1-X)×21+(1-X)×20 }+1
53
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e In the 2’s complement scheme, a
•1’s complement negative number, K, is obtained by
•2’s complement subtracting its equivalent positive
number, P, from 2n; namely, K = 2n - P.
(1X…X)2’s complement=1×2n-1+X×2n-2+…+X×21+X×20
K=-{2n-{1×2n-1+X×2n-2+…+X×21+X×20 }}=-1×2n-1+X×2n-2+…+X×21+X×20
-(1X…X)2’s complement=-{1×2n-1+X×2n-2+…+X×21+X×20 }
-K={2n-{1×2n-1+X×2n-2+…+X×21+X×20 }}=-{-1×2n-1+X×2n-2+…+X×21+X×20 }
=1×2n-1-X×2n-2-…-X×21-X×20 }
= {1×2n-2+…+1×21+1×20 }+1-X×2n-2-…-X×21-X×20 }
{1×2n-2+…+1×21+1×20 }=2n-1-1 = {0×2n-1 + (1-X)×2n-2+…(1-X)×21+(1-X)×20 } }+1
(0X…X)2’s complement={0×2n-1+X×2n-2+…+X×21+X×20 } 54
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•s i g n - a n d - m a g n i t u d e
•1’s complement
•2’s complement ( + 5) 0101 (–5) 1011
+ ( + 2) + 0010 + ( + 2) + 0010
( + 7) 0111 (–3) 1101
2’scomplement 2’scomplement
ignore ignore
Examples of 2’s complement addition
55
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers ( + 21) 010101
+ ( –2) + 1110
•s i g n - a n d - m a g n i t u d e
•1’s complement ( + 19 )
•2’s complement
( + 21) 010101
+ ( –2) + 001110 ?
Sign: Auto extension ( + 19 ) 100011
in addition
( + 21) 010101
(010011)2’s complement= + ( –2) + 111110 ?
0×25+1×24+0×23+0×22+1×21+1×20 ( + 19 ) 1010011
=19
ignore
Examples of 2’s complement addition 56
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers ( + 21) 010101
+ ( +2) + 0010
•s i g n - a n d - m a g n i t u d e
•1’s complement ( + 23 )
•2’s complement
( + 21) 010101
+ ( +2) + 000010 ?
Sign: Auto extension ( + 23 ) 010111
in addition
( + 21) 010101
(010111)2’s complement= + ( +2) + 110010 ?
0×25+1×24+0×23+1×22+1×21+1×20 ( + 23 ) 1000111
=23
ignore
Examples of 2’s complement addition 57
EE421/621
Number Representations &
Arithmetic in Digital Systems
( + 5) 0101 0101
Signed Integers – ( + 2) – 0010 + 1110
•s i g n - a n d - m a g n i t u d e ( + 3) 10011
•1’s complement
•2’s complement
ignore
( –5 ) 1011 1011
– + 2)
( – 0010 + 1110
( –7 ) 11001
ignore
( + 5) 0101 0101
– ( –2) – 1110 + 0010
( + 7) 0111
( –5 ) 1011 1011
– ( –2) – 1110 + 0010
( –3 ) 1101
xn– 1 x1 x0
cn n-bit adder c0
sn– 1 s1 s0
Adder/subtractor unit 59
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•2’s complement
Overflow
•If n bits are used to represent signed numbers, then the result must be in
the range – 2n- 1 to 2n- 1 - 1.
•If the result does not fit in this range, then we say that arithmetic overflow
has occurred.
60
EE421/621
Number Representations &
Arithmetic in Digital Systems
Signed Integers In the following additions, which operation is out of range?
•2’s complement (n=4)
EE421/621
Examples of determination of overflow 61
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•2’s complement
EE421/621
Multiplication of signed numbers 62
Number Representations &
Arithmetic in Digital Systems
Signed Integers
•2’s complement
Multiplicand M (– 14) 10010
Multiplier Q (+11) 01011
Partial product 0 1 11 0 0 1 0
+ 11 0 0 1 0
Partial product 1 11 0 1 0 1 1
+ 00 0 0 0 0
Partial product 2 11 1 0 1 0 1
+ 11 0 0 1 0
Partial product 3 11 0 1 1 0 0
+ 00 0 0 0 0
Product P (–154) 1101100110
EE421/621
Multiplication of signed numbers 63
Number Representations &
Arithmetic in Digital Systems
Fixed-Point Format
A fixed- point number consists of integer and fraction parts.
Logic circuits that deal with fixed- point numbers are
essentially the same as those used for integers.
EE421/621
Number Representations &
Arithmetic in Digital Systems
Conversion of fractions
from decimal to binary
65
EE421/621
EE421/621
Number Representations &
Arithmetic in Digital Systems
BCD Code - Addition
X 0111 7
+ Y +0 1 0 1 +5
Z 1100 12
+0 1 1 0
carry 10010
S=2
X 1000 8
+ Y +1 0 0 1 +9
Z 10001 17
+0 1 1 0
Binary-coded decimal digits carry 10111
S=7 67
EE421/621
Number Representations &
Arithmetic in Digital Systems
X Y
BCD Code - Addition
c in
4-bit adder
carry-out
Detect if
sum 9>
6 0
68
EE421/621 S
Number Representations &
Arithmetic in Digital Systems
BCD Code - Subtraction
X 0111 7
- Y -0101 - 5
Z 0010 2
S=2
X 01000 8
- Y + 1 0 1 1 1 - 9
Z 11111 -1
- 00001
Other approaches??
EE421/621
Number Representations &
Arithmetic in Digital Systems
ASCII Code
70
EE421/621
Summary
Boolean Logic and Gate Network
Optimized Implementation of Logic Function
Number Representation & Arithmetic
EE421/621