Lecture 10: Floating Point, Digital Design

Similar documents
Lecture 10: Floating Point, Digital Design

Written Homework 3. Floating-Point Example (1/2)

Floating Point Arithmetic

Floating Point Arithmetic. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Chapter 3. Arithmetic Text: P&H rev

Thomas Polzer Institut für Technische Informatik

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

CSCI 402: Computer Architectures. Arithmetic for Computers (4) Fengguang Song Department of Computer & Information Science IUPUI.

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

3.5 Floating Point: Overview

Arithmetic. Chapter 3 Computer Organization and Design

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W4-W

COMPUTER ORGANIZATION AND DESIGN

CO Computer Architecture and Programming Languages CAPL. Lecture 15

CS222: Processor Design

Chapter 3 Arithmetic for Computers (Part 2)

Slide Set 11. for ENCM 369 Winter 2015 Lecture Section 01. Steve Norman, PhD, PEng

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

Computer Organization and Levels of Abstraction

Arithmetic for Computers. Hwansoo Han

ECE232: Hardware Organization and Design

Boolean Algebra. Chapter 3. Boolean Algebra. Chapter 3 Arithmetic for Computers 1. Fundamental Boolean Operations. Arithmetic for Computers

Floating Point COE 308. Computer Architecture Prof. Muhamed Mudawar. Computer Engineering Department King Fahd University of Petroleum and Minerals

TDT4255 Computer Design. Lecture 4. Magnus Jahre

COMP2611: Computer Organization. Data Representation

LECTURE 4. Logic Design

Computer Organization and Levels of Abstraction

Floating Point Arithmetic

CS Computer Architecture. 1. Explain Carry Look Ahead adders in detail

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

Numeric Encodings Prof. James L. Frankel Harvard University

Chapter 2 Float Point Arithmetic. Real Numbers in Decimal Notation. Real Numbers in Decimal Notation

Floating-Point Arithmetic

Chapter 3. Arithmetic for Computers

Floating Point Numbers. Lecture 9 CAP

Lecture 14: Recap. Today s topics: Recap for mid-term No electronic devices in midterm

15213 Recitation 2: Floating Point

Floating-Point Arithmetic

Chapter 3. Arithmetic for Computers

Format. 10 multiple choice 8 points each. 1 short answer 20 points. Same basic principals as the midterm

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

CSCI 402: Computer Architectures. Arithmetic for Computers (3) Fengguang Song Department of Computer & Information Science IUPUI.

Chapter 3. Arithmetic for Computers

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

System Programming CISC 360. Floating Point September 16, 2008

9 Floating-Point. 9.1 Objectives. 9.2 Floating-Point Number Representation. Value = ± (1.F) 2 2 E Bias

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two Solutions 26 February 2014

5DV118 Computer Organization and Architecture Umeå University Department of Computing Science Stephen J. Hegner. Topic 3: Arithmetic

Floating Point Numbers

Floating Point Numbers

Floating point. Today! IEEE Floating Point Standard! Rounding! Floating Point Operations! Mathematical properties. Next time. !

Floating Point Arithmetic

CO212 Lecture 10: Arithmetic & Logical Unit

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Floating point. Today. IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties Next time.

Floating Point Numbers

Floating Point Puzzles. Lecture 3B Floating Point. IEEE Floating Point. Fractional Binary Numbers. Topics. IEEE Standard 754

Lecture 13: (Integer Multiplication and Division) FLOATING POINT NUMBERS

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

Systems I. Floating Point. Topics IEEE Floating Point Standard Rounding Floating Point Operations Mathematical properties

Floating Point January 24, 2008

Computer Architecture Set Four. Arithmetic

Precision and Accuracy

Data Representation Floating Point

Chapter 3: Arithmetic for Computers

Bryant and O Hallaron, Computer Systems: A Programmer s Perspective, Third Edition. Carnegie Mellon

Giving credit where credit is due

Floating Point. CSE 238/2038/2138: Systems Programming. Instructor: Fatma CORUT ERGİN. Slides adapted from Bryant & O Hallaron s slides

