Вы находитесь на странице: 1из 7

CSE 675.

02: Introduction to Computer Architecture

Arithmetic / Logic Unit ALU Design


Presentation F
Reading Assignment: B5, 3.4
Slides by Gojko Babi

32-bit ALU
ALU Control A
32

32-bit ALU
B
32

32

Result Zero Overflow Carry out

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

Functioning of 32-bit ALU


ALU Control lines
Function
and or add subtract slt nor Ainvert 0 0 0 0 0 1 Binvert 0 0 0 1 1 1 Operation 00 01 10 10 11 00
B
32

ALU Control

4
A
32

32-bit ALU

32

Result Zero Overflow Carry out

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

Designing 32-bit ALU: Beginning


1. Let us start with and function 2. Let us now add or function
a0 b0 0 1 a1 b1 Result1 Result0

Operation

=0 =1

and or

0 1

a2 b2 0 1

Result2

a31 b31

0 1

Result31

g. babic

Designing 32-bit ALU: Principles


A number of functions are performed internally, but only one a0 result is chosen for b0 the output of ALU
a1

Operation = 0
=1
and or and or

and or
Result0

0 1

32-bit ALU is built out of 32 identical 1-bit ALUs

b1

0 1

Result1

a2 b2

and or

0 1

Result2

a31 b31

and or

0 1

Result31

g. babic

Designing the Adder


32-bit adder is built out of 32 1-bit adders
1-bit Adder 1-bit Adder Truth Table Input
a Figure B.5.2 0 0 0 0 1 1 1 1 0 0 1 1 0 0 1 1 b Carry In 0 1 0 1 0 1 0 1

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

This is a ripple carry adder.


a1 b1
Cin

+
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

32-bit ALU With 3 Functions


=0

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

32-bit Adder / Subtractor


binvert 0
Cin

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

32-bit ALU With 4 Functions


1-bit ALU
B in ve rt O pe ra tion C a r r y In a

B in v e r t

O p e r a tio n

a0 b0
0

C a rryI n ALU0 C a rryO u t

R e s u l t0

R e s u lt

0 1

a1 b1

C a rryI n ALU1 C a rryO u t

R e s u l t1

Figure B.5.8
C a r ry O u t

a2 b2

C a rryI n ALU2 C a rryO u t

R e s u l t2

Control lines Function


and or add subtract g. babic Binvert (1 line) 0 0 0 1 Operation (2 lines) 00 01 10 10 Presentation F
a3 1 b3 1

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

32-bit ALU With 4 Functions and Overflow


B in v e r t O p e r a tio n a0 b0 C a rryI n ALU0 C a rryO u t

R e s u l t0

Control lines Function


and or add subtract Binvert (1 line) 0 0 0 1 Operation (2 lines) 00 01 10 10
a2 b2 C a rryI n ALU2 C a rryO u t R e s u l t2 a1 b1 C a rryI n ALU1 C a rryO u t R e s u l t1

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

Missing: slt & nor functions and Zero output


g. babic Presentation F

Carry Out