Unit-Ii Central Processing Unit

Unit-Ii Central Processing Unit

UNIT‐II CENTRAL PROCESSING UNIT •INTODUCTION •ARITHMETIC LOGIC UNIT •FIXED POINT ARITHMETIC •FLOATING POINT ARITHMETIC •EXECUTION OF A COMPLETE INSTRUCTION •BASIC CONCEPTS OF PIPELINING Slides Courtesy of Carl Hamacher,”Computer Organization,” Fifth edition,McGrawHill The arithmetic logic unit (ALU) The central processing unit (CPU) performs operations on data. In most architectures it has three parts: an arithmetic logic unit (ALU), a control unit and a set of registers, fast storage locations (Figure ). Figure Central processing unit (CPU) Data Representation • The basic form of information handled by a computer are instructions and data • Data can be in the form of numbers or nonnumeric data • Data in the number form can further classified as fixed point and floating point Digit Sets and Encodings Conventional and unconventional digit sets • Decimal digits in [0, 9]; 4-bit BCD, 8-bit ASCII • Hexadecimal, or hex for short: digits 0-9 & a-f • Conventional digit set for radix r is [0, r –1] • Conventional binary digit set in [0, 1] Positional Number Systems Representations of natural numbers {0, 1, 2, 3, …} ||||| ||||| ||||| ||||| ||||| || sticks or unary code 27 radix-10 or decimal code 11011 radix-2 or binary code XXVII Roman numerals Fixed-radix positional representation with k digits k–1 i Value of a number: x =(xk–1xk–2 ...x1x0)r = Σ xi r i=0 For example: 4 3 2 1 0 27 = (11011)two =(1×2 )+(1×2 )+(0×2 )+(1×2 )+(1×2 ) Fixed Point Representation • Fixed point number actually symbolizes the real data types. • As radix point is fixed ,the number system is fixed point number system • Fixed point numbers are those which have a defined numbers after and before the decimal point. Fixed‐Point Numbers Positional representation: k whole and l fractional digits i Value of a number: x = (xk–1xk–2 . x1x0 . x–1x–2 . x–l )r = Σ xi r For example: 1 0 −1 −2 −3 2.375 = (10.011)two =(1×2 )+(0×2 )+(0×2 )+(1×2 )+(1×2 ) Numbers in the range [0, rk – ulp] representable, where ulp = r –l Fixed-point arithmetic same as integer arithmetic (radix point implied, not explicit) Two’s complement properties (including sign change) hold here as well: 1 0 –1 –2 –3 (01.011)2’s-compl =(–0×2 )+(1×2 )+(0×2 )+(1×2 )+(1×2 )=+1.375 1 0 –1 –2 –3 (11.011)2’s-compl =(–1×2 )+(1×2 )+(0×2 )+(1×2 )+(1×2 )=–0.625 Unsigned Integer • Unsigned integers represent positive numbers • The decimal range of unsigned 8‐bit binary numbers is 0 ‐ 255 Unsigned Binary Integers 0000 1111 0001 Turn x notches counterclockwise 0 1110 15 1 0010 to add x 14 2 1101 0011 15 1 13 3 14 2 0 Inside: Natural number 13 3 1100 12 Outside: 4-bit encoding 4 0100 12 4 11 5 10 11 5 6 1011 0101 9 8 7 10 6 1010 9 7 0110 Turn y notches 8 clockwise 1001 0111 to subtract y 1000 Schematic representation of 4-bit code for integers in [0, 15]. Signed Integers • We dealt with representing the natural numbers • Signed or directed whole numbers = integers {...,−3, −2, −1, 0, 1, 2, 3, . } •Signed magnitude for 8 bit numbers ranges from +127 to -127 • Signed-magnitude representation +27 in 8-bit signed-magnitude binary code 0 0011011 –27 in 8-bit signed-magnitude binary code 1 0011011 –27 in 2-digit decimal code with BCD digits 1 0010 0111 Introduction to Fixed Point Arithmetic • Using fixed point numbers to simulate floating point numbers • Fixed point processor is usually cheaper Addition Subtraction A Serial Multiplier Example of Multiplication Using Serial Multiplier Serial Divider Division Example Using Serial Divider Floating‐Point Numbers To accommodate very large integers and very small fractions, a computer must be able to represent numbers and operate on them in such a way that the position of the binary point is variable and is automatically adjusted as computation proceeds. • Floating-point representation is like scientific notation: −20 000 000 = −2 × 10 7 0.000 000 007 = 7 × 10–9 Also, 7E−9 Significand Exponent Exponent base Floating‐point Computations • Representation: (fraction, exponent) Has three fields: sign, significant digits and exponent eg.111101.100110 1.11101100110*25 • Value representation = +/‐ M*2 E’‐127 In case of a 32 bit number 1 bit represents sign 8 bits represents exponent E’=E +127(bias) [ excess 127 format] 23 bits represents Mantissa Floating‐point Computations • Arithmetic operations .5372400 x 102 .5372400 x 102 .56780 x 105 + .1580000 x 10-1 + .0001580 x 102 + .56430 x 105 .5373980 x 102 .00350 x 105 .35000 x 103 .5372400 x 102 x .1580000 x 10-1 Addition Floating‐point Computations • Biased Exponent – Bias: an excess number added to the exponent so that all exponents become positive – Advantages • Only positive exponents • Simpler to compare the relative magnitude Floating‐point Computations • Standard Operand Format of floating‐point numbers – Single‐precision data type: 32bits • ADDFS – Double‐precision data type: 64bits • ADDFL IEEE Floating-Point Operand Format Floating‐point Computations • Significand – A leading bit to the left of the implied binary point, together with the fraction in the field f field Significand Decimal Equivalent 100…0 1.100…0 1.50 010…0 1.010…0 1.25 000…0 1.000…0 1.00 s ~ ~ Minimum number 01000..000 Maximum number ANSI/IEEE Standard Floating‐Point Format (IEEE 754) Revision (IEEE 754R) is being considered by a committee Short exponent range is –127 to 128 Short (32-bit) format but the two extreme values are reserved for special operands (similarly for the long format) 8 bits, 23 bits for fractional part bias = 127, (plus hidden 1 in integer part) –126 to 127 Sign Exponent Significand 11 bits, bias = 1023, 52 bits for fractional part –1022 to 1023 (plus hidden 1 in integer part) Long (64-bit) format The two ANSI/IEEE standard floating-point formats. Short and Long IEEE 754 Formats: Features Table Some features of ANSI/IEEE standard floating-point formats Feature Single/Short Double/Long Word width in bits 32 64 Significand in bits 23 + 1 hidden 52 + 1 hidden Significand range [1, 2 – 2–23] [1,2–2–52] Exponent bits 8 11 Exponent bias 127 1023 Zero (±0) e +bias=0,f =0 e +bias=0,f =0 Denormal e +bias=0,f ≠ 0 e +bias=0,f ≠ 0 represents ±0.f × 2–126 represents ±0.f × 2–1022 Infinity (±∞) e + bias = 255, f =0 e + bias = 2047, f =0 Not-a-number (NaN) e + bias = 255, f ≠ 0 e + bias = 2047, f ≠ 0 Ordinary number e +bias∈ [1, 254] e +bias∈ [1, 2046] e ∈ [–126, 127] e ∈ [–1022, 1023] represents 1.f × 2e represents 1.f × 2e min 2–126 ≅ 1.2 × 10–38 2–1022 ≅ 2.2 × 10–308 max ≅ 2128 ≅ 3.4 × 1038 ≅ 21024 ≅ 1.8 × 10308 Floating Point Arithmetic • Floating point arithmetic differs from integer arithmetic in that exponents must be handled as well as the magnitudes of the operands. • The exponents of the operands must be made equal for addition and subtraction. The fractions are then added or subtracted as appropriate, and the result is normalized. 3 4 • Eg: Perform the floating point operation:(.101*2 +.111*2 )2 • Start by adjusting the smaller exponent to be equal to the larger exponent, and adjust the fraction accordingly. Thus we have .101* 23 = .010 *24, losing .001 *23 of precision in the process. • The resulting sum is (.010 +.111)*24 =1.001*24 =.1001* 25, and rounding to three significant digits, .100 *25, and we have lost another 0.001 *24 in the rounding process. Floating Point Multiplication/Division • Floating point multiplication/division are performed in a manner similar to floating point addition/subtraction, except that the sign, exponent, and fraction of the result can be computed separately. • Like/unlike signs produce positive/negative results, respectively. Exponent of result is obtained by adding exponents for multiplication, or by subtracting exponents for division. Fractions are multiplied or divided according to the operation, and then normalized. 5 4 • Ex: Perform the floating point operation: (+.110 *2 )/(+.100* 2 )2 • The source operand signs are the same, which means that the result will have a positive sign. We subtract exponents for division, and so the exponent of the result is 5 – 4 = 1. • We divide fractions, producing the result: 110/100 = 1.10. • Putting it all together, the result of dividing (+.110 *25) by (+.100 * 24) produces (+1.10* 21). After normalization, the final result is (+.110* 22). Floating point Arithmetic • Represent binary number in floating point format • 10011101011.001=1.0011101011001*210 • In single precision format sign =0,exponent =e+127 =10+127=137=10001001 • 0 1000 1001 0011101011001…0 Floating Point Addition • A= 0 1000 1001 0010000…0 • B= 0 1000 0101 0100000…0 • Exponent for A=1000 1001+137 • Actual Exponent =137‐127=10 • Exponent B =1000 0101=133 • Actual exponent=133‐127=6 • Number B has smaller exponent with difference 4 .Hence its mantissa is shifted right by 4 bits • Shifted mantissa of B= 00000100..0 • Add mantissas • A =00100000…0 • B =00000100…0 • Result=00100100…0 • Result = 0 1000 1001 00100100…0 Adders and Simple ALUs Addition is the most important arithmetic operation in computers: – Even the simplest computers must have an adder – An adder, plus a little extra logic, forms a simple ALU • Simple Adders • Carry Lookahead Adder • Counting and Incrementing • Design of Fast Adders • Logic and Shift Operations • Multifunction ALUs Simple Adders Inputs Outputs x y x y c s c 0 0 0 0 HA 0 1 0 1 1 0 0 1 1 1 1 0 s Inputs Outputs x y c in cout s x y 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 FA 0 1 1 1 0 cout cin 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1 s Binary half-adder (HA) and full-adder (FA).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    78 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us