CS61C Floating Point Operations & Multiply/Divide. Lecture 9. February 17, 1999 Dave Patterson (http.cs.berkeley.edu/~patterson)

Giving credit where credit is due

Inf2C - Computer Systems Lecture 2 Data Representation

Review: MIPS Organization

Review 1/2 Big Idea: Instructions determine meaning of data; nothing inherent inside the data Characters: ASCII takes one byte

UC Berkeley CS61C : Machine Structures

ECE 2020B Fundamentals of Digital Design Spring problems, 6 pages Exam Two 26 February 2014

IEEE Standard for Floating-Point Arithmetic: 754

CPE300: Digital System Architecture and Design

ECE331: Hardware Organization and Design

ECE260: Fundamentals of Computer Engineering

xx.yyyy Lecture #11 Floating Point II Summary (single precision): Precision and Accuracy Fractional Powers of 2 Representation of Fractions

Signed Multiplication Multiply the positives Negate result if signs of operand are different

UC Berkeley CS61C : Machine Structures

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

Floating Point : Introduction to Computer Systems 4 th Lecture, May 25, Instructor: Brian Railing. Carnegie Mellon

IEEE Standard 754 for Binary Floating-Point Arithmetic.

Data Representation Floating Point

Floating Point Puzzles The course that gives CMU its Zip! Floating Point Jan 22, IEEE Floating Point. Fractional Binary Numbers.

ECE331: Hardware Organization and Design

MIPS Integer ALU Requirements

Chapter Three. Arithmetic

Computer Organisation CS303

IEEE Standard 754 for Binary Floating-Point Arithmetic.

Data Representation Floating Point

Logic, Words, and Integers

ECE 331 Hardware Organization and Design. Professor Jay Taneja UMass ECE - Discussion 5 2/22/2018

ECE331: Hardware Organization and Design

Cache Organizations for Multi-cores

CS 261 Fall Floating-Point Numbers. Mike Lam, Professor.

CS61C : Machine Structures

Transcription:

Lecture 10: Floating Point, Digital Design Today s topics: FP arithmetic Intro to Boolean functions 1

Examples Final representation: (-1) S x (1 + Fraction) x 2 (Exponent Bias) Represent -0.75 ten in single and double-precision formats Single: (1 + 8 + 23) Double: (1 + 11 + 52) What decimal number is represented by the following single-precision number? 1 1000 0001 01000 0000 2

Examples Final representation: (-1) S x (1 + Fraction) x 2 (Exponent Bias) Represent -0.75 ten in single and double-precision formats Single: (1 + 8 + 23) 1 0111 1110 1000 000 Double: (1 + 11 + 52) 1 0111 1111 110 1000 000 What decimal number is represented by the following single-precision number? 1 1000 0001 01000 0000-5.0 3

Details The number 0 has a special code so that the implicit 1 does not get added: the code is all 0s (it may seem that this takes up the representation for 1.0, but given how the exponent is represented, that s not the case) (see discussion of denorms (pg. 222) in the textbook) The largest exponent value (with zero fraction) represents +/- infinity The largest exponent value (with non-zero fraction) represents NaN (not a number) for the result of 0/0 or (infinity minus infinity) Note that these choices impact the smallest and largest numbers that can be represented 4

FP Addition Consider the following decimal example (can maintain only 4 decimal digits and 2 exponent digits) 9.999 x 10 1 + 1.610 x 10-1 Convert to the larger exponent: 9.999 x 10 1 + 0.016 x 10 1 Add 10.015 x 10 1 Normalize 1.0015 x 10 2 Check for overflow/underflow Round 1.002 x 10 2 Re-normalize 5

FP Addition Consider the following decimal example (can maintain only 4 decimal digits and 2 exponent digits) 9.999 x 10 1 + 1.610 x 10-1 Convert to the larger exponent: 9.999 x 10 1 + 0.016 x 10 1 Add 10.015 x 10 1 Normalize 1.0015 x 10 2 Check for overflow/underflow Round 1.002 x 10 2 Re-normalize If we had more fraction bits, these errors would be minimized 6

