0% found this document useful (0 votes)
12 views48 pages

Chapter 3

Uploaded by

sakhawat.hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views48 pages

Chapter 3

Uploaded by

sakhawat.hossain
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 48

Computer Architecture

Chapter-3
Addition & Subtraction
Overflow conditions for addition &
subtraction
Multiplication
First Version of Multiplication Hardware
Flowchart (First Version of Multiplication)
Refined Version of Multiplication Hardware
Refined Version of Multiplication Hardware
Refined Version of Multiplication Hardware
Signed 2's Complement Multiplication
Booth’s Algorithm

• Uses addition as well as subtraction in the multiplication process and is faster.


• Works for signed 2's complement arithmetic also
• Has same overall form as above algorithm exception the step:
“if low bit of product = 1, Add multiplicand to left half of product register”

Is replaced by the following new rule:


If low bit and shifted out bit of product = 00:
Do nothing
If low bit and shifted out bit of product = 01:
Add multiplicand to left half of product register
If low bit and shifted out bit of product = 10:
Subtract multiplicand to left half of product register
If low bit and shifted out bit of product = 11:
Do nothing

... The rest of the algorithm is the same.

Note 1: The this algorithm is easy to use, but hairy to theoretically prove.
Note 2: All shifting of the product extends the sign bit.
Signed 2's Complement Multiplication
Booth’s Algorithm
Signed 2's Complement Multiplication
Booth’s Algorithm
Signed 2's Complement Multiplication
Booth’s Algorithm
Signed 2's Complement Multiplication
Booth’s Algorithm
Interpretation of New Rule For Booth’s Algorithm
• Now we now are testing 2 bits: LSB of product register and previous
shifted out bit (initialized to 0 at the beginning):
– A way of detecting a run of consecutive ones in the multiplier:
Multiplier being shifted out of the right side of the product register:
end of run middle of run beginning of run
000000000001111111111110000000000000

Current LSB bit Previous Explanation example


shifted out bit
1 0 Beginning of 000011110000)2
a run of ones
1 1 Middle of a 000011110000)2
run of ones
0 1 End of a run 000011110000)2
of ones
0 0 Middle of a 000011110000)2
run of zeros
Interpretation of New Rule For Booth’s Algorithm (cont)
• Depending on the current bit (LSB) in the product register, and the previous
shifted out bit, we have:

– 00: middle of string of 0’s, so no arithmetic operation

– 01: End of string of 1’’s, so add the multiplicand to the left half of th product
register (ignore any net carry outs)

– 10: beginning of a string of 1’s, so subtract the multiplicand from the left half of the
product register (ignoring any net carry outs)

– 11: Middle of a string of 1’s, so no arithmetic operation

• Note that all the “action” (subtract or add) takes place only on “entering” or
leaving a run of ones.
Example of Booth’s Algorithm

• 2)ten x –3)ten = -6)two …where -3)ten = 1101)two is the multiplier


or
0010)two x 1101)two = 1111 1010)2
… note the 2’s complement of 2)ten = 0010)two is 1110)two

From Patterson &


Hennessy, p. 262
Division
First Version of Division
Hardware
First Version of Division
Flowchart
First Version of Division
Example
Final Version of Division
Hardware
Final Version of Division
Algorithm
Final Version of Division
Example
4.8 Floating Point
• Real numbers:
• 3.14159265…. ()
• 2.71828… (e)
• 0.000000001 or 1.0 × 10-9 (seconds in a
nanosecond)
• 3,155,760,000 or 3.15576 × 109 (seconds in a
century)

• Scientific Notation
4.8 Floating Point

• Normalized numbers:
• A number in scientific notation that has no leading
zeros.
• 1.0 × 10-9

• 0.1 × 10-8
• 10.0 × 10-10 ×
4.8 Floating Point

• Binary numbers in scientific notation:

• 1.0 × 2-1

Binary Point

• 1. xxxxxxxx × 2yyyy
• Computer arithmetic that support such numbers is called
floating point because it represents numbers in which the
binary point is not fixed.
4.8 Floating Point

• A standard scientific notation for reals in


normalized form offers three advantages:
– It simplifies exchange of data that includes floating-point
numbers
– It simplifies the floating-point arithmetic algorithms to
know that numbers will always be in this form
– It increases the accuracy of the numbers that can be
stored in a word
Floating Point Representation
• Single precision
• Sign and magnitude representation
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
s exponent significand
1 bit 8 bits 23 bits
• (-1)S × F × 2E
• S – sign
• F – significand
• E – exponent
Floating Point Representation
• Double precision

• (-1)S × (1 + Significand) × 2E
• (-1)S × (1 + (s1 × 2-1) + (s2 × 2-2) + … … ) × 2E
• IEEE 754
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
s exponent significand
1 bit 11 bits 20 bits
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
Significand (Continued)
32 bits
Floating Point Representation
• When we want to represent zero (0)

• (-1)S × (1 + Significand) × 2E
• (-1)S × (1 + (s1 × 2-1) + (s2 × 2-2) + … … ) × 2E

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

• 1+0=1
Floating Point Representation
• Biased Notation
• 1.0 × 2-1
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
• 1.0 × 2+1
31302928272625242322212019181716151413121110 9 8 7 6 5 4 3 2 1 0
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
• -1  -1 + 127 = 126
• +1  +1 + 127 = 128
• (-1)S × (1 + Significand) × 2(Exponent – Bias)
• For Double Precision bias is 1023
Floating Point
Addition
Floating Point Addition
9.999 × 101 + 1.610 × 10-1
• Step 1: (Change the smaller number)
1.610 × 10-1 = 0.1610 × 100 = 0.01610 × 101
• Step 2: (Addition of the significands)
9.999
+ 0.016
10.015
10.015 × 101
Floating Point Addition
• 10.015 × 101
• Step 3: (Find the normalized form)
10.015 × 101 = 1.0015 × 102
Check for overflow and underflow
• Step 4: (Round the number)
1.0015 × 102 = 1.002 × 102
Normalize again if required
Floating Point
Multiplication
Floating Point Multiplication
(1.110 × 1010) × (9.200 × 10-5)
• Step 1: (Find the exponent of the product)
New exponent = 10 + (-5) = 5
• Considering bias
New exponent = (10 + 127) + (-5 + 127)
= 137 +122 = 259 ×
New exponent = 137 + 122 -127
= 132 
Floating Point Multiplication
(1.110 × 1010) × (9.200 × 10-5)
New exponent = 5 or 132
• Step 2: (Multiplication of the significands)
1.110
× 9.200
0000
0000
2220
9990
10212000
• 10.212000 × 105 = 10.212 × 105
Floating Point Multiplication
(1.110 × 1010) × (9.200 × 10-5)
New exponent = 5 or 132
New product = 10.212 × 105
• Step 3: (Normalize the product)
10.212 × 105 = 1.0212 × 106
Check for overflow and underflow
• Step 4: (Round the number)
1.0212 × 106 = 1.021 × 106
Floating Point Multiplication
(1.110 × 1010) × (9.200 × 10-5)
New product = 1.021 × 106
• Step 5: (Put the sign of the product)
+1.0212 × 106

You might also like