figure 1.1 block diagram of a digital computer. functional units

27
Figure 1.1 Block diagram of a digital computer. Functional Units

Upload: annabella-phelps

Post on 01-Jan-2016

284 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Figure 1.1 Block diagram of a digital computer. Functional Units

Figure 1.1 Block diagram of a digital computer.

Functional Units

Page 2: Figure 1.1 Block diagram of a digital computer. Functional Units

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 11 2 7 5 4 3

A F 6 3

OctalBinaryHexa

Page 3: Figure 1.1 Block diagram of a digital computer. Functional Units

CONVERSION OF BASES

Decimal to Base R number

Base R to Decimal Conversion

V(A) = akRk

A = an-1 an-2 an-3 … a0 . a-1 … a-m

(736.4)8 = 7 x 82 + 3 x 81 + 6 x 80 + 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

Page 4: Figure 1.1 Block diagram of a digital computer. Functional Units

EXAMPLE

Convert 41.687510 to base 2.

Integer = 414120 110 0 5 0 2 1 1 0 0 1

Fraction = 0.68750.6875x 21.3750x 20.7500x 21.5000 x 21.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

Page 5: Figure 1.1 Block diagram of a digital computer. Functional Units

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 83510 is 16410

- 1's complement of 10102 is 01012(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 83510 is 16410 + 1 = 16510

- 2's complement of 10102 is 01012 + 1 = 01102

Page 6: Figure 1.1 Block diagram of a digital computer. Functional Units

FIXED POINT NUMBERS

Binary Fixed-Point Representation

X = xnxn-1xn-2 ... x1x0. x-1x-2 ... x-m

Sign Bit(xn): 0 for positive - 1 for negative

Remaining Bits(xn-1xn-2 ... x1x0. x-1x-2 ... x-m)

Numbers: Fixed Point Numbers and Floating Point Numbers

Page 7: Figure 1.1 Block diagram of a digital computer. Functional Units

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

Page 8: Figure 1.1 Block diagram of a digital computer. Functional Units

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)0010overflow

Fixed Point Representations

Page 9: Figure 1.1 Block diagram of a digital computer. Functional Units

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 -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

overflow9 0 10019 0 1001+)

+) +)

+) +)

18 1 00102 operands have the same signand the result sign changes

xn-1yn-1s’n-1 + x’n-1y’n-1sn-1 = cn-1 cn

x’n-1y’n-1sn-1

(cn-1 cn)

xn-1yn s’n-1

(cn-1 cn)

Fixed Point Representations

Page 10: Figure 1.1 Block diagram of a digital computer. Functional Units

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-9 1 0110 (1)0 1100 1 0 1101

+)

+)

9 0 10019 0 1001 1 (1)0010

+)

overflow

Example

not overflow (cn-1 cn) = 0

(cn-1 cn)

Fixed Point Representations

Page 11: Figure 1.1 Block diagram of a digital computer. Functional Units

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

mn ekek-1 ... e0 mn-1mn-2 … m0 . 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) * RV(E) M: MantissaE: ExponentR: Radix

Floating Point Representation

Page 12: Figure 1.1 Block diagram of a digital computer. Functional Units

FLOATING POINT NUMBERS

0 .1234567 0 04sign sign

mantissa exponent==> +.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.

Exponent MantissaSignor

Floating Point Representation

Page 13: Figure 1.1 Block diagram of a digital computer. Functional Units

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

Page 14: Figure 1.1 Block diagram of a digital computer. Functional Units

• 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)

Page 15: Figure 1.1 Block diagram of a digital computer. Functional Units

• 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

Page 16: Figure 1.1 Block diagram of a digital computer. Functional Units

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 0101 101011 000000 000000 00000

0 0111 1110 100000 000000 000000 00000

Page 17: Figure 1.1 Block diagram of a digital computer. Functional Units

17

Algorithms for Multiplication (Manual Method)

1101 Multiplicand M

X 1011 Multiplier Q

1101

1101

0000

1101____

10001111 Product P

Partial product

Page 18: Figure 1.1 Block diagram of a digital computer. Functional Units

18

4) Algorithms for Multiplication

Multiplicand

Multiplier

Product

Page 19: Figure 1.1 Block diagram of a digital computer. Functional Units

Sequential Multiplication Method for Unsigned Number

START

A=0; F=0, Q= MultiplierM=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

Page 20: Figure 1.1 Block diagram of a digital computer. Functional Units

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

Page 21: Figure 1.1 Block diagram of a digital computer. Functional Units

Booth’s Multiplication Method (for signed numbers) START

A=0; Q[-1]=0, Q= MultiplierM=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

Yes

Yes

No

No

Page 22: Figure 1.1 Block diagram of a digital computer. Functional Units

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

Page 23: Figure 1.1 Block diagram of a digital computer. Functional Units

Division Algorithm

START

A=0; F=0, Q= DividendM=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

Page 24: Figure 1.1 Block diagram of a digital computer. Functional Units

Illustration of Restoring division Algorithmdividend 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

Page 25: Figure 1.1 Block diagram of a digital computer. Functional Units

Restoring Division Algorithm

M A Q Size

Step4LS(AQ) 00011 00001 001- __ A=A-M, 00011 11110 001- __As sign of A=+veSet Q[0]=0 Restore A 00011 00001 0010 0

RESULT :

Quotient = Q = 0010

Remainder = A = 00001 = 1

Page 26: Figure 1.1 Block diagram of a digital computer. Functional Units

Illustration of Non-Restoring division Algorithmdividend 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

Page 27: Figure 1.1 Block diagram of a digital computer. Functional Units

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=+veLS(AQ) 00011 00001 001- __ A=A-M, 00011 11110 001- __As sign of A=-veSet Q[0]=0 00011 00001 0010 0

RESULT : Quotient = Q = 0010Remainder = A = 00001 = 1