Morgan Kaufmann Publishers

Slides:



Advertisements
Similar presentations
The MIPS 32 1)Project 1 Discussion? 1)HW 2 Discussion? 2)We want to get some feel for programming in an assembly language - MIPS 32 We want to fully understand.
Advertisements

Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
Chapter 3 Arithmetic for Computers. Exam 1 CSCE
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
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.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
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.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 4: Arithmetic / Data Transfer Instructions Partially adapted from Computer Organization.
1  2004 Morgan Kaufmann Publishers Chapter Three.
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.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 6: Logic/Shift Instructions Partially adapted from Computer Organization and Design, 4.
MIPS Architecture Multiply/Divide Functions & Floating Point Chapter 4
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
Lecture Objectives: 1)Explain the relationship between addition and subtraction with twos complement numbering systems 2)Explain the concept of numeric.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /14/2013 Lecture 16: Floating Point Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
Lecture 7: Multiplication and Floating Point EEN 312: Processors: Hardware, Software, and Interfacing Department of Electrical and Computer Engineering.
Lec 13Systems Architecture1 Systems Architecture Lecture 13: Integer Multiplication and Division Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan.
Lecture 9: Floating Point
Chapter 3 Arithmetic for Computers (Integers). Florida A & M University - Department of Computer and Information Sciences Arithmetic for Computers Operations.
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.
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Csci 136 Computer Architecture II – Multiplication and Division
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers.
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
COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
William Stallings Computer Organization and Architecture 8th Edition
/ Computer Architecture and Design
Computer System Design Lecture 3
Morgan Kaufmann Publishers Arithmetic for Computers
Computer Architecture & Operations I
ALU Architecture and ISA Extensions
Integer Multiplication, Division Arithmetic shift
Morgan Kaufmann Publishers Arithmetic for Computers
Computer Architecture & Operations I
Morgan Kaufmann Publishers Arithmetic for Computers
Computer Architecture & Operations I
Integer Multiplication and Division
Computer Architecture & Operations I
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers
Lecture 9: Floating Point
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers Arithmetic for Computers
/ Computer Architecture and Design
CS/COE 0447 (term 2181) Jarrett Billingsley
Morgan Kaufmann Publishers
Lecture 8: Binary Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
Arithmetic for Computers
CS352H: Computer Systems Architecture
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
Computer Architecture Computer Science & Engineering
Systems Architecture I
Arithmetic Logical Unit
Computer Arithmetic Multiplication, Floating Point
ECEG-3202 Computer Architecture and Organization
Morgan Kaufmann Publishers Arithmetic for Computers
Number Representation
Floating Point Arithmetic
Presentation transcript:

Morgan Kaufmann Publishers July 31, 2018 3.4: Division Instructor: Robert Utterback Lecture 30 Chapter 1 — Computer Abstractions and Technology

Morgan Kaufmann Publishers 31 July, 2018 Optimized Multiplier Perform steps in parallel: add/shift Multiplier is in the right half of the product register. One cycle per partial-product addition That’s ok, if frequency of multiplications is low Chapter 3 — Arithmetic for Computers — 2 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 31 July, 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 This last is a pseudoinstruction Chapter 3 — Arithmetic for Computers — 3 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 31 July, 2018 Division §3.4 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 subtract, 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 1001010 -1000 10 101 1010 divisor remainder n-bit operands yield n-bit quotient and remainder Chapter 3 — Arithmetic for Computers — 4 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 31 July, 2018 Division Hardware First version of Division Hardware 32-bit quotient 64-bit ALU 64-bit remainder Initially divisor in left half Divisor starts in left half of divisor register, remainder initialized to dividend Initially dividend Chapter 3 — Arithmetic for Computers

First Version Division Hardware Morgan Kaufmann Publishers 31 July, 2018 First Version Division Hardware Initially divisor in left half Example: Fill out a table for 7/2 Table: Iteration, Step (1,2b,3), Quotient, Divisor, Remainder Initially dividend Chapter 3 — Arithmetic for Computers

Example 7/2

Morgan Kaufmann Publishers 31 July, 2018 Optimized Divider One cycle per partial-remainder subtraction Looks a lot like a multiplier! Same hardware can be used for both Remainder in left half, Dividend in right half Chapter 3 — Arithmetic for Computers — 8 Chapter 3 — Arithmetic for Computers

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

Morgan Kaufmann Publishers 31 July, 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 — 10 Chapter 3 — Arithmetic for Computers

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

Summary Multiplication Division First version of multiplication Optimized multiplication Division

Morgan Kaufmann Publishers 31 July, 2018 Floating Point §3.5 Floating Point Representation for non-integral numbers Including very small and very large numbers Like scientific notation –2.34 × 1056 +0.002 × 10–4 +987.02 × 109 In binary ±1.xxxxxxx2 × 2yyyy Types float and double in C normalized not normalized Normalized: >= 1 < 10 Chapter 3 — Arithmetic for Computers — 13 Chapter 3 — Arithmetic for Computers

Floating Point Standard Morgan Kaufmann Publishers 31 July, 2018 Floating Point Standard Defined by IEEE Std 754-1985 Developed in response to divergence of representations Portability issues for scientific code Now almost universally adopted Two representations Single precision (32-bit) Double precision (64-bit) Chapter 3 — Arithmetic for Computers — 14 Chapter 3 — Arithmetic for Computers

IEEE Floating-Point Format Morgan Kaufmann Publishers 31 July, 2018 IEEE Floating-Point Format single: 8 bits double: 11 bits single: 23 bits double: 52 bits S Exponent Fraction 𝑥= (−1) 𝑆 ×(1+Fraction)× 2 Exponent S: sign bit (0  non-negative, 1  negative) Normalize significand: 1.0 ≤ |significand| < 2.0 Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the “1.” restored Not really, though Exponent is slightly more complicated Try an example on Sign: 1 Exponent: 0 0 0 0 0 0 0 1 Fraction: 0 1 0 (0…) Which is -1.25 * 2^1 = -2.5, exception not really Chapter 3 — Arithmetic for Computers — 15 Chapter 3 — Arithmetic for Computers

IEEE Floating-Point Format Morgan Kaufmann Publishers 31 July, 2018 IEEE Floating-Point Format single: 8 bits double: 11 bits single: 23 bits double: 52 bits S Exponent Fraction S: sign bit (0  non-negative, 1  negative) Normalize significand: 1.0 ≤ |significand| < 2.0 Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit) Significand is Fraction with the “1.” restored Exponent: excess representation: actual exponent + Bias Ensures exponent is unsigned Single: Bias = 127; Double: Bias = 1203 See p.200 for the reason behind biasing --- basically, it makes comparison a lot easier, hence sorting can be done efficiently. The bias makes the most negative exponent (which makes a small number) 0…0 and the most positive exponent 1..1 Now let’s do the example of p.202 Now example on p.201 Chapter 3 — Arithmetic for Computers — 16 Chapter 3 — Arithmetic for Computers