Presentation is loading. Please wait.

Presentation is loading. Please wait.

ALU & CPU Computer Architecture. Introducing ALU ALU: Arithmetic & Logic Unit –Performs arithmetic operations Addition Subtraction –Performs logic operations.

Similar presentations


Presentation on theme: "ALU & CPU Computer Architecture. Introducing ALU ALU: Arithmetic & Logic Unit –Performs arithmetic operations Addition Subtraction –Performs logic operations."— Presentation transcript:

1 ALU & CPU Computer Architecture

2 Introducing ALU ALU: Arithmetic & Logic Unit –Performs arithmetic operations Addition Subtraction –Performs logic operations AND: AB OR: A+B NOT: A –Desired operation/result is chosen based on a selection logic.

3 Exercise Develop a circuit that accepts 3 inputs (say A, B, and C in ) and generates 2 outputs (say Out and C out ) depending on 3 control inputs S 1,S 2, and S 3 as shown in the truth table: S0S0 S1S1 S2S2 OutC out 000ABX 001A+BX 010AX 011BX 100 A  B  C in AB+ BC in + AC in X = Don’t care (can be 1 or 0)

4 Solution: 1-bit ALU A B Out 000 001 010 011 100 S0S0 S1S1 S2S2 S0S1S2S0S1S2 AB A+BA+B A B Full Adder C in Sum C out Multiplexer This approach can be extended to include other operations such as subtraction.

5 n-bit ALU –Repeat 1-bit ALU n times –All 1-bit ALUs get the same selection lines –Carry out (C out )from one stage is wired to carry-in of next state Similar to how a ripple carry adder (or subtraction circuit) is wired –Performs operation on n-bits simultaneously

6 Example 4-bit ALU ALU 3 ALU 2 ALU 1 ALU 0 A3A3 B3B3 A2A2 B2B2 A1A1 B1B1 A0A0 B0B0 Add/Sub O0O0 O1O1 O2O2 O3O3 O4O4 OP 0 OP 1 OP 2 Selection lines simply renamed to operation code (OPCode) lines Cin

7 ALU Notation An ALU is denoted using the following graphical notation. ALU Operand1 (A) Operand2 (B) Result 8 8 9 Operation Selection (OP Code) Indicates number of bits on each line. The size of each operand is typically the same and corresponds to the word size. 4 OP CodeResult 0 10 AB 1 10 A+BA+B 2 10 A 3 10 B ……

8 Thought Experiment Where do the inputs to the ALU come from? –The two operands –The operation the ALU needs to perform Similarly where do the outputs from the ALU go? Solution: Registers! –The fundamental storage units.

9 Fixed number of D-Flip Flops to form a Word –Corresponding to size of ALU operands! –Operate as a single unit Store/Read n-bits at a time D Q CK D Q D Q D Q D0D1D2D3 Q3 Q2Q1 Q0 Registers Revisited

10 Selecting a Register Given n Registers how to read data from a specific register? Register 1 00 8 Register 2 01 8 Register 3 10 8 Register 4 11 8 2 MUXMUX Register Select 8 Set of registers is called a Register File This is not a single Mux but a set of 8 Mux’s all having the same selection logic!

11 Selecting 2 Registers ALU needs 2 operands to work! –How to select 2 registers from a Register File? 00 8 01 10 11 2 MUX1MUX1 Register Select 1 8 8 8 8 00 01 10 11 2 MUX2MUX2 Register Select 2 8 8 8 8 8 Register File Operand1 Operand2

12 ALU with Inputs ALU 8 8 8 Operation 4 Mux1 Mux2 Register File (4) 8 Operand1 2 Operand2 2 Results What do we do with results or output from the ALU?

13 ALU Output Solution: Put it into a register! OK, so do we do that? –That is, Given 1 input how to route it on n different paths? 8 8 8 8 8 Result from ALU Select Inputs 2 DeMux 00 01 10 11 Register 1 Register 2 Register 3 Register 4

14 Handling ALU Output ALU 8 8 8 Operation 4 Mux1 Mux2 Register File (4) Flags DeMux 8 8 8 8 8 Operand1 2 Operand2 2 Destination 2 A B Each device has its own slection logic typically specified using a truth table! OperationResult 0 10 AB 1 10 A+BA+B 2 10 A Clock

15 Data path The ALU and associated components constitute the Data Path –Includes Registers, Multiplexers and any other device associated with ALU operations –All operands are typically the same size Register sizes match with size of operand –Size of operands are associated with CPU 32-bit processor (ALU uses 32-bit operands) 64-bit processor (ALU uses 64-bit operands)


Download ppt "ALU & CPU Computer Architecture. Introducing ALU ALU: Arithmetic & Logic Unit –Performs arithmetic operations Addition Subtraction –Performs logic operations."

Similar presentations


Ads by Google