Multiplication

Tom Kelliher, CS 240

Feb. 27, 2004

Administrivia

Announcements

Exam I in one week, covering all material through Section 4.6.

Assignment

Read 5.1--2.

From Last Time

Carry lookahead addition.

Outline

  1. Paper and pencil multiplication.

  2. Shift and add multipliers.

  3. Booth recoding.

Coming Up

MIPS datapath.

Multiplication

  1. Consider paper and pencil binary unsigned multiplication:
    1. Shift multiplicand left one bit position after each add/hold cycle.

    2. Add/hold depending upon current multiplier bit (examine lsb; shift right).

    3. Example: .

    4. Multiplying two n-bit numbers results in a 2n-bit result.

  2. Naive 32-bit shift-and-multiply hardware:

    How many bits in the datapath?

    Running time?

  3. Observation: Shifting multiplicand left and keeping partial product stationary is equivalent to keeping multiplicand stationary and shifting partial product right.
    1. Bonus 1: only 32-bits are added at any one time.

    2. Bonus 2: the multiplier can be stored in the unused part of the partial product register.

    More sophisticated 32-bit shift-and-multiply hardware:

  4. Optimal running time: O, achieved with tree of carry-save adders with CLA adder at root.

Booth Recoding

  1. We can speed up multiplication by a factor of two by taking two multiplier bits at a time.

    Problem: must be able to form !

  2. Solution:
    1. Adopt a signed digit set: .

    2. The multiply unit's ALU lets us add or subtract.

    3. Observe that a run of 1's:

      can be re-written as

      Why? All runs of 1's are recoded this way.

    4. Advantage of recoding: now multiplicand need only be multiplied by 1, -1, 2, and -2 --- all easy to do with shift and add/subtract.

    5. Example multiply: or . (-29 = 100011). Recoded multiplier?

      Perform in three cycles. Use 8-bit arithmetic and sign-extend.



Thomas P. Kelliher
Wed Feb 25 10:18:49 EST 2004
Tom Kelliher