Multiplication CPSC 252 Computer Organization Ellen Walker, Hiram College.

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.
Division CPSC 321 Computer Architecture Andreas Klappenecker.
Lecture 15: Computer Arithmetic Today’s topic –Division 1.
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.
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
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.
Lecture 9 Sept 28 Chapter 3 Arithmetic for Computers.
Arithmetic IV CPSC 321 Andreas Klappenecker. Any Questions?
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.
Chap 3.3~3.5 Construction an Arithmetic Logic Unit (ALU) Jen-Chang Liu, Spring 2006.
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.
CPSC 321 Computer Architecture ALU Design – Integer Addition, Multiplication & Division Copyright 2002 David H. Albonesi and the University of Rochester.
1 Lecture 4: Arithmetic for Computers (Part 4) CS 447 Jason Bakos.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
Arithmetic for Computers
ECE232: Hardware Organization and Design
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
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
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
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.
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
CDA 3101 Spring 2016 Introduction to Computer Organization
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Multipliers. More complicated than addition accomplished via shifting and addition More time and more area Multiplication What should be the length of.
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.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
Computer System Design Lecture 3
Computer Architecture & Operations I
Multiplication and Division basics
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
CDA 3101 Spring 2016 Introduction to Computer Organization
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
CSCE 350 Computer Architecture
Topic 3c Integer Multiply and Divide
CDA 3101 Summer 2007 Introduction to Computer Organization
Computer Organization and Design
Arithmetic Logical Unit
Computer Arithmetic Multiplication, Floating Point
A.R. Hurson 323 CS Building, Missouri S&T
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Booth's Algorithm for 2's Complement Multiplication
Presentation transcript:

Multiplication CPSC 252 Computer Organization Ellen Walker, Hiram College

Multiplication Multiplication result needs twice as many bits –E.g. 7*7 = 49 (7 is 3 bits, 49 is 6 bits) Multiplication is more complex than addition/subtraction –Develop algorithm, implement using simpler hardware

Multiplication Algorithms Repeated addition –Easy to implement in software –Can only multiply positive numbers directly –Time depends on magnitude of operands Shift-and add –Efficient use of hardware –Time depends only on width of operands –No special case for negative numbers

Shift and Add Algorithm For each bit in multiplier –If bit = 1, add multiplicand to result –Shift multiplicand left by 1 This is the “usual” multiplication algorithm you learned many years ago (but simpler in binary)

Shift and Add example X (included for completeness) ( )

Hardware to Multiply 64-bit register for multiplicand –32 bits for original value –Option to shift left 32 times 64-bit ALU –Add shifted multiplicand to product 32-bit register for multiplier –Shift right after each step (low bits fall off) Control hardware

Multiplication: Implementation Datapath Control

How Long Does it Take? 32 shift/add cycles Each cycle has 3 steps (add, shift left, shift right) Without parallelism, that’s 96 cycles per multiply

Improvements Save hardware by using 1 64-bit register for the product and multiplier –Left part is product (so far) –Right part is unused multiplier –Add a bit to the product and lose a bit from the multiplier each cycle –Shift product right & add instead of shift multiplicand left & add! Shift and add in the same cycle (in parallel) This revision requires only 32 cycles

Final Version What goes here? Multiplier starts in right half of product

Parallel Multiplication Instead of 32 cycles, use 32 adders Each adds 0 or multiplicand Arrange in tree so results cascade properly Result pulls each bit from the appropriate adder

Parallel Multiplication (cont)

x (6 bits) (initial product) Rightmost bit is 1, add multiplicand Shift product right Shift product right Rightmost bit is 1, add multiplicand Shift product right Shift product right Shift product right Shift product right, answer is 105

Negative numbers Convert to positive, multiply, then negate if initial signs were different Or, consider 3 cases: –Both negative: convert to positive and multiply –One negative: make multiplier positive, multiplicand negative –Negative multiplicand: when high bit is 1, shift in 1’s (shift right arithmetic)

MIPS multiplication 2 32-bit registers: Hi and Lo mflo $s0move from lo (to $s0) mfhi $s0move from hi (to $s0) Multiplication Operations mult $s0, $s1{Hi,Lo}= $s0 x $s1 multu $s0, $s1unsigned version