Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture & Operations I

Similar presentations


Presentation on theme: "Computer Architecture & Operations I"— Presentation transcript:

1 Computer Architecture & Operations I
Instructor: Ryan Florin

2 Sequential Version of Multiplication Algorithm and Hardware
Morgan Kaufmann Publishers Sequential Version of Multiplication Algorithm and Hardware 31 May, 2018 Start with long-multiplication approach multiplicand 1000 × 1001 0000 multiplier product Length of product is the sum of operand lengths Chapter 3 — Arithmetic for Computers

3 Multiplication Hardware
Morgan Kaufmann Publishers 31 May, 2018 Multiplication Hardware First version of Multiplication Hardware 32-bit multiplier 64-bit ALU 64-bit product (initialized to 0) Chapter 3 — Arithmetic for Computers

4 Multiplication Hardware
Morgan Kaufmann Publishers 31 May, 2018 Multiplication Hardware How many steps? 32 Each step has two operations Shift Add Initially 0 Chapter 3 — Arithmetic for Computers

5 Example 2*3

6 Morgan Kaufmann Publishers
31 May, 2018 Refined Multiplier Refined Multiplier 32-bit multiplicand and ALU Multiplier is placed in the right half of the product register 64-bit product register Chapter 3 — Arithmetic for Computers

7 Refined Multiplier (cont)
Morgan Kaufmann Publishers 31 May, 2018 Refined Multiplier (cont) Perform steps in parallel: add/shift One cycle per partial-product addition That’s ok, if frequency of multiplications is low Chapter 3 — Arithmetic for Computers

8 Morgan Kaufmann Publishers
31 May, 2018 Faster Multiplier Uses multiple adders Cost/performance tradeoff Done in 5 steps But needs 31 ALUs Can be pipelined Several multiplication performed in parallel Chapter 3 — Arithmetic for Computers

9 Morgan Kaufmann Publishers
31 May, 2018 MIPS Multiplication Two 32-bit registers for product HI: most-significant 32 bits LO: least-significant 32-bits Instructions mult rs, rt / multu rs, rt 64-bit product in HI/LO mfhi rd / mflo rd Move from HI/LO to rd Can test HI value to see if product overflows 32 bits mul rd, rs, rt Least-significant 32 bits of product –> rd Chapter 3 — Arithmetic for Computers

10 Back to the Example A better way to do 2*3?
3 << 1 using SLL Almost all compilers will perform a strength reduction optimization by replacing multiplication of power of 2 by shifting

11 Morgan Kaufmann Publishers
31 May, 2018 Division Check for 0 divisor Long division approach If divisor ≤ dividend bits 1 bit in quotient, subtract Otherwise 0 bit in quotient, bring down next dividend bit Restoring division Do the subtraction, and if remainder goes < 0, add divisor back Signed division Divide using absolute values Adjust sign of quotient and remainder as required quotient dividend 1001 -1000 1 10 101 1010 divisor remainder n-bit operands yield n-bit quotient and remainder Chapter 3 — Arithmetic for Computers

12 Morgan Kaufmann Publishers
31 May, 2018 Division Hardware First version of Division Hardware 32-bit quotient 64-bit ALU 64-bit remainder Initially divisor in left half Initially dividend Chapter 3 — Arithmetic for Computers

13 First Version Division Hardware
Morgan Kaufmann Publishers 31 May, 2018 First Version Division Hardware Initially divisor in left half Initially dividend Chapter 3 — Arithmetic for Computers

14 Example 7/2

15 Morgan Kaufmann Publishers
31 May, 2018 Optimized Divider One cycle per partial-remainder subtraction Looks a lot like a multiplier! Same hardware can be used for both Chapter 3 — Arithmetic for Computers

16 Morgan Kaufmann Publishers
31 May, 2018 Faster Division Can’t use parallel hardware as in multiplier Subtraction is conditional on sign of remainder Faster dividers (e.g. SRT devision) generate multiple quotient bits per step Still require multiple steps Chapter 3 — Arithmetic for Computers

17 Morgan Kaufmann Publishers
31 May, 2018 MIPS Division Use HI/LO registers for result HI: 32-bit remainder LO: 32-bit quotient Instructions div rs, rt / divu rs, rt No overflow or divide-by-0 checking Software must perform checks if required Use mfhi, mflo to access result Chapter 3 — Arithmetic for Computers

18 Example Revisit A better way to do 7/2?
7>>2 SRL Most compiler will replace divide by power of 2 using right shift operations

19 Summary Multiplication Division First version of multiplication
Optimized multiplication Division

20 What I want you to do Review Chapters 3.3 and 3.4 Review Midterm II


Download ppt "Computer Architecture & Operations I"

Similar presentations


Ads by Google