ECE331: Hardware Organization and Design

Similar documents
ECE232: Hardware Organization and Design

ECE331: Hardware Organization and Design

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

ECE331: Hardware Organization and Design

Thomas Polzer Institut für Technische Informatik

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

ECE 30 Introduction to Computer Engineering

Divide: Paper & Pencil

Number Systems and Computer Arithmetic

COMPUTER ORGANIZATION AND DESIGN

MIPS Integer ALU Requirements

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

IEEE Standard for Floating-Point Arithmetic: 754

Chapter 3. Arithmetic Text: P&H rev

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

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Review: MIPS Organization

Chapter 3: Arithmetic for Computers

Arithmetic for Computers. Hwansoo Han

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

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

Floating Point Arithmetic

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

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

Tailoring the 32-Bit ALU to MIPS

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

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

Numeric Encodings Prof. James L. Frankel Harvard University

Chapter 3 Arithmetic for Computers (Part 2)

TDT4255 Computer Design. Lecture 4. Magnus Jahre

Floating Point Arithmetic

Integer Multiplication and Division

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

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

Computer Architecture. Chapter 3: Arithmetic for Computers

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

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

ECE260: Fundamentals of Computer Engineering

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Arithmetic. Chapter 3 Computer Organization and Design

15213 Recitation 2: Floating Point

Chapter 5 : Computer Arithmetic

Organisasi Sistem Komputer

Chapter 3. Arithmetic for Computers

Chapter 3. Arithmetic for Computers

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

Chapter 3 Arithmetic for Computers

Number Systems. Both numbers are positive

Module 2: Computer Arithmetic

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

CMPSCI 145 MIDTERM #1 Solution Key. SPRING 2017 March 3, 2017 Professor William T. Verts

Floating Point Numbers

COMP2611: Computer Organization. Data Representation

Chapter 3. Arithmetic for Computers

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

Floating Point. The World is Not Just Integers. Programming languages support numbers with fraction

CS61C : Machine Structures

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

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

Inf2C - Computer Systems Lecture 2 Data Representation

Chapter Three. Arithmetic

Introduction to Computers and Programming. Numeric Values

CHW 261: Logic Design

CS2214 COMPUTER ARCHITECTURE & ORGANIZATION SPRING 2014

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

IEEE Standard 754 for Binary Floating-Point Arithmetic.

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

Lecture 8: Addition, Multiplication & Division

Timing for Ripple Carry Adder

Signed umbers. Sign/Magnitude otation

CPE300: Digital System Architecture and Design

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

3.5 Floating Point: Overview

Integer Multiplication and Division

Computer Organisation CS303

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

Recap from Last Time. CSE 2021: Computer Organization. It s All about Numbers! 5/12/2011. Text Pictures Video clips Audio

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

MACHINE LEVEL REPRESENTATION OF DATA

Arithmetic for Computers

Computer Arithmetic Floating Point

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

Representing and Manipulating Floating Points. Jo, Heeseung

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

CS 265. Computer Architecture. Wei Lu, Ph.D., P.Eng.

Outline. EEL-4713 Computer Architecture Multipliers and shifters. Deriving requirements of ALU. MIPS arithmetic instructions

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

Review: MULTIPLY HARDWARE Version 1. ECE4680 Computer Organization & Architecture. Divide, Floating Point, Pentium Bug

Computer Architecture Set Four. Arithmetic

CPS 104 Computer Organization and Programming

Part III The Arithmetic/Logic Unit. Oct Computer Architecture, The Arithmetic/Logic Unit Slide 1

Floating-point representations

Floating-point representations

Integer Multiplication. Back to Arithmetic. Integer Multiplication. Example (Fig 4.25)

Lecture Topics. Announcements. Today: Integer Arithmetic (P&H ) Next: The MIPS ISA (P&H ) Consulting hours. Milestone #1 (due 1/26)

Data Representation Floating Point

FLOATING POINT NUMBERS

CMSC 313 Lecture 03 Multiple-byte data big-endian vs little-endian sign extension Multiplication and division Floating point formats Character Codes

Transcription:

ECE331: Hardware Organization and Design Lecture 10: Multiplication & Floating Point Representation Adapted from Computer Organization and Design, Patterson & Hennessy, UCB

MIPS Division Two 32-bit registers for product HI: most-significant 32 bits LO: least-significant 32-bits Instructions div rs, rt / divu rs, rt 32-bit result in LO, 32-bit remainder in HI mfhi rd / mflo rd Moves data from hi and lo registers Example mfhi $s0 -> move remainder to register $s0 mflo $s0 -> move result of division to register $s0 ECE331: Floating Point 2

MULTIPLY Paper and pencil example (unsigned): Multiplicand 1000 Multiplier 1001 1000 0000 0000 1000 Product 1001000 m bits x n bits = m+n bit product Issues to note: The number of partial products is equal to the number of bits in the multiplier The partial products are added together A total of n-1 adders could be used to generate the result ECE331: Floating Point 3

MULTIPLY Paper and pencil example (unsigned): Multiplicand 1000 Multiplier 11 1000 1000 Product 11000 Need one adder ECE331: Floating Point 4

MULTIPLY Paper and pencil example (unsigned): Multiplicand 1000 Multiplier 11 1000 1000 Product 11000 Need one adder ECE331: Floating Point 5

MULTIPLY Paper and pencil example Multiplicand 1000 Multiplier 1001 1000 0000 0000 three additions 1000 Product 1001000 B 3 B 2 B 1 B 0 -> Multiplicand A 3 A 2 A 1 A 0 -> Multiplier ECE331: Floating Point 6

