Q-Format number representation. Lecture 5 Fixed Point vs Floating Point. How to store Q30 number to 16-bit memory? Q-format notation.



Similar documents
Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

ECE 0142 Computer Organization. Lecture 3 Floating Point Representations

2010/9/19. Binary number system. Binary numbers. Outline. Binary to decimal

Systems I: Computer Organization and Architecture

The string of digits in the binary number system represents the quantity

This 3-digit ASCII string could also be calculated as n = (Data[2]-0x30) +10*((Data[1]-0x30)+10*(Data[0]-0x30));

Data Storage 3.1. Foundations of Computer Science Cengage Learning

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

DNA Data and Program Representation. Alexandre David

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

CSI 333 Lecture 1 Number Systems

CS321. Introduction to Numerical Methods

Measures of Error: for exact x and approximation x Absolute error e = x x. Relative error r = (x x )/x.

This Unit: Floating Point Arithmetic. CIS 371 Computer Organization and Design. Readings. Floating Point (FP) Numbers

Numerical Matrix Analysis

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Numbering Systems. InThisAppendix...

LSN 2 Number Systems. ECT 224 Digital Computer Fundamentals. Department of Engineering Technology

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

1. Convert the following base 10 numbers into 8-bit 2 s complement notation 0, -1, -12

To convert an arbitrary power of 2 into its English equivalent, remember the rules of exponential arithmetic:

Useful Number Systems

Floating point package user s guide By David Bishop (dbishop@vhdl.org)

Computer Science 281 Binary and Hexadecimal Review

Solution for Homework 2

Goals. Unary Numbers. Decimal Numbers. 3,148 is s 100 s 10 s 1 s. Number Bases 1/12/2009. COMP370 Intro to Computer Architecture 1

Correctly Rounded Floating-point Binary-to-Decimal and Decimal-to-Binary Conversion Routines in Standard ML. By Prashanth Tilleti

HOMEWORK # 2 SOLUTIO

Lecture 11: Number Systems

Number Representation

Attention: This material is copyright Chris Hecker. All rights reserved.

What Every Computer Scientist Should Know About Floating-Point Arithmetic

CS101 Lecture 11: Number Systems and Binary Numbers. Aaron Stevens 14 February 2011

Exponents. Learning Objectives 4-1

Lecture 2. Binary and Hexadecimal Numbers

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

THE BINARY NUMBER SYSTEM

Software Programmable DSP Platform Analysis Episode 7, Monday 19 March 2007, Ingredients. Software Pipelining. Data Dependence. Resource Constraints

CHAPTER 5 Round-off errors

Binary Adders: Half Adders and Full Adders

MBA Jump Start Program

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

Binary Numbering Systems

AN617. Fixed Point Routines FIXED POINT ARITHMETIC INTRODUCTION. Thi d t t d ith F M k Design Consultant

Zuse's Z3 Square Root Algorithm Talk given at Fall meeting of the Ohio Section of the MAA October College of Wooster

CDA 3200 Digital Systems. Instructor: Dr. Janusz Zalewski Developed by: Dr. Dahai Guo Spring 2012

Arithmetic Coding: Introduction

Programming languages C

Chapter 5. Binary, octal and hexadecimal numbers

A Static Analyzer for Large Safety-Critical Software. Considered Programs and Semantics. Automatic Program Verification by Abstract Interpretation

Arithmetic in MIPS. Objectives. Instruction. Integer arithmetic. After completing this lab you will:

Today. Binary addition Representing negative numbers. Andrew H. Fagg: Embedded Real- Time Systems: Binary Arithmetic

Binary Numbers. Binary Octal Hexadecimal

Computers. Hardware. The Central Processing Unit (CPU) CMPT 125: Lecture 1: Understanding the Computer

Binary Representation. Number Systems. Base 10, Base 2, Base 16. Positional Notation. Conversion of Any Base to Decimal.

FAST INVERSE SQUARE ROOT

FX 115 MS Training guide. FX 115 MS Calculator. Applicable activities. Quick Reference Guide (inside the calculator cover)

The programming language C. sws1 1

Monday January 19th 2015 Title: "Transmathematics - a survey of recent results on division by zero" Facilitator: TheNumberNullity / James Anderson, UK

Positional Numbering System

Chapter Binary, Octal, Decimal, and Hexadecimal Calculations

Rules of Exponents. Math at Work: Motorcycle Customization OUTLINE CHAPTER

Computer Arithmetic Aliasing issues: Call by reference, Pointer programs

1.Eastron SDM220Modbus Smart Meter Modbus Protocol Implementation V1.0

