Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science 210 Computer Organization The Arithmetic Logic Unit.

Similar presentations


Presentation on theme: "Computer Science 210 Computer Organization The Arithmetic Logic Unit."— Presentation transcript:

1 Computer Science 210 Computer Organization The Arithmetic Logic Unit

2 ALU - General Goal is to design simple ALU Actually there are relatively few basic arithmetic logic operations needed Many instructions can be implemented in terms of the basic ones

3 ALU Building Blocks AND GateNOT Gate OR Gate Multiplexor

4 Let's build an ALU to support the andi and ori instructions –we'll just build a 1 bit ALU, and use 32 of them An ALU (arithmetic logic unit) b a operation result

5 Selects one of the inputs to be the output, based on a control input We’ll use a MUX for our ALU Review: The Multiplexer 0101 S C A B

6 1-Bit Logical Unit 0101 0 - And Operation 1 - Or Result Operation

7 1-Bit ALU with Addition b 0 2 Result Operation a 1 CarryIn CarryOut

8 32 bit ALU

9 Two's complement approach: just negate b and add one. How do we negate? What about subtraction (a – b) ?

10 32 bit ALU 0 2 Result Operation a 1 CarryIn CarryOut 0 1 b binvert binvert = 1, carryin = 1, operation = 2, gives a + ~b + 1 = a - b binvert +

11 Overflow Detection OperationOperand AOperand BResult +  0 < 0 +  0 - < 0 -  0 Note: This can be determined by what happens in the high order bit.

12 Overflow Detection OperationA’s High BitB’s High BitResult High Bit +001 +110 - 011 - 100 Note: If we used the output of the binvert MUX, the rows for subtraction would be the same as for addition.

13 Overflow Detection A’s High BitBinvert MUXResult High Bit Overflow 0011 1101 Note: The other rows of a truth table for Overflow would be 0. So, we could build an overflow detector with _ _ _ AMR + AMR

14 High Order 1-Bit ALU (with overflow hardware) 0 2 Result Operation a 1 CarryIn CarryOut 0 1 Binvert b Overflow


Download ppt "Computer Science 210 Computer Organization The Arithmetic Logic Unit."

Similar presentations


Ads by Google