Digital DesignFloating-Point Number-0 CS3104: 數位系統導論 Principles of Digital Design [project2] floating-point number addition 吳中浩 教授 助教 高鵬程 國立清華大學資訊工程學系.

Slides:



Advertisements
Similar presentations
Lecture 11 Oct 12 Circuits for floating-point operations addition multiplication division (only sketchy)
Advertisements

Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Topics covered: Floating point arithmetic CSE243: Introduction to Computer Architecture and Hardware/Software Interface.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Datorteknik FloatingPoint bild 1 Floating point Number system corresponding to the decimal notation 1,837 * 10 significand exponent a great number of corresponding.
Floating Point Numbers
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Booth’s Algorithm.
Number Systems Standard positional representation of numbers:
CSE 378 Floating-point1 How to represent real numbers In decimal scientific notation –sign –fraction –base (i.e., 10) to some power Most of the time, usual.
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
ECEN 248 Integer Multiplication, Number Format Adopted from Copyright 2002 David H. Albonesi and the University of Rochester.
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Computer Architecture ALU Design : Division and Floating Point
Computing Systems Basic arithmetic for computers.
ECE232: Hardware Organization and Design
Floating Point. Agenda  History  Basic Terms  General representation of floating point  Constructing a simple floating point representation  Floating.
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
9.4 FLOATING-POINT REPRESENTATION
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Spring 2006 University of Ilam.
ECEG-3202: Computer Architecture and Organization, Dept of ECE, AAU 1 Floating-Point Arithmetic Operations.
Computer Arithmetic II Instructor: Mozafar Bag-Mohammadi Ilam University.
Floating Point Arithmetic
1 Number Systems Lecture 10 Digital Design and Computer Architecture Harris & Harris Morgan Kaufmann / Elsevier, 2007.
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Computer Arithmetic Floating Point. We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large.
Computer Engineering FloatingPoint page 1 Floating Point Number system corresponding to the decimal notation 1,837 * 10 significand exponent A great number.
Floating Point Numbers Representation, Operations, and Accuracy CS223 Digital Design.
Dr Mohamed Menacer College of Computer Science and Engineering Taibah University CE-321: Computer.
CS 232: Computer Architecture II Prof. Laxmikant (Sanjay) Kale Floating point arithmetic.
Cosc 2150: Computer Organization Chapter 9, Part 3 Floating point numbers.
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Floating Point Number system corresponding to the decimal notation
CS 232: Computer Architecture II
CS/COE0447 Computer Organization & Assembly Language
William Stallings Computer Organization and Architecture 7th Edition
ECE/CS 552: Floating Point
CSCE 350 Computer Architecture
CSCI206 - Computer Organization & Programming
How to represent real numbers
ECEG-3202 Computer Architecture and Organization
Computer Architecture
Chapter 8 Computer Arithmetic
CS 286 Computer Architecture & Organization
Numbers with fractions Could be done in pure binary
Presentation transcript:

Digital DesignFloating-Point Number-0 CS3104: 數位系統導論 Principles of Digital Design [project2] floating-point number addition 吳中浩 教授 助教 高鵬程 國立清華大學資訊工程學系 八十七學年度第一學期

Digital DesignFloating-Point Number-1 Scientific Notation 6.02 x x exponent radix (base) Mantissa decimal point Sign, magnitude IEEE F.P. (SP):  1.M x 2 e oIssues: m Arithmetic (+, -, *, / ) m Representation, Normal form m Range and Precision m Rounding m Exceptions (e.g., divide by zero, overflow, underflow) m Errors m Properties ( negation, inversion, if A = B then A - B = 0 )

Digital DesignFloating-Point Number-2 Floating-Point Representation Representation of floating point numbers in IEEE 754 standard: single precision 1823 sign exponent: excess 127 binary integer mantissa: sign + magnitude, normalized binary significand w/ hidden integer bit: 1.M actual exponent is e = E SE M N = (-1) 2 (1.M) S E < E < 255 Magnitude of numbers that can be represented is in the range: (1.0) to2 127 ( ) which is approximately: 1.8 x to3.40 x (integer comparison valid on IEEE Fl.Pt. numbers of same sign!)