Advanced Tutorials. Numeric Data In SAS : Guidelines for Storage and Display Paul Gorrell, Social & Scientific Systems, Inc., Silver Spring, MD

A numerically adaptive implementation of the simplex method

2 Number Systems. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

A High-Performance 8-Tap FIR Filter Using Logarithmic Number System

Data Storage: Each time you create a variable in memory, a certain amount of memory is allocated for that variable based on its data type (or class).

Base Conversion written by Cathy Saxton

The New IoT Standard: Any App for Any Device Using Any Data Format. Mike Weiner Product Manager, Omega DevCloud KORE Telematics

THE EXACT DOT PRODUCT AS BASIC TOOL FOR LONG INTERVAL ARITHMETIC

2011, The McGraw-Hill Companies, Inc. Chapter 3

Precision & Performance: Floating Point and IEEE 754 Compliance for NVIDIA GPUs

Lecture 8: Binary Multiplication & Division

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

Some Functions Computable with a Fused-mac

Chapter 7D The Java Virtual Machine

Floating-point control in the Intel compiler and libraries or Why doesn t my application always give the expected answer?

Binary Representation

Technical Information. Digital Signals. 1 bit. Part 1 Fundamentals

Copyright 2012 Pearson Education, Inc. Chapter 1 INTRODUCTION TO COMPUTING AND ENGINEERING PROBLEM SOLVING

2003 HSC Notes from the Marking Centre Software Design and Development

ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

Adaptive Stable Additive Methods for Linear Algebraic Calculations

TMS320C67x FastRTS Library Programmer s Reference

Introduction to Xilinx System Generator Part II. Evan Everett and Michael Wu ELEC Spring 2013

Basics of Floating-Point Quantization

2000: 3100 pages ( Source: Volkswagen AG ) This chapter will start with a brief comparison between the two types of processor.

RS485 & Modbus Protocol Guide

FLOATING-POINT ARITHMETIC IN AMD PROCESSORS MICHAEL SCHULTE AMD RESEARCH JUNE 2015

Chapter 2 Elementary Programming

Digital Logic Design. Introduction

Lecture N -1- PHYS Microcontrollers

Session 29 Scientific Notation and Laws of Exponents. If you have ever taken a Chemistry class, you may have encountered the following numbers:

Numerical Analysis I

Number of bits needed to address hosts 8

Transcription:

Lecture 5 Fixed Point vs Floating Point Objectives: Understand fixed point representations Understand scaling, overflow and rounding in fixed point Understand Q-format Understand TM32C67xx floating point representations Understand relationship between the two in C6x architecture Reference: "What Every Computer cientist hould Know About Floating-Point Arithmetic" by David GoldbergACM Computing urveys 23, 5 (March 1991). Lecture 5 - Fixed point vs Floating point 5-1 Q-Format number representation N-bit fixed point, 2 s complement number is given by: x = b N-1 N 1 N 2 1 N 12 + bn 22 + + b1 2 + b 2 imaginary binary point Difficult to work with due to possible overflow & scaling problems Often normalise number to some fractional representation (e.g. between ± 1) x = b N-1 1 N 2 N 1 N 12 + bn 22 + + b1 2 + b 2 imaginary binary point Lecture 5 - Fixed point vs Floating point 5-2 Q-format notation How to store Q3 number to 16-bit memory? Q-format representation: if N=16, 15 bit fractional representation Q15 format Rule: Q m + Q m Q m Q m x Q n Q m+n Assume 16-bit data format, Q15 x Q15 Q3 X Q15 Q15 Q3 15 31 16 15 toring Q3 number to 16-bit memory requires rounding or truncation: Q3 Rounding: 31 16 if r =, round down, r = 1, round up rounding by addition a '1' here 15 r + 1 MPY A3,A4,A6 ; A3 x A4 A6 NOP ; Delay slot K 4h,A6 ; rounding add HR A6,15,A6 ; truncate bottom 15 bits TH A6,*A7 ; A6 mem[a7] Lecture 5 - Fixed point vs Floating point 5-3 Lecture 5 - Fixed point vs Floating point 5-4

