lect24
DESCRIPTION
nTRANSCRIPT
CS221: Digital Designg g
Data Path Components
Adder
Dr. A. Sahu
Dept of Comp. Sc. & Engg.Dept of Comp. Sc. & Engg.
Indian Institute of Technology Guwahati
OutlineOut e• Adder: Basic Model
• Carry Propagation and Generation • Machester Adder• Machester Adder
• Carry Skip Addery p
• Carry Select Adder• Carry Look Ahead Adder• Carry Save Adder: Multiple Operand• Carry Save Adder: Multiple Operand
Computer Arithmetic: C Assembly Machine
• C : short int long float doubleC : short, int, long, float, double
• 16 bit, 32 bit, 32 bit, 32 bit, 64 bit
Si d/ i d• Signed/Unsigned
• Have a FU in your processor– Processor is capable to do it in hardware
– 8086: No support of FP, 8087 FP Co processor
• If you don’t have FPU : Write FP in software– $gcc –mfloat‐soft –S test c$gcc mfloat soft S test.c
– undefined reference to `__mulsf3'3
ALU: Arithmetic and Logic UnitALU: Arithmetic and Logic Unit
• Binary arithmetic and ALU design• Signed operations, overflow• Compare/Shift A
R l• Multiplier design• Divider design ALUB
Result
• Speeding up addition/subtraction• Floating point representation
and operations• Floating point unit design
Operation
4
Adder Universal UseAdder Universal Use• Adder : A = B + C
• Substractor: A = B + (‐C), 2’s complement
• Compare : C = A> B ? 1 : 0 , (A‐B > 0) ? 1 : 0p , ( )– Special case of compare with 0
• MultiplyMultiply
• Divide
d• Mod
• Floating point: Add/sub/mul…
5
Adding Two One‐bit Operands• One‐bit Half Adder:
A B Sum CoutA B 0 0 0 0
0 1 1 0
HACout
0 1 1 01 0 1 0
Sum1 1 0 1
Sum = A ⊕ B
6
Cout = A.B
Adding Two One‐bit Operands• One‐bit Full adder
A B Cin A B Sum Cout
FAA B
C
Cin A B Sum Cout
0 0 0 0 0
0 0 1 1 0FA CinCout
S
0 0 1 1 0
0 1 0 1 0
S A⊕ B ⊕ Ci
Sum 0 1 1 0 1
1 0 0 1 0Sum = A ⊕ B ⊕ CinCout = A.B + B.Cin
1 0 1 0 1
1 1 0 0 1
7
+ A.Cin 1 1 1 1 1
Addition of Two N‐Bit numbersAddition of Two N Bit numbers
x + y + cin = 2n cout + sx y cin 2 cout sThe solution:
s = (x + y + cin) mod 2n
cout = 1 if (x + y + cin) ≥ 2n else 0
8
ExampleExample• 011110 + 101101 = 1 (x 2x 266 )+ 001011
• X=30, Y=45
• 30 + 45 = 75= 26 x 1 + 11
• SolutionSolution – S= (30+45+0) % 26=11
Cout= 1 if (30+45+0 >= 26) else 0 = 1– Cout= 1 if (30+45+0 >= 26) else 0 = 1
Primitive module FAPrimitive module FA
xi + yi + ci = 2 ci+1 + sii yi i i+1 i
with solution Xi Yi
• si = (xi + yi + ci) mod 2
fl [ ( )/ ] FA Ci• ci+1 =floor [ (xi + yi + ci)/2] FA i
C SCi+1 S
10
N‐Bit Ripple‐Carry Adder: Series of FA C llFA Cells• To add two n‐bit numbers
A0 B0A1 B1A2 B2A 1B 1
C0FA
A0 B0
FA
A1 B1
FA
A2 B2
FA
An-1Bn-1
Cn. . .
0FA
S0
FA
S1
FA
S2
FA
Sn-1
n
• Adder delay = Tc * n• Tc = (C to C delay) of a FA
A B• Tc = (Cin to Cout delay) of a FA
FA CinCout
11Sum
Adder/SubstractorAdder/Substractor• C= A‐B=A+(‐B)=A+ (Bb+1), Bb is complement of B
• D is control bit: D=0/1 operation is add/sub
A
Result
ALUB
Operation
12
Operation
Adder Schemes• Step1: Obtain carries• Step1: Obtain carries
– (Carry at i depends on j < i), Non‐trivial to do fast
S 2 C bi (l l f i )• Step2: Compute sum bits (local function)
X Y
Step1:
C0=Cin
C =C Step1: Obtain Carries
Cout=Cn
yix
y1x1
y0x0
yn‐1xn‐1
Step2: Computer Sum
xi x1 x0
13
sn‐1 si s1 s0
Mathematically: Ci & SiMathematically: Ci & Si• C =FuncC ( x x y y c )• Ci =FuncC ( xi‐1, ..,x0, yi‐1, ..,y0, cin)
• Si =FuncS (xi, yi, ci) i i i i
= ( xi + yi + ci) mod 2
14