ECE 8053 Introduction to Computer Arithmetic (Website: Course & Text Content: Part 1: Number...

21
ECE 8053 Introduction to Computer Arithmetic e: http://www.ece.msstate.edu/classes/ece8053/fall_ Course & Text Content: Part 1: Number Representation Part 2: Addition/Subtraction Part 3: Multiplication Part 4: Division Part 5: Real Arithmetic (Floating-Point) Part 6: Function Evaluation Part 7: Implementation Topics

Transcript of ECE 8053 Introduction to Computer Arithmetic (Website: Course & Text Content: Part 1: Number...

Page 1: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

ECE 8053 Introduction to Computer Arithmetic

(Website: http://www.ece.msstate.edu/classes/ece8053/fall_2002/)

Course & Text Content:Part 1: Number RepresentationPart 2: Addition/SubtractionPart 3: MultiplicationPart 4: DivisionPart 5: Real Arithmetic (Floating-Point)Part 6: Function EvaluationPart 7: Implementation Topics

Page 2: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Course Learning ObjectivesComputer Arithmetic students will be able to ...

1. explain the relative merits of number systems used by arithmetic circuits including both fixed- and floating-point number systems

2. demonstrate the use of key acceleration algorithms and hardware for addition/subtraction, multiplication, and division, plus certain functions

3. distinguish between the relative theoretical merits of the different acceleration schemes

Page 3: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Course Learning Objectives(Continued)

4. identify the implementation limitations constraining the speed of acceleration schemes

5. evaluate, design, and optimize arithmetic circuits for low-power

6. evaluate, design, and optimize arithmetic circuits for precision

Page 4: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Course Learning Objectives(Continued)

7. design, simulate, and evaluate an arithmetic circuit using appropriate references including current journal and conference literature

8. write a paper compatible with journal format standards on an arithmetic design

9. make a professional presentation with strong technical content and audience interaction

Page 5: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Importance of Computer Arithmetic1.7GHz Pentium has a clock cycle of 0.59 ns1 integer addition < 0.59 ns in execution stage of P/L

Assume a 4-bit adder – ripple carry, 0.2 ns gate delay

STEP 11101

1110 11011

-Note: added from right to left. Why?

Page 6: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Ripple-carry Structure

STEP 2 – Design a circuit

z4 z3 z2 z1 z0

c4 c3 c3 c3 c0=0

x3 y3 x2 y2 x1 y1 x0 y0

– Each box is a full-adder– Implement it

Page 7: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Full Adder Implementationx y cin z cout 0 0 0 0 0 0 0 1 1 0 0 1 0 1 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 0 0 1 1 1 1 1 1

xy

cin

00 01 11 10

0

1

0 1 0 1

1 0 1 0

xy

cin

00 01 11 10

0

1

0 0 1 0

0 1 1 1

in in in in

in

z c x y c x y c x y c x y

c x y

( )out inc c x y xy

Page 8: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Adder Circuit Analysis

STEP 3 – Analysis

Critical Path is 3 gates34=12(12)(0.2ns)=2.4ns2.4ns > 0.59nsMust Use Faster Adder!!!!

Page 9: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Roman Numeral SystemSymbolic Digitssymbol value

I 1 V 5 X 10 L 50 C 100 D 500 M 1000

RULES:• If symbol is repeated or lies to the right of another higher-valued symbol, value is additive XX=10+10=20 CXX=100+10+10=120• If symbol is repeated or lies to the left of a higher-valued symbol, value is subtractive XXC = - (10+10) + 100 = 80 XLVIII = -(10) + 50 + 5 + 3 = 48

Page 10: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Weighted Positional Number System

Example: Arabic Number System (first used by Chinese)

symbol (digit)

value (in 1’s position)

0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9

Page 11: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Addition Paradigms• right to left serial 1 147865 +30921 178786

• right to left, parallel 147865 +30921 177786 001000 178786

•random 461325 147865 +30921 177786 001000 178786

Page 12: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Binary Number System• n-ordered sequence:

• each xi{0,1} is a BInary digiT (BIT)

• magnitude of n is important• sequence is a short-hand notation• more precise definition is:

1 2 2 1 0n nx x x x x

11 2 2 1 0

1 2 2 1 00

2 2 2 2 2 2n

n n in n i

i

x x x x x x

• This is a radix-polynomial form

Page 13: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Number System• A Number System is defined if the following exist

•Example: The binary number system

1. 2. 3. Addition operator defined by addition table4. Multiplication operator defined by multiplication table

1. A digit set2. A radix or base value3. An addition operation4. A multiplication operation

{0,1}ix 2

+ 0 1 0 0 1 1 1 10

0 1 0 0 0 1 0 1

Page 14: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Number System Observations• Cardinality of digit set (2) is equal to radix value• Addition operator XOR, Multiplication is AND

•How many integers exist?Mathematically, there are an infinite number, In computer, finite due to register length

minX

maxX

min max[ , ]X X

smallest representable number

largest representable number

range of representable numbers[-inclusive; (-exclusive interval bounds

•When ALU produces a result >Xmax or <Xmin, incorrect result occurs

•ALU should produce an error signal

Page 15: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Example•Assume 4-bit registers, unsigned binary numbers

min 2 100000 0X max 2 101111 15X

min max 2 2[ , ] [0000 ,1111 ]X X

max 2 101 10000 16X

max 2 21 [0000 ,1111 ] (mod16)X X

1101 13

0110 6

1 0011 19

X

Y 19(mod16) 3

Answer in register is 00112=310

Overflow

Page 16: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Machine Representations• Most familiar number systems are:1. nonredundant – every value is uniquely represented

by a radix polynomial2. weighted – sequence of weights

determines the value of the n-tuple formed from the digit set

3. positional – wi depends only on position i4. conventional number systems

where ß is a constant. These are fixed-radix systems.

1 2 2 1 0, , , , ,n nw w w w w

1 2 2 1 0, , , , ,n nx x x x x 1

0

n

i ii

X x w

iiw

Page 17: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Example

4 3 1 07 8 6 8 2 8 4 8X

876024X

Since octal is fixed-radix and positional,we can rewrite this value using shorthand notation

Note the importance of the use of 0 to serve as acoefficient of the weight value w2=82

Page 18: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Fixed-Radix Systems

1 2 1 01 2 1 0

11

1

k kk k

km i

m ii m

X x x x x

x x x

Register of length n can represent a number with a fractional part and an integral part

k – number of integral digitsm – number of fractional digitsn=k+m

1 2 1 0 1.k k mx x x x x x

radix point

A programmer can use an implied radix point in any position

Page 19: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Scaling FactorsFixed point arithmetic can utilize scaling factors to adjust radix point position

a – scaling factor

2

( )aX aY a X Y

aX aY a XY

aX X

aY Y

no correction

must divide by a

must multiply by a

Page 20: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Scaling Factor Example10 10

10 10

2

4.2 2.1 10

42 21

63 ( )

6.3

42 21 21 ( )

2.1

42 21 882

8.82

422

214.2

22.1

X Y a

aX aY

aX aY a X Y

X Y

aX aY a X Y

X Y

aX aY a X Y

X Y

aX

aYX

Y

Page 21: ECE 8053 Introduction to Computer Arithmetic (Website:  Course & Text Content: Part 1: Number Representation.

Unit in the Last Position (ulp)

• Given w0=r-m and n, the position of the radix point is determined

• Simpler to disregard position of the radix point in fixed point by using ulp

mulp r

Example

98.67510

1 ulp = 110-3=0.001

1 ulp is the smallest amount a fixed point number may increase or decrease