1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.

Slides:



Advertisements
Similar presentations
Multiplication and Division
Advertisements

Datorteknik IntegerMulDiv bild 1 MIPS mul/div instructions Multiply: mult $2,$3Hi, Lo = $2 x $3;64-bit signed product Multiply unsigned: multu$2,$3Hi,
CMPE 325 Computer Architecture II
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Integer division Pencil and paper binary division (dividend)(divisor) 1000.
THE ARITHMETIC-LOGIC UNIT. BINARY HALF-ADDER BINARY HALF-ADDER condt Half adder InputOutput XYSC
Division CPSC 321 Computer Architecture Andreas Klappenecker.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Binary Addition Rules Adding Binary Numbers = = 1
Integer Multiplication and DivisionICS 233 – KFUPM © Muhamed Mudawar slide 1 Multiplicand and HI are sign-extended  Sign is the sign of the result Signed.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Integer Multiplication and Division
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
CPSC 321 Computer Architecture ALU Design – Integer Addition, Multiplication & Division Copyright 2002 David H. Albonesi and the University of Rochester.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
ECE 4110– Sequential Logic Design
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
Integer Conversion Between Decimal and Binary Bases Conversion of decimal to binary more complicated Task accomplished by –Repeated division of decimal.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
Multiplication of signed-operands
Lecture 6: Multiply, Shift, and Divide
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Integer Multiplication and Division
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Csci 136 Computer Architecture II – Multiplication and Division
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
CDA 3101 Spring 2016 Introduction to Computer Organization
Division Quotient Divisor Dividend – – Remainder.
Integer Operations Computer Organization and Assembly Language: Module 5.
Ch. 4 Computer Arithmetic
Multipliers. More complicated than addition accomplished via shifting and addition More time and more area Multiplication What should be the length of.
Quick Guide to Adding, Subtracting, Multiplying, and Dividing Decimals
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Computer System Design Lecture 3
More Binary Arithmetic - Multiplication
Multiplication and Division basics
Digital Logic & Design Adil Waheed Lecture 02.
Integer Multiplication and Division
MIPS mul/div instructions
CSCI206 - Computer Organization & Programming
Part II : Lecture III By Wannarat.
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers
Lecture 8: Binary Multiplication & Division
Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
Digital Systems Section 14 Registers. Digital Systems Section 14 Registers.
CDA 3101 Spring 2016 Introduction to Computer Organization
Lecture 8: Addition, Multiplication & Division
King Fahd University of Petroleum and Minerals
Lecture 8: Addition, Multiplication & Division
CSCE 350 Computer Architecture
CSCI206 - Computer Organization & Programming
Topic 3c Integer Multiply and Divide
Lecture 5 Multiplication and Division
CDA 3101 Summer 2007 Introduction to Computer Organization
ECE/CS 552: Integer Multipliers
Computer Organization and Design
Multiplication More complicated than addition
مظفر بگ محمدی دانشگاه ایلام
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Binary to Decimal Conversion
October 5 Register to vote! Go to the State Fair! (15-24 October)
Presentation transcript:

1 Lecture 5Multiplication and Division ECE 0142 Computer Organization

2 Multiplication  More complicated than addition –A straightforward implementation will involve shifts and adds  More complex operation can lead to –More area (on silicon) and/or –More time (multiple cycles or longer clock cycle time)  Let ’ s begin from a simple, straightforward method

3 Straightforward Algorithm (multiplicand) (multiplier)x

4 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

5 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

6 Straightforward Algorithm (multiplicand) (multiplier)x

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

9 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

11 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

13 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

15 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

16 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

17 Straightforward Algorithm (multiplicand) (multiplier)x (partial sum)

(partial sum) Straightforward Algorithm (multiplicand) (multiplier)x

(full sum) Straightforward Algorithm (multiplicand) (multiplier)x

20 Implementation 1

21 Example ( Implementation 1 )  Let ’ s do 0010 x 0110 (2 x 6), unsigned Iterati on Implementation 1 StepMultiplierMultiplicandProduct 0 initial values : 0 -> no op : Multiplier shift right/ Multiplicand shift left : 1 -> product = product + multiplicand : Multiplier shift right/ Multiplicand shift left : 1 -> product = product + multiplicand : Multiplier shift right/ Multiplicand shift left : 0 -> no op : Multiplier shift right/ Multiplicand shift left

