CSC114 ยท 2078 ยท 10 marks
Differentiate analog computer with digital computer. What is CPU and how it works? What does an instruction cycle in CPU consist of?
Differentiate analog computer with digital computer. What is CPU and how it works? What does an instruction cycle in CPU consist of?[10]
Quick answer
A Central Processing Unit (CPU) is the primary component of a computer that carries out the instructions of a computer program.
Differentiate Analog Computer with Digital Computer. What is CPU and How it Works? What Does an Instruction Cycle in CPU Consist of?
Part 1: Difference Between Analog Computer and Digital Computer (3 marks)
Analog Computer: A computer that uses continuously changeable aspects of physical phenomena such as electrical, mechanical, etc. Examples: Planimeter, Nomogram.
Digital Computer: A computer that is used to process information with quantities using digits, usually the binary number system. Examples: IBM PC, Apple Macintosh.
| Basis | Analog Computer | Digital Computer |
|---|---|---|
| Definition | Works with continuous physical quantities (voltage, current, etc.) | Works with discrete digits, usually binary (0s and 1s) |
| Data Representation | Represents data as continuous signals | Represents data as discrete digits |
| Accuracy | Less accurate | Highly accurate |
| Speed | Slower for general-purpose tasks | Very fast in processing |
| Output | Output is in the form of graphs or dials | Output is in the form of numbers, text, images |
| Memory | Does not have significant memory | Has large memory capacity |
| Examples | Planimeter, Nomogram, Speedometer | IBM PC, Apple Macintosh |
| Usage | Used in scientific and engineering measurements | Used for general-purpose computing |
| Cost | Generally less expensive | Can be more expensive |
| Programming | Not easily programmable | Easily programmable |
Part 2: What is CPU and How it Works? (4 marks)
Definition of CPU
A Central Processing Unit (CPU) is the primary component of a computer that carries out the instructions of a computer program. As noted in the reference:
Microprocessor: An integrated circuit that contains all the functions of a central processing unit of a computer is called a microprocessor.
The CPU is often called the "brain of the computer" because it controls all operations of the computer system.
Components of CPU
The CPU consists of three main components:
1. Arithmetic and Logic Unit (ALU)
- Performs all arithmetic operations (addition, subtraction, multiplication, division)
- Performs all logical operations (AND, OR, NOT, comparison)
2. Control Unit (CU)
- Directs and coordinates all operations of the CPU
- Fetches instructions from memory, decodes them, and controls execution
- Acts as the manager of the CPU
3. Registers
- Small, high-speed temporary storage locations inside the CPU
- Examples: Program Counter (PC), Instruction Register (IR), Accumulator (ACC), Memory Address Register (MAR), Memory Buffer Register (MBR)
How CPU Works
The CPU works by following a continuous cycle of operations:
- Fetch: The Control Unit fetches the next instruction from main memory using the address stored in the Program Counter (PC).
- Decode: The fetched instruction is decoded by the Control Unit to determine what operation needs to be performed. As noted in the reference, the Opcode tells the processor what to do with the data.
- Execute: The ALU or other components carry out the instruction (arithmetic, logical, or data transfer operation).
- Store/Write Back: The result is stored back into a register or memory location.
This process repeats continuously as long as the computer is running.
Instruction Format (Supporting Detail)
An instruction format is a binary format which specifies a computer instruction. It specifies:
- Opcode: Tells the processor what operation to perform
- Operand: Stores the data to be operated or manipulated
- Addressing Mode: Specifies how the operand is accessed
Part 3: Instruction Cycle in CPU (3 marks)
The Instruction Cycle (also called the Fetch-Decode-Execute Cycle) is the complete process the CPU follows to process a single instruction. It consists of the following steps:
Steps of the Instruction Cycle
+----------+ +----------+ +-----------+ +----------+
| FETCH | --> | DECODE | --> | EXECUTE | --> | STORE |
+----------+ +----------+ +-----------+ +----------+
^ |
|____________________________________________________|
(Cycle repeats)
Step 1: Fetch
- The CPU fetches the instruction from main memory
- The Program Counter (PC) holds the address of the next instruction
- The instruction is loaded into the Instruction Register (IR)
- The PC is incremented to point to the next instruction
Step 2: Decode
- The Control Unit decodes the instruction stored in the IR
- It identifies the Opcode (what operation to do) and the Operand (what data to use)
- In RISC architecture, decoding is simple (CPI range: ~1.5)
- In CISC architecture, decoding is complex (CPI range: 2 to 15)
Step 3: Execute
- The decoded instruction is executed by the ALU or other units
- Arithmetic or logical operations are performed on the operands
- RISC does not require external memory for calculations; CISC does
Step 4: Store (Write Back)
- The result of the execution is written back to a register or memory location
- The cycle then repeats for the next instruction
Summary Table of Instruction Cycle
| Phase | Action | Unit Involved |
|---|---|---|
| Fetch | Get instruction from memory | Control Unit, PC, IR |
| Decode | Interpret the opcode and operand | Control Unit |
| Execute | Perform the operation | ALU |
| Store | Save the result | Registers / Memory |
Key Note: RISC vs CISC in Instruction Cycle
| Feature | RISC | CISC |
|---|---|---|
| CPI | ~1.5 | 2 to 15 |
| Decoding | Simple |
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.