Unit - 2 Arithmetic Unit
Unit - 2 Arithmetic Unit
Arithmetic Unit
Table of Contents
Example:
X 7 0 1 1 1 Carry-out xi Carry-in
+ Y = +6 = +00 1 1 1 1 0 0 0 yi
ci+1 ci
Z 13 1 1 0 1 si
ci + 1 Full adder ci
(FA)
s
i
xn - 1
yn- 1 x1 y1 x0 y0
cn - 1
c1
cn FA FA FA c0
sn - 1
s1 s0
Most significant bit Least significant bit
(MSB) position (LSB) position
+ 0011
1110
• 11 + 3 = 14
(8 + 4 + 2)
Signed and unsigned additions
• 8 bit 2s compliment
– +127 = 01111111 = 27 -1
– -128 = 10000000 = -27
• 16 bit 2s compliment
– +32767 = 011111111 11111111 = 215 - 1
– -32768 = 100000000 00000000 = -215
Conversion Between Lengths
• Simple Adders
• Multifunction ALUs
Full adder
si Assum
= xi e3 y
- i/i ci gate for S and SOP
p XOR i
T form
D = 1 (or 2for
); C i+ 1
Ripple-Carry Adder
c4
2 N;
O Cn Cn1; TD/C = 2 N-1 ;
TD/S = 2 N+2
O xn1 yn1 S n1 xn1 yn1Sn1 TD/O =
Building a 32 bit ALU CarryIn Operation
a0 CarryIn
Operation ALU0
Result0
b0
CarryIn CarryOut
19
a a1 CarryIn
0 ALU1
Result1
b1
CarryOut
1
Result
a2 CarryIn
Result2
ALU2
b2
2 CarryOut
b
CarryOut
a31 CarryIn
Result31
ALU31
b31
CarryIn
adders a4
b4
CarryIn
Result4--7
a5
• Can’t build a 16 bit adder this b5
a6
ALU1
pi + 1
P1
b6 G1 gi + 1
way... (too big) a7
b7
C2
• Could use ripple carry of 4-bit ci + 2
CLA adders a8
b8
CarryIn
Result8--11
a9
• Better: use the CLA principle b9
a10
ALU2
P2 pi + 2
b10 G2 gi + 2
again! a11
b11
C3
ci + 3
a12 CarryIn
b12 Result12--15
a13
b13 ALU3
a14 P3 pi + 3
b14 G3 gi + 3
a15 C4
b15 ci + 4
20
CarryOut
Detecting Overflow
• No overflow when adding a positive and a negative number
• Complex
• Work out partial product for each digit
• Take care with place value (column)
• Add partial products
Multiplication Example
00001101 Quotient
• Arithmetic operations
.5372400 x 102 .5372400 x 102 .56780 x 105
+ .1580000 x 10-1 + .0001580 x 102 + .56430 x 105
.5373980 x 102 .00350 x 105
.35000 x 103
.5372400 x 102
x .1580000 x 10-1
Addition
Floating-point Computations
• Biased Exponent
– Bias: an excess number added to the exponent so that all exponents
become positive
– Advantages
• Only positive exponents
• Simpler to compare the relative magnitude
Floating-point Computations
• Significand
– A leading bit to the left of the implied binary point, together with the
fraction in the field
~ ~
Minimum number 01000..000 Maximum number
Thank You.