19
University of Pune S.E. I.T. Subject code: 214442 Part 07: Computer Arithmetic Computer Organization UNIT I

Part 07 - Computer Arithmetic

Embed Size (px)

Citation preview

Page 1: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 1/19

University of Pune

S.E. I.T.

Subject code: 214442

Part 07: Computer Arithmetic

Computer Organization

UNIT I

Page 2: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 2/19

Fixed point numbers

Floating point numbers

Page 3: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 3/19

Page 4: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 4/19

Page 5: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 5/19

1 1 0 1 - Number

0 0 1 0 - 1¶s Complement

1 0 1 1 - Number

0 1 0 0 - 1¶s Complement

Page 6: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 6/19

1 1 0 1 - Number

0 0 1 0 - 1¶s Complement

+ 1

---------------

0 0 1 1 - 2¶s complement

Page 7: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 7/19

0 0 1 0 0 0 (+8)

0 0 1 0 0 1 (+9)

0 1 0 0 0 1 (+17)

Page 8: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 8/19

 A ddition of 28 and 15:

1 1 1

0 0 1 1 1 0 0 (+28)

0 0 0 1 1 1 1 (+15)

0 1 0 1 0 1 1 (+43)

Page 9: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 9/19

 A ddition of 28 and -15:x (10000) ² 1·s Complement of 15

0 1 1 1 0 0 (+28)

1 1 0 0 0 0 (-15)

1 0 0 1 1 0 0

1

0 0 1 1 0 1 (13)

 A dd end-around carry

Page 10: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 10/19

 A ddition of -28 and 15:x (100011) ² 1·s Complement of 28

1 0 0 0 1 1 (-28)

0 0 1 1 1 1 (+15)

1 1 0 0 1 0 (-13)

Result is in 1·s complement form

Page 11: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 11/19

 A ddition of -28 and -15:x (10000) ² 1·s Complement of 15

x (100011) ² 1·s Complement of 28

1 1 0 0 0 1 1 (-28)

1 1 1 0 0 0 0 (-15)

1 1 0 1 0 0 1 1

1

1 0 1 0 1 0 0 (-43)

 A dd end-around carry

Result is in 1·s complement form

Page 12: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 12/19

Page 13: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 13/19

 A ddition of 28 and 15:

1 1 1

0 0 1 1 1 0 0 (+28)

0 0 0 1 1 1 1 (+15)

0 1 0 1 0 1 1 (+43)

Page 14: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 14/19

 A ddition of 28 and -15:x (10001) ² 2·s Complement of 15

0 1 1 1 0 0 (+28)

1 1 0 0 0 1 (-15)

1 0 0 1 1 0 1 (+13)

Ignore the carry

Page 15: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 15/19

 A ddition of -28 and 15:x (100100) ² 2·s Complement of 28

1 1 0 0 1 0 0 (-28)

0 0 0 1 1 1 1 (+15)

1 1 1 0 0 1 1 (-13)

Result is in 2·s complement form

Page 16: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 16/19

 A ddition of -28 and -15:x (10001) ² 2·s Complement of 15

x (100100) ² 2·s Complement of 28

1 1 0 0 1 0 0 (-28)

1 1 1 0 0 0 1 (-15)

1 1 0 1 0 1 0 1 (-43)

Ignore end-around carry

Result is in 2·s complement form

Page 17: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 17/19

Paper and Pencil Example:Multiplicand 1100

2= 12

Multiplier × 11012= 13

1100

0000

1100

1100

Product 100111002= 156

m-bit multiplicand × n-bit multiplier = (m+n)-bit product

A ccomplished via shifting and addition

Consumes more time and more chip area

Binary multiplication is easy

0 × multiplicand = 0

1 × multiplicand = multiplicand

Page 18: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 18/19

Start

Multiplier[0]?

1a. Product = Product + Multiplicand

2. Shift the Multiplicand Left 1 bit

3. Shift the Multiplier Right 1 bit

32nd Repetition?

Done

= 0= 1

No

Yes

Initialize

P

roduct =0

Multiplicand is zero extended

Multiplicand

64-bit ALU

Control

Multiplier 

Product

64 bits

64 bits

write

shift left

add

shift right

Multiplier[0]32 bits

64 bits

Page 19: Part 07 - Computer Arithmetic

8/3/2019 Part 07 - Computer Arithmetic

http://slidepdf.com/reader/full/part-07-computer-arithmetic 19/19

Consider: 11002 × 11012 ,Product = 100111002

4-bit multiplicand and multiplier are used in this

example

Multiplicand is zero extended because it is unsigned

000101100000SLL Multiplicand and SRL Multiplier 

00001100Multiplier[0] = 0 => Do Nothing

001100110000S

LL Multiplicand andS

RL Multiplier 

00011000 0110SLL Multiplicand and SRL Multiplier 

000011000000SLL Multiplicand and SRL Multiplier 

00001100Multiplier[0] = 1 => ADD +

00111100Multiplier[0] = 1 => ADD +

10011100Multiplier[0] = 1 => ADD +

2

00001100 000000001101Initialize0

1

3

4

Multiplicand ProductMultiplier Iteration