100 likes | 283 Views
Multipliers. Multiplication. More complicated than addition accomplished via shifting and addition More time and more area. Shift the multiplicand, and add partial products if multiplier bit equals 1. Let's look at 3 versions based on gradeschool algorithm. 0010 (multiplicand)
E N D
Multiplication • More complicated than addition • accomplished via shifting and addition • More time and more area Shift the multiplicand, and add partial products if multiplier bit equals 1 Let's look at 3 versions based on gradeschool algorithm 0010 (multiplicand) x_ 1011 (multiplier) 0010 x 1 00100 x 1 001000 x 0 0010000 x 1 00010110 0010 (multiplicand) x_ 1011 (multiplier) 0010 00100 000000 0010000 00010110 What if the available adder is only a full adder? What should be the length of the storage for the product?
Multiplication: Implementation LSB tells the control unit what operation the ALU should do?
Multiplication • If each step took a clock cycle, this algorithm would use almost 100 clock cycles to multiply two 32-bit numbers. • Requires 64-bit wide adder • Multiplicand register 64-bit wide
Variations on a Theme • Product register has to be 64-bit • Can we take advantage of that fact? • Yes! Add multiplicand to 32 MSBs • product = product >> 1 • Repeat last steps • New algorithm needs fewer resources
Second Version Note: Mcand is added to the left half only of the Prod reg Multiplicand is not shifted to the left, the product now is initially stored in the 32 MSBs then shifted to the right every iteration
Critique • Registers needed for • multiplicand • multiplier • Product • Use lower 32 bits of product register: • place multiplier in lower 32 bits • add multiplicand to higher 32 bits • product = product >> 1 • repeat
Multiplying Signed Numbers • If sign(a)!=sign(b) then s = true • a = abs(a) • b = abs(b) • p = a*b /* multiply as before */ • negate p if s = true Algorithm is straightforward but awkward