FP Addition Binary Example Consider the following binary example 1.010 x 2 1 + 1.100 x 2 3 Convert to the larger exponent: 0.0101 x 2 3 + 1.1000 x 2 3 Add 1.1101 x 2 3 Normalize 1.1101 x 2 3 Check for overflow/underflow Round Re-normalize IEEE 754 format: 0 10000010 11010000000000000000000 7

FP Multiplication Similar steps: Compute exponent (careful!) Multiply significands (set the binary point correctly) Normalize Round (potentially re-normalize) Assign sign 8

MIPS Instructions The usual add.s, add.d, sub, mul, div Comparison instructions: c.eq.s, c.neq.s, c.lt.s. These comparisons set an internal bit in hardware that is then inspected by branch instructions: bc1t, bc1f Separate register file $f0 - $f31 : a double-precision value is stored in (say) $f4-$f5 and is referred to by $f4 Load/store instructions (lwc1, swc1) must still use integer registers for address computation 9

Code Example float f2c (float fahr) { return ((5.0/9.0) * (fahr 32.0)); } (argument fahr is stored in $f12) lwc1 $f16, const5 lwc1 $f18, const9 div.s $f16, $f16, $f18 lwc1 $f18, const32 sub.s $f18, $f12, $f18 mul.s $f0, $f16, $f18 jr $ra 10

Fixed Point FP operations are much slower than integer ops Fixed point arithmetic uses integers, but assumes that every number is multiplied by the same factor Example: with a factor of 1/1000, the fixed-point representations for 1.46, 1.7198, and 5624 are respectively 1460, 1720, and 5624000 More programming effort and possibly lower precision for higher performance 11

Subword Parallelism ALUs are typically designed to perform 64-bit or 128-bit arithmetic Some data types are much smaller, e.g., bytes for pixel RGB values, half-words for audio samples Partitioning the carry-chains within the ALU can convert the 64-bit adder into 4 16-bit adders or 8 8-bit adders A single load can fetch multiple values, and a single add instruction can perform multiple parallel additions, referred to as subword parallelism 12

Digital Design Basics Two voltage levels high and low (1 and 0, true and false) Hence, the use of binary arithmetic/logic in all computers A transistor is a 3-terminal device that acts as a switch V V V 0 Conducting 0 V Non-conducting 0 0 13

Logic Blocks A logic block has a number of binary inputs and produces a number of binary outputs the simplest logic block is composed of a few transistors A logic block is termed combinational if the output is only a function of the inputs A logic block is termed sequential if the block has some internal memory (state) that also influences the output A basic logic block is termed a gate (AND, OR, NOT, etc.) We will only deal with combinational circuits today 14

Truth Table A truth table defines the outputs of a logic block for each set of inputs Consider a block with 3 inputs A, B, C and an output E that is true only if exactly 2 inputs are true A B C E 15

Truth Table A truth table defines the outputs of a logic block for each set of inputs Consider a block with 3 inputs A, B, C and an output E that is true only if exactly 2 inputs are true A B C E 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 0 Can be compressed by only representing cases that have an output of 1 16

Boolean Algebra Equations involving two values and three primary operators: OR : symbol +, X = A + B X is true if at least one of A or B is true AND : symbol., X = A. B X is true if both A and B are true NOT : symbol, X = A X is the inverted value of A 17

Boolean Algebra Rules Identity law : A + 0 = A ; A. 1 = A Zero and One laws : A + 1 = 1 ; A. 0 = 0 Inverse laws : A. A = 0 ; A + A = 1 Commutative laws : A + B = B + A ; A. B = B. A Associative laws : A + (B + C) = (A + B) + C A. (B. C) = (A. B). C Distributive laws : A. (B + C) = (A. B) + (A. C) A + (B. C) = (A + B). (A + C) 18

DeMorgan s Laws A + B = A. B A. B = A + B Confirm that these are indeed true 19

Title Bullet 20