Professional Documents
Culture Documents
32-bit ALU
ALU Control A
32
32-bit ALU
B
32
32
Our ALU should be able to perform functions: logical and function logical or function arithmetic add function arithmetic subtract function arithmetic slt (set-less-then) function logical nor function ALU control lines define a function to be performed on A and B.
g. babic Presentation F 2
ALU Control
4
A
32
32-bit ALU
32
Result lines provide result of the chosen function applied to values of A and B Since this ALU operates on 32-bit operands, it is called 32-bit ALU Zero output indicates if all Result lines have value 0 Overflow indicates integer overflow of add and subtract functions; for unsigned integers, this overflow indicator does not provide any useful information Carry out indicates carry out and unsigned integer overflow
g. babic Presentation F 3
Operation
=0 =1
and or
0 1
a2 b2 0 1
Result2
a31 b31
0 1
Result31
g. babic
Operation = 0
=1
and or and or
and or
Result0
0 1
b1
0 1
Result1
a2 b2
and or
0 1
Result2
a31 b31
and or
0 1
Result31
g. babic
Output
Sum 0 1 1 0 1 0 0 1 Carry Out 0 0 0 1 0 1 1 1
From the truth table and after minimization, we can have this design for CarryOut
Figure B.5.5
g. babic Presentation F
Figure B.5.3
6
32-bit Adder
0
a0 b0
Cin
+
Cout
sum0
+
Cout
sum1
a2 b2
Cin
+
Cout
sum2
The key to speeding up addition is determining carry out in the higher order bits sooner. Result: Carry look-ahead adder.
a31 b31
Cin
+
Cout
sum31
g. babic
Carry out
Presentation F
1-bit ALU
Operation = 00 = 01 = 10
and or add
Figure B.5.6
Figure B.5.7
CarryOut
+ carry out 8
g. babic
Presentation F
32-bit Subtractor
0 1
a0 b0
Cin
+
Cout
Result0
A B = A + (B) =A+B+1
a1 b1
Cin
+
Cout
Result1
a2 b2
Cin
+
Cout
Result2
a31 b31
Cin
+
Cout
Result31
CarryOut
g. babic
Presentation F
a0 b0 0 1 a1 b1 0 1 a2 b2 0 1
+
Cout
Result0
Cin
+
Cout
Result1
Cin
+
Cout
Result2
Binvert = 0 =1
addition subtraction
a31 b31 0 1
Cin
+
Cout
Result31
0 1
CarryOut
g. babic
10
B in v e r t
O p e r a tio n
a0 b0
0
R e s u l t0
R e s u lt
0 1
a1 b1
R e s u l t1
Figure B.5.8
C a r ry O u t
a2 b2
R e s u l t2
C a rr y In
C a rryI n A L U 31
R e s u l t3 1
0 1
Carry Out
11
2s Complement Overflow
2s complement overflow happens: if a sum of two positive numbers results in a negative number if a sum of two negative numbers results in a positive number
B in v e r t O p e r a tio n C a r ry In a 0
R e s u lt b 0 1 L e ss 3
Carry Out
O v e r f lo w d e te c tio n O v e rflo w
1-bit ALU for the most significant bit Other 1-bit ALUs, i.e. non-most significant bit ALUs, are not affected.
g. babic Presentation F 12
R e s u l t0
C a rr y In
a3 1 b3 1
C a rryI n A L U 31
R e s u l t3 1 O v e r flo w
Carry Out