CDA 3101 Spring 2016 Introduction to Computer Organization

Slides:



Advertisements
Similar presentations
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,
Advertisements

CMPE 325 Computer Architecture II
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 8 - Multiplication.
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
Lecture Objectives: 1)Perform binary division of two numbers. 2)Define dividend, divisor, quotient, and remainder. 3)Explain how division is accomplished.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
Fixed-Point Arithmetics: Part I
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Computer Organization Multiplication and Division Feb 2005 Reading: Portions of these slides are derived from: Textbook figures © 1998 Morgan Kaufmann.
Integer Multiplication and Division
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
Multipliers CPSC 321 Computer Architecture Andreas Klappenecker.
MIPS Architecture Multiply/Divide Functions & Floating Point Chapter 4
1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.
ECE 232 L9.Mult.1 Adapted from Patterson 97 ©UCBCopyright 1998 Morgan Kaufmann Publishers ECE 232 Hardware Organization and Design Lecture 9 Computer Arithmetic.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
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.
Multiplication CPSC 252 Computer Organization Ellen Walker, Hiram College.
Conversion Between Lengths Positive number pack with leading zeros +18 = = Negative numbers pack with leading ones -18 =
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
July 2005Computer Architecture, The Arithmetic/Logic UnitSlide 1 Part III The Arithmetic/Logic Unit.
Lecture 6: Multiply, Shift, and Divide
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Integer Multiplication and Division
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Csci 136 Computer Architecture II – Multiplication and Division
Orange Coast College Business Division Computer Science Department CS 116- Computer Architecture Arithmetic: Part II.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication, Division Arithmetic shift Twice the number of places MIPS multiply unit. mult, multu Significant bits Mfhi, mflo, div, divu Arithmetic.
CMPUT Computer Organization and Architecture I1 CMPUT229 - Fall 2003 Topic6: Logic, Multiply and Divide Operations José Nelson Amaral.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Integer Operations Computer Organization and Assembly Language: Module 5.
Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 © McQuain Multiplication Design 1.0 Multiplicand Shift left.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
William Stallings Computer Organization and Architecture 8th Edition
Computer System Design Lecture 3
More Binary Arithmetic - Multiplication
CDA3101 Recitation Section 5
Computer Architecture & Operations I
Integer Multiplication, Division Arithmetic shift
Computer Architecture & Operations I
Integer Multiplication and Division
MIPS mul/div instructions
Morgan Kaufmann Publishers
CSCI206 - Computer Organization & Programming
Morgan Kaufmann Publishers
Morgan Kaufmann Publishers
Lecture 8: Binary Multiplication & Division
Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
CSCE 350 Computer Architecture
Systems Architecture I
CDA 3101 Summer 2007 Introduction to Computer Organization
Arithmetic Logical Unit
Computer Arithmetic Multiplication, Floating Point
Multiplication More complicated than addition
Computer Architecture EECS 361 Lecture 6: ALU Design
Morgan Kaufmann Publishers Arithmetic for Computers
Arithmetic Logic Unit A.R. Hurson Electrical and Computer Engineering Missouri University of Science & Technology A.R. Hurson.
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

CDA 3101 Spring 2016 Introduction to Computer Organization Multiplication 09 February 2016

Multiplication More complicated than addition Accomplished via shifting and addition Requires more time and chip area 3 versions of pencil-and-paper algorithm 0010 (multiplicand) __x_ 1011 (multiplier) 0010 1 -> copy & shift 0010 1 -> copy & shift 0000 0 -> shift 0010 . 1 -> copy & shift 00010110 Sum Partial Products

First Version (V.1) 0 0 1 0 1 0 1 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 1 0

V.1: Hardware Multiplicand (64 bits) Multiplier (32 bits) 64-bit ALU Shift left Multiplier (32 bits) 64-bit ALU Shift right Multiplier0 Product (64 bits) Control test Write

Second Version (V.2) Product Multiplier0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 0 0 0 0 0 1 0 1 1 0

Final Version (V.3) M u l t i p l i c a n d 3 2 b i t s 3 2 - b i t A L U S h i f t r i g h t C o n t r o l P r o d u c t W r i t e t e s t 6 4 b i t s Product 0 0 0 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1 0 0 0 0 0 1 1 0 1 0 0 1 0 1 1 0 1 0 0 0 1 0 1 1 0

Summary Unsigned multiplication Generate one partial product for each digit in the multiplier Partial product = Total product = sum of (left shifted) partial products The multiplication of two n-bit binary integers results in a product of up to 2n bits in length 0 If multiplier digit = 0 Multiplicand If multiplier digit = 1