Digital DesignFloating-Point Number-3 oExamples: Floating-Point Representation = -0.11x2**0 = -1.1x2**(-1) = … i.e. (-1) x ( ) x (2 ) 0 = =

Digital DesignFloating-Point Number-4 Floating-Point Addition oBasic addition algorithm: Illustrate: ten x ten x 10 Assume that 4 decimal digits of the significand and two decimal digits of the exponent. STEP 1: compute Ye - Xe (getting ready to align binary point) STEP 2: right shift the smaller number, e.g., Xm, that many positions to form Xm 2 EX: ten x 10 = ten x 10 = ten x 10 If we can represent only four decimal digits, so the number is really: ten x 10 SETP 3: compute Xm 2 + Ym EX: ten ten ten The sum is ten x 10 Xe-Ye

Digital DesignFloating-Point Number-5 Floating-Point Addition oBasic addition algorithm (continue) : if representation demands normalization, then normalize: STEP 4: left shift result, decrement result exponent (e.g.,0.001xx) right shift result, increment result exponent (e.g., 101.1xx) EX: we pick up the normalized form: ten x 10 = ten x 10 NOTE: check overflow or underflow during the shift STEP 5: round the mantissa continue until MSB of data is 1 (NOTE: Hidden bit in IEEE Standard) EX: we must round the number : ten x10 = x

Digital DesignFloating-Point Number-6 Extra Bits for Accuracy oExtra bits during intermediate calculations to help rounding, to get closer to actual number m Two extra bits on the right in IEEE 754: guard and round m E.g., base = 10 precision = 3 bit m Guard bits: digits to the right of mantissa to guard against loss of digits => can later be shifted left into mantissa during normalization (especially when the two numbers are very close, or when multiplication) m Round bits: after the guards being shifted into mantissa, the result can be rounded according to the round bits m Sticky bit: additional bit to the right of the round digit to better fine tune rounding = * 10 = * 10 = * 10 2-bias - d0. d1 d2 d3... dp X... X X X S X X S + Sticky bit: set to 1 if any 1 bits fall off the end of the round digit

Digital DesignFloating-Point Number-7 oAlways round up (toward +  ) oAlways round down (toward -  ) oTruncate oRound-to-nearest-even Four Rounding Modes x Round-to- nearest-even(x)

Digital DesignFloating-Point Number-8 Example with G, R, and S bits sign exponent mantissa GRS A (131) B (127) B aligned (131) A-B (131) Postnormalization (131) RS Rounding (131) Result (131) Note1: The original G bit can serve an R bit, and the original R and S bits must be ORed in order to generate a new sticky bit. Note2: If the Boolean expression RS + R S’L = R (S + L) where L is LSB of the resultant significand equals 1, we must round up.

Digital DesignFloating-Point Number-9 Flow of Floating-Point Addition Start 1. Compare the exponents of the two numbers. Shift the smaller number to right until its exponent would match the larger exponent. 2. Add the significands 3. Normalize the sum, either shifting right and incrementing the exponent or shifting left and decrementing the exponent. 4. Round the significand to the appropriate number of bits Done Overflow or Underflow? Exception Yes No Still normalized? Yes No

Digital DesignFloating-Point Number-10 Architecture Example Sign Exponent Significand Small ALU Big ALU 0 1 Exponent difference 0 1 Increment or Decrement Shift left or right Sign Exponent Significand Rounding Hardware Control Shift right

Digital DesignFloating-Point Number-11 Schedule and score rules oSchedule: Project 2-1 (deadline on 11/30): Step1 and 2 Project 2-2 (deadline on 12/21): Step3 (Post-normalization) Project 2-3 (deadline on 01/11): Step4 (Rounding) oScore rules: (1). Completeness. (2). Modulize. (3). Architecture.