Download presentation
Presentation is loading. Please wait.
Published byΣίβύλ Άγνη Χριστόπουλος Modified over 6 years ago
1
Data Representation and Arithmetic Algorithms
Module II Data Representation and Arithmetic Algorithms
2
Non-Restoring Division
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
4
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
5
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
6
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
7
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
8
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
9
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
10
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
11
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
12
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
13
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
14
Floating Point Arithmetic
15
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.
16
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.
17
Example : Floating Point Adder Unit
18
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.
19
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= x 103 B= x 102 a = b= p=3 & q =2
20
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
21
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= Shift right b by 1 unit is 0.082
22
Floating Point Adder Unit
Perform fixed-point addition of two fractions to produce the intermediate sum fraction c Example : a = b= 0.082 c = a + b = =
23
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 = , u = -1 right shift d = , s= r – u = 3-(-1) = 4 C = x 104
24
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)
25
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= =1.0324 -1
26
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
27
Problem Using Non-Restoring division algorithm perform 1011/0101
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.