Computer Architecture & Operations I

Slides:



Advertisements
Similar presentations
Spring 2013 Advising Starts this week! CS2710 Computer Organization1.
Advertisements

Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Chapter Three.
Lecture 11 Oct 12 Circuits for floating-point operations addition multiplication division (only sketchy)
Computer Organization CS224 Fall 2012 Lesson 19. Floating-Point Example  What number is represented by the single-precision float …00 
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
CS/ECE 3330 Computer Architecture Chapter 3 Arithmetic.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
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.
1 Ó1998 Morgan Kaufmann Publishers Chapter 4 計算機算數.
ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 11: Floating Point Partially adapted from Computer Organization and Design, 4 th edition,
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
1 Lecture 10: FP, Performance Metrics Today’s topics:  IEEE 754 representations  FP arithmetic  Evaluating a system Reminder: assignment 4 due in a.
Morgan Kaufmann Publishers
Systems Architecture Lecture 14: Floating Point Arithmetic
Chapter 3 -Arithmetic for Computers Operations on integers – Addition and subtraction – Multiplication and division – Dealing with overflow Floating-point.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
CEN 316 Computer Organization and Design Computer Arithmetic Floating Point Dr. Mansour AL Zuair.
Ellen Spertus MCS 111 October 11, 2001 Floating Point Arithmetic.
ECE232: Hardware Organization and Design
COSC 2021: Computer Organization Instructor: Dr. Amir Asif Department of Computer Science York University Handout # 5 Unsigned integer and floating point.
CPS3340 COMPUTER ARCHITECTURE Fall Semester, /14/2013 Lecture 16: Floating Point Instructor: Ashraf Yaseen DEPARTMENT OF MATH & COMPUTER SCIENCE.
1 ECE369 Sections 3.5, 3.6 and ECE369 Number Systems Fixed Point: Binary point of a real number in a certain position –Can treat real numbers as.
CSF 2009 Arithmetic for Computers Chapter 3. Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing.
Lecture 9: Floating Point
Floating Point Representation for non-integral numbers – Including very small and very large numbers Like scientific notation – –2.34 × –
Lecture 12: Integer Arithmetic and Floating Point CS 2011 Fall 2014, Dr. Rozier.
CHAPTER 3 Floating Point.
CDA 3101 Fall 2013 Introduction to Computer Organization
1 Lecture 10: Floating Point, Digital Design Today’s topics:  FP arithmetic  Intro to Boolean functions.
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.
Chapter 3 Arithmetic for Computers CprE 381 Computer Organization and Assembly Level Programming, Fall 2012 Revised from original slides provided by MKP.
University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell CS352H: Computer Systems Architecture Lecture 6: MIPS Floating.
C OMPUTER O RGANIZATION AND D ESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers.
CS 224 Computer Organization Spring 2011 Arithmetic for Computers With thanks to M.J. Irwin, D. Patterson, and J. Hennessy for some lecture slide contents.
CSE 340 Simulation Modeling | MUSHFIQUR ROUF CSE340:
10/7/2004Comp 120 Fall October 7 Read 5.1 through 5.3 Register! Questions? Chapter 4 – Floating Point.
King Fahd University of Petroleum and Minerals King Fahd University of Petroleum and Minerals Computer Engineering Department Computer Engineering Department.
COMPUTER ORGANIZATION ARITHMETIC YASSER MOHAMMAD.
Computer Organization & Design 计算机组成与设计 Weidong Wang ( 王维东 ) College of Information Science & Electronic Engineering 信息与通信工程研究所 Zhejiang.
Chapter 3 — Arithmetic for Computers — 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with.
Floating Point Representations
/ Computer Architecture and Design
Morgan Kaufmann Publishers Arithmetic for Computers
ALU Architecture and ISA Extensions
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers Arithmetic for Computers
Topics IEEE Floating Point Standard Rounding Floating Point Operations
Floating Point Number system corresponding to the decimal notation
CS/COE0447 Computer Organization & Assembly Language
Morgan Kaufmann Publishers Arithmetic for Computers
Morgan Kaufmann Publishers
/ Computer Architecture and Design
PRESENTED BY J.SARAVANAN. Introduction: Objective: To provide hardware support for floating point arithmetic. To understand how to represent floating.
Chapter 6 Floating Point
Arithmetic for Computers
Lecture 10: Floating Point, Digital Design
CSCE 350 Computer Architecture
Computer Architecture Computer Science & Engineering
Computer Arithmetic Multiplication, Floating Point
October 17 Chapter 4 – Floating Point Read 5.1 through 5.3 1/16/2019
Digital System Design II 数字系统设计2
Chapter 3 Arithmetic for Computers
Morgan Kaufmann Publishers Arithmetic for Computers
Fundamentals of Digital Logic and Number Systems
Computer Organization and Assembly Language
CDA 3101 Spring 2016 Introduction to Computer Organization
Presentation transcript:

