IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these...

14
IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC, which is derived from Howard Huang’s work and developed by Jeff Carlyle; Prof. Daniel Gajski’s transparency for Principles of Digital Design.

Transcript of IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these...

Page 1: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

IKI10201 05b-Arithmetic Logic Unit (ALU)

Bobby NaziefSemester-I 2005 -

2006

The materials on these slides are adopted from:

•CS231’s Lecture Notes at UIUC, which is derived from Howard Huang’s work and developed by Jeff Carlyle;

•Prof. Daniel Gajski’s transparency for Principles of Digital Design.

Page 2: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Adders/Subractors: Arithmetic Unit

• When Sub = 0, the XOR gates output B3 B2 B1 B0 and the carry in is 0. The adder output will be A + B + 0, or just A + B.

• When Sub = 1, the XOR gates output B3’ B2’ B1’ B0’ and the carry in is 1. Thus, the adder output will be a two’s complement subtraction, A - B.

• Arithmetic Unit that is capable to do addition & subtraction can be constructed using Full Adders.

Page 3: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Logical Unit

• In addtion to arithmetic operations, most computers also support logical operations like AND, OR and NOT, but extended to multi-bit words instead of just single bits.

• To apply a logical operation to two words X and Y, apply the operation on each pair of bits Xi and Yi:

1 0 1 1AND 1 1 1 0

1 0 1 0

1 0 1 1OR 1 1 1 0

1 1 1 1

1 0 1 1XOR 1 1 1 0

0 1 0 1

Page 4: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Defining a logic unit

• Boolean functions of 2 variables have 2 inputs, 1 output, and 4 minterms

• We can generate 16 Boolean functions using 4 (select) variables:

the Truth Table:

• Boolean Functions:

– AND f8 values of select variables S3S2S1S0 = 1000

– OR f14 values of select variables S3S2S1S0 = 1110

– ...

Page 5: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Logic unit implementation

Page 6: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Arithmetic-Logic Units (ALUs)

• An arithmetic-logic unit, or ALU, performs many different arithmetic and logic operations. The ALU is the “heart” of a processor—you could say that everything else in the CPU is there to support the ALU.

Page 7: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

One of ALU structures

• AE = Arithmetic Extender (Add, Sub, Inc, Dec)

• LE = Logic Extender (AND, OR, PASS, NOT)

Page 8: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Additional variables for AE & LE

• M: select arithmetic or logic operations

– M = 1 ALU will perform arithmetic operation

– M = 0 ALU will perform logic operation

• S1 & S0: once arithmetic or logic operations has been selected, these 2 variable will select specific operations to be performed by ALU

– M = 1 S1 & S0 will select one of Add, Sub, Inc, Dec

– M = 0 S1 & S0 will select one of AND, OR, PASS, NOT

Page 9: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Arithmetic Extender

• Functional Table:

• Implementation:LE’s requirement

Page 10: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Logic Extender

• Functional Table:

• Truth Table:

satisfy AE

Conforms with AE’s output

Page 11: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

Logic Extender (cont.)

• Map & Implementation:

Page 12: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

The ALU

• If M = 1, then

– Xi = ai, Yi = A(bi), c0 = S1

• If M = 0, then

– Xi = L(ai,bi), Yi = 0, c0 = 0

Page 13: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

ALU function table

M S1 S0 C0 Operation

0 0 0 0 F = A’ 0 0 1 0 F = A AND B 0 1 0 0 F = A 0 1 1 0 F = A OR B 1 0 0 0 F = A – 1 1 0 1 0 F = A + B 1 1 0 1 F = A + B’ + 1 1 1 1 1 F = A + 1

Page 14: IKI10201 05b-Arithmetic Logic Unit (ALU) Bobby Nazief Semester-I 2005 - 2006 The materials on these slides are adopted from: CS231’s Lecture Notes at UIUC,

ALU’s summary

• This ALU is a good example of hierarchical design.

– With the 12 inputs, the truth table would have had 212 = 4096 lines. That’s an awful lot of paper.

– Instead, we were able to re-use components that we’ve seen before to construct the entire circuit from a couple of easy-to-understand components.

• As always, we encapsulate the complete circuit in a “black box” so we can reuse it in fancier circuits.