22 Drawbacks  The ALU is twice as wide as necessary  The multiplicand register takes twice as many bits as needed  The product register won’t need 2n bits till the last step –Being filled  The multiplier register is being emptied during the process

23 Implementation 2 Multiplicand stationary - Multiplier right - PP right

24 Example ( Implementation 2 )  Let ’ s do 0010 x 0110 (2 x 6), unsigned Iteration Implementation 2 StepMultiplierMultiplicandProduct 0 initial values ×××× 1 1: 0 -> no op ×××× 2: Multiplier shift right/ Product shift right × ××× 2 1: 1 -> product = product + multiplicand × ××× 2: Multiplier shift right/ Product shift right ×× ×× 3 1: 1 -> product = product + multiplicand ×× ×× 2: Multiplier shift right/ Product shift right ×x× × 4 1: 0 -> no op ××× × 2: Multiplier shift right/ Product shift right ××××

25 Implementation 3 Multiplier on right half of PP reg Multiplicand stationary - Multiplier right - PP right

26 Example ( Implementation 3 )  Let ’ s do 0010 x 0110 (2 x 6), unsigned Iteration Implementation 3 StepMultiplierMultiplicandProduct|Multiplier 0 initial values : 0 -> no op : Multiplier shift right/ Product shift right × : 1 -> product = product + multiplicand × : Multiplier shift right/ Product shift right ×× : 1 -> product = product + multiplicand ×× : Multiplier shift right/ Product shift right ×× : 0 -> no op ××× : Multiplier shift right/ Product shift right ××××

27 Example (signed)  Note: –Sign extension of partial product subtract –If most significant bit of multiplier is 1, then subtract → + + → + → → → + → → → → + → → →

28 Booth ’ s Encoding  Three symbols to represent numbers: 1, 0, -1  -1 in 8 bits – (two ’ s complement) – (Booth ’ s encoding)  14 in 8 bits – (two ’ s complement) – (Booth ’ s encoding)  Bit transitions show Booth ’ s encoding –0 to 0: 0 –0 to 1: -1 –1 to 1: 0 –1 to 0: 1  Partial results are obtained by –Adding multiplicand –Adding 0 –Subtracting multiplicand

29 Booth ’ s Algorithm Example  Let ’ s do 0010 x 1101 (2 x -3) Iteration Implementation 3 StepMultiplicandProduct 0 initial values > product = product – multiplicand shift right > product = product + multiplicand shift right > product = product – multiplicand shift right > no op shift right

30 Why it works? b × (a 31 a 30 ….a 0 ) = a 0 × b × a 1 × b × … a 31 × b × 2 31 = ( 0 – a 0 ) × b × ( a 0 – a 1 ) × b × … (a 30 – a 31 ) × b × a 31 × b × 2 32  Booth's algorithm performs an addition when it encounters the first digit of a block of ones (0 1) and a subtraction when it encounters the end of the block (1 0). When the ones in a multiplier are grouped into long blocks, Booth's algorithm performs fewer additions and subtractions than the normal multiplication algorithm. ?

31 Why it works?  Works for positive multiplier coz a 31 is 0  What happens for negative multipliers? a 31 is 1 –Remember that we are using 2’s complement binary b × (a 31 a 30 ….a 0 ) = b × (- a 31 × a 30 × ….a 0 ×2 0 ) Same derivation applies

32 Division

33 Integer Division  Dividend = Quotient × Divisor + Remainder  How to do it using paper and pencil? Q ?R ? ÷2 = 3 … 1

34 Implementation 1 64-bit wide 32-bit shift register

35 IterationStepQuotientDivisorRemainder 0 Initial values : Rem=Rem-Div b: Rem +Div, sll Q, Q 0 = : Shift Div right : Rem=Rem-Div b: Rem +Div, sll Q, Q 0 = : Shift Div right : Rem=Rem-Div b: Rem +Div, sll Q, Q 0 = : Shift Div right : Rem=Rem-Div a: Rem≥0=> sll Q, Q 0 = : Shift Div right : Rem=Rem-Div a: Rem≥0=> sll Q, Q 0 = : Shift Div right

36 Implementation 2 1. Place dividend in lower half 2. Do the division 3. Get remainder here 4. Get quotient here