Module 2: - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Module 2:

Description:

Multiplicand register, product ... multiplicand starts at right half of multiplicand ... the multiplier and multiplicand to positive numbers and ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 16
Provided by: jb153
Category:

less

Transcript and Presenter's Notes

Title: Module 2:


1
  • Module 2
  • Arithmetic of Computers Arithmetic Operations
  • (Book Computer Organization and Design,3ed,
    David L. Patterson and John L. Hannessy, Morgan
    Kaufmann Publishers)

2
Introduction
  • Numbers are represented by binary bits
  • How are negative numbers represented?
  • What is the largest number that can be
    represented in a computer world?
  • What happens if an operation creates a number
    bigger than can be represented?
  • What about fractions and real numbers?
  • A mystery How does hardware really multiply or
    divide numbers?

3
Binary Numbers
4
Twos Complement (32-bit)
  • 0111 ... 1111 1111 1111 1111two
    2,147,483,647ten
  • 0111 ... 1111 1111 1111 1110two
    2,147,483,646ten
  • 0111 ... 1111 1111 1111 1101two
    2,147,483,645ten
  • . . .
  • 0000 ... 0000 0000 0000 0010two 2ten
  • 0000 ... 0000 0000 0000 0001two 1ten
  • 0000 ... 0000 0000 0000 0000two 0ten
  • 1111 ... 1111 1111 1111 1111two -1ten
  • 1111 ... 1111 1111 1111 1110two -2ten
  • 1111 ... 1111 1111 1111 1101two -3ten
  • . . .
  • 1000 ... 0000 0000 0000 0001two
    -2,147,483,647ten
  • 1000 ... 0000 0000 0000 0000two
    -2,147,483,648ten
  • To represent positive and negative numbers
  • MSB - 0 means positive
  • MSB - 1 means negative

Indicates sign of the integer
5
Twos Complement Shortcut NegationConvert
Decimal to Twos ComplementConvert Twos
Complement to Decimal
Therefore -2 since the MSB is 1
6
Binary Addition and Subtraction
6
7
Detecting Overflow in Two Complement Numbers
  • Overflow occurs when adding two positive numbers
    and the sum is negative, or vice versa
  • A carry out occurred into the sign bit

Overflow conditions for addition and subtraction
8
Binary Mutiplication
9
1st Version of Multiplication Hardware
Flows of 1st Version Multiplication

32-bit multiplicand starts at right half of
multiplicand register
Product register is initialized at 0
Multiplicand register, product register, ALU
are 64-bit wide multiplier register is 32-bit
wide
Algorithm
10
Example of Multiplication 4 bits
11
Signed Multiplication
  • So far we have dealt with positive numbers. But
    how to deal with signed numbers?
  • To first convert the multiplier and multiplicand
    to positive numbers and then remember the
    original signs
  • Leave the sign out of the calculation
  • To negate the product only if the original signs
    disagree

12
Binary Division
13
1st Version of Division Hardware
Flows of 1st Version Division

32-bit divisor starts at left half of divisor
register
Quotient register is initialized to be 0
Remainder register is initialized with the
dividend at right
Divisor register, remainder register, ALU
are 64-bit wide quotient register is 32-bit wide
Algorithm
14
Example of Division
15
Signed Division
  • Signed divide
  • - make both divisor and dividend positive and
    perform division
  • - negate the quotient if divisor and dividend
    were of opposite signs
  • - make the sign of the remainder match that of
    the dividend
  • - this ensures always
  • dividend (quotient divisor) remainder
  • quotient (x/y) quotient (x/y) (e.g. 7 32
    1 7 32 1)
Write a Comment
User Comments (0)
About PowerShow.com