Mohamed Younis CMCS 411, Computer Architecture 1 CMSC 411-101 Computer Architecture Lecture 11 Performing Division March 5, 2001 www.csee.umbc.edu/~younis/CMSC411/

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,
Mohamed Younis CMCS 411, Computer Architecture 1 CMCS Computer Architecture Lecture 7 Arithmetic Logic Unit February 19,
CMPE 325 Computer Architecture II
Cosc 2150: Computer Organization Chapter 9, Part 2 Integer multiplication and division.
Prof. John Nestor ECE Department Lafayette College Easton, Pennsylvania ECE Computer Organization Lecture 8 - Multiplication.
Arithmetic Intro Computer Organization 1 Computer Science Dept Va Tech February 2008 © McQuain Algorithm for Integer Division The natural (by-hand)
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.
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, ©
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
Arithmetic IV CPSC 321 Andreas Klappenecker. Any Questions?
1  2004 Morgan Kaufmann Publishers Chapter Three.
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.
1 Lecture 4: Arithmetic for Computers (Part 5) CS 447 Jason Bakos.
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
Computer Architecture ALU Design : Division and Floating Point
ECE232: Hardware Organization and 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.
Multiplication of signed-operands
Lecture 6: Multiply, Shift, and Divide
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.
Cs 152 l6 Multiply 1 DAP Fa 97 © U.C.B. ECE Computer Architecture Lecture Notes Multiply, Shift, Divide Shantanu Dutt Univ. of Illinois at.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
CS61C Finishing the Datapath: Subtract, Multiple, Divide Lecture 21
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
COE 308: Computer Architecture (T032) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
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
Division Quotient Divisor Dividend – – Remainder.
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.
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.
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
Computer Architecture & Operations I
Integer Multiplication and Division
MIPS mul/div instructions
Part II : Lecture III By Wannarat.
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
CSCI206 - Computer Organization & Programming
Topic 3c Integer Multiply and Divide
Computer Organization and Design
ECEG-3202 Computer Architecture and Organization
1 Lecture 5Multiplication and Division ECE 0142 Computer Organization.
Presentation transcript:

Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5, CMSC411.htm

Mohamed Younis CMCS 411, Computer Architecture 2 Lecture’s Overview q Previous Lecture: Algorithms for multiplying unsigned numbers (Evolution of optimization, complexity) Booth’s algorithm for signed number multiplication (Different approach to multiplying, 2-bit based operation selection) Multiple hardware design for integer multiplier (Hardware cost-driven optimization) q This Lecture: Algorithms for dividing unsigned numbers Handling of sign while performing a division Hardware design for integer division

Mohamed Younis CMCS 411, Computer Architecture 3 q Paper and pencil example (unsigned): 1001 Quotient Divisor Dividend – – Remainder (or Modulo result) q See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or 0 * divisor q Dividend = Quotient x Divisor + Remainder  3 versions of divide, successive refinement Dividing Unsigned Numbers * Slide is courtesy of Dave Patterson

Mohamed Younis CMCS 411, Computer Architecture 4 Divide Hardware (version 1) q 64-bit Divisor register, 64-bit ALU, 64-bit Remainder register, and 32-bit Quotient register q The 32-bit value of the Divisor starts in the left half of the 64-bit register q The Divisor is shifted to the right every step to align with the Dividend q The Remainder register is initialized with the value of the Dividend q Control decides when to shift the Divisor and the Quotient registers and when to write new value into the Remainder register * Figure is courtesy of Dave Patterson Remainder Quotient Divisor 64-bit ALU Shift Right Shift Left Write Control 32 bits 64 bits Subtract

Mohamed Younis CMCS 411, Computer Architecture 5 Divide Algorithm Version 1 è If the Remainder is positive, a 1 is generated in the Quotient è A negative Remainder indicates that Divisor did not go into the Dividend è Shifting the Divisor in step 3 aligns the Divisor with the Dividend for next iteration è Repeat for 33 times? (we need a final shift) Dividing two n-bit numbers needs n+1 steps to generate n-bit Quotient and Remainder

Mohamed Younis CMCS 411, Computer Architecture 6 An Example Follow the division algorithm (version 1) to divide 7 by 2 using only 4-bit binary representation

Mohamed Younis CMCS 411, Computer Architecture 7 Divide Hardware (version 2) * Figure is courtesy of Dave Patterson q In the first version of divide hardware, half the bits in Divisor always 0 => 1/2 of 64-bit adder is wasted & 1/2 of divisor is wasted q Uses only 32-bit Divisor register, 32-bit ALU, 64-bit Remainder register, and 32-bit Quotient register q Since the least significant bits of the product would not change, the Remainder could be shifted to the left instead of shifting the Divisor to the right q1st step cannot produce a 1 in quotient bit (otherwise too big) => switch order to shift first and then subtract, can save 1 iteration q The most significant 32-bits would be used by the ALU as a result register Remainder Quotien t Divisor 32-bit ALU Shift Left Write Control 32 bits 64 bits Shift Left Subtrac t

Mohamed Younis CMCS 411, Computer Architecture 8 Divide Algorithm Version 2 Early shifting the remainder register saves one iteration Early shifting the remainder register saves one iteration

Mohamed Younis CMCS 411, Computer Architecture 9 An Example Follow the division algorithm (version 2) to divide 7 by 2 using only 4-bit binary representation

Mohamed Younis CMCS 411, Computer Architecture 10 Divide Hardware Version 3 * Figure is courtesy of Dave Patterson q Remainder register wastes space that exactly matches size of Quotient  combine Quotient register and Remainder register q Uses only 32-bit Divisor register, 32-bit ALU, 64-bit Remainder register, and 0-bit Quotient register q The same number of shift operations would apply to both the Remainder and the Quotient  the Remainder needs to be corrected at the end q The most significant 32-bits are still being used by ALU as a result register Remainder (Quotient) Divisor 32-bit ALU Write Control 32 bits 64 bits Shift Left “HI”“LO” Subtract

Mohamed Younis CMCS 411, Computer Architecture 11 Divide Algorithm Version 3 è Eliminate Quotient register by combining with Remainder and shifted left è Remainder would be shifted an extra time and need to be corrected at the end Dividing 7 by 2

Mohamed Younis CMCS 411, Computer Architecture 12 Dividing Signed Numbers Simplest approach is to remember signs, make positive, and complement quotient and remainder if necessary è Rule 1: Dividend and Remainder must have same sign è Rule 2: Quotient negated if Divisor sign & Dividend sign disagree Examples: Dividend = Quotient  Divisor + Remainder 7 ÷ 2 = 3, remainder = 1 –7 ÷ 2 = –3, remainder = –1 7 ÷ – 2 = –3, remainder = 1 –7 ÷ – 2 = 3, remainder = –1

Mohamed Younis CMCS 411, Computer Architecture 13 Conclusion q Summary è Algorithms for dividing unsigned numbers (Evolution of optimization, complexity) è Handling of sign while performing a division (Remainder sign matches the dividend’s) è Hardware design for integer division (Same hardware as Multiply) q Next Lecture è Representation of floating point numbers è Floating point arithmetic è Floating point hardware Reading assignment includes section 4.7 in the text book