Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.

Similar presentations


Presentation on theme: "1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos."— Presentation transcript:

1 1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos

2 2 Binary Multiplication In multiplication, the first operand is called the multiplicand, and the second is called the multiplier The result is called the product Not counting the sign bits, if we multiply an n-bit multiplicand with a m-bit multiplier, we’ll get a n+m-bit product

3 3 Binary Multiplication Binary multiplication works exactly like decimal multiplication In fact, multiply 100101 by 111001 and pretend you’re using decimal numbers

4 4 First Hardware Design for Multiplier Note that the multiplier is not routed into the ALU

5 5 Second Hardware Design for Multiplier Architects realized that at the least, half of the bits in the multiplicand register were 0 Reduce ALU to 32 bits, shift the product right instead of shifting the multiplicand left In this case, the product is only 32 bits

6 6 Second Hardware Design for Multiplier

7 7 Final Hardware Design for Multiplier Let’s combine the product register with the multiplier register… –Put the multiplier in the right half of the product register and initialize the left half with zeros – when we’re done, the product will be in the right half

8 8 Final Hardware Design for Multiplier

9 9 For the first two designs, we need to convert the multiplicand and the multiplier must be converted to positive –The signs would need to be remembered so the product can be converted to whatever sign it needs to be The third design will deal with signed numbers, as long as the sign bit is extended in the product register

10 10 Booth’s Algorithm Booth’s Algorithm starts with the observation that if we have the ability to both add and subtract, there are multiple ways to compute a product –For every 0 in the multiplier, we shift the multiplicand –For every 1 in the multiplier, we add the multiplicand to the product, then shift the multiplicand

11 11 Booth’s Algorithm Instead, when a 1 is seen in the multiplier, subtract instead of add Shift for all 1’s after this, until the first 0 is seen, then add The method was developed because in Booth’s era, shifters were faster than adders

12 12 Booth’s Algorithm Example: 0010 == 2 x 0110 == 6 0000 == 0shift 0010 == -2(*2 1 ) subtract (first 1) 0000 == 0shift (second 1) 0010 == 2(*2 3 ) (first 0) -4+16=2*6=12


Download ppt "1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos."

Similar presentations


Ads by Google