What is the Delay Through the Multiplier? x3,x2,x1,x0=1111 y3,y2,y1,y0=0001 ΔFA - operation time - delay Assuming equal delays for sum and carry-out Longest carry propagation chain when adding two 4-bit numbers In synchronous arithmetic units - time allowed for adder's operation is worst-case delay - nδfa ECE331: Floating Point 7

Multiplier Delay ΔFA - operation time delay through each adder bit Ignore AND gate delay For 4-bit adder, delay is 4*ΔFA Second adder (controlled by A2) can t generate its last add bit until second sum bit of first adder propagates through second adder So, extra delay of 2*ΔFA for second adder. Third adder (controlled by A3) can t generate its last add bit until second sum bit for second adder propagates through third adder So, extra delay of 2*ΔFA for third adder. Total delay is 2*ΔFA + 2*ΔFA + 4*ΔFA = 8*ΔFA What s the delay for n bits? ECE331: Floating Point 8

Multiplier Delay Critical paths C0 delay = 0 C1 delay = ΔFA C2 delay = 3ΔFA C3 delay = 5ΔFA C4 delay = 6ΔFA C5 delay = 7ΔFA C6 delay = 8ΔFA C7 delay = 8ΔFA What s the delay for n bits? (n-2) * (2ΔFA) + nδfa = (3n-4)ΔFA ECE331: Floating Point 9 Critical path for c7

Floating Point Representation for non-integral numbers Including very small and very large numbers Like scientific notation 2.34 10 56 +0.002 10 4 +987.02 10 9 In binary ±1.xxxxxxx 2 2 yyyy Types float and double in C normalized ECE331: Floating Point 10

Floating Point Numbers The largest 32 bit unsigned integer number is 1111 1111 1111 1111 1111 1111 1111 1111 = 4,294,967,295 What if we want to encode the approx. age of the earth? 4,600,000,000 or 4.6 x 10 9 or the weight in kg of one a.m.u. (atomic mass unit) 0.0000000000000000000000000166 or 1.6 x 10-27 There is no way we can encode either of the above in a 32- bit integer. ECE331: Floating Point 11

Exponential Notation The following are equivalent representations of 1,234 123,400.0 x 10-2 12,340.0 x 10-1 1,234.0 x 10 0 123.4 x 10 1 12.34 x 10 2 1.234 x 10 3 0.1234 x 10 4 0.01234x 10 5 The representations differ in that the decimal place the point - floats to the left or right (with the appropriate adjustment in the exponent). ECE331: Floating Point 12

Parts of a Floating Point Number -0.9876 x 10-3 Exponent Sign of mantissa Location of decimal point Mantissa Sign of exponent Base Mantissa is also called Significand ECE331: Floating Point 13

Single Precision Format Note that the exponent has no explicit sign bit Base? 32 bits M: Mantissa (23 bits) E: Exponent (8 bits) S: Sign of mantissa (1 bit) ECE331: Floating Point 14

Normalization The mantissa M is a normalized fraction Has an implied decimal place on left Has an implied (hidden) 1 on left of the decimal place E.g., Fraction 10100000000000000000000 Represents 1.101 2 = 1.625 10 The significand=1.f is in the range [1, 2-ulp] ulp unit in the last position (what remains to reach a whole number when all bits are set to one) F ECE331: Floating Point 15 S = ( 1) 1. f 2 E Bias Value of exponent (unsigned integer) Bias value (known; set by convention)

Binary Fractions To convert binary fractions to floating point 0.1110 0010 2-1 2-2 2-3 2-7 = 1*(0.5) + 1*(0.25) + 1*(0.125) + 0*(0.0625) + 0*(0.03125) + 0*(0.015625) + 1*(0.0078125) + 0*(0.00390625) = 0.8828125000 ECE331: Floating Point 16

Binary Fractions To convert floating point to binary 9.625 whole number fraction 9 à 1001 2 0.625 1*(0.5) = 0.125 0.125 1*(0.25) = neg. num. 0.125 1*(0.125) = 0 X 1 0 1 9.625 à 1001.1010 0000 2 = 0.1001 1010 0000 x 2 4 = 1.0011 0100 0000 x 2 3 Note that we can shift positions left and right of the decimal point by multiplying by different powers of 2 ECE331: Floating Point 17

Working with normalization (single precision) S {0,1} (1-bit) 1 E 254 (8-bits unsigned integer); Bias = 127 0.0000 0000 0000 0000 0000 000 f base-2 < 0.1111 1111 1111 1111 1111 111 Formula provides for the full range of possible floating point numbers. F S = ( 1) 1. f 2 E Bias 2-2 2-1 2 0 2 1 2 2 2 3 0.25 0.5 1.0 2.0 4.0 8.0 ECE331: Floating Point 18

IEEE Floating-Point Format single: 8 bits double: 11 bits S Exponent single: 23 bits double: 52 bits Fraction x = ( 1) S (1+ Fraction) 2 (Exponent Bias) 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 ECE331: Floating Point 19

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 ECE331: Floating Point 20

Floating-Point Example To convert floating point number to binary Represent 0.75 0.75 = 0.11 2 = ( 1) 1 1.1 2 2 1 S = 1 Fraction = 1000 00 2 Exponent = 1 + Bias Single: 1 + 127 = 126 = 01111110 2 Double: 1 + 1023 = 1022 = 01111111110 2 Single: 1 01111110 1000 00 fraction sign exponent and bias Double: 1 01111111110 1000 00 ECE331: Floating Point 21

Floating-Point Example To convert from binary to floating point What number is represented by the single-precision float? 1 10000001 01000 00 Identify the components S = 1 Fraction = 01000 00 2 Exponent = 10000001 2 = 129 Calculate the value x = ( 1) 1 (1 + 0.01 2 ) 2 (129 127) = ( 1) 1.25 2 2 = 5.0 ECE331: Floating Point 22