Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

101
Images courtesy of Addison Wesley Longman, Inc. Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Copyright © 2001 Chapter 8 Chapter 8 Computer Arithmetic Computer Arithmetic

Transcript of Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Page 1: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Chapter 8Chapter 8Computer ArithmeticComputer Arithmetic

Page 2: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Chapter OutlineChapter Outline

• Unsigned notationsUnsigned notations

• Signed notationsSigned notations

• Binary Coded DecimalBinary Coded Decimal

• Specialized arithmetic hardwareSpecialized arithmetic hardware

• Floating point numbersFloating point numbers

• IEEE 754 floating point standardIEEE 754 floating point standard

Page 3: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Unsigned NotationsUnsigned Notations

• Unsigned non-negativeUnsigned non-negative

• Unsigned twoUnsigned two’’s-complements-complement

Page 4: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Unsigned NotationsUnsigned Notations

• Unsigned non-negativeUnsigned non-negative

• Unsigned twoUnsigned two’’s-complements-complement

Page 5: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Addition: X Addition: X X + Y X + Y

Page 6: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

OverflowOverflow

Page 7: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Subtraction: X Subtraction: X X - Y X - Y

Page 8: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

OverflowOverflow

Page 9: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• A non-optimal methodA non-optimal method

z = 0 z = 0

FOR i = 1 TO y DO { z = z + x }FOR i = 1 TO y DO { z = z + x }

Page 10: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• A more typical methodA more typical method

Page 11: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• Calculating running totalsCalculating running totals

Page 12: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• Shifting partial results to align sumsShifting partial results to align sums

Page 13: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Shift-add Multiplication Shift-add Multiplication AlgorithmAlgorithm

C = 0, U = 0;

Page 14: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: UV Example: UV X X Y Y(X = 1101, Y = 1001)(X = 1101, Y = 1001)

C = 0, U = 0 0

Page 15: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

C 0, U 0, i n

Page 16: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: UV Example: UV X X Y Y(X = 1101, Y = 1001)(X = 1101, Y = 1001)

C 0, U 0, i 4 0

Page 17: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 18: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Optimizing the RTL CodeOptimizing the RTL Code

• UV UV X X V V

• Register Y not neededRegister Y not needed

• One operand is lostOne operand is lost

Page 19: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Optimizing the RTL CodeOptimizing the RTL Code

C 0, U 0

Page 20: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

C 0, U 0, i 4 0

Page 21: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

BoothBooth’’s Algorithms Algorithm• Multiplying unsigned 2Multiplying unsigned 2’’s-complement s-complement

numbersnumbers

Page 22: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample• UV UV X X Y, X = -3 (1101), Y = -5 Y, X = -3 (1101), Y = -5

(1011)(1011)

Page 23: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample• UV UV X X Y, X = -3 (1101), Y = -5 Y, X = -3 (1101), Y = -5

(1011)(1011)

Page 24: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 25: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 26: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Optimized RTL CodeOptimized RTL Code

Page 27: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 28: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

DivisionDivision

• A non-optimal methodA non-optimal method

Page 29: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

DivisionDivision• A more typical methodA more typical method

Page 30: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

DivisionDivision• Shifting results to align remaindersShifting results to align remainders

Page 31: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Shift-subtract Division AlgorithmShift-subtract Division Algorithm

Page 32: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: UV Example: UV X X(UV = 1001 0011, X = 1101)(UV = 1001 0011, X = 1101)

Page 33: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 34: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 35: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 36: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Restoring Division AlgorithmRestoring Division Algorithm

Page 37: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Overflow ComparisonOverflow Comparison

Page 38: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 39: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 40: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 41: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 42: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Signed NotationsSigned Notations

• Signed-magnitudeSigned-magnitude

Page 43: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Signed NotationsSigned Notations

• Signed-magnitudeSigned-magnitude

• Signed-2Signed-2’’s complements complement

Page 44: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Signed NotationsSigned Notations

• Signed-magnitudeSigned-magnitude

• Signed-2Signed-2’’s complements complementValue Signed-magnitude Signed-2Value Signed-magnitude Signed-2’’s complements complement

+3 0 0011 0 0011+3 0 0011 0 0011

-3 1 0011 1 1101-3 1 0011 1 1101

Page 45: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Addition and SubtractionAddition and Subtraction

Page 46: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 47: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 48: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 49: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 50: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 51: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 52: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

Page 53: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 54: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Binary Coded Decimal (BCD)Binary Coded Decimal (BCD)

