Download presentation
Presentation is loading. Please wait.
Published byAnnabella Phelps Modified over 9 years ago
1
Figure 1.1 Block diagram of a digital computer. Functional Units
2
REPRESENTATION OF NUMBERS - POSITIONAL NUMBERS Decimal Binary Octal Hexadecimal 00 0000 00 0 01 0001 01 1 02 0010 02 2 03 0011 03 3 04 0100 04 4 05 0101 05 5 06 0110 06 6 07 0111 07 7 08 1000 10 8 09 1001 11 9 10 1010 12 A 11 1011 13 B 12 1100 14 C 13 1101 15 D 14 1110 16 E 15 1111 17 F Binary, octal, and hexadecimal conversion 1 0 1 0 1 1 1 1 0 1 1 0 0 0 1 1 1 2 7 5 4 3 A F 6 3 Octal Binary Hexa
3
CONVERSION OF BASES Decimal to Base R number Base R to Decimal Conversion V(A) = a k R k A = a n-1 a n-2 a n-3 … a 0. a -1 … a -m (736.4) 8 = 7 x 8 2 + 3 x 8 1 + 6 x 8 0 + 4 x 8 -1 = 7 x 64 + 3 x 8 + 6 x 1 + 4/8 = (478.5) 10 (110110) 2 =... = (54) 10 (110.111) 2 =... = (6.785) 10 (F3) 16 =... = (243) 10 (0.325) 6 =... = (0.578703703.................) 10 - Separate the number into its integer and fraction parts and convert each part separately. - Convert integer part into the base R number → successive divisions by R and accumulation of the remainders. - Convert fraction part into the base R number → successive multiplications by R and accumulation of integer digits
4
EXAMPLE Convert 41.6875 10 to base 2. Integer = 41 41 20 1 10 0 5 0 2 1 1 0 0 1 Fraction = 0.6875 0.6875 x 2 1.3750 x 2 0.7500 x 2 1.5000 x 2 1.0000 (41) 10 = (101001) 2 (0.6875) 10 = (0.1011) 2 (41.6875) 10 = (101001.1011) 2 Convert (63) 10 to base 5: (223) 5 Convert (1863) 10 to base 8: (3507) 8 Convert (0.63671875) 10 to hexadecimal: (0.A3) 16 Exercise
5
COMPLEMENT OF NUMBERS Two types of complements for base R number system: - R's complement and (R-1)'s complement The (R-1)'s Complement Subtract each digit of a number from (R-1) Example - 9's complement of 835 10 is 164 10 - 1's complement of 1010 2 is 0101 2 (bit by bit complement operation) The R's Complement Add 1 to the low-order digit of its (R-1)'s complement Example - 10's complement of 835 10 is 164 10 + 1 = 165 10 - 2's complement of 1010 2 is 0101 2 + 1 = 0110 2
6
FIXED POINT NUMBERS Binary Fixed-Point Representation X = x n x n-1 x n-2... x 1 x 0. x -1 x -2... x -m Sign Bit(x n ): 0 for positive - 1 for negative Remaining Bits(x n-1 x n-2... x 1 x 0. x -1 x -2... x -m ) Numbers:Fixed Point Numbers and Floating Point Numbers
7
SIGNED NUMBERS Signed magnitude representation Signed 1's complement representation Signed 2's complement representation Example: Represent +9 and -9 in 7 bit-binary number Only one way to represent +9 ==> 0 001001 Three different ways to represent -9: In signed-magnitude: 1 001001 In signed-1's complement: 1 110110 In signed-2's complement: 1 110111 In general, in computers, fixed point numbers are represented either integer part only or fractional part only. Need to be able to represent both positive and negative numbers - Following 3 representations
8
ARITHMETIC ADDITION: SIGNED MAGNITUDE [1] Compare their signs [2] If two signs are the same, ADD the two magnitudes - Look out for an overflow [3] If not the same, compare the relative magnitudes of the numbers and then SUBTRACT the smaller from the larger --> need a subtractor to add [4] Determine the sign of the result 6 0110 +) 9 1001 15 1111 -> 01111 9 1001 - ) 6 0110 3 0011 -> 00011 9 1001 -) 6 0110 - 3 0011 -> 10011 6 0110 +) 9 1001 -15 1111 -> 11111 6 + 9 -6 + 9 6 + (- 9) -6 + (-9) Overflow 9 + 9 or (-9) + (-9) 9 1001 +) 9 1001 (1)0010 overflow Fixed Point Representations
9
ARITHMETIC ADDITION: SIGNED 2’s COMPLEMENT Example 6 0 0110 9 0 1001 15 0 1111 -6 1 1010 9 0 1001 3 0 0011 6 0 0110 -9 1 0111 -3 1 1101 -9 1 0111 -18 (1)0 1110 Add the two numbers, including their sign bit, and discard any carry out of leftmost (sign) bit - Look out for an overflow overflow 9 0 1001 +) 18 1 0010 2 operands have the same sign and the result sign changes x n-1 y n-1 s’ n-1 + x’ n-1 y’ n-1 s n-1 = c n-1 c n x’ n-1 y’ n-1 s n-1 (c n-1 c n ) x n-1 y n s’ n-1 (c n-1 c n ) Fixed Point Representations
10
ARITHMETIC ADDITION: SIGNED 1’s COMPLEMENT Add the two numbers, including their sign bits. - If there is a carry out of the most significant (sign) bit, the result is incremented by 1 and the carry is discarded. 6 0 0110 -9 1 0110 -3 1 1100 -6 1 1001 9 0 1001 (1) 0(1)0010 1 3 0 0011 +) end-around carry -9 1 0110 (1)0 1100 1 0 1101 +) 9 0 1001 1 (1)0010 +) overflow Example not overflow (c n-1 c n ) = 0 (c n-1 c n ) Fixed Point Representations
11
FLOATING POINT NUMBER REPRESENTATION * The location of the fractional point is not fixed to a certain location * The range of the representable numbers is wide F = EM m n e k e k-1... e 0 m n-1 m n-2 … m 0. m -1 … m -m sign exponent mantissa - Mantissa Signed fixed point number, either an integer or a fractional number - Exponent Designates the position of the radix point Decimal Value V(F) = V(M) * R V(E) M: Mantissa E: Exponent R: Radix Floating Point Representation
12
FLOATING POINT NUMBERS 0.1234567004 sign mantissaexponent ==> +.1234567 x 10 +04 Example A binary number +1001.11 in 16-bit floating point number representation (6-bit exponent and 10-bit fractional mantissa) 0 0 00100 100111000 0 0 00101 010011100 Example Note: In Floating Point Number representation, only Mantissa(M) and Exponent(E) are explicitly represented. The Radix(R) and the position of the Radix Point are implied. ExponentMantissaSign or Floating Point Representation
13
IEEE Standard for FLOATING POINT NUMBERS To represent IEEE standard for floating-point numbers is called IEEE floating-point. This standard specifies how single precision (32 bit) and double precision (64 bit) floating point numbers are to be represented. It is divided in two formats as follows: 1. Single Precision: The IEEE single precision floating point standard representation requires a 32 bit word, which may be represented as numbered from 0 to 31, left to right. The first bit is the sign bit, S, the next eight bits are the exponent bits, 'E', and the final 23 bits are the fraction 'F': S EEEEEEEE FFFFFFFFFFFFFFFFFFFFFFF 0 1 8 9 31
14
The value V represented by the word may be determined as follows: If E=255 and F is nonzero, then V=NaN ("Not a number") If E=255 and F is zero and S is 1, then V=-Infinity If E=255 and F is zero and S is 0, then V=Infinity If 0<E<255 then V=(-1)**S * 2 ** (E-127) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-126) * (0.F) These are "unnormalized" values. If E=0 and F is zero and S is 1, then V=-0 If E=0 and F is zero and S is 0, then V=0 In particular, 0 00000000 00000000000000000000000 = 0 1 00000000 00000000000000000000000 = -0 0 11111111 00000000000000000000000 = Infinity 1 11111111 00000000000000000000000 = -Infinity 0 11111111 00000100000000000000000 = NaN 1 11111111 00100010001001010101010 = NaN 0 10000000 00000000000000000000000 = +1 * 2**(128-127) * 1.0 = 2 0 10000001 10100000000000000000000 = +1 * 2**(129-127) * 1.101 = 6.5 1 10000001 10100000000000000000000 = -1 * 2**(129-127) * 1.101 = -6.5 0 00000001 00000000000000000000000 = +1 * 2**(1-127) * 1.0 = 2**(-126) 0 00000000 10000000000000000000000 = +1 * 2**(-126) * 0.1 = 2**(-127) 0 00000000 00000000000000000000001 = +1 * 2**(-126) * 0.00000000000000000000001 = 2**(- 149) (Smallest positive value)
15
Double Precision The IEEE double precision floating point standard representation requires a 64 bit word, which may be represented as numbered from 0 to 63, left to right. The first bit is the sign bit, S, the next eleven bits are the exponent bits, 'E', and the final 52 bits are the fraction 'F': S EEEEEEEEEEE FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 0 1 11 12 63 The value V represented by the word may be determined as follows: If E=2047 and F is nonzero, then V=NaN ("Not a number") If E=2047 and F is zero and S is 1, then V=-Infinity If E=2047 and F is zero and S is 0, then V=Infinity If 0<E<2047 then V=(-1)**S * 2 ** (E-1023) * (1.F) where "1.F" is intended to represent the binary number created by prefixing F with an implicit leading 1 and a binary point. If E=0 and F is nonzero, then V=(-1)**S * 2 ** (-1022) * (0.F) These are "unnormalized" values. If E=0 and F is zero and S is 1, then V=-0 If E=0 and F is zero and S is 0, then V=0
16
Example of Single Precision Format Ex-1 Represent a binary positive number 1101011 in the IEEE aingle-precision format. The binary positive number 1101011= + 1.101011 X 2^6 The 23-bit mantissa M= 0.101011 000000 000000 00000 The biased exponent E’= E+ 127 = 6+127=133 = 1000 0101 The sign bit S=0, since the number is positive. So 32-bit representation is Ex-2 Represent the decimal number -0.75 in the IEEE single-precision format. The decimal number -0.75= - 0.11 in binary= - 1.1X2^(-1) The 23-bit mantissa M= 0.100000 000000 000000 00000 The biased exponent E’= E+127= -1+127=126=0111 1110 Since the number is negative, the sign bit S=1 0 1000 0101101011 000000 000000 00000 00111 1110100000 000000 000000 00000
17
17 Algorithms for Multiplication (Manual Method) 1101 Multiplicand M X 1011 Multiplier Q 1101 0000 1101____ 10001111 Product P Partial product
18
18 4) Algorithms for Multiplication Multiplicand Multiplier Product
19
Sequential Multiplication Method for Unsigned Number START A=0; F=0, Q= Multiplier M=Multiplicand, size=n Q[0]=1? A=A+M Right Shift(FAQ) Size=size-1 Size=0? Product=AQ End Yes No F=flip-flop holds the end carry generated in the addition
20
Illustration of Sequential Multiplication Method Multiplier Q=14=1110 and multiplicand M=6=0110 Initial Config M F A Q Size Step 1,Q[0] =0 0110 0 0000 0111 3 R.S(FAQ) Step 2,Q[0] =1 0110 0 0110 0111 A=A+M, R.S(FAQ) 0110 0 0011 0011 2 Step3,Q[0] =1 A=A+M, R.S(FAQ) 0110 0 1001 0011 1 0110 0 0100 1001 Step4,Q[0] =1 0110 0 1010 1001 0 A=A+M, R.S(FAQ) 0110 0 0101 0100 Product= AQ= 0101 0100 =84
21
Booth’s Multiplication Method (for signed numbers) START A=0; Q[-1]=0, Q= Multiplier M=Multiplicand, size=n Q[0]=0? and Q[- 1]=1 A=A-M Right Shift(AQ) Size=size-1 Size=0? Product=AQ End No Q[0]=1 and Q[- 1]=0 A=A+M Yes No
22
Illustration of Booth’s Algorithm Multiplier Q=7=0111 and multiplicand M= --6 = 1010(as negetive results are automatically in 2’s complement form). [A flip-flop (a fictitious bit position)is used to the right of lsb of the multiplier and it is initialized to 0] Initial Config M A Q Size Step 1,Q[0] =0 1010 0000 0111 0 4 R.S(FAQ) Step 2,Q[0] =1,Q[-1] =0 1010 0110 0111 0 A=A-M, R.S(AQ) 1010 0011 0011 1 3 Step3,Q[0] =1 A=A+M, R.S(AQ) 1010 0001 1001 1 2 Step4,Q[0] =1 1010 0000 1100 1 1 A=A+M, R.S(AQ) Step5,Q[0] =1 1010 1010 1100 1 0 A=A+M, R.S(AQ) 1010 1101 0110 0 Product= AQ= 1101 0110, it shows that the product is negative number so to get the number in familiar form we take 2’s complement of magnitude. The result is -42
23
Division Algorithm START A=0; F=0, Q= Dividend M=Divisor, size=n Sign of A=0? A=A+M Q[0] =1 Size=size-1 Size=0? quotient=Q, Remainder=A End No Left shift(AQ) A=A-M Q[0]=0 No Yes
24
Illustration of Restoring division Algorithm dividend Q=7=0111 and divisor M= 3 =0011 Initial Config M A Q Size 00011 00000 0111 4 Step 1 LS(AQ) 00011 00000 111- __ A=A-M 00011 11101 111- __ Sign of A=-ve Set Q[0]=0 & Restore A by (A+M) 00011 00000 1110 3 Step 2 LS(AQ) 00011 00001 110- __ A=A-M, 00011 11110 110- __ As sign of A=-ve Set Q[0]=0 Restore A 00011 00001 1100 2 Step3 LS(AQ) 00011 00011 100- __ A=A-M, 00011 00000 100- __ As sign of A=+ve Set Q[0]=0 00011 00000 1001 1
25
Restoring Division Algorithm M A Q Size Step4 LS(AQ) 00011 00001 001- __ A=A-M, 00011 11110 001- __ As sign of A=+ve Set Q[0]=0 Restore A 00011 00001 0010 0 RESULT : Quotient = Q = 0010 Remainder = A = 00001 = 1
26
Illustration of Non-Restoring division Algorithm dividend Q=7=0111 and divisor M= 3 =0011 Initial Config M A Q Size 00011 00000 0111 4 Step 1 As sign of A=+ve LS(AQ) 00011 00000 111- __ A=A-M 00011 11101 111- __ As sign of A=-ve Set Q[0]=0 00011 11101 1110 3 Step 2 As sign of A=-ve LS(AQ) 00011 11011 110- __ A=A+M, 00011 11110 110- __ As sign of A=-ve Set Q[0]=0 00011 00001 1100 2
27
Non-restoring Division Algorithm M A Q Size Step3 As sign of A=-ve LS(AQ) 00011 11101 100- __ A=A+M, 00011 00000 100- __ As sign of A=+ve Set Q[0]=1 00011 00000 1001 1 Step4 As sign of A=+ve LS(AQ) 00011 00001 001- __ A=A-M, 00011 11110 001- __ As sign of A=-ve Set Q[0]=0 00011 00001 0010 0 RESULT : Quotient = Q = 0010 Remainder = A = 00001 = 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.