Data Representation and Arithmetic Algorithms

Slides:



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

Binary Arithmetic Binary addition Binary subtraction
Number Systems Standard positional representation of numbers:
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
Computer ArchitectureFall 2008 © August 27, CS 447 – Computer Architecture Lecture 4 Computer Arithmetic (2)
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
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 Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
Fixed-Point Arithmetics: Part II
ECE232: Hardware Organization and Design
Floating Point (a brief look) We need a way to represent –numbers with fractions, e.g., –very small numbers, e.g., –very large numbers,
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
9.4 FLOATING-POINT REPRESENTATION
ECEG-3202: Computer Architecture and Organization, Dept of ECE, AAU 1 Floating-Point Arithmetic Operations.
CSC 221 Computer Organization and Assembly Language
Speeding up of pipeline segments © Fr Dr Jaison Mulerikkal CMI.
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Principles of Linear Pipelining
Computer Arithmetic See Stallings Chapter 9 Sep 10, 2009
Principles of Linear Pipelining. In pipelining, we divide a task into set of subtasks. The precedence relation of a set of subtasks {T 1, T 2,…, T k }
Chapter One Introduction to Pipelined Processors
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
Speedup Speedup is defined as Speedup = Time taken for a given computation by a non-pipelined functional unit Time taken for the same computation by a.
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
Chapter 8 Computer Arithmetic. 8.1 Unsigned Notation Non-negative notation  It treats every number as either zero or a positive value  Range: 0 to 2.
Computer Arithmetic. Integer Representation Sign-magnitude representation ’s complement representation magnitudes
Floating Point Arithmetic – Part I
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Computer System Design Lecture 3
COMPUTER ARITHMETIC Arithmetic with Signed-2's Complement Numbers
Combinational Circuits
Integer Division.
NxN Crossbar design for Barrel Shifter
Expressible Numbers.
Unit -2 ARITHMETIC.
William Stallings Computer Organization and Architecture 7th Edition
Outline Introduction Floating Point Arithmetic Adder Multiplier.
Data Representation and Arithmetic Algorithms
CSCE 350 Computer Architecture
Data Representation Data Types Complements Fixed Point Representation
CSCI206 - Computer Organization & Programming
Floating Point Arithmetic
ECEG-3202 Computer Architecture and Organization
Computer Architecture
Chapter 8 Computer Arithmetic
UNIVERSITY OF MASSACHUSETTS Dept
Combinational Circuits
Arithmetic Logic Unit A.R. Hurson Electrical and Computer Engineering Missouri University of Science & Technology A.R. Hurson.
UNIVERSITY OF MASSACHUSETTS Dept
Chapter3 Fixed Point Representation
Presentation transcript:

Data Representation and Arithmetic Algorithms Module II Data Representation and Arithmetic Algorithms

Non-Restoring Division

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1

10 / 3 A Q Cnt 0000 1010 4 M 0011 START Initial values A  0 M Divisor END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 10 / 3 A Q Cnt 0000 1010 4 Initial values M 0011

10 / 3 A Q Cnt 0000 1010 4 0001 0100 M 0011 START Initial values A  0 END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 10 / 3 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift M 0011

10 / 3 A Q Cnt 0000 1010 4 0001 0100 1110 M 0011 START Initial values END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 10 / 3 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A - M M 0011

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M 2 M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M 2 0010 M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M 2 0010 1 Q0 = 1 M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M 2 0010 1 Q0 = 1 A - M M 0011 10 / 3

END A  A + M START A  0 M Divisor Q Dividend Count n A < 0? Yes No Shift Left A,Q A  A - M A  A + M Q0 = 0 Count =0? Count  Count -1 Q0 = 1 A Q Cnt 0000 1010 4 Initial values 0001 0100 Shift 1110 A – M 3 Q0 = 0 1100 1000 1111 A + M 2 0010 1 Q0 = 1 0011 M 0011 10 / 3

Floating Point Arithmetic

Addition and Subtraction Phase 1: Zero check. The process begins by changing the sign of the subtrahend if it is a subtract operation. If either operand is 0, the other is reported as result. Phase 2: Significand alignment. This phase manipulate the numbers so that the two exponents are equal.

Addition and Subtraction Phase 3: Addition The two significands are added together, taking into account their signs. If there is significand overflow by 1 digit,the result is shifted right and the exponent is incremented. If exponent overflow occurs, this will be reported. Phase 4: Normalization. It consists of shifting significand digits left until the most significant digit is nonzero.

Example : Floating Point Adder Unit

Floating Point Adder Unit The inputs to adder are two normalized floating point numbers of the form A = a x 10p B = b x 10q where a and b are two fractions and p and q are their exponents.

Floating Point Adder Unit Our purpose is to compute the sum C = A + B = c x 10r = d x 10s where r = max(p,q) and 0.1 ≤ d < 1 For example: A=0.9504 x 103 B=0.8200 x 102 a = 0.9504 b= 0.8200 p=3 & q =2

Floating Point Adder Unit Operations performed are : Compare p and q and choose the largest exponent, r = max(p,q)and compute t = |p – q| Example: r = max(p , q) = 3 t = |p-q| = |3-2|= 1

Floating Point Adder Unit Shift right the fraction associated with the smaller exponent by t units to equalize the two exponents before fraction addition. Example: Smaller exponent, b= 0.8200 Shift right b by 1 unit is 0.082

Floating Point Adder Unit Perform fixed-point addition of two fractions to produce the intermediate sum fraction c Example : a = 0.9504 b= 0.082 c = a + b = 0.9504 + 0.082 = 1.0324

Floating Point Adder Unit Count the number of leading zeros (u) in fraction c and shift left c by u units to produce the normalized fraction sum d = c x 10u, with a leading bit 1. Update the large exponent s by subtracting s = r – u to produce the output exponent. Example: c = 1.0324 , u = -1  right shift d = 0.10324 , s= r – u = 3-(-1) = 4 C = 0.10324 x 104

Floating Point Adder Unit The above 4 steps can all be implemented with combinational logic circuits and the 4 stages are: Comparator / Subtractor Shifter Fixed Point Adder Normalizer (leading zero counter and shifter)

Example for floating-point adder Exponents Segment 1: Segment 2: Segment 3: Segment 4: R Adjust exponent Normalize result Add mantissas Align mantissas Choose exponent Compare exponents by subtraction Difference=3-2=1 Mantissas b a A B For example: X=0.9504*103 Y=0.8200*102 0.082 3 S=0.9504+0.082=1.0324 0.10324 -1

4-STAGE FLOATING POINT ADDER A = a x 2 p B = b x 2 q a b A B Exponent subtractor Fraction selector Fraction with min(p,q) Right shifter Other fraction t = |p - q| r = max(p,q) adder Leading zero counter r c Left shifter s d Stages: S1 S2 S3 S4 C= X + Y = d x 2s

Problem Using Non-Restoring division algorithm perform 1011/0101