General View 1 2 3 4 x 1101 Multiplier (13) Product (143) 1011 Multiplicand (11) x 1101 Multiplier (13) Product (143) Multiplicand M31 . . . M0 C A Q M 0 0000 1101 1011 0 1011 1101 1011 0 0101 1110 1011 0 0010 1111 1011 0 1101 1111 1011 0 0110 1111 1011 0001 1111 1011 0 1000 1111 1011 Initial values Add 32-bit ALU Add Shift 1 2 Shift Shift right Control Add Shift 3 Add Shift C A31 . . . A0 Q31 . . . Q0 4 Multiplier

Signed Arithmetic Signed addition and subtraction Treat operands as unsigned numbers Use the same algorithm/hardware used for the corresponding unsigned operations Unsigned Signed 1 0 0 1 + 0 0 1 1 1 1 0 0 9 3 12 -7 3 -4 Cannot do this for multiplication!

Example Unsigned Signed x 1101 10001111 11 13 143 -5 -3 -113 1011 x 1101 10001111 11 13 143 -5 -3 -113 Partial solution for negative multiplicands 1001 (9) x 0011 (3) 00001001 1001 x 20 00010010 1001 x 21 00011011 (27) 1001 (-7) x 0011 (3) 11111001 (-7) x 20 = (-7) 11110010 (-7) x 21 = (-14) 11101011 (-21) No straightforward solution if multiplier is negative

Negative Multiplier The bits of the multiplier no longer correspond to the partial products Example: (-3) = 1101 The partial products would be generated based on that representation of the multiplier, i.e.: Instead, the partial products should be generated using the following powers of 2: 1: - 1 x 20 0: - 0 x 21 1: - 1 x 22 1: - 1 x 23 - 1 x 20 - 1 x 21

Solution: Booth’s Algorithm  A 0, Q-1 0 M Multiplicand Q Multiplier Count n START = 10 = 01 Q0,Q-1 = 00 = 11 A A - M A A + M Arithmetic shift right: A, Q, Q-1 Count Count - 1 No Yes Count = 0 ? END

Booth’s Hardware Multiplicand M31 . . . M0 Add / Subtract 32-bit ALU Control SRA A31 . . . A0 Q31 . . . Q0 Q-1 Multiplier

Example 7 (0 1 1 1) x 3 (0 0 1 1) A Q Q-1 M 0000 0011 0 0111 1001 0011 0 0111 1100 1001 1 0111 1110 0100 1 0111 0101 0100 1 0111 0010 1010 0 0111 0001 0101 0 0111 Initial values A = A - M Shift 1 2 Shift A = A + M Shift 3 4 Shift

Proof: Positive Multiplier First, consider a simple positive multiplier 0 0 0 1 1 1 1 0 (one block of 1s surrounded by 0s) M x (0 0 0 1 1 1 1 0) = M x (24 + 23 + 22 + 21) = M x (16 + 8 + 4 + 2) = M x 30 Notice: 2n + 2n-1 + . . . + 2n-k = 2n+1 – 2n-k => M x (0 0 0 1 1 1 1 0) = M x (25 - 21) Both’s algorithm conforms to this scheme: Subtracts when beginning of 1 block is found (1-0) Adds when end of the block is encountered (0-1) This scheme extends to any number of 1 blocks 5 4 3 2 1 0

Proof: Negative Multipliers Representation of a negative number (X): { 1 xn-2 xn-3 . . . x1 x0 } X = -2n-1 + xn-2*2n-2 + xn-3*2n-3 . . . x0*20 Assume the leftmost 0 is in the kth position Representation of X = { 1 1 1 … 10 Xk-1 … X0} X = -2n-1 + 2n-2 . . . 2k+1 + xk-1*2k-1 . . . x0*20 -2n-1 + 2n-2 + … + 2k+1 = -2k+1 X = -2k+1 + xk-1*2k-1 . . . x0*20 (1-0) transition occurs and a subtraction takes place

MIPS Multiplication Special purpose registers for the result (Hi, Lo) Two multiply instructions Mult: signed Multu: unsigned mflo, mfhi – move contents from Hi, Lo to general purpose registers (GPRs) No overflow detection in hardware => Software overflow detection Hi must be 0 for multu or the replicated sign of Lo for mult

Conclusions Multiplication => Shift-and-add Unsigned mult = Signed mult Booth’s Algorithm used for signed mult MIPS has special registers (Hi,Lo) and two instructions (mult, multu) Think about: Weekend! 