Professional Documents
Culture Documents
Multipliers and Dividers
Multipliers and Dividers
Sachin Gajjar
sachin.gajjar@nirmauni.ac.in
Reading Material
• Chapter 11 Multipliers and Dividers
• Book - Computer Architecture from Microprocessor to Super
Computer by Behrooz Parahami, Oxford Publications
Use of Multipliers and Dividers
• Multiplication and division are used in:
• Numerical Computation
• Data encryption for privacy/ security
• Image compression methods
• Graphic rendering etc.
• Multipliers and Dividers are essential for most of the processors
Pencil and Paper multiplication
(Partial Product)
(Partial Product)
(Partial Product Shifted and Added)
(Partial Product Shifted and Added)
(Partial Product Shifted and Added)
Shift-Add Multiplication
• Simplest machine multipliers are
designed to follow a variant of
pencil-and-paper multiplication
algorithm Multiplicand x
Multiplier y
• Each row of dots in partial
products bit-matrix is either all 0s y0 x 20
Partial y x 21
(if the corresponding yi = 0) or the products 1
y2 x 22
same as x (if yi = 1) bit-matrix
y3 x 23
• For k x k multiplication manually, Product z
we form all of k partial products
Multiplication of 4-bit numbers in dot notation.
and add the resulting k numbers to
obtain the product p
Shift-Add Multiplication
• For machine execution:
• a cumulative partial product is initialized to z(0) = 0, (Accumulator)
• each row of bit-matrix added to it as the corresponding term (partial product of each stage) is generated,
• result of addition shifted to right by one bit to achieve proper alignment with the next term as machine
adds two numbers at a time
• the recurrence equation describing the process is:
z(j+1) = (z(j) + yj x 2k) 2–1 with z(0) = 0 and z(k) = z
|––– add –––|
|–– shift right ––|
Multiplicand x
Multiplier y
y0 x 20
Partial y x 21
products 1
y2 x 22
bit-matrix
y3 x 23
Product z
Decimal Multiplication – When variant of Pen and Paper method is implemented in machine
Position 7 6 5 4 3 2 1 0 Position 7 6 5 4 3 2 1 0
========================= =========================
x2 4 1 x0 Multiplier
1 0 x104 3 5 2 8 SL by 4
Multiplicand
y 0 0 1 1 y 4 0 6 7
3528 x 4067
========================= =========================
z (0) 0 0 0 0 z (0) 0 0 0 0 Partial Product is initialized to 0
+y 4
x2 x 4 digit
1 0 1 0 +y0x10 4 2 4 6 9 6
4 0digit i.e. 7 x 3528
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (1) 0 1 0 1 0 10z (1) 2 4 6 9 6 z0+y0x104
zResultant product
(1) 0 1 0 1will0 be 8 z (1) 0 2 4 6 9 6 Shift right by 1 (i.e. 10z1/10)
+y 4 +y1x104 2 1 1 6 8
1 x2
digits 1 0 1 0 i.e. 6 x 3528
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (2) 0 1 1 1 1 0 10z (2) 2 3 6 3 7 6
z (2) 0 1 1 1 1 0 z (2) 2 3 6 3 7 6 Shift right by 1 (i.e. 10z2/10)
+y2x2 4 0 0 0 0 +y2x104 0 0 0 0 0 i.e. 0 x 3528
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (3) 0 0 1 1 1 1 0 10z (3) 0 2 3 6 3 7 6
z (3) 0 0 1 1 1 1 0 z (3) 0 2 3 6 3 7 6
+y3x2 4 0 0 0 0 +y3x10 4 1 4 1 1 2
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (4) 0 0 0 1 1 1 1 0 10z (4) 1 4 3 4 8 3 7 6
z (4) 0 0 0 1 1 1 1 0 z (4) 1 4 3 4 8 3 7 6
========================= =========================
(a) Binary (b) Decimal
Binary Multiplication – When variant of Pen and Paper method is implemented in machine
Position 7 6 5 4 3 2 1 0 Position 7 6 5 4 3 2 1 0
========================= =========================
x24 1 0 1 0 SL 4by 4
x10 3 5 2 8
Multiplicand x Multiplier y 0 0 1 1 y 4 0 6 7
1010 x 0011 = 11110 ========================= =========================
z (0) 0 0 0 0 Partial Product is initialized
z (0) to 0 0 0 0 0
10 D x 3 D = 30 D +y0x2 4 1 0 1 0 i.e. 1 x +y 0x10
1010 4 2 4 6 9 6
4 bit x 4 bit –––––––––––––––––––––––––– ––––––––––––––––––––––––––
0+y x24 , extra bit 0 for carry generated through addition
2z (1) 0 1 0 1 0 z 0 10z (1) 2 4 6 9 6
Resultant product will be (1) (1)1/2)
z 0 1 0 1 0 Shift right by 1 (i.e.z2z 0 2 4 6 9 6
8 bits +y1x2 4 1 0 1 0 i.e. 1 x+y 4
1 x10
1010 2 1 1 6 8
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (2) 0 1 1 1 1 0 10z (2) 2 3 6 3 7 6
z (2) 0 1 1 1 1 0 z (2) 2 3 6 3 7 6
+y2x2 4 0 0 0 0 +y2x10 4 0 0 0 0 0
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (3) 0 0 1 1 1 1 0 10z (3) 0 2 3 6 3 7 6
z (3) 0 0 1 1 1 1 0 z (3) 0 2 3 6 3 7 6
+y3x2 4 0 0 0 0 +y3x10 4 1 4 1 1 2
–––––––––––––––––––––––––– ––––––––––––––––––––––––––
2z (4) 0 0 0 1 1 1 1 0 10z (4) 1 4 3 4 8 3 7 6
z (4) 0 0 0 1 1 1 1 0 z (4) 1 4 3 4 8 3 7 6
========================= =========================
Shift – Add Multiplication – the actual implementation
Shift-Add
Operation
Shift-Add Operation for signed numbers
• Signed-magnitude numbers can be multiplied by using the shift-add
algorithm to multiply their magnitudes
• and separately deriving sign of product as XOR of multiplicand and
multiplier sign bits (If they are alike, sign of product is positive else
negative)
Hardware
Implementation
Flowchart
Shift-Add Operation
Shift-Add Operation through programming