Documente Academic
Documente Profesional
Documente Cultură
Course Leaders
Chaitra S., Naveeta, Gp Capt N Rath VSM
1
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Objectives
• At the end of these lectures, students will be able to
– Describe the process of performing basic mathematical
operations on signed and unsigned numbers
2
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Contents
• Addition and Subtraction of Signed Numbers
– Full Adder
– Ripple Carry Adder
– N-bit Ripple Carry Adder
3
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Contents
• Addition and Subtraction of Signed Numbers
– Full Adder
– Ripple Carry Adder
– N-bit Ripple Carry Adder
4
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition and Subtraction of Signed Numbers
• Consider the addition of two binary numbers X and Y
5
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition and Subtraction of Signed Numbers
• The generic expression to arrive at the sum and carry
for each bit is given by
6
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition and Subtraction of Signed Numbers
• For example, the addition of the 4 bit unsigned
numbers, 7 and 6 is shown below
7
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Half Adder
8
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Half Adder
9
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Half Adder (Continues…)
10
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Half Adder (Continues…)
11
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Half Adder (Continues…): CD4011
(QUAD 2 Input Nand Gate)
12
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Full Adder
13
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Full Adder: Truth Table
14
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Full Adder: Another Implementation
• The logic expressions for sum and carry out can be implemented
with a 3 input XOR gate and an AND-OR circuit respectively
15
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Ripple Carry Adder
• A cascaded connection of n full-adder blocks can be used
to add two n-bit numbers
16
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
n Bit Ripple Carry Adder: k n bit FA
• The carry-in into the LSB position provides a
convenient means of adding 1 to a number
17
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition/Subtraction: Overflow
• Arithmetic overflow occurs when the signs of the two
operands are the same, but the sign of the result is
different
Overflow = xn−1yn−1sn−1 + xn−1yn−1s_n−1
18
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition/Subtraction: 2’s Compliment
• Recall that the difference between calculating X + Y and X – Y lies
in the two’s complement
X – Y = X + (2’s complement(Y))
Where,
2’s complement (Y) = 1’s Complement (Y) + 1
21
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition/Subtraction Logic Unit
22
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition/Subtraction Logic Unit
0/1
23
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Addition/Subtraction Logic Unit
• This logic can be implemented in the ALU using an
Add/Sub input control line
24
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
n bit Ripple Carry Adder- Timing Issues
25
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
4 bit Ripple Carry Adder- Gate Delays
27
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
4 bit Ripple Carry Adder- Gate Delays
28
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
n bit Ripple Carry Adder- Gate Delays
• Consider a 4 bit Adder
x0 y0 x0 y0 x0 y0 x0 y0
FA FA FA FA c0
c4 c3 c2 c1
s3 s2 s1 s0
• s0 available after 1 gate delays, c1 available after 2 gate delays
31
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
A 4 Bit Carry Look Ahead Adder
• A = An An-1 …. A1 A0
• B = Bn Bn-1 …. B1 B0
• Gn = An.Bn
• Pn = An XOR Bn
• C1 = G0+C0.P0
• C2 = G1+ G0.P1+C0.P0.P1 32
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Multiplication of Unsigned Numbers
33
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Multiplication of Unsigned Numbers
• The product of two, unsigned, n-digit numbers can be accommodated in
2n digits
• The product is computed at the End one bit at a time by adding the bit
columns from right to left and propagating carry values between columns
34
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers
• Instead of adding the parallel products at the end, we
could add them at each stage
35
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers: Processing of 1 bit of m & q
Multiplicand
Multiplier
36
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers: Processing of 1 bit of m & q
Multiplicand
Multiplier
37
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers: Processing of 1 bit of m & q
Multiplicand
Multiplier
38
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers: Processing of 1 bit of m & q
Multiplicand
Multiplier
39
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers
• Multiplicand is shifted by displacing it through an array
of adders
40
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers
• Multiplicand is shifted by displacing it through an array
of adders
Carry Out
41
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Array Multipliers
• Multiplicand is shifted by displacing it through an array
of adders
Carry Out
42
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Disadvantages of Array Multipliers
• Extremely inefficient
45
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
46
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1 Step 1
MX1
47
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1 Add
48
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1 Add
0 1 1 0 1 1 0 1 1
49
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
50
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 0 1 1 0 1 1 0 1 1
51
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
52
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
Step 2
0 1 1 0 1 1 1 0 1
MX1
53
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
54
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
55
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
What Next ?
56
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
Shift Right
57
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
What Next ?
58
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
Add…
59
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Exercise: Seq Mult (13X11)
M
1 1 0 1
C A Q
0 0 0 0 0 1 0 1 1
0 1 1 0 1 1 0 1 1
0 0 1 1 0 1 1 0 1
0 1 1 0 1 1 1 0 1 Add
1 0 0 1 1 1 1 0 1
Add…
60
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Panoramic View: Sequential Cct Multiplier Proc
• 1101 (Dec 13) X 1011 (Dec 11) using Sequential Cct
Multiplier (SCM)
61
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Sequential Circuit Multiplier
62
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Sequential Circuit Multiplier
Depending on q0 = 1 or q0 = 0
63
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Sequential Circuit Multiplier-Steps
• If the LSB q0=1:
– Add the multiplicand to A
– Store carry-out in flip-flop C
• Else if q0 = 0
– Do not add
65
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Multiplication of Signed Numbers
• Consider the case of a positive multiplier and a negative
multiplicand
66
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Andrew Donald Booth’s Algorithm: 1950 London
• The Booth algorithm generates a 2n-bit product and treats
both positive and negative (2’s complement) n-bit
operands uniformly
Step 1: Determine the values of A and S, and the initial value of P. All of
these numbers should have a length equal to (x + y + 1)
– A : Fill the most significant (leftmost) bits with the value of m. Fill the
remaining (y + 1) bits with zeros
– S: Fill the most significant bits with the value of (−m) in two's complement
notation. Fill the remaining (y + 1) bits with zeros
– P: Fill the most significant x bits with zeros. To the right of this, append the
value of r. Fill the least significant (rightmost) bit with a zero.
68
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Booth’s Algorithm: Action based on 2 LSBs of P (Step 2)
• Step 2: If the two least significant (rightmost) bits of P
are:
– 01, find the value of P + A. Ignore any overflow
– 10, find the value of P + S. Ignore any overflow
– 00 & 01 do nothing. Use P directly in the next step
• Step 3: Right Shift P by 1 Bit
• Step 4: Repeat steps 2 and 3 until they have been
done y times
Solution:
m = 0011, -m = 1101, r = 1100
A = 0011 0000 0
S = 1101 0000 0
P = 0000 1100 0
70
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Example
• P = 0000 1100 0(The last two bits are 00)
– P = 0000 0110 0 (Arithmetic right shift)
73
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Restoring Division
• The divisor is positioned appropriately with respect to the
dividend and performs a subtraction
74
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Circuit Arrangement for Restoring Division
75
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Circuit Arrangement for Restoring Division
• An n-bit positive divisor is loaded into register M and an n-bit
positive dividend is loaded into register Q at the start of the
operation
• Register A is set to 0
77
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Example
• Given that dividend = 1000 and divisor = 11, show how
the answer is obtained using the restoring division
algorithm
78
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Try This…
• Given that dividend = 1101 and divisor = 10, show how
the answer is obtained using the restoring division
algorithm
79
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Non Restoring Division
• Consider the sequence of operations that takes place after the
subtraction operation in the preceding algorithm
80
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Algorithm for Non-Restoring Division
Stage 1: Do the following two steps n times:
– If the sign of A is 0, shift A and Q left one bit position and
subtract M from A;
82
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences
Summary
• The logic expressions for sum and carry out can be implemented with a 3 input
XOR gate and an AND-OR circuit respectively
• Arithmetic overflow occurs when the signs of the two operands are the same,
but the sign of the result is different
• The Booth algorithm generates a 2n-bit product and treats both positive and
negative 2’s complement n-bit operands uniformly
83
Faculty of Engineering & Technology © Ramaiah University of Applied Sciences