• Every 4 bits = 1 decimal digitEvery 4 bits = 1 decimal digit

• 1 bit sign1 bit sign

• Example: +27 = 0 0010 0111Example: +27 = 0 0010 0111

Page 55: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

BCD AdderBCD Adder

Page 56: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

NineNine’’s Complements Complement• Equivalent of 1Equivalent of 1’’s complement in binarys complement in binary

Page 57: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

NineNine’’s Complements Complement• Equivalent of 1Equivalent of 1’’s complement in binarys complement in binary

Page 58: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 59: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 60: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 61: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExamplesExamples

Page 62: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Hardware ImplementationHardware Implementation

Page 63: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• dshr: decimal shift rightdshr: decimal shift right

Page 64: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• dshr: decimal shift rightdshr: decimal shift right

Page 65: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 66: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Arithmetic PipelinesArithmetic Pipelines

• Increase throughputIncrease throughput

Page 67: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Arithmetic PipelinesArithmetic Pipelines

• Increase throughputIncrease throughput

• Speedup:Speedup:

Page 68: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 69: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 70: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 71: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Steady State SpeedupSteady State Speedup

Page 72: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Steady State SpeedupSteady State Speedup

Page 73: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Speedup with Latch DelaysSpeedup with Latch Delays

Page 74: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Speedup with Latch DelaysSpeedup with Latch Delays

Page 75: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Lookup TablesLookup Tables

Page 76: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 77: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Wallace TreesWallace Trees

• Carry Save AdderCarry Save Adder

Page 78: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Wallace TreesWallace Trees

• Carry Save AdderCarry Save Adder

Page 79: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Wallace TreesWallace Trees• Partial productsPartial products

Page 80: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Wallace TreesWallace Trees

• Partial productsPartial products

Page 81: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 82: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 83: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

4 4 4 Wallace Tree 4 Wallace Tree

Page 84: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

8 8 8 Wallace Tree 8 Wallace Tree

Page 85: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Floating Point NumbersFloating Point Numbers

• Sign, Significand, ExponentSign, Significand, Exponent

• Normalized:Normalized: -1234.5678 = -.12345678 -1234.5678 = -.12345678 10 1044

• NaNNaN

• BiasingBiasing

Page 86: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Floating Point NumbersFloating Point Numbers

• PrecisionPrecision

• GapGap

• RangeRange

• Round, Guard, Sticky bitsRound, Guard, Sticky bits

Page 87: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RoundingRounding

• Round toward nearestRound toward nearest

• Round toward 0Round toward 0

• Round toward +Round toward +• Round toward -Round toward -

Page 88: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

ExampleExample

Page 89: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Addition and SubtractionAddition and Subtraction

Page 90: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Addition and SubtractionAddition and Subtraction

Page 91: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 92: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: (.1101 Example: (.1101 2 233) + (.1110 ) + (.1110 2222))

Page 93: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: (.1101 Example: (.1101 2 233) - (.1110 ) - (.1110 2222))

Page 94: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

MultiplicationMultiplication

• Check for special valuesCheck for special values

• Add exponentsAdd exponents

• Multiply significandsMultiply significands

• Normalize resultNormalize result

Page 95: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

RTL CodeRTL Code

Page 96: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Example: (.1101 Example: (.1101 2 233) ) (.1110 (.1110 2222))

Page 97: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

IEEE 754 Floating Point IEEE 754 Floating Point StandardStandard

• 11 significand < 2 significand < 2

• Single of double precisionSingle of double precision

Page 98: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

IEEE 754 Floating Point StandardIEEE 754 Floating Point Standard

Page 99: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

IEEE 754 Floating Point StandardIEEE 754 Floating Point Standard

Page 100: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

Denormalized ValuesDenormalized Values

• Used to express smaller numbers than Used to express smaller numbers than possible with normalized notationpossible with normalized notation

• Smallest normalized value: 2Smallest normalized value: 2-126-126 (single (single precision)precision)

• Smallest denormalized value: 2Smallest denormalized value: 2-149-149 (single precision)(single precision)

Page 101: Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Chapter 8 Computer Arithmetic.

Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001 Images courtesy of Addison Wesley Longman, Inc. Copyright © 2001

SummarySummary

• Unsigned notationsUnsigned notations

• Signed notationsSigned notations

• Binary Coded DecimalBinary Coded Decimal

• Specialized arithmetic hardwareSpecialized arithmetic hardware

• Floating point numbersFloating point numbers

• IEEE 754 floating point standardIEEE 754 floating point standard