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

Slides:



Advertisements
Similar presentations
Binary Arithmetic Binary addition Binary subtraction
Advertisements

Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
1 IEEE Floating Point Revision Guide for Phase Test Week 5.
COMP3221: Microprocessors and Embedded Systems Lecture 14: Floating Point Numbers Lecturer: Hui Wu Session 2, 2004.
CHAPTER 2 Number Systems, Operations, and Codes
CS 447 – Computer Architecture Lecture 3 Computer Arithmetic (2)
Computer ArchitectureFall 2007 © September 5, 2007 Karem Sakallah CS 447 – Computer Architecture.
Major Numeric Data Types Unsigned Integers Signed Integer Alphanumeric Data – ASCII & UNICODE Floating Point Numbers.
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
Floating Point Numbers
1 Module 2: Floating-Point Representation. 2 Floating Point Numbers ■ Significant x base exponent ■ Example:
Floating Point Numbers
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
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.
Simple Data Type Representation and conversion of numbers
1 Data Representation Computer Organization Prof. H. Yoon DATA REPRESENTATION Data Types Complements Fixed Point Representations Floating Point Representations.
Data Representation – Binary Numbers
Binary Real Numbers. Introduction Computers must be able to represent real numbers (numbers w/ fractions) Two different ways:  Fixed-point  Floating-point.
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.
Eng. Mohammed Timraz Electronics & Communication Engineer University of Palestine Faculty of Engineering and Urban planning Software Engineering Department.
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.
Data Representation Dr. Ahmed El-Bialy Dr. Sahar Fawzy.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
CSC 221 Computer Organization and Assembly Language
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.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Lecture notes Reading: Section 3.4, 3.5, 3.6 Multiplication
Integer and Fixed Point P & H: Chapter 3
Number Systems & Operations
Computing Machinery Chapter 6: Computer Arithmetic.
Computer Architecture Lecture 11 Arithmetic Ralph Grishman Oct NYU.
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.
Fixed-point and floating-point numbers Ellen Spertus MCS 111 October 4, 2001.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
DATA REPRESENTATION Data Types Complements Fixed Point Representations
Computer Arithmetic. Integer Representation Sign-magnitude representation ’s complement representation magnitudes
Chapter 9 Computer Arithmetic
William Stallings Computer Organization and Architecture 8th Edition
Floating Point Representations
Overview Introduction Data representation Fixed Point Representation
Integer Division.
Chapter 2 Data Types and Representations
IEEE floating point format
William Stallings Computer Organization and Architecture 7th Edition
Number Representations
Data Representation Data Types Complements Fixed Point Representation
Data Representation in Computer Systems
ECEG-3202 Computer Architecture and Organization
Chapter 8 Computer Arithmetic
Chapter 6: Computer Arithmetic
Overview Fractions & Sign Extension Floating Point Representations
Number Representations
Lecture 9: Shift, Mult, Div Fixed & Floating Point
Presentation transcript:

Figure 1.1 Block diagram of a digital computer. Functional Units

REPRESENTATION OF NUMBERS - POSITIONAL NUMBERS Decimal Binary Octal Hexadecimal A B C D E F Binary, octal, and hexadecimal conversion A F 6 3 Octal Binary Hexa

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 x x x 8 -1 = 7 x x x 1 + 4/8 = (478.5) 10 (110110) 2 =... = (54) 10 ( ) 2 =... = (6.785) 10 (F3) 16 =... = (243) 10 (0.325) 6 =... = ( ) 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

EXAMPLE Convert to base 2. Integer = Fraction = x x x x (41) 10 = (101001) 2 (0.6875) 10 = (0.1011) 2 ( ) 10 = ( ) 2 Convert (63) 10 to base 5: (223) 5 Convert (1863) 10 to base 8: (3507) 8 Convert ( ) 10 to hexadecimal: (0.A3) 16 Exercise

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 is 's complement of is (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 is = 's complement of is =

