Multipliers
More complicated than addition accomplished via shifting and addition More time and more area Multiplication What should be the length of the storage for the product? 0010 (multiplicand) x_ 1011 (multiplier) (multiplicand) x_ 1011 (multiplier) 0010 x x x x Shift the multiplicand, and add partial products if multiplier bit equals 1 Let's look at 3 versions based on gradeschool algorithm What if the available adder is only a full adder?
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 Multiplicand is not shifted to the left, the product now is initially stored in the 32 MSBs then shifted to the right every iteration Note: Mcand is added to the left half only of the Prod reg
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
Final Version
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