# DEC30032 Computer Architecture & Organization
## CHAPTER 3: ARITHMETIC LOGIC UNIT (ALU)
### Provided by: AHMAD FUAD BIN ELLIAS, POLITEKNIK SULTAN IDRIS SHAH
---
## Page 2: Synopsis
- **Components of ALU**
- Understand various components in the ALU.
- Apply basic processes in the ALU.
- Evaluate the design of block components in the ALU.
---
## Page 3: ALU Operations
- **Logic Operations**
- AND, NOT, OR, XOR
- **Arithmetic Operations**
- Simple integer operations: addition, subtraction, multiplication, division.
- **Bit Shifting**
- **Complex Operations**
---
## Page 4: Overview of ALU
- **Definition**
- The ALU is a digital circuit that performs arithmetic and logical operations.
- **Importance**
- Fundamental building block of the CPU; present in even the simplest microprocessors.
---
## Page 5: ALU Functionality
- **Operation Process**
- Loads data from input registers.
- Control Unit directs the ALU on operations.
- Results are stored in output registers.
- **Control Unit Role**
- Moves processed data between registers, ALU, and memory.
---
## Page 6: ALU Operation Codes
- **Operation Codes**
- 00: operand1 + operand2
- 01: NOT (operand1)
- 10: operand1 AND operand2
- 11: operand1 OR operand2
- **Example**
- Addition of 1010 and 0111 results in 10001.
---
## Page 7: Registers in ALU
- **Operands**
- One operand is always in a register; the other may be in a register or part of the instruction.
- **Result Storage**
- The result is stored in a general-purpose register.
---
## Page 8: Machine Instructions
- **Instruction Components**
- Operation to perform.
- First operand (often in a register).
- Second operand (often in a register).
- Register for the result.
- **Example Instruction**
- `addu $10, $8, $9` for a 32-bit addition.
---
## Page 9: Integer Representation in ALU
- **Number Formats**
- Early computers used various number systems.
- **Modern Preference**
- Two's complement binary representation is standard for modern processors.
---
## Page 11: Half Adder
- **Functionality**
- Performs 1-bit addition.
- **Outputs**
- SUM (S) from XOR gate.
- CARRY (Cout) from AND gate.
---
## Page 12: Half Adder Limitations
- **Carry-in Issue**
- Cannot handle carry from previous additions.
- **Solution**
- Use a Full Adder for multiple data bits.
---
## Page 14: Full Adder
- **Definition**
- Adds three binary digits and generates a carry-out.
- **Components**
- Two half adders connected together.
---
## Page 17: 4-bit Ripple Carry Adder
- **Structure**
- Consists of multiple full adders for 4-bit addition.
- **Operation**
- Carries ripple through each adder.
---
## Page 21: Shift Registers
- **Types of Shift Registers**
- Serial in/serial out (SISO)
- Serial in/parallel out (SIPO)
- Parallel in/serial out (PISO)
- Parallel in/parallel out (PIPO)
---
## Page 28: Logic Operations in ALU
- **Arithmetic vs. Logic Operations**
- Arithmetic: Z = A + B, Z = A - B
- Logic: Z = NOT A, Z = A AND B, Z = A OR B
---
## Page 36: Multiplexer
- **Definition**
- Selects between multiple input signals and forwards to a single output.
- **Applications**
- Used in communication systems, computer memory, and telephone networks.
---
## Page 41: Magnitude Comparator
- **Functionality**
- Compares two binary numbers to determine their relative magnitude.
- **Applications**
- Used in CPUs and microcontrollers for variable comparisons.
---
## Page 44: Summary – 32-bit ALU
- **Components**
- 32-bit adder/subtractor, logic operations, multiplexers, and demultiplexers.
---
## Page 45: Assignment
- **Task**
- Construct an 8-bit shift register block (SISO) with a timing diagram operation.