Avoid overflow with afe add routine in C to avoid overflow - saturation add instruction Always clip to max (or min) possible et bit 9 of the CR register to indicate saturation has occurred Lecture 5 - Fixed point vs Floating point 5-5 Lecture 5 - Fixed point vs Floating point 5-6 ingle Precsion Floating Point number Easy (and lazy) way of dealing with scaling problem 32-bit single precision floating point: single precision 31 3 23 22 x = 8-bit exp s 1 2 1.175 1 38 exp 127 23-bit frac 1. frac MB is sign-bit (same as fixed point) 8-bit exponent in bias-127 integer format (i.e., add 127 to it) 23-bit to represent only the fractional part of the mantissa. The MB of the mantissa is ALWAY 1, therefore it is not stored < x < 1.7 1 38 Double Precision Floating Point number 64-bit double precision floating point: double precision 31 3 2 19 31 11-bit exp 52-bit frac Odd register (e.g. A5) Even register (e.g. A4) x s = 1 2 2.2 1 38 < exp 123 1. frac x < 1.7 1 MB is sign-bit (same as fixed point) 11-bit exponent in bias-123 integer format (i.e., add 123 to it) 52-bit to represent only the fractional part of the mantissa. The MB of the mantissa is ALWAY 1, therefore it is not stored 38 Lecture 5 - Fixed point vs Floating point 5-7 Lecture 5 - Fixed point vs Floating point 5-8

Convert 5.75 to P FP Examples 5.75 to binary: +1.111... x 2 2 exponent in bias-127 is 127+2 = 129 = 1 b The fractional part is.111... after we drop the hidden 1 bit. Answer: 11 111... = 4B8 (hex) Convert.1 to DP FP.1 to binary: 1.1111(11 repeats) x 2-4 exponent in bias-123 is 123-4 = 119 = 11 1111 111 b The fractional part is.1111...11 after we drop the hidden 1 bit and rounding Answer: 111111111 111...11 11 = 3FB9 9999 9999 999A (hex). Problems of Q-format Wrong Q-format representation will give totally wrong results Even correct use of Q-format notation may reduce precision For this example, Q12 result is totally wrong, and Q8 result is imprecise: Q12 7.5195 111. 1 1 Q12 7.25 * 111. 1 Q24 54.38916 11 11. 11 11 11 Q12 6.38916 Q8 54.38281 Lecture 5 - Fixed point vs Floating point 5-9 Lecture 5 - Fixed point vs Floating point 5-1 Data types used by C6x DPs pecial P numbers IEEE floating point standard has a set of special numbers: pecial ign (s) Exponent (e) Fraction (f) Hex Value Decimal + x. - 1 x8 -. 1 127 x3f8 1. 2 128 x4 2. +Inf 255 x7f8 + -Inf 1 255 xff8 - NaN x 255 Nonzero x7fff FFFF not a number LFPN 254 All 1 s x7f7f FFFF 3.4282347 e+38 FPN 1 All s x8 1.17549435e-38 Lecture 5 - Fixed point vs Floating point 5-11 Lecture 5 - Fixed point vs Floating point 5-12

pecial DP numbers TM32C67x Internal ystem Architecture Double precision floating point special numbers: pecial Exponent (e) Fraction (f) Hex Value Decimal + x. - x8 -. 1 123 x3ff 1. 2 124 x4 2. +Inf 247 x7ff + -Inf 247 xfff - NaN 247 Nonzero x7fff FFFF FFFF FFFF not a number LFPN 246 All 1 s x7fef FFFF FFFF FFFF 1.7976931348623157 e+38 FPN 1 All s x1 2.2257385857214 e-38 External Memory P E R I P H E R A L Regs (A-A15/31) Internal Memory Internal Buses.D1.M1.L1.1 CPU.D2.M2.L2.2 Regs (B-B15/31) Lecture 5 - Fixed point vs Floating point 5-13 Lecture 5 - Fixed point vs Floating point 5-14 Four functional units for each datapath Mapping of instructions to functional units..l.d.m K 2 AND B CLR EXT C K KH AB LDB LDDW. Unit NOT OR ET HL HR HL UB UB2 XOR ZERO ABP ABDP CMPGTP CMPEQP CMPLTP CMPGTDP CMPEQDP CMPLTDP RCPP RCPDP RQRP RQRDP PDP.D Unit (B/H/W) TB (B/H/W) (B/H/W) UB UBAB (B/H/W) ZERO AB AND CMPEQ CMPGT CMPLT LMBD NORM MPY MPYH MPYLH MPYHL.L Unit NOT P OR DP UBP AT UBDP UB INTP UB INTDP UBC PINT XOR DPINT ZERO PRTUNC DPTRUNC DPP.M Unit MPY MPYH MPYP MPYDP MPYI MPYID No Unit Used NOP IDLE Lecture 5 - Fixed point vs Floating point 5-15 Lecture 5 - Fixed point vs Floating point 5-16

Detailed internal datapaths Data path A Data path B Lecture 5 - Fixed point vs Floating point 5-17