Computer Architecture & Operations I Instructor: Yaohang Li

Review Last Class This Class Next Class Final Exam Division Floating Point Numbers Floating Operations Next Class Final Review Final Exam Apr. 26, 3:45PM-6:45PM

Scientific Notation Scientific Notation Renders numbers with a single digit to the left of the decimal point Normalization ±d0. d1d2d3d4… × 10n d0,d1,d2,d3,d4… are based 10 digits d0 is not 0 n is an integer Including very small and very large numbers

Morgan Kaufmann Publishers 1 June, 2018 Floating Point §3.5 Floating Point Floating Point Numbers Computer arithmetic that represents numbers in which the binary point is not fixed 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 Chapter 3 — Arithmetic for Computers

Floating-Point Representation Two components Fraction between 0 and 1 precision of the floating point number Exponent numerical value range of the floating point number Representation of floating point Determine the sizes of fraction and exponent Tradeoff between range and precision S Exponent Fraction

Terms in Floating Point Representation Overflow A positive exponent becomes too large to fit in the exponent field Underflow A negative exponent becomes too large to fit in the exponent field Double precision A floating-point value represented in 64 bits Single precision A floating-point value represented in 32 bits

Floating Point Standard Morgan Kaufmann Publishers 1 June, 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

IEEE 754 Encoding

IEEE Floating-Point Format Morgan Kaufmann Publishers 1 June, 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 = 1023 Chapter 3 — Arithmetic for Computers

Floating-Point Example Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Example Represent –0.375 –0.375 = -3/8=-3/23=(–1)1 × 112 × 2–3 Normalization=(–1)1 × 1.12 × 2–2 S = 1 Fraction = 1000…002 Exponent = –2 + Bias Single: –2 + 127 = 125 = 011111012 Double: –2 + 1023 = 1021 = 011111111012 Chapter 3 — Arithmetic for Computers

Floating Point Example Single Precision Double Precision 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 S Exponent (8-bit) Fraction (23 bit) 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 1 S Exponent (11-bit) Fraction (52 bit) 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 Fraction (52 bits)

Floating-Point Example Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Example What number is represented by the single-precision float S = 1 Fraction = 01000…002 Exponent = 100000012 = 129 x = (–1)1 × (1 + 0.012) × 2(129 – 127) = (–1) × 1.25 × 22 = –5.0 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 S Exponent (8-bit) Fraction (23 bit) Chapter 3 — Arithmetic for Computers

Single-Precision Range Morgan Kaufmann Publishers 1 June, 2018 Single-Precision Range Exponents 00000000 and 11111111 reserved Smallest value Exponent: 00000001  actual exponent = 1 – 127 = –126 Fraction: 000…00  significand = 1.0 ±1.0 × 2–126 ≈ ±1.2 × 10–38 Largest value exponent: 11111110  actual exponent = 254 – 127 = +127 Fraction: 111…11  significand ≈ 2.0 ±2.0 × 2+127 ≈ ±3.4 × 10+38 Chapter 3 — Arithmetic for Computers

Double-Precision Range Morgan Kaufmann Publishers 1 June, 2018 Double-Precision Range Exponents 0000…00 and 1111…11 reserved Smallest value Exponent: 00000000001  actual exponent = 1 – 1023 = –1022 Fraction: 000…00  significand = 1.0 ±1.0 × 2–1022 ≈ ±2.2 × 10–308 Largest value Exponent: 11111111110  actual exponent = 2046 – 1023 = +1023 Fraction: 111…11  significand ≈ 2.0 ±2.0 × 2+1023 ≈ ±1.8 × 10+308 Chapter 3 — Arithmetic for Computers

Floating-Point Precision Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Precision Relative precision all fraction bits are significant Single: approx 2–23 Equivalent to 23 × log102 ≈ 23 × 0.3 ≈ 6 decimal digits of precision Double: approx 2–52 Equivalent to 52 × log102 ≈ 52 × 0.3 ≈ 16 decimal digits of precision Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 June, 2018 Denormal Numbers Exponent = 000...0  hidden bit is 0 Smaller than normal numbers allow for gradual underflow, with diminishing precision Denormal with fraction = 000...0 Two representations of 0.0! Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 June, 2018 Infinities and NaNs Exponent = 111...1, Fraction = 000...0 ±Infinity Can be used in subsequent calculations, avoiding need for overflow check Exponent = 111...1, Fraction ≠ 000...0 Not-a-Number (NaN) Indicates illegal or undefined result e.g., 0.0 / 0.0 Can be used in subsequent calculations Chapter 3 — Arithmetic for Computers

Floating-Point Addition Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Addition Consider a 4-digit decimal example 9.999 × 101 + 1.610 × 10–1 1. Align decimal points Shift number with smaller exponent 9.999 × 101 + 0.016 × 101 2. Add significands 9.999 × 101 + 0.016 × 101 = 10.015 × 101 3. Normalize result & check for over/underflow 1.0015 × 102 4. Round and renormalize if necessary 1.002 × 102 Chapter 3 — Arithmetic for Computers

Floating-Point Addition Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Addition Now consider a 4-digit binary example 1.0002 × 2–1 + –1.1102 × 2–2 (0.5 + –0.4375) 1. Align binary points Shift number with smaller exponent 1.0002 × 2–1 + –0.1112 × 2–1 2. Add significands 1.0002 × 2–1 + –0.1112 × 2–1 = 0.0012 × 2–1 3. Normalize result & check for over/underflow 1.0002 × 2–4, with no over/underflow 4. Round and renormalize if necessary 1.0002 × 2–4 (no change) = 0.0625 Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 June, 2018 FP Adder Hardware Much more complex than integer adder Doing it in one clock cycle as a single instruction would take too long Much longer than integer operations Slower clock would penalize all instructions FP adder usually takes several cycles Can be pipelined Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 June, 2018 FP Adder Hardware Step 1 Step 2 Step 3 Step 4 Chapter 3 — Arithmetic for Computers

Floating-Point Multiplication Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Multiplication Consider a 4-digit decimal example 1.110 × 1010 × 9.200 × 10–5 1. Add exponents For biased exponents, subtract bias from sum New exponent = 10 + –5 = 5 2. Multiply significands 1.110 × 9.200 = 10.212  10.212 × 105 3. Normalize result & check for over/underflow 1.0212 × 106 4. Round and renormalize if necessary 1.021 × 106 5. Determine sign of result from signs of operands +1.021 × 106 Chapter 3 — Arithmetic for Computers

Floating-Point Multiplication Morgan Kaufmann Publishers 1 June, 2018 Floating-Point Multiplication Now consider a 4-digit binary example 1.0002 × 2–1 × –1.1102 × 2–2 (0.5 × –0.4375) 1. Add exponents –1 + –2 = –3 Biased: –3 + 127 2. Multiply significands 1.0002 × 1.1102 = 1.1102  1.1102 × 2–3 3. Normalize result & check for over/underflow 1.1102 × 2–3 (no change) with no over/underflow 4. Round and renormalize if necessary 1.1102 × 2–3 (no change) 5. Determine sign: +value × –value  –ve –1.1102 × 2–3 = –0.21875 Chapter 3 — Arithmetic for Computers

FP Arithmetic Hardware Morgan Kaufmann Publishers 1 June, 2018 FP Arithmetic Hardware FP multiplier is of similar complexity to FP adder But uses a multiplier for significands instead of an adder FP arithmetic hardware usually does Addition, subtraction, multiplication, division, reciprocal, square-root FP  integer conversion Operations usually takes several cycles Can be pipelined Chapter 3 — Arithmetic for Computers

FP Instructions in MIPS Morgan Kaufmann Publishers 1 June, 2018 FP Instructions in MIPS FP hardware is coprocessor 1 Adjunct processor that extends the ISA Separate FP registers 32 single-precision: $f0, $f1, … $f31 Paired for double-precision: $f0/$f1, $f2/$f3, … Release 2 of MIPs ISA supports 32 × 64-bit FP reg’s FP instructions operate only on FP registers Programs generally don’t do integer ops on FP data, or vice versa More registers with minimal code-size impact FP load and store instructions lwc1, ldc1, swc1, sdc1 e.g., ldc1 $f8, 32($sp) Chapter 3 — Arithmetic for Computers

FP Instructions in MIPS Morgan Kaufmann Publishers 1 June, 2018 FP Instructions in MIPS Single-precision arithmetic add.s, sub.s, mul.s, div.s e.g., add.s $f0, $f1, $f6 Double-precision arithmetic add.d, sub.d, mul.d, div.d e.g., mul.d $f4, $f4, $f6 Single- and double-precision comparison c.xx.s, c.xx.d (xx is eq, lt, le, …) Sets or clears FP condition-code bit e.g. c.lt.s $f3, $f4 Branch on FP condition code true or false bc1t, bc1f e.g., bc1t TargetLabel Chapter 3 — Arithmetic for Computers

Morgan Kaufmann Publishers 1 June, 2018 FP Example: °F to °C C code: float f2c (float fahr) { return ((5.0/9.0)*(fahr - 32.0)); } fahr in $f12, result in $f0, literals in global memory space Compiled MIPS code: f2c: lwc1 $f16, const5($gp) lwc1 $f18, const9($gp) div.s $f16, $f16, $f18 lwc1 $f18, const32($gp) sub.s $f18, $f12, $f18 mul.s $f0, $f16, $f18 jr $ra Chapter 3 — Arithmetic for Computers

Summary Floating Pointer Number Floating Pointer Operations Exponent Fraction IEEE Std 754-1985 Single Precision Double Precision Floating Pointer Operations Addition Multiplication Floating point processor MIPS floating point operations

What I want you to do Review Chapters 3.3 and 3.4 Prepare for your Final