FIXED POINT NUMBERS Binary Fixed-Point Representation X = x n x n-1 x n-2... x 1 x 0. x -1 x 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 x -m ) Numbers:Fixed Point Numbers and Floating Point Numbers

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 ==> Three different ways to represent -9: In signed-magnitude: In signed-1's complement: In signed-2's complement: 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

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 ) > ) > ) > ) > (- 9) -6 + (-9) Overflow or (-9) + (-9) ) (1)0010 overflow Fixed Point Representations

ARITHMETIC ADDITION: SIGNED 2’s COMPLEMENT Example (1) Add the two numbers, including their sign bit, and discard any carry out of leftmost (sign) bit - Look out for an overflow overflow ) 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

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 (1) 0(1) ) end-around carry (1) ) (1)0010 +) overflow Example not overflow (c n-1  c n ) = 0 (c n-1  c n ) Fixed Point Representations

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

FLOATING POINT NUMBERS sign mantissaexponent ==> x Example A binary number in 16-bit floating point number representation (6-bit exponent and 10-bit fractional mantissa) 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

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

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, = = = Infinity = -Infinity = NaN = NaN = +1 * 2**( ) * 1.0 = = +1 * 2**( ) * = = -1 * 2**( ) * = = +1 * 2**(1-127) * 1.0 = 2**(-126) = +1 * 2**(-126) * 0.1 = 2**(-127) = +1 * 2**(-126) * = 2**(- 149) (Smallest positive value)

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

Example of Single Precision Format Ex-1 Represent a binary positive number in the IEEE aingle-precision format. The binary positive number = X 2^6 The 23-bit mantissa M= The biased exponent E’= E+ 127 = 6+127=133 = The sign bit S=0, since the number is positive. So 32-bit representation is Ex-2 Represent the decimal number in the IEEE single-precision format. The decimal number -0.75= in binary= - 1.1X2^(-1) The 23-bit mantissa M= The biased exponent E’= E+127= =126= Since the number is negative, the sign bit S=

17 Algorithms for Multiplication (Manual Method) 1101 Multiplicand M X 1011 Multiplier Q ____ Product P Partial product

18 4) Algorithms for Multiplication Multiplicand Multiplier Product

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

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] = R.S(FAQ) Step 2,Q[0] = A=A+M, R.S(FAQ) Step3,Q[0] =1 A=A+M, R.S(FAQ) Step4,Q[0] = A=A+M, R.S(FAQ) Product= AQ= =84

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

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] = R.S(FAQ) Step 2,Q[0] =1,Q[-1] = A=A-M, R.S(AQ) Step3,Q[0] =1 A=A+M, R.S(AQ) Step4,Q[0] = A=A+M, R.S(AQ) Step5,Q[0] = A=A+M, R.S(AQ) Product= AQ= , 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

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

Illustration of Restoring division Algorithm dividend Q=7=0111 and divisor M= 3 =0011 Initial Config M A Q Size Step 1 LS(AQ) __ A=A-M __ Sign of A=-ve Set Q[0]=0 & Restore A by (A+M) Step 2 LS(AQ) __ A=A-M, __ As sign of A=-ve Set Q[0]=0 Restore A Step3 LS(AQ) __ A=A-M, __ As sign of A=+ve Set Q[0]=

Restoring Division Algorithm M A Q Size Step4 LS(AQ) __ A=A-M, __ As sign of A=+ve Set Q[0]=0 Restore A RESULT : Quotient = Q = 0010 Remainder = A = = 1

Illustration of Non-Restoring division Algorithm dividend Q=7=0111 and divisor M= 3 =0011 Initial Config M A Q Size Step 1 As sign of A=+ve LS(AQ) __ A=A-M __ As sign of A=-ve Set Q[0]= Step 2 As sign of A=-ve LS(AQ) __ A=A+M, __ As sign of A=-ve Set Q[0]=

Non-restoring Division Algorithm M A Q Size Step3 As sign of A=-ve LS(AQ) __ A=A+M, __ As sign of A=+ve Set Q[0]= Step4 As sign of A=+ve LS(AQ) __ A=A-M, __ As sign of A=-ve Set Q[0]= RESULT : Quotient = Q = 0010 Remainder = A = = 1