Skip to content

Computer Architecture: University-Level 20-Mark Bilingual Answer Bank

English and āĻŦāĻžāĻ‚āϞāĻž | Expanded exam-ready answers | Diagrams, formulas, worked examples

How to use this file: In the examination, begin with a definition or introduction, draw the relevant diagram, explain the main points under headings, add an example or equation, and finish with a short conclusion. The answers below are intentionally structured in that order.


Contents

Part A — Core Concepts

  1. Classes of computers
  2. Layers of computer system architecture
  3. Throughput and response time
  4. Basic functional units of a computer
  5. Bus structure of a processor
  6. Instruction Set Architecture and MIPS formats
  7. RISC versus CISC

Part B — Instructions, ISA, Datapath and Control

  1. Execution of Load R2, LOC
  2. Characteristics of a RISC processor
  3. Three-bus CISC-style processor organization
  4. Execution of Add (R3), R1
  5. MIPS addressing modes
  6. MIPS code for two C statements
  7. Compilation of a C program
  8. General addressing modes
  9. Instruction and its computer representation
  10. Processor datapath
  11. Datapath control signals
  12. Dynamic scheduling
  13. Microprogrammed control for a branch
  14. Purpose of the control unit
  15. Word, address and memory access time

Part C — Pipelining and Hazards

  1. Pipeline performance
  2. Ideal pipelined operation
  3. Pipeline issues
  4. Operand forwarding
  5. Datapath modification for forwarding
  6. Data hazards and their performance effects

Part D — Computer Arithmetic and Performance

  1. Multiplication algorithm and hardware
  2. Binary division
  3. IEEE 754 representation of −0.625
  4. Four-bit binary multiplier
  5. Booth multiplication: 16 × (−2)
  6. Measuring computer performance
  7. Comparative processor-performance problem

Part E — Parallelism and Memory

  1. Flynn’s classification
  2. Cache memory, hit, miss and miss penalty
  3. Write-through and write-back
  4. RTL for selected MIPS instructions
  5. Processor–memory connection
  6. Internal organization of memory bit cells
  7. Design of a 2M×32 memory module
  8. Virtual memory and cache mapping

Part A — Core Concepts

Discuss the basic functional units of a computer.

Discuss the basic functional units of a computer.

A digital computer has five basic functional units: the input unit, memory unit, arithmetic logic unit (ALU), control unit, and output unit. Together, the ALU and control unit form the Central Processing Unit (CPU).
## Input Unit

  • Accepts raw data and instructions from the user.
  • Converts input into a binary code that the computer can understand.
  • Common devices include keyboards, mice, and microphones.

## Memory Unit

  • Stores data, program instructions, and intermediate results.
  • Primary memory (RAM) offers fast, temporary workspace during processing.
  • Secondary memory (hard drives, SSDs) provides long-term, permanent storage.

## Arithmetic Logic Unit (ALU)

  • Performs math tasks like addition, subtraction, multiplication, and division.
  • Handles logic choices like comparing numbers or doing true/false checks.

## Control Unit (CU)

  • Acts as the central nervous system or manager of the computer.
  • Directs the flow of data and commands between all other units.
  • Fetches and decodes instructions from memory to run programs.

## Output Unit

  • Takes processed binary data from the computer and converts it into a usable format.
  • Delivers the final results to the user.
  • Common devices include monitors, printers, and speakers.

A1. Classes of Computers

Enhanced question

Classify computers from the viewpoints of data representation, purpose, and size/performance. Explain the defining characteristics and typical applications of every major class with suitable examples.

A computer is an electronic programmable system that accepts data, processes it according to stored instructions, produces information, and stores the result. A single classification is insufficient because computers differ in the type of data they process, the task for which they are built, and their processing capacity.

1. Classification by data representation

Class Main characteristics Typical applications
Analog computer Works with continuous physical quantities such as voltage, pressure, speed or temperature; gives approximate results; very fast for simulation of continuous systems. Process control, old flight simulators, differential analysers.
Digital computer Represents data using discrete binary values; programmable, accurate, repeatable and suitable for storage and logical operations. PCs, smartphones, servers, calculators.
Hybrid computer Combines analog measurement with digital control and accuracy. An A/D converter usually connects the two parts. ICU monitoring, petrol pumps, industrial and scientific control.

2. Classification by purpose

  • General-purpose computer: Can perform many tasks by changing software. A laptop may be used for programming, accounting, communication and entertainment.
  • Special-purpose computer: Designed and optimized for one restricted task. Examples include an automobile engine-control unit, traffic-light controller and washing-machine controller.
  • Embedded computer: A special-purpose computer built inside a larger product. It normally has limited memory and power, real-time constraints, high reliability and little or no general user interface.

3. Classification by size and performance

Class Important characteristics Examples/uses
Microcomputer / Personal computer One main user; microprocessor-based; low cost; desktop, laptop, tablet or smartphone form. Education, office and home use.
Workstation High-end single-user system; powerful CPU/GPU, large RAM and professional reliability. CAD, 3-D design, engineering and scientific work.
Midrange system / Minicomputer Supports several or many users and I/O terminals; historically smaller than a mainframe. Modern departmental servers occupy this role. Laboratories, factories and departmental databases.
Mainframe Very high I/O throughput, reliability, security, virtualization and support for thousands of concurrent users or transactions. Banks, airlines, census and government records.
Supercomputer Highest computational performance through massive parallelism; measured using FLOPS rather than only instruction rate. Weather prediction, molecular modelling, AI and nuclear simulation.

Thus, “largest” does not always mean “best.” A mainframe is optimized mainly for reliable transaction and I/O processing, whereas a supercomputer is optimized for enormous numerical computation.

A2. Layers of Computer System Architecture

Explain the layers of computer system architecture đŸ—ī¸âš™ī¸ with a neat diagram.

Figure: layered computer system

Layers of Computer System Architecture

Computer architecture is understood more easily as a hierarchy of abstractions. Each layer hides unnecessary implementation details and offers a simpler interface to the layer above.

  1. Application layer: Contains programs that solve users’ problems, such as browsers, word processors and database systems.
  2. High-level language and library layer: Programmers express algorithms using C, C++, Java or libraries. Compilers translate this representation toward the ISA.
  3. Operating-system layer: Manages processes, memory, files, security and I/O devices. It provides system calls and makes hardware resources appear orderly and shareable.
  4. ISA layer: The boundary visible to machine-language programmers and compilers. It defines instructions, registers, data formats, addressing modes, exceptions and the memory model. MIPS, ARM and x86 are ISAs.
  5. Microarchitecture layer: The particular hardware organization that implements an ISA—datapath, control unit, ALU, pipeline, cache and branch predictor. Different processors can implement the same ISA differently.
  6. Digital-logic layer: Implements the microarchitecture using gates, adders, decoders, multiplexers, registers and state machines.
  7. Circuit/device layer: Implements logic with transistors, semiconductor devices, wires, voltage and timing.

The important idea is abstraction. For example, a C statement is compiled into ISA instructions; those instructions are executed by a microarchitecture; the microarchitecture is constructed from logic gates; and the gates are implemented using transistors. This separation permits software portability and independent improvement of hardware.

A3. Throughput and Response Time

Enhanced question

Define response time and throughput as measures of computer performance. Derive their basic performance relationships, compare them, and explain with examples how a design change may affect either or both.

Response time (latency) is the total elapsed time from submitting one task until its completion:

\[T_{\text{response}}=T_{\text{finish}}-T_{\text{start}}\]

It includes CPU time, memory and I/O waiting, operating-system overhead and any queueing delay. Performance for a single task is inversely related to execution time:

\[\text{Performance}\propto\frac{1}{T_{\text{execution}}}\]

Throughput (bandwidth) is the number of tasks completed per unit time:

\[\text{Throughput}=\frac{\text{Number of completed jobs}}{\text{Total time}}\]
Aspect Response time Throughput
Concern How long one job takes How many jobs finish
Unit seconds/job jobs/second
Important to Interactive user Server/data-centre operator
Common improvement Faster core, lower latency More cores, disks or servers

Example: If one request completes in 0.2 s, its response time is 0.2 s. If a server completes 500 requests in 10 s, throughput is 50 requests/s. Replacing one processor with a faster processor may improve both. Adding a second processor may nearly double throughput when jobs are independent, but it may not shorten the response time of one serial job. Queueing also connects the measures: when arrival rate approaches maximum throughput, response time can rise sharply.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Response time āĻŦāĻž latency āĻšāϞ⧋ āĻāĻ•āϟāĻŋ āĻ•āĻžāϜ āϜāĻŽāĻž āĻĻ⧇āĻ“āϝāĻŧāĻž āĻĨ⧇āϕ⧇ āĻĢāϞ āĻĒāĻžāĻ“āϝāĻŧāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻŽā§‹āϟ āϏāĻŽāϝāĻŧ:

\[T_{\text{response}}=T_{\text{finish}}-T_{\text{start}}\]

āĻāϰ āĻŽāĻ§ā§āϝ⧇ CPU execution, memory/I/O wait, OS overhead āĻāĻŦāĻ‚ queueing delay āĻ…āĻ¨ā§āϤāĻ°ā§āϭ⧁āĻ•ā§āϤāĨ¤ āĻāĻ•āϟāĻŋ āĻ•āĻžāĻœā§‡āϰ performance execution time-āĻāϰ āĻŦā§āϝāĻ¸ā§āϤāĻžāύ⧁āĻĒāĻžāϤāĻŋāĻ•āĨ¤

Throughput āĻŦāĻž bandwidth āĻšāϞ⧋ āĻāĻ•āĻ• āϏāĻŽāϝāĻŧ⧇ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āĻžāĻœā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻž:

\[\text{Throughput}=\frac{\text{āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āĻžāĻœā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻž}}{\text{āĻŽā§‹āϟ āϏāĻŽāϝāĻŧ}}\]

Response time āĻŦāϞ⧇ āĻāĻ•āϟāĻŋ āĻ•āĻžāϜ āĻ•āϤ āĻĻā§āϰ⧁āϤ āĻļ⧇āώ āĻšāϝāĻŧ, āφāϰ throughput āĻŦāϞ⧇ āĻāĻ•āĻ• āϏāĻŽāϝāĻŧ⧇ āĻ•āϤāϗ⧁āϞ⧋ āĻ•āĻžāϜ āĻļ⧇āώ āĻšāϝāĻŧāĨ¤ Interactive user āĻ•āĻŽ response time āϚāĻžāϝāĻŧ; server administrator āĻŦ⧇āĻļāĻŋ throughput āϚāĻžāϝāĻŧāĨ¤

āωāĻĻāĻžāĻšāϰāĻŖ: āĻāĻ•āϟāĻŋ request āĻļ⧇āώ āĻšāϤ⧇ 0.2 s āϞāĻžāĻ—āϞ⧇ response time 0.2 sāĨ¤ 10 s-āĻ 500āϟāĻŋ request āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāϞ⧇ throughput 50 requests/sāĨ¤ āφāϰāĻ“ processor āϝ⧋āĻ— āĻ•āϰāϞ⧇ independent āĻ•āĻžāĻœā§‡āϰ throughput āĻĒā§āϰāĻžāϝāĻŧ āĻĻā§āĻŦāĻŋāϗ⧁āĻŖ āĻšāϤ⧇ āĻĒāĻžāϰ⧇, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāĻ•āϟāĻŋ serial āĻ•āĻžāĻœā§‡āϰ response time āĻ•āĻŽāϤ⧇āχ āĻšāĻŦā§‡â€”āĻāĻŽāύ āύāϝāĻŧāĨ¤ āφāĻŦāĻžāϰ system-āĻāϰ arrival rate āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ throughput-āĻāϰ āĻ•āĻžāĻ›āĻžāĻ•āĻžāĻ›āĻŋ āϗ⧇āϞ⧇ queue āϤ⧈āϰāĻŋ āĻšāϝāĻŧ⧇ response time āĻĻā§āϰ⧁āϤ āĻŦ⧇āĻĄāĻŧ⧇ āϝ⧇āϤ⧇ āĻĒāĻžāϰ⧇āĨ¤

āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽā§‡āϰ āĻ•āĻžāĻ°ā§āϝāĻ•ā§āώāĻŽāϤāĻž āĻŦā§‹āĻāĻžāϰ āĻŽā§‚āϞ āĻŦāĻŋāώ⧟ āĻšāϞ⧋ āϰ⧇āϏāĻĒāĻ¨ā§āϏ āϟāĻžāχāĻŽ, āĻĨā§āϰ⧁āĻĒ⧁āϟ āĻāĻŦāĻ‚ āĻ•āĻŋāω āĻ—āĻ āύāĨ¤ āĻāχ āϤāĻŋāύāϟāĻŋ āωāĻĒāĻžāĻĻāĻžāύ āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰ⧇ āĻāĻ•āϟāĻŋ āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ āĻŦāĻž āϏāĻžāĻ°ā§āĻ­āĻžāϰ āĻ•āϤ āĻĻā§āϰ⧁āϤ āĻ“ āĻĻāĻ•ā§āώāϤāĻžāϰ āϏāĻžāĻĨ⧇ āĻ•āĻžāϜ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤

āϰ⧇āϏāĻĒāĻ¨ā§āϏ āϟāĻžāχāĻŽ āĻ“ āĻĨā§āϰ⧁āĻĒ⧁āϟ
āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āĻžāϜ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻšāϤ⧇ āϝ⧇ āϏāĻŽā§Ÿ āϞāĻžāϗ⧇ āϤāĻž āĻšāϞ⧋ āϰ⧇āϏāĻĒāĻ¨ā§āϏ āϟāĻžāχāĻŽ (āϝ⧇āĻŽāύ: ā§Ļ.⧍ āϏ⧇āϕ⧇āĻ¨ā§āĻĄ)āĨ¤
āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϏāĻŽā§Ÿā§‡ āϝāϤāϗ⧁āϞ⧋ āĻ•āĻžāϜ āĻļ⧇āώ āĻšā§Ÿ āϤāĻž āĻšāϞ⧋ āĻĨā§āϰ⧁āĻĒ⧁āϟ (āϝ⧇āĻŽāύ: āĻĒā§āϰāϤāĻŋ āϏ⧇āϕ⧇āĻ¨ā§āĻĄā§‡ ā§Ģā§ĻāϟāĻŋ āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¸ā§āϟ)āĨ¤
āĻĒā§āϰāϏ⧇āϏāϰ āĻ“ āĻ•āĻžāĻœā§‡āϰ āϧāϰāύ
āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āĻĒā§āϰāϏ⧇āϏāϰ āϝ⧁āĻ•ā§āϤ āĻ•āϰāϞ⧇ āφāϞāĻžāĻĻāĻž āĻ“ āĻ¸ā§āĻŦāĻžāϧ⧀āύ (independent) āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ āĻ“ āĻĨā§āϰ⧁āĻĒ⧁āϟ āĻŦāĻžā§œā§‡āĨ¤
āĻ•āĻŋāĻ¨ā§āϤ⧁ āϧāĻžāϰāĻžāĻŦāĻžāĻšāĻŋāĻ• āĻŦāĻž āϏāĻŋāϰāĻŋ⧟āĻžāϞ (serial) āĻ•āĻžāĻœā§‡āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻĒā§āϰāϏ⧇āϏāϰ āĻŦāĻžā§œāϞ⧇āĻ“ āϰ⧇āϏāĻĒāĻ¨ā§āϏ āϟāĻžāχāĻŽ āĻ•āĻŽāĻžāϰ āϕ⧋āύ⧋ āύāĻŋāĻļā§āϚ⧟āϤāĻž āύ⧇āχāĨ¤
āĻ•āĻŋāω āĻ“ āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āϚāĻžāĻĒ
āĻ•āĻžāĻœā§‡āϰ āϚāĻžāĻĒ āĻŦāĻž āφāĻ—āĻŽāύ āĻšāĻžāϰ (arrival rate) āϝāĻ–āύ āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ āĻ•ā§āώāĻŽāϤāĻžāϰ āĻ•āĻžāĻ›āĻžāĻ•āĻžāĻ›āĻŋ āĻĒ⧌āρāĻ›āĻžā§Ÿ, āϤāĻ–āύ āϜāϟ āĻŦāĻž āĻ•āĻŋāω (queue) āϤ⧈āϰāĻŋ āĻšā§ŸāĨ¤
āĻāχ āĻ•āĻŋāω āĻŦāĻž āϏāĻžāϰāĻŋāϰ āĻ•āĻžāϰāϪ⧇ āĻ•āĻžāĻœā§‡āϰ āĻ…āĻĒ⧇āĻ•ā§āώāĻž āĻ•āϰāĻžāϰ āϏāĻŽā§Ÿ āĻŦāĻž āϰ⧇āϏāĻĒāĻ¨ā§āϏ āϟāĻžāχāĻŽ āϖ⧁āĻŦ āĻĻā§āϰ⧁āϤ āĻŦ⧃āĻĻā§āϧāĻŋ āĻĒāĻžā§ŸāĨ¤


A4. Basic Functional Units of a Computer

Enhanced question

Identify and explain the basic functional units of a stored-program computer. Describe the flow of instructions and data among these units with a block diagram.

Figure: functional organization

Basic Functional Units of a Computer
Basic Functional Units of a Computer

A stored-program computer contains five fundamental units:

  1. Input unit: Accepts programs and data from keyboards, sensors, networks or storage and converts them into binary form.
  2. Memory unit: Holds both instructions and data. Registers are fastest and closest to the ALU; cache reduces the gap between CPU and main memory; main memory stores currently active programs; secondary storage provides long-term capacity.
  3. Arithmetic and Logic Unit (ALU): Performs arithmetic, logic, comparison and shift operations. Condition flags may record zero, carry, sign and overflow.
  4. Control unit: Fetches and decodes instructions and issues timing/control signals that move data and select ALU, memory and I/O operations. The program counter (PC) identifies the next instruction and the instruction register (IR) holds the current one.
  5. Output unit: Converts binary results into a form usable by people or other systems.

The register file, ALU and control unit together form the CPU. Buses and Interconnects carry addresses, data and control information. During the fetch–decode–execute cycle, the CPU fetches an instruction from memory, decodes its opcode, obtains operands, executes the operation, accesses memory if required and writes back the result.

Main Parts of a CPU

  • Register file: stores fast data inside the CPU.
  • ALU: does math and logic work.
  • Control unit: tells the other parts what to do.

Buses and Interconnects

  • Data bus: moves the actual data.
  • Address bus: points to memory spots.
  • Control bus: sends signals for timing and commands.

The Fetch–Decode–Execute Cycle Steps

  • Fetch: gets the next instruction from memory.
  • Decode: reads what the instruction means.
  • Get operands: finds the needed numbers or items.
  • Execute: runs the math or logic task.
  • Access memory: reads or writes to memory if needed.
  • Write back: saves the final answer.

A5. Bus Structure of a Processor

Enhanced question

Explain the internal and external bus structure of a processor. Distinguish address, data and control buses, and compare single-bus, two-bus and three-bus CPU organizations.

Figure: system bus and internal three-bus datapath

Processor Bus Structure

A bus is a shared collection of lines that transfers information among components.
Here is the complete and detailed English version of the video's content regarding the Bus Structure in Computer Architecture, without skipping any information:

1. What is a Bus?

The major hardware components of a computer are the CPU (Central Processing Unit), memory unit, and I/O (Input/Output) devices. These components work together to perform any given computational task. To communicate with each other, they use a set of communication paths or lines.

Collectively, this set of communication paths is called a Bus. Simply put, a bus is a collection of wires or paths that connects the major hardware components of a computer.

2. System Bus

A bus that connects the computer's primary hardware components (CPU, memory, and I/O devices) is called a System Bus. The system bus is divided into three functional categories:

  • Data Bus: This bus carries only data from one component to another. It consists of 8, 16, 32, or more parallel data lines. Because it is used for both receiving data (from memory or input devices) and sending data (to memory or output devices), the data bus is bidirectional.
  • Address Bus: This bus carries only the address of a memory location or an I/O device. It typically consists of 16, 20, or 24 address lines. Because the CPU can only perform one operation at a time on this bus—either sending an address to write or receiving an address to read—the address bus is unidirectional.
  • Control Bus: This bus carries control information in the form of control signals provided by the control unit. These signals are required to perform various activities, such as reading data from an input device, writing data to memory, or displaying data on an output device.
    System Bus

3. Types of Bus Structures

There are three main types of bus structures used in computer architecture:

A. Single Bus Structure

In this structure, the data bus, address bus, and control bus are combined into a single system bus. All major hardware components are connected to this one bus.
Single Bus Structure
* Operation: The most important rule here is that only one transfer can be done at a time. This means only two major components (e.g., the CPU and memory, or the CPU and an I/O device) can actively use the bus at any given moment.
* Advantages: It is highly cost-effective and provides great flexibility for attaching a large number of peripheral devices to the system.
* Disadvantages: Because only two units can communicate at a time, all other connected peripherals must wait in an inactive state until the current transfer is complete. This results in high propagation delay and slower overall performance.

B. Double Bus Structure

Double Bus Structure
As the name implies, this structure utilizes two separate buses to improve efficiency:

  1. Memory Bus: Used primarily by the processor to fetch instructions and transfer data to and from the memory unit.
  2. I/O Bus: Used by the processor to fetch data from input devices and send data to output devices.

  3. Advantages: The performance is significantly higher than a single bus structure. Because there are two distinct buses, two separate transfers can occur simultaneously (parallel execution). This makes the execution of processes much faster.

  4. Disadvantages: The cost of constructing a double bus structure is higher since it requires wiring and managing two separate buses instead of one.

C. Multiple Bus Structure

The multiple bus structure incorporates several specialized buses to handle different capacities and speeds. Aside from the standard system bus, it mainly focuses on three specific buses:
Multiple Bus Structure
1. Local Bus: This connects the processor to the cache memory through a local I/O controller.
2. High-Speed Bus: High-capacity I/O devices (like graphics cards, video, and LAN networks) operate at very fast speeds. These are connected to the high-speed bus using interfaces like SCSI (Small Computer System Interface) and P1394 (FireWire). This bus is also connected directly to the cache memory.
3. Expansion Bus: Low-capacity and slower I/O devices (like fax machines, modems, and serial devices) are connected to the expansion bus.

  • Note: The high-speed bus and the expansion bus are linked together via an Expansion Bus Interface. This hierarchical separation keeps slow devices from bottlenecking the fast devices.

Summary of Differences

  • Single Bus Structure: Uses exactly 1 bus (System Bus) for all data and instruction fetching.
  • Double Bus Structure: Uses 2 buses (Memory Bus for instructions/memory data, I/O Bus for device data).
  • Multiple Bus Structure: Uses 3 specialized buses (Local Bus, High-speed Bus, Expansion Bus) to manage varied device speeds.
    (Note: The foundational "System Bus" concept exists in all architectures as the base connection between the processor, main memory, and I/O).

Conclusion:
At the end of the video, the presenter recaps the topics discussed (definition of a bus, system bus components, and the three structures), invites viewers to ask questions in the comment section, and encourages viewers to like, share, and subscribe to the channel for future updates.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Bus āĻšāϞ⧋ āĻāĻ•āϗ⧁āĻšā§āĻ› shared signal line, āϝāĻž āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ hardware unit-āĻāϰ āĻŽāĻ§ā§āϝ⧇ āϤāĻĨā§āϝ āĻĒāϰāĻŋāĻŦāĻšāύ āĻ•āϰ⧇āĨ¤

  • Address bus memory location āĻŦāĻž I/O port āύāĻŋāĻ°ā§āĻŦāĻžāϚāύ āĻ•āϰ⧇āĨ¤ \(n\)āϟāĻŋ address line āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ \(2^n\)āϟāĻŋ location āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤
  • Data bus instruction āĻ“ operand āĻŦāĻšāύ āĻ•āϰ⧇ āĻāĻŦāĻ‚ āϏāĻžāϧāĻžāϰāĻŖāϤ bidirectionalāĨ¤
  • Control bus Read, Write, clock, interrupt, reset, byte-enable, bus-request āĻāĻŦāĻ‚ ready/wait signal āĻŦāĻšāύ āĻ•āϰ⧇āĨ¤

CPU-āĻāϰ āϭ⧇āϤāϰ⧇ bus register file, ALU, shifter āĻ“ memory interface āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇āĨ¤ Single-bus organization āϏāĻšāϜ āĻ“ āĻ•āĻŽ āĻŦā§āϝāϝāĻŧāĻŦāĻšā§āϞ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻāĻ•āϏāĻŽāϝāĻŧ⧇ āĻāĻ•āϟāĻŋ transfer āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ āĻŦ⧇āĻļāĻŋ cycle āϞāĻžāϗ⧇āĨ¤ Two-bus organization āĻ•āĻŋāϛ⧁ parallel transfer āϏāĻŽā§āĻ­āĻŦ āĻ•āϰ⧇āĨ¤ Three-bus organization-āĻ A āĻ“ B bus āĻĻāĻŋāϝāĻŧ⧇ āĻĻ⧁āχāϟāĻŋ source operand ALU-āϤ⧇ āϝāĻžāϝāĻŧ āĻāĻŦāĻ‚ C bus āĻĻāĻŋāϝāĻŧ⧇ āĻĢāϞ register-āĻ āĻĢ⧇āϰ⧇; āĻĢāϞ⧇ R1 ← R2 + R3 āĻāĻ•āχ register-transfer cycle-āĻ āĻ•āϰāĻž āϝāĻžāϝāĻŧāĨ¤ āϤāĻŦ⧇ register file-āĻ āĻŦ⧇āĻļāĻŋ port āĻ“ āĻŦ⧇āĻļāĻŋ wire āĻĻāϰāĻ•āĻžāϰ āĻšāϝāĻŧāĨ¤

Synchronous bus clock āĻ…āύ⧁āϏāϰāĻŖ āĻ•āϰ⧇; asynchronous bus request/acknowledge signal āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤ Bus width, frequency āĻ“ protocol āĻŽā§‹āϟ bandwidth āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤ CPU āĻ“ DMA-āĻāϰ āĻŽāϤ⧋ āĻāĻ•āĻžāϧāĻŋāĻ• master āĻĨāĻžāĻ•āϞ⧇ arbitration āĻĒā§āϰāϝāĻŧā§‹āϜāύāĨ¤


A6. Instruction Set Architecture and MIPS Instruction Formats

A6. Instruction Set Architecture and MIPS Instruction Formats

Explanation of the ISA Layered Diagram
ISA Layered Diagram
Let us carefully look at the provided image to understand the real-life feeling of how Instruction Set Architecture works. The picture beautifully shows a layered computer system where the ISA block sits exactly in the middle.

To feel how ISA actually works, we need to divide this image into three simple zones.

The Software Domain (Top Portion)

In the upper half of the image, we have the complete Software area. This contains high-level things like your daily Application programs, the Operating System, and translation tools like the Compiler, Assembler, and Linker.

  • The software programmers work only in this area.
  • They write human-readable code in languages like C, Java, or Python.
  • They do not need to worry about how the physical wires, logic gates, or electrical signals are working inside the silicon chip.

The Hardware Domain (Bottom Portion)

In the lower half of the image, we have the complete Hardware area. This starts from the major hardware blocks like the Processor, Memory, and I/O System, and goes deep down to Datapath Control, Digital Logic Design, and finally the Physical IC Layout (which means the actual silicon transistors).

  • The electrical and hardware engineers work exactly in this area.
  • They design the electronic circuits and chip layouts.
  • They do not need to know what specific software application or web browser the final user will run on the machine.

The ISA as the Universal Bridge (The Middle Layer)

Now, to make you feel "Yes, ISA works like that", just look at the large, light-green block perfectly separating the top and bottom. It is labeled "Instruction Set Architecture (Interface S/H)".

  • The word "Interface S/H" simply means Software-to-Hardware Interface.
  • The ISA is acting like a universal translator or a strict contract between two completely different worlds.
  • The software side compiles all its complex logic down into simple ISA commands (like add, load, or jump). It drops these instructions onto the ISA layer.
  • The hardware side looks up at this ISA layer, takes those exact binary instructions, and uses its logic gates to execute them.

Final Conclusion

Therefore, this image proves that ISA is nothing but a strict boundary line. It makes us feel that software and hardware are completely blind to each other's internal complexities. As long as both the Software top layer and the Hardware bottom layer agree to follow the standard rules of this middle ISA block, the computer will function perfectly.

## Concept of Instruction Set Architecture (ISA đŸ“œđŸ—ī¸

Basically, the Instruction Set Architecture (ISA) is the main boundary line or interface between the software programs and the hardware of the computer system. We can say that it is a complete rulebook for the microprocessor. It tells the software programmer exactly what commands the CPU hardware can understand and execute.

A complete ISA defines several important things for the system:

  • It defines the complete set of instructions the hardware can do, like addition, subtraction, or moving data.
  • It defines the data types and the size of the registers available inside the processor.
  • It tells us about the addressing modes, which means the exact mathematical ways the CPU will find data inside the main memory.

The best advantage of ISA is that even if two different companies design the internal chip circuits very differently, if they follow the same ISA standard, they can run the exact same software programs without any problem.
To understand more watch this
Explanation of MIPS Instruction Set Formats with Examples 💡📋

In the MIPS architecture, every single instruction is strictly fixed to a length of exactly 32 bits. This fixed size makes the hardware decoding process very fast and simple. Based on how these 32 bits are internally divided, the MIPS instructions are classified into three main formats.

1. R-Type (Register Format)

This format is used when all the data we need for calculation is already present inside the CPU registers. It does not use any fixed constant number from the instruction itself.

The 32 bits of R-Type are divided into 6 parts:

  • opcode (6 bits): It is the operation code. For all R-type instructions, this value is always 0.
  • rs (5 bits): The first source register index.
  • rt (5 bits): The second source register index.
  • rd (5 bits): The destination register where the final answer is saved.
  • shamt (5 bits): Shift amount. It is used only for logical shift operations, otherwise it is kept as 0.
  • funct (6 bits): Function code. Since the opcode is 0, this part tells the ALU the exact mathematical operation to do (like add, subtract, or AND).

Example of R-Type:
Let us consider the assembly instruction: add $s1, $s2, $s3
This means we are adding the data of register $s2 and $s3, and storing the final result in register $s1.
=> Opcode for R-type = 0
=> rs register = $s2
=> rt register = $s3
=> rd register = $s1
=> shamt = 0
=> funct code for add operation = 32

2. I-Type (Immediate Format)

This format is used when the instruction contains a direct constant number (called an immediate value), or when we need to transfer data between the main memory and registers using load or store commands.

The 32 bits of I-Type are divided into 4 parts:

  • opcode (6 bits): Tells the CPU the exact operation to perform (like addi for add immediate, or lw for load word).
  • rs (5 bits): The source or base register index.
  • rt (5 bits): The target destination register.
  • immediate (16 bits): A constant mathematical value or a memory address offset.

Example of I-Type:
Let us consider the assembly instruction: addi $t0, $t1, 100
This means we are adding the direct constant value of 100 to the data inside register $t1 and saving it in register $t0.
=> Opcode for addi = 8
=> rs register = $t1
=> rt register = $t0
=> immediate value = 100

3. J-Type (Jump Format)

This format is very simple and is used only for unconditional jump instructions. It is used when the program execution needs to go to a completely new address location far away in the memory space.

The 32 bits of J-Type are divided into only 2 parts:

  • opcode (6 bits): Tells the CPU it is a jump operation.
  • target address (26 bits): Holds the direct memory address target where the program execution needs to jump.

Example of J-Type:
Let us consider the assembly instruction: j Label_Name
This means the processor will immediately jump to the memory address of Label_Name.
=> Opcode for standard jump = 2
=> target address = The 26-bit binary location of the target label.

A7. RISC and CISC Architecture

RISC and CISC Architecture

RISC and CISC are design philosophies rather than rigid categories. Modern processors often combine ideas from both.

Criterion RISC CISC
Instruction set Small, regular, simple operations Large set with complex operations
Instruction length Usually fixed or few formats Often variable length
Memory access Load/store: only load and store access memory Many instructions may use memory operands
Registers Usually many general-purpose registers Historically fewer, often specialized registers
Addressing modes Few and regular Numerous and complex
Control unit Commonly hardwired Traditionally microprogrammed
Cycles per instruction Often close to one for simple instructions May require several internal steps
Pipelining Easier because formats and stages are regular Harder due to variable decoding and latency
Code size More instructions may be required Better code density is often possible
Compiler role Compiler performs more scheduling and register use Hardware performs more complex instruction work
Examples MIPS, RISC-V, SPARC, ARM conceptually x86, VAX, Motorola 68000

RISC aims to make frequent operations fast and pipeline-friendly. CISC aims to express more work per instruction and preserve compact, powerful instruction semantics. Modern x86 processors decode complex x86 instructions into simpler internal micro-operations, while modern RISC processors include sophisticated caches, prediction and out-of-order execution. Therefore, implementation quality and workload matter more than the label alone.
alt text


MIPS instruction formats.

MIPS instruction formats.

āĻ…āĻŦāĻļā§āϝāχ! āĻļāĻŋāĻŸā§‡āϰ āĻļ⧁āϰ⧁āϰ āĻĻāĻŋāϕ⧇ MIPS-āĻāϰ āϝ⧇ āĻŽā§ŒāϞāĻŋāĻ• āĻŦāĻŋāώ⧟āϗ⧁āϞ⧋ āĻāĻŦāĻ‚ āĻāϰ āĻĒ⧇āĻ›āύ⧇āϰ āϧāĻžāϰāĻŖāĻž āύāĻŋā§Ÿā§‡ āφāϞ⧋āϚāύāĻž āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇, āϤāĻž āύāĻŋāĻšā§‡ āϏāĻšāϜāĻ­āĻžāĻŦ⧇ āϤ⧁āϞ⧇ āϧāϰāĻž āĻšāϞ⧋:

### MIPS āϕ⧀?

MIPS-āĻāϰ āĻĒā§‚āĻ°ā§āĻŖāϰ⧂āĻĒ āĻšāϞ⧋ Microprocessor without Interlocked Pipelined StagesāĨ¤
āĻāϟāĻŋ ā§§ā§¯ā§Žā§Ļ-āĻāϰ āĻĻāĻļāϕ⧇ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āĻāĻ•āϟāĻŋ RISC (Reduced Instruction Set Computer) āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ, āϝāĻž āĻŽā§‚āϞāϤ āωāĻšā§āϚ āĻ•āĻ°ā§āĻŽāĻ•ā§āώāĻŽāϤāĻž (high performance) āĻāĻŦāĻ‚ āϏāϰāϞāϤāĻžāϰ āϜāĻ¨ā§āϝ āĻĄāĻŋāϜāĻžāχāύ āĻ•āϰāĻž āĻšā§Ÿā§‡āĻ›āĻŋāϞāĨ¤

### MIPS āĻŦāĻž RISC āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇āϰ āĻŽā§‚āϞ āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝāϏāĻŽā§‚āĻš

MIPS āĻ•āĻŋāϛ⧁ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āύ⧀āϤāĻŋ āĻŦāĻž āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝ⧇āϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇:

  • āϏāϰāϞ āĻ…āĻĒāĻžāϰ⧇āĻļāύ (Simple operation): MIPS-āĻ āĻĒā§āϰāϤāĻŋāϟāĻŋ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ (instruction) āĻĻāĻŋā§Ÿā§‡ āϕ⧇āĻŦāϞ āĻāĻ•āϟāĻŋ āĻŽāĻžāĻ¤ā§āϰ āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāϜ (arithmetic task) āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤

  • āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻŽāĻžāĻĒ (Fixed format): MIPS-āĻāϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ āĻŋāĻ• ā§Šā§¨-āĻŦāĻŋāϟ (32-bit) āϞāĻŽā§āĻŦāĻž āĻŦāĻž āĻĢāĻŋāĻ•ā§āϏāĻĄ āϏāĻžāχāĻœā§‡āϰ āĻšā§ŸāĨ¤

  • āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ-āĻ­āĻŋāĻ¤ā§āϤāĻŋāĻ• (Register based / Load-Store Architecture): MIPS-āĻ āϝāĻžāĻŦāĻ¤ā§€ā§Ÿ āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāϜ (āϝ⧇āĻŽāύ: āϝ⧋āĻ—, āĻŦāĻŋā§Ÿā§‹āĻ—) āϏāϰāĻžāϏāϰāĻŋ āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āĻ•āϰāĻž āϝāĻžā§Ÿ āύāĻž, āĻāϗ⧁āϞ⧋ āϕ⧇āĻŦāϞ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϭ⧇āϤāϰ⧇āϰ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āĻĄā§‡āϟāĻžāϰ āĻ“āĻĒāϰ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤ āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āĻĒā§āϰāĻŦ⧇āĻļ⧇āϰ āϜāĻ¨ā§āϝ āĻļ⧁āϧ⧁āĻŽāĻžāĻ¤ā§āϰ load āĻāĻŦāĻ‚ store āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āĻšā§ŸāĨ¤

  • āĻĻā§āϰ⧁āϤ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ (Fast execution): āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϗ⧁āϞ⧋ āĻāϤāχ āϏāϰāϞ āϝ⧇, āĻāϗ⧁āϞ⧋āϕ⧇ āĻāĻ• āĻ•ā§āϞāĻ• āϏāĻžāχāϕ⧇āϞ⧇āχ (one clock cycle) āĻ•āĻžāϜ āĻļ⧇āώ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻĄāĻŋāϜāĻžāχāύ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇āĨ¤

### "Without Interlocked Pipeline Stages" āĻ•āĻĨāĻžāϰ āĻ…āĻ°ā§āĻĨ āϕ⧀?

āϏāĻžāϧāĻžāϰāĻŖāϤ āĻĒā§āϰāϏ⧇āϏāϰ⧇ āϝāĻ–āύ āĻāĻ•āϟāĻžāϰ āĻĒāϰ āĻāĻ•āϟāĻž āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇ (āĻĒāϰāĻĒāϰ āϧāĻžāĻĒ⧇) āϚāϞāϤ⧇ āĻĨāĻžāϕ⧇, āϤāĻ–āύ āĻāĻ•āϟāĻŋ āĻĄā§‡āϟāĻž āĻĒā§āϰāĻ¸ā§āϤ⧁āϤ āĻšāĻ“ā§ŸāĻžāϰ āφāϗ⧇āχ āϝāĻĻāĻŋ āĻĒāϰ⧇āϰ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āϤāĻž āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āϚāĻžā§Ÿ, āϤāĻ–āύ āĻāϰāϰ (Data Hazard) āĻĻ⧇āĻ–āĻž āĻĻā§‡ā§ŸāĨ¤ āĻāχ āĻ…āĻŦāĻ¸ā§āĻĨāĻžā§Ÿ āĻ…āύ⧇āĻ• āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āύāĻŋāĻœā§‡ āĻĨ⧇āϕ⧇āχ āĻ•āĻžāϜ āĻ•āĻŋāϛ⧁āĻ•ā§āώāĻŖ āĻĨāĻžāĻŽāĻŋā§Ÿā§‡ āĻĻā§‡ā§Ÿ āĻŦāĻž 'āĻ¸ā§āϟāϞ' (stall) āĻ•āϰ⧇āĨ¤ āϝāĻžāϕ⧇ 'āχāĻ¨ā§āϟāĻžāϰāϞāĻ•āĻĄ' āĻĒāĻžāχāĻĒāϞāĻžāχāύ āĻŦāϞāĻž āĻšā§ŸāĨ¤
āĻ•āĻŋāĻ¨ā§āϤ⧁ MIPS āĻŽā§‡āĻļāĻŋāύ⧇ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āύāĻŋāĻœā§‡ āĻĨ⧇āϕ⧇ āĻāχ āĻ•āĻžāϜ āĻ•āϰ⧇ āύāĻžāĨ¤ āĻāχ āĻĄā§‡āϟāĻž āĻšā§āϝāĻžāϜāĻžāĻ°ā§āĻĄ āĻŦāĻž āĻāϰāϰ āϏāĻžāĻŽāϞāĻžāύ⧋āϰ (explicit NOPs āĻœā§‡āύāĻžāϰ⧇āϟ āĻ•āϰāĻžāϰ) āĻĻāĻžā§ŸāĻŋāĻ¤ā§āĻŦ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ⧇āϰ āĻŦāĻĻāϞ⧇ āϏāĻĢāϟāĻ“ā§Ÿā§āϝāĻžāϰ āĻŦāĻž āĻ•āĻŽā§āĻĒāĻžāχāϞāĻžāϰ⧇āϰ āĻ“āĻĒāϰ āĻ›ā§‡ā§œā§‡ āĻĻ⧇āĻ“ā§ŸāĻž āĻšā§ŸāĨ¤ āĻ āϜāĻ¨ā§āϝāχ āĻāϕ⧇ "Without Interlocked Pipeline Stages" āĻŦāϞāĻž āĻšā§ŸāĨ¤

### MIPS-āĻāϰ ā§ĢāϟāĻŋ āĻ•ā§āϞāĻžāϏāĻŋāĻ• āĻĒāĻžāχāĻĒāϞāĻžāχāύ āĻ¸ā§āĻŸā§‡āϜ (Pipeline Stages)

MIPS-āĻ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ⧇āϰ āĻ•āĻžāϜ āĻļ⧇āώ āĻšāϤ⧇ āĻĒā§āϰāĻĨāĻžāĻ—āϤāĻ­āĻžāĻŦ⧇ ā§ĢāϟāĻŋ āϧāĻžāĻĒ āĻŦāĻž āĻ¸ā§āĻŸā§‡āϜ āĻĒāĻžāϰ āĻšāϤ⧇ āĻšā§Ÿ:
ā§§. IF (Instruction Fetch): āĻŽā§‡āĻŽāϰāĻŋ āĻĨ⧇āϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϟāĻŋ āĻĒā§āϰāϏ⧇āϏāϰ⧇ āύāĻŋā§Ÿā§‡ āφāϏāĻž āĻšā§ŸāĨ¤
⧍. ID (Instruction Decode/Register Fetch): āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϟāĻŋ āĻĄāĻŋāϕ⧋āĻĄ āĻ•āϰ⧇ āĻāϰ āĻ…āĻ°ā§āĻĨ āĻŦā§‹āĻāĻž āĻšā§Ÿ āĻāĻŦāĻ‚ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āύ⧇āĻ“ā§ŸāĻž āĻšā§ŸāĨ¤
ā§Š. EX (Execute): āĻāχ āϧāĻžāĻĒ⧇ āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāϜ āĻŦāĻž āĻšāĻŋāϏāĻžāĻŦ āĻ•āϰāĻž āĻšā§ŸāĨ¤
ā§Ē. MEM (Memory access): āĻļ⧁āϧ⧁ load āĻŦāĻž store āύāĻŋāĻ°ā§āĻĻ⧇āĻļ⧇āϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻāχ āϧāĻžāĻĒ⧇ āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āĻĸā§‹āĻ•āĻž āĻšā§Ÿ (āĻ…āĻ¨ā§āϝ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ⧇āϰ āϜāĻ¨ā§āϝ āĻāϟāĻŋ āĻ¸ā§āĻ•āĻŋāĻĒ āĻ•āϰāĻž āĻšā§Ÿ)āĨ¤
ā§Ģ. WB (Write Back): āĻĢāϞāĻžāĻĢāϞāϟāĻŋ āφāĻŦāĻžāϰ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āϞāĻŋāϖ⧇ āϏ⧇āĻ­ āĻ•āϰāĻž āĻšā§ŸāĨ¤

### MIPS-āĻ āĻŽāĻžāĻ¤ā§āϰ ā§Šā§¨āϟāĻŋ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āϕ⧇āύ?

MIPS-āĻ āĻŽā§‹āϟ ā§Šā§¨āϟāĻŋ āĻœā§‡āύāĻžāϰ⧇āϞ-āĻĒāĻžāϰāĻĒāĻžāϏ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨāĻžāϕ⧇āĨ¤ āĻāϰ āĻĒā§āϰāϧāĻžāύ āĻ•āĻžāϰāĻŖ āĻšāϞ⧋ "Smaller is faster"āĨ¤ āĻ…āĻ°ā§āĻĨāĻžā§Ž, āĻŽā§‡āĻŽāϰāĻŋ āĻŦāĻž āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āφāĻ•āĻžāϰ āϝāϤ āϛ⧋āϟ āĻšāĻŦ⧇, āĻĒā§āϰāϏ⧇āϏāϰ āϏ⧇āĻ–āĻžāύ āĻĨ⧇āϕ⧇ āϤāϤ āĻĻā§āϰ⧁āϤ āĻĄā§‡āϟāĻž āϖ⧁āρāĻœā§‡ āĻŦ⧇āϰ āĻ•āϰāϤ⧇ āĻĒāĻžāϰāĻŦ⧇āĨ¤ āĻ¸ā§āĻĒāĻŋāĻĄ āĻŦāĻž āĻĻā§āϰ⧁āϤāĻ—āϤāĻŋāϰ āϜāĻ¨ā§āϝāχ āĻāϤ⧇ āϖ⧁āĻŦ āĻŦ⧇āĻļāĻŋ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āϰāĻžāĻ–āĻž āĻšā§ŸāύāĻŋāĨ¤
alt text

āφāĻĒāύāĻžāϰ āĻĻ⧇āĻ“ā§ŸāĻž āĻ¸ā§āϞāĻžāχāĻĄ āĻāĻŦāĻ‚ āĻ­āĻŋāĻĄāĻŋāĻ“āϟāĻŋ āĻĨ⧇āϕ⧇ MIPS Instruction Format-āĻāϰ āĻĒ⧁āϰ⧋ āĻŦāĻŋāώ⧟āϟāĻŋ āϏāĻšāϜ āĻ“ āϗ⧁āĻ›āĻŋā§Ÿā§‡ āύāĻŋāĻšā§‡ āϤ⧁āϞ⧇ āϧāϰāĻž āĻšāϞ⧋āĨ¤

MIPS āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇ āĻĒā§āϰāϤāĻŋāϟāĻŋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻŦāĻž āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ āĻŋāĻ• ā§Šā§¨-āĻŦāĻŋāĻŸā§‡āϰ (32-bit) āĻšā§ŸāĨ¤ āĻāχ ā§Šā§¨ āĻŦāĻŋāϟāϕ⧇ āϕ⧀āĻ­āĻžāĻŦ⧇ āĻ­āĻžāĻ— āĻ•āϰ⧇ āĻĒā§āϰāϏ⧇āϏāϰāϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻĻ⧇āĻ“ā§ŸāĻž āĻšāĻŦ⧇, āϤāĻžāϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ MIPS āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϕ⧇ ā§ŠāϟāĻŋ āĻĒā§āϰāϧāĻžāύ āĻĢāϰāĻŽā§āϝāĻžāĻŸā§‡ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§Ÿ:

### ā§§. R-Type (Register Type)

āϝ⧇āϏāĻŦ āĻ…āĻĒāĻžāϰ⧇āĻļāύ⧇ āϕ⧋āύ⧋ āĻŽā§‡āĻŽāϰāĻŋ āĻŦāĻž āĻŦāĻžāχāϰ⧇āϰ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻĻāϰāĻ•āĻžāϰ āĻšā§Ÿ āύāĻž, āϕ⧇āĻŦāϞ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āύāĻŋā§Ÿā§‡ āĻ•āĻžāϜ āĻ•āϰāĻž āĻšā§Ÿ, āϏ⧇āϗ⧁āϞ⧋ R-typeāĨ¤
āĻāχ ā§Šā§¨ āĻŦāĻŋāϟāϕ⧇ ā§ŦāϟāĻŋ āĻ…āĻ‚āĻļ⧇ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§Ÿ:

  • op (6 bits): Opcode. R-type āĻāϰ āĻ•ā§āώ⧇āĻ¤ā§āϰ⧇ āĻāϟāĻŋ āϏāĻŦāϏāĻŽā§Ÿ ā§ŦāϟāĻŋ āĻļā§‚āĻ¨ā§āϝ (000000) āĻšā§ŸāĨ¤
  • rs (5 bits): First source register (āĻĒā§āϰāĻĨāĻŽ āĻ‰ā§ŽāϏ)āĨ¤

  • rt (5 bits): Second source register (āĻĻā§āĻŦāĻŋāĻ¤ā§€ā§Ÿ āĻ‰ā§ŽāϏ)āĨ¤

  • rd (5 bits): Destination register (āĻ—āĻ¨ā§āϤāĻŦā§āϝ, āϝ⧇āĻ–āĻžāύ⧇ āĻĢāϞāĻžāĻĢāϞ āϰāĻžāĻ–āĻž āĻšāĻŦ⧇)āĨ¤
  • shamt (5 bits): Shift amountāĨ¤ (āĻļāĻŋāĻĢāϟ āĻ…āĻĒāĻžāϰ⧇āĻļāύ āĻ›āĻžā§œāĻž āĻ…āĻ¨ā§āϝ āϏāĻŽā§Ÿ āĻāϟāĻŋ ā§ĢāϟāĻŋ āĻļā§‚āĻ¨ā§āϝ āĻšā§Ÿ)āĨ¤
  • funct (6 bits): Function codeāĨ¤ āϝ⧇āĻšā§‡āϤ⧁ op āϏāĻŦāϏāĻŽā§Ÿ ā§Ļ, āϤāĻžāχ āĻāχ āĻ…āĻ‚āĻļāϟāĻŋ āĻĒā§āϰāϏ⧇āϏāϰāϕ⧇ āĻŦāϞ⧇ āĻĻā§‡ā§Ÿ āĻ āĻŋāĻ• āϕ⧀ āĻ•āĻžāϜ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇ (āϝ⧇āĻŽāύ: add, sub)āĨ¤

āωāĻĻāĻžāĻšāϰāĻŖ:

  • add $t0, $s1, $s2 : āĻāĻ–āĻžāύ⧇ $s1 (rs) āĻāĻŦāĻ‚ $s2 (rt) āĻāϰ āĻŽāĻžāύ āϝ⧋āĻ— āĻ•āϰ⧇ āĻĢāϞāĻžāĻĢāϞ $t0 (rd) āϤ⧇ āϰāĻžāĻ–āĻž āĻšāĻšā§āϛ⧇āĨ¤
  • sll $s2, $t3, 2 (Shift Left Logical): āĻāĻ–āĻžāύ⧇ $t3 (rs) āĻāϰ āĻĄā§‡āϟāĻžāϕ⧇ ⧍ āĻŦāĻŋāϟ (shamt) āĻŦāĻžāĻŽā§‡ āĻļāĻŋāĻĢāϟ āĻ•āϰ⧇ $s2 (rd) āϤ⧇ āϏ⧇āĻ­ āĻ•āϰāĻž āĻšāĻšā§āϛ⧇āĨ¤

### ⧍. I-Type (Immediate Type)

āϝāĻ–āύ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āϭ⧇āϤāϰ⧇āχ āϏāϰāĻžāϏāϰāĻŋ āϕ⧋āύ⧋ āϏāĻ‚āĻ–ā§āϝāĻž (constant) āĻŦāĻž āĻŽā§‡āĻŽāϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻĻ⧇āĻ“ā§ŸāĻž āĻĨāĻžāϕ⧇, āϤāĻ–āύ I-type āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§ŸāĨ¤
āĻāϰ ā§Šā§¨ āĻŦāĻŋāϟāϕ⧇ ā§ĒāϟāĻŋ āĻ…āĻ‚āĻļ⧇ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§Ÿ:

  • op (6 bits): Opcode (āĻāϟāĻŋ āĻŦāϞ⧇ āĻĻā§‡ā§Ÿ āϕ⧀ āĻ•āĻžāϜ āĻšāĻŦ⧇, āϝ⧇āĻŽāύ: lw, sw, beq)āĨ¤
  • rs (5 bits): Source register (āĻŦ⧇āχāϜ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻŦāĻž āĻ‰ā§ŽāϏ)āĨ¤
  • rt (5 bits): Destination āĻŦāĻž Source register (āύāĻŋāĻ°ā§āĻĻ⧇āĻļ⧇āϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇)āĨ¤
  • Immediate / Constant (16 bits): āϏāϰāĻžāϏāϰāĻŋ āĻĻ⧇āĻ“ā§ŸāĻž āϏāĻ‚āĻ–ā§āϝāĻž āĻŦāĻž āĻ…āĻĢāϏ⧇āϟ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāĨ¤ āĻāχ ā§§ā§Ŧ-āĻŦāĻŋāĻŸā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻžāϟāĻŋāϕ⧇ āĻĒā§āĻ°ā§Ÿā§‹āϜāύ⧇ āϏāĻžāχāύ-āĻāĻ•ā§āϏāĻŸā§‡āĻ¨ā§āĻĄ (Sign-extend) āĻ•āϰ⧇ ā§Šā§¨-āĻŦāĻŋāϟ āĻ•āϰāĻž āĻšā§ŸāĨ¤

āωāĻĻāĻžāĻšāϰāĻŖ āĻ“ āĻ­āĻŋāĻĄāĻŋāĻ“āϰ āϗ⧁āϰ⧁āĻ¤ā§āĻŦāĻĒā§‚āĻ°ā§āĻŖ āϟāĻŋāĻĒāϏ:

  • Load Word (lw $t0, 4($s3)): āĻŽā§‡āĻŽāϰāĻŋ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āφāύāĻžāϰ āϜāĻ¨ā§āϝāĨ¤ āĻāĻ–āĻžāύ⧇ $s3 āĻšāϞ⧋ āĻŦ⧇āϏ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ, āϝāĻžāϰ āϏāĻžāĻĨ⧇ 4 āϝ⧋āĻ— āĻ•āϰ⧇ āφāϏāϞ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻĒāĻžāĻ“ā§ŸāĻž āϝāĻžā§ŸāĨ¤ āϏ⧇āχ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇āϰ āĻĄā§‡āϟāĻž $t0 āϤ⧇ āϞ⧋āĻĄ āĻšā§ŸāĨ¤ (āĻāĻ–āĻžāύ⧇ āĻĒā§āϰāĻĨāĻŽ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ $t0 āĻšāϞ⧋ Destination)āĨ¤

  • Store Word (sw $t0, 8($s3)): āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āϏ⧇āĻ­ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝāĨ¤ (āĻ­āĻŋāĻĄāĻŋāĻ“ āĻ…āύ⧁āϝāĻžā§Ÿā§€, āĻāĻ–āĻžāύ⧇ āĻĒā§āϰāĻĨāĻŽ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ $t0 āĻšāϞ⧋ Source, āĻ•āĻžāϰāĻŖ āĻĄā§‡āϟāĻž $t0 āĻĨ⧇āϕ⧇ āĻŽā§‡āĻŽāϰāĻŋāϤ⧇ āϝāĻžāĻšā§āϛ⧇)āĨ¤

  • Branching (beq $t0, $t1, else): āϝāĻĻāĻŋ $t0 āĻāĻŦāĻ‚ $t1 āϏāĻŽāĻžāύ āĻšā§Ÿ, āϤāĻŦ⧇ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ else āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āϞāĻžāĻĢ āĻĻ⧇āĻŦ⧇ (Jump)āĨ¤

  • Add Immediate (addi $t0, $t1, 14): $t1 āĻāϰ āϏāĻžāĻĨ⧇ āϏāϰāĻžāϏāϰāĻŋ ā§§ā§Ē (Immediate value) āϝ⧋āĻ— āĻ•āϰ⧇ $t0 āϤ⧇ āϰāĻžāĻ–āĻžāĨ¤

### ā§Š. J-Type (Jump Type)

āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽā§‡āϰ āĻāĻ• āϞāĻžāχāύ āĻĨ⧇āϕ⧇ āĻ…āĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻŽā§‡āĻŽāϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āϏāϰāĻžāϏāϰāĻŋ āϞāĻžāĻĢ āĻĻ⧇āĻ“ā§ŸāĻžāϰ (Jump) āϜāĻ¨ā§āϝ āĻāχ āĻĢāϰāĻŽā§āϝāĻžāϟ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§ŸāĨ¤
āĻāϰ ā§Šā§¨ āĻŦāĻŋāϟāϕ⧇ āĻŽāĻžāĻ¤ā§āϰ ⧍āϟāĻŋ āĻ…āĻ‚āĻļ⧇ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§Ÿ:

  • op (6 bits): Opcode.
  • Target Address (26 bits): āϝ⧇ āĻŽā§‡āĻŽāϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āϞāĻžāĻĢ āĻĻāĻŋāϤ⧇ āĻšāĻŦ⧇āĨ¤

āωāĻĻāĻžāĻšāϰāĻŖ:

  • j loop (Jump): āĻāϟāĻŋ āϏāϰāĻžāϏāϰāĻŋ loop āύāĻžāĻŽāĻ• āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽāϕ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤
  • jal loop (Jump and Link): āĻāϟāĻŋāĻ“ āϞāĻžāĻĢ āĻĻā§‡ā§Ÿ, āϤāĻŦ⧇ āϝāĻžāĻ“ā§ŸāĻžāϰ āφāϗ⧇ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āϞāĻžāχāύ⧇āϰ āĻ āĻŋāĻ• āĻĒāϰ⧇āϰ āϞāĻžāχāύ⧇āϰ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ $ra (Return Address) āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āϏ⧇āĻ­ āĻ•āϰ⧇ āϰāĻžāϖ⧇āĨ¤ āĻāϰ āĻĢāϞ⧇ āĻĢāĻžāĻ‚āĻļāύ⧇āϰ āĻ•āĻžāϜ āĻļ⧇āώ āĻšāĻ“ā§ŸāĻžāϰ āĻĒāϰ jr $ra āĻ•āĻŽāĻžāĻ¨ā§āĻĄ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āφāĻŦāĻžāϰ āφāϗ⧇āϰ āϜāĻžā§ŸāĻ—āĻžā§Ÿ āĻ āĻŋāĻ•āĻŽāϤ⧋ āĻĢāĻŋāϰ⧇ āφāϏāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤

āϏāĻ‚āĻ•ā§āώ⧇āĻĒ⧇:
* R-type: āϏāĻŦ āĻ•āĻžāϜ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āϭ⧇āϤāϰ⧇āχ āĻšā§Ÿ (ā§ŦāϟāĻŋ āĻĢāĻŋāĻ˛ā§āĻĄ)āĨ¤
* I-type: āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϏāĻ‚āĻ–ā§āϝāĻž (constant/immediate) āύāĻŋā§Ÿā§‡ āĻ•āĻžāϜ āĻšā§Ÿ (ā§ĒāϟāĻŋ āĻĢāĻŋāĻ˛ā§āĻĄ)āĨ¤
* J-type: āĻ…āύ⧇āĻ• āĻĻā§‚āϰ⧇āϰ āϕ⧋āύ⧋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āϞāĻžāĻĢ āĻĻ⧇āĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ (⧍āϟāĻŋ āĻĢāĻŋāĻ˛ā§āĻĄ)āĨ¤

Part B — Instructions, ISA, Datapath and Control

Basic:

Define instruction types and define each types in details for 50 marks with example and block diagrams.

An instruction in Computer Organisation and Architecture (COA) is a binary command given to the Central Processing Unit (CPU) to perform a specific operation. The collection of all instructions understood by a processor is called its Instruction Set Architecture (ISA).

Architecturally, instructions are classified into three primary functional categories:

  1. Data Transfer Instructions: Move data between registers, memory, and I/O devices without modifying the content.
  2. Data Manipulation Instructions: Perform computational tasks on data, subdivided into Arithmetic, Logical, and Shift instructions.
  3. Program Control Instructions: Alter the sequential execution flow of a program by modifying the Program Counter (PC).

Category 1: Data Transfer Instructions

Data Transfer Instructions handle the relocation of data between source and destination endpoints across the system buses. They do not alter the binary bits being moved.

1. Data Transfer Paths & Locations

Data movement occurs across three hardware boundaries:

  • Register to Register: Fast transfer within internal CPU registers (e.g., Accumulator, General Purpose Registers).
  • Register to/from Memory: Relocating data between CPU registers and primary memory (RAM).
  • Register/Memory to/from I/O Devices: Interfacing with peripherals (keyboard, monitor, printer). External devices like printers maintain their own internal memory buffers and control registers to handle incoming data streams.
+-------------------------------------------------------------------+
|                        DATA TRANSFER PATHS                        |
|                                                                   |
|   +-------------------+  Load / Store  +----------------------+   |
|   |  CPU Registers    | <------------> |    Main Memory       |   |
|   | (ACC, R1, PC, IR) |                |        (RAM)         |   |
|   +-------------------+                +----------------------+   |
|             ^                                     ^               |
|             | IN / OUT                            | Direct Memory |
|             v                                     v Access (DMA)  |
|   +-----------------------------------------------------------+   |
|   |                  I/O Peripheral Devices                   |   |
|   |             (Keyboard, Printer Buffer, Display)           |   |
|   +-----------------------------------------------------------+   |
+-------------------------------------------------------------------+

2. Role of Addressing Modes

The micro-operations executed during data transfer depend on the Addressing Mode (e.g., Immediate, Direct, Indirect, Register Indirect, Indexed). A single command like MOV or LD can execute in 7 to 8 distinct variations depending on how operand addresses are specified in the instruction format.

3. Command List & Sub-categories

Sub-category Command / Mnemonic Description / Micro-operation Example
Register Transfer MOV Dest, Src Copies contents from source location to destination. MOV R1, R2 (R1 ← R2)
Immediate Transfer MOV Reg, Data Loads a direct operand constant directly into a register. MOV R1, 500 (R1 ← 500)
Memory Load LD / LDA Fetches data from memory into a register or Accumulator. LD R1, X (R1 ← M[X])
Memory Store ST / STA Transfers data from a register or Accumulator to memory. STA X (M[X] ← ACC)
Data Exchange XCHG Swaps contents between two registers or memory locations. XCHG R1, R2 (R1 ↔ R2)
Input Operation IN Fetches data from an input port to an internal register. IN R1, Port_A
Output Operation OUT Sends data from a register to an output port. OUT Port_B, R1
Stack Transfer PUSH / POP Pushes data onto or pops data off a LIFO Stack memory. PUSH R1 / POP R2
Bit Setting SET / CLR Forces target register bits to 1 (SET) or 0 (CLR). CLR R1 (R1 ← 0)

Category 2: Data Manipulation Instructions

Data Manipulation Instructions perform computational operations on binary data. They are divided into Arithmetic, Logical, and Shift instructions.

+-------------------------------------------------------------------+
|                   DATA MANIPULATION INSTRUCTIONS                  |
|                                                                   |
|   +-------------------+   +-------------------+   +-----------+   |
|   |    Arithmetic     |   |      Logical      |   |   Shift   |   |
|   | (+, -, *, /, INC) |   | (AND, OR, NOT, X) |   | (LSL, ASR)|   |
|   +-------------------+   +-------------------+   +-----------+   |
|             \                       |                  /          |
|              v                      v                 v           |
|   +-----------------------------------------------------------+   |
|   |               Arithmetic Logic Unit (ALU)                 |   |
|   +-----------------------------------------------------------+   |
+-------------------------------------------------------------------+

Sub-category 2A: Arithmetic Instructions

Arithmetic instructions perform basic mathematical operations (\(+\), \(-\), \(\times\), \(\div\)) on numeric operands stored in registers or memory.

1. Hardware Primitives vs. Software Loops

  • Primitive Hardware: Basic microprocessors contain hardware circuits only for Addition and Subtraction.
  • Software Multiplication: Implemented via addition loops (e.g., \(2 \times 3 = 2 + 2 + 2\)).
  • Software Division: Implemented via repeated subtraction loops.

  • Modern ALU Optimizations: Modern CPUs incorporate dedicated, high-speed hardware multipliers and dividers within the ALU. Dedicated hardware eliminates software loop overhead, increasing execution speed. Higher mathematical functions (exponential, logarithmic, trigonometric) are derived from these four core operations.

2. Instruction vs. Micro-Operation Execution

An Instruction is a macro-level assembly command, whereas a Micro-operation is an elementary hardware step performed by the ALU during execution clock cycles.

For a 3-Address instruction \(C = A + B\) (ADD C, A, B):

[Instruction Memory] ---> [Fetch Phase] ---> [Instruction Register (IR)]
                                                    |
                                                    v
                                            [Decode Phase]
                                            (Opcode + Operands)
                                                    |
                                                    v
[Write Back C] <--- [Execute Phase (ALU)] <--- [Operand Fetch Phase]
  1. Instruction Fetch: Instruction is transferred from memory to the Instruction Register (IR).
  2. Instruction Decode: Decoder separates the Opcode (ADD) from Operands (\(A, B, C\)).
  3. Operand Fetch: Operands \(A\) and \(B\) are retrieved based on the addressing mode.
  4. Execution: ALU adds values and writes the result into destination address \(C\).

3. Command List & Examples

Mnemonic Name Operation / Example Description
ADD Add ADD R1, R2 (R1 ← R1 + R2) Adds contents of two registers.
SUB Subtract SUB R1, R2 (R1 ← R1 - R2) Subtracts source from destination.
MUL Multiply MUL R1, R2 (R1 ← R1 * R2) Hardware binary multiplication.
DIV Divide DIV R1, R2 (R1 ← R1 / R2) Hardware binary division.
INC Increment INC R1 (R1 ← R1 + 1) Increments register flip-flop counter by 1.
DEC Decrement DEC R1 (R1 ← R1 - 1) Decrements register flip-flop counter by 1.
ADC Add with Carry ADC R1, R2 (R1 ← R1 + R2 + Carry) Propagates previous carry bit into higher-order addition.
SBB Subtract w/ Borrow SBB R1, R2 *(R1 ← R1 - R2 - Borrow) Propagates borrow bit into higher-order subtraction.
NEG Negate NEG R1 (R1 ← 2's Complement of R1) Converts positive values to negative (e.g., \(+5 \to -5\)).

Sub-category 2B: Logical Instructions

Logical instructions perform bitwise boolean operations on binary vectors. They are used for bit manipulation, masking, testing, and flag control.

1. Core Logic Operations & Applications

  • Complement / NOT: Inverts all bits (\(0 \to 1, 1 \to 0\)). 1's complement is derived in hardware by XORing data against an all-1s bitmask (\(0101_2 \text{ XOR } 1111_2 = 1010_2\)).
  • Clear (CLR): Resets target register flip-flops to 0 in a single clock pulse.
  • Bitwise AND (Bit Masking & Selective Clearing): ANDing any bit with \(0\) forces it to \(0\).
  • Subnetting Application: Performs bitwise AND between an IP address and a Subnet Mask to isolate the Network/Subnet ID.
  • Even/Odd Detection: Performs bitwise AND between an integer bitstring and \(0001_2\):
  • Even Result (\(0000_2\)): Least Significant Bit (LSB) is \(0\).
  • Odd Result (\(0001_2\)): Least Significant Bit (LSB) is \(1\).

  • Bitwise OR (Selective Setting): ORing any bit string with \(1\) forces those bit positions to \(1\).

  • Bitwise XOR (Modulo-2 Addition): Outputs \(0\) for matching bits and \(1\) for different bits. Equivalent to Modulo-2 addition without carry (\(1 + 1 = 2 \pmod 2 = 0\)).

2. Flag & Interrupt Control Commands

Mnemonic Name Operation Primary Use Case
CLC Clear Carry Carry Flag \(\leftarrow 0\) Clears unwanted carry status before addition.
STC Set Carry Carry Flag \(\leftarrow 1\) Provides \(+1\) offset for 2's complement generation.
CMC Complement Carry Carry Flag \(\leftarrow \overline{\text{Carry}}\) Inverts existing carry status.
EI Enable Interrupt Interrupt Flag \(\leftarrow 1\) Unmasks hardware/software interrupts.
DI Disable Interrupt Interrupt Flag \(\leftarrow 0\) Masks interrupts during critical execution sections.

Sub-category 2C: Shift Instructions

Shift instructions move bits within a register left or right. They are used in serialization, bit manipulation, and fast arithmetic computations.

1. Operational Types

1. Logical Shift Left (LSL):       [0] <-- [Bit 7 <-- Bit 0] <-- 0
                                (Exits)

2. Logical Shift Right (LSR):       0 --> [Bit 7 --> Bit 0] --> [0]
                                                            (Exits)

3. Arithmetic Shift Right (ASR): [Sign] -> [Sign Copy --> Bit 0] --> [0]
                                (Preserved)                        (Exits)

4. Rotate Left (ROL):             +--- [Bit 7 <-- Bit 0] <---+
                                |                          |
                                +--------------------------+

5. Rotate Right w/ Carry (RCR):   +-> [Carry] -> [Bit 7 --> Bit 0] -+
                                |                                 |
                                +---------------------------------+
  • Logical Shift Left (LSL): Moves bits left. Discards the MSB; fills the vacated LSB with \(0\). Equivalent to multiplying by 2 (\(\times 2\)).
  • Logical Shift Right (LSR): Moves bits right. Discards the LSB; fills the vacated MSB with \(0\). Equivalent to unsigned integer division by 2 (\(\div 2\)).
  • Arithmetic Shift Right (ASR): Used for signed 2's complement numbers. Moves bits right and discards the LSB, but copies the MSB sign bit back into the vacated MSB position to preserve sign integrity.
  • Arithmetic Shift Left (ASL): Identical to Logical Shift Left (\(0\) inserted at LSB). Hardware systems implement only one version.
  • Rotate Left (ROL) & Rotate Right (ROR): Circular shifts where exiting boundary bits wrap around to fill the vacated opposite end without losing bits.
  • Rotate Through Carry (RCL / RCR): Operates across a 9-bit circular loop consisting of the 8-bit register plus the 1-bit Carry Flag.

2. Instruction Format

Shift instruction opcodes contain dedicated fields specifying the shift type, shift direction, and shift count:

\[\begin{array}{\|c\|c\|c\|c\|c\|} \hline \text{Addressing Mode} & \text{Opcode (Shift)} & \text{Type (Logical/Arith/Rotate)} & \text{Direction \& Count} & \text{Register Operand} \\ \hline \end{array}\]

Category 3: Program Control (Transfer of Control) Instructions

Program Control Instructions alter the normal execution sequence of a program.

1. Sequential Execution vs. Transfer of Control

  • Implicit Mode (Sequential Execution): Under default conditions, the CPU executes instructions sequentially. The Program Counter (PC) automatically increments to hold the memory address of the next instruction (\(100 \to 101 \to 102 \to 103\)).
  • Transfer of Control (Non-Sequential Execution): Program Control instructions break sequential execution by loading a new target address into the Program Counter (\(PC \leftarrow \text{Target Address}\)). This enables loops, function/subroutine calls, conditional branching (if-else), and interrupt handling.

2. Detailed Sub-categories & Commands

Sequential Execution: [PC = 100] -> [PC = 101] -> [PC = 102] -> [PC = 103]

Unconditional Branch: [PC = 101 (JMP 3000)] -------------------> [PC = 3000]

Conditional Branch:   [PC = 101 (BE R1, R2, 2000)]
                            |
                    +---------+---------+
                    |                   |
            (R1 == R2)          (R1 != R2)
                    |                   |
                    v                   v
            [PC = 2000]          [PC = 102] (Sequential)

A. Unconditional Branch Instructions

Transfers execution directly to a target address without evaluating conditions.

  • JMP Target / BRANCH Target: Writes the target address directly into the Program Counter (\(PC \leftarrow 2000\)).
  • SKP (Skip): Bypasses the immediately following instruction by incrementing the Program Counter an extra step (\(PC \leftarrow PC + 2\)), skipping execution of the next line.

B. Conditional Branch Instructions

Evaluates processor status flags or register comparisons before branching. If the condition evaluates to True, control branches to the target address; if False, execution continues sequentially.

  • BE R1, R2, Target (Branch if Equal): Compares \(R1\) and \(R2\). If \(R1 == R2\), \(PC \leftarrow \text{Target}\); otherwise, \(PC \leftarrow PC + 1\).
  • BNZ R1, Target (Branch if Non-Zero): Branches to the target address if register \(R1 \neq 0\).
  • BGT / BLT: Branch if Greater / Branch if Less Than.

C. Subroutine Instructions & Stack Flow

Used to handle reusable code modules (functions/procedures).

Main Program                              Stack Memory
+-----------------------+                 +-----------------------+
| Address 100: Inst 1   |                 |                       |
| Address 101: CALL 3000| --(1. Push)---> | Return Addr (102)     | [SP]
| Address 102: Inst 3   | <-(3. Pop RET)- +-----------------------+
+-----------------------+
            |
    (2. Jump)
            v
Subroutine (Function)
+-----------------------+
| Address 3000: Code... |
| Address 3015: RET     | 
+-----------------------+
  1. CALL Target:
  2. Pushes the current return address (\(PC + 1\)) onto the Stack (\(M[SP] \leftarrow PC\)).
  3. Loads the target subroutine address into the Program Counter (\(PC \leftarrow 3000\)).

  4. RET (Return):

  5. Pops the saved return address from the Stack back into the Program Counter (\(PC \leftarrow M[SP]\)), resuming execution in the main program.

D. Interrupt & Machine Control Instructions

  • TRAP / INTR: Hardware or software-generated interrupts that suspend current main-line execution to service an Interrupt Service Routine (ISR).
  • NOP (No Operation): Consumes one clock cycle without modifying registers or memory. Used for delay loops.
  • HALT: Stops CPU instruction fetching and execution until a hardware reset or interrupt occurs.

Comprehensive Master Instruction Set Reference

Instruction Category Sub-category Key Mnemonics Primary Target / Operand Hardware Effect / Purpose
Data Transfer Register/Memory Transfer MOV, LD, ST, XCHG Registers, RAM Moves data without modification across system buses.
Peripheral Transfer IN, OUT I/O Ports, Peripherals Interfaces processor with external hardware.
Stack Operations PUSH, POP Stack Memory, Stack Pointer Manages temporary parameters and function frames.
Data Manipulation Arithmetic Operations ADD, SUB, MUL, DIV ALU Registers Performs algebraic math operations on data.
Extended Arithmetic ADC, SBB, INC, DEC, NEG Registers, Carry Flag Handles multi-byte arithmetic, counters, and 2's complements.
Logical Operations AND, OR, XOR, NOT, CLR Bit Vectors, Registers Performs bit masking, selective setting, and even/odd checks.
Machine Flag Control CLC, STC, CMC, EI, DI Status Flags Configures carry flags and masks processor interrupts.
Bit Shifting LSL, LSR, ASL, ASR Registers Performs bit alignment, binary multiplication, and division.
Circular Rotations ROL, ROR, RCL, RCR Registers, Carry Bit Rotates bits circular-wise with or without carry status.
Program Control Unconditional Branching JMP, BR, SKP Program Counter (PC) Changes PC address unconditionally.
Conditional Branching BE, BNZ, BGT, BLT Status Flags, PC Implements decision-making blocks (if-else).
Subroutines CALL, RET Stack, PC Manages function invocations and returns.
System / Halt Control NOP, HALT, TRAP CPU Control Logic Handles timing delays, interrupts, and system termination.

Here are the short notes structured as a hierarchical mindmap tree. Every single sub-type discussed across the videos is listed clearly without compression.

Mindmap: Instruction Types in Computer Architecture

  • 1. DATA TRANSFER INSTRUCTIONS
  • Core Function: Copy data from source to destination without modification.
  • A. Based on Location
    1. Register to Register
    1. Register to Memory
    1. Memory to Register
    1. Input to Register/Memory (from peripheral)
    1. Register/Memory to Output (to peripheral)
    1. Stack Operations
  • a. PUSH (Store to stack)
  • b. POP (Retrieve from stack)

  • B. Based on Addressing Mode Variations (Example: MOV)

    1. Immediate Move (MOV R1, 500)
    1. Direct Move (MOV R1, X)
    1. Indirect Move
    1. Base Addressing Move
  • (Note: 7 to 8 variations exist based on mode)

  • C. Core Mnemonic List

    1. MOV (Move/Copy)
    1. LD / LOAD (Load to Register/Accumulator)
    1. ST / STORE (Store to Memory)
    1. XCHG (Exchange/Swap)
    1. IN (Input)
    1. OUT (Output)
    1. SET (Set to 1)
    1. CLR (Clear to 0)
  • 2. DATA MANIPULATION INSTRUCTIONS

  • Core Function: Perform operations on data to form new results.
  • I. ARITHMETIC INSTRUCTIONS
  • Function: Perform basic mathematical calculations.
  • A. Fundamental Operations
    1. ADD (Addition)
    1. SUB (Subtraction)
    1. MUL (Multiplication)
    1. DIV (Division)
  • B. Incremental Operations

    1. INC (Increment by 1)
    1. DEC (Decrement by 1)
  • C. Operations with Flags

    1. ADC (Add with Carry)
    1. SBB / SUBB (Subtract with Borrow)
  • D. Sign Manipulation

    1. NEG (Negate - create 2's complement)
  • II. LOGICAL INSTRUCTIONS

  • Function: Perform bitwise operations on binary data.
  • A. Boolean Logic Operations
    1. NOT / COMPLEMENT (1's Complement)
    1. AND (Bitwise multiplication / Masking)
    1. OR (Bitwise addition / Selective setting)
    1. XOR (Modulo-2 addition / Swapping/Testing parity)
  • B. Flag Manipulation

    1. CLC (Clear Carry flag to 0)
    1. STC (Set Carry flag to 1)
    1. CMC (Complement Carry flag)
  • C. Machine Control

    1. EI (Enable Interrupts)
    1. DI (Disable Interrupts)
    1. CLR (Clear/Reset register bits)
  • III. SHIFT INSTRUCTIONS

  • Function: Move bits left or right within a register.
  • A. Logical Shifts
    1. Logical Shift Left (LSL)
    1. Logical Shift Right (LSR)
  • B. Arithmetic Shifts

    1. Arithmetic Shift Left (ASL) — (Often identical to LSL)
    1. Arithmetic Shift Right (ASR)
  • C. Rotate / Circular Shifts

    1. Rotate Left (ROL)
    1. Rotate Right (ROR)
  • D. Rotate through Carry

    1. Rotate Left through Carry (RCL)
    1. Rotate Right through Carry (RCR)
  • 3. PROGRAM CONTROL INSTRUCTIONS

  • Core Function: Change the flow of program execution by modifying the Program Counter.
  • A. Unconditional Transfer
  • Function: Jump without checking any condition.
    1. JMP / JUMP (Direct jump to address)
    1. BRA / BRANCH (Jump relative to current location)
    1. SKP / SKIP (Skip the very next instruction)
    1. CALL (Invoke subroutine/function; save return address)
    1. RET / RETURN (Return from subroutine; retrieve return address)
  • B. Conditional Transfer

  • Function: Jump only if a specific condition is met.
    1. Branch on Register Comparison
  • a. BE / BZ (Branch if Equal/Zero)

  • b. BNE / BNZ (Branch if Not Equal/Not Zero)

    1. Branch on Processor Flags
  • (Note: Examples include Branch if Carry, Branch if No Overflow, etc.)

instruction types
Instruction types Classifications-tinified

1. Consider the below instruction: Load R2, LOC. Write the execution step of the above machine instruction.

Consider the below instruction: Load R2, LOC. Write the execution step of the above machine instruction.

Assume direct addressing, so LOC is the memory address of the operand and the instruction means:

\[R2 \leftarrow M[\text{LOC}]\]

Using PC, MAR, MDR and IR, a typical sequence is:

Step Register-transfer operation Meaning
T0 MAR ← PC Send next-instruction address to memory.
T1 MDR ← M[MAR], PC ← PC + instruction_length Read instruction and advance PC.
T2 IR ← MDR Place instruction in IR and decode it.
T3 MAR ← IR[address] Put LOC in MAR.
T4 MDR ← M[MAR] Read the operand stored at LOC.
T5 R2 ← MDR Complete the load.

With a cache or synchronous memory, T1/T4 may include wait states. The operation changes R2 but not the memory word at LOC.

2. Characteristics of a RISC vs CISC Processor show 12 disctinction with example.

Characteristics of a RISC vs CISC Processor show 12 disctinction with example.

The Classic Example: Multiplying Two Numbers in Memory

Imagine you want to multiply the data at memory address A with the data at memory address B, and save it back to A.

  • The CISC Approach (1 step):
    MULT A, B
    The CPU's hardware does everything. It goes to memory, fetches both values, multiplies them, and stores the result back. It takes multiple clock cycles, but it only takes up one line of code.
  • The RISC Approach (4 steps):
    LOAD R1, A
    LOAD R2, B
    PROD R1, R2
    STORE R1, A
    The CPU can only do math on registers, not directly on memory. The compiler has to break the complex task into simple, one-step commands.

The 12 Key Distinctions

Here is how the two architectures fundamentally differ:

Feature RISC (Reduced Instruction Set Computer) CISC (Complex Instruction Set Computer)
1. Design Philosophy Moves the complexity to the software (compiler). Moves the complexity to the hardware (silicon).
2. Instruction Length Fixed-length (e.g., every command is exactly 32 bits). Variable-length (commands change size based on complexity).
3. Execution Time Most instructions execute in a single clock cycle. Complex instructions can take many clock cycles to finish.
4. Memory Access Load/Store Architecture: Only specific commands access RAM. Memory-to-Memory: Math operations can happen directly on RAM.
5. Register Count High. Data is kept in the CPU as long as possible to avoid slow RAM. Low. The CPU frequently reads and writes directly to RAM.
6. Pipelining Highly efficient. Uniform instruction lengths make it easy to queue up commands. Difficult. Variable execution times cause bottlenecks in the queue.
7. Code Size (RAM Usage) Larger program sizes because complex tasks require multiple lines of code. Smaller program sizes because a single line can execute a complex task.
8. Addressing Modes Very few, simple ways to locate data in memory. Dozens of complex ways to locate and interact with memory.
9. Hardware Circuitry Simpler circuits, which leaves physical room on the chip for more L1/L2 Cache. Highly complex circuits, requiring a dedicated microcode ROM on the chip.
10. Power Consumption Extremely low, making it ideal for battery-powered mobility. High, generating more heat and requiring active cooling systems.
11. Execution Predictability Highly predictable, making it excellent for real-time operating systems. Unpredictable, as time varies wildly depending on the instruction.
12. Real-World Examples ARM processors (Apple Silicon M-series, Snapdragon, smartphones). x86 processors (Intel Core, AMD Ryzen, traditional desktop PCs).

3. Three-Bus CISC-Style Processor Organization

Draw the three-bus CISC-style processor organization.

What is a Three-Bus Architecture and Why Do We Use It?

Inside a processor, data travels from one component to another through electrical pathways called Busses.

In older 1-bus architectures, performing a simple operation like \(A + B\) took multiple clock cycles because two different inputs could not travel over the same bus at the same time. The Three-Bus Architecture solves this by providing three separate pathways (Bus A, Bus B, and Bus C). This allows the system to fetch two inputs simultaneously, process them, and write the output back—all in a single step.

  • Bus A and Bus B (Input Busses): These fetch data from registers or memory registers and feed them directly into the execution units (like the ALU).
  • Bus C (Output Bus): This carries the resulting output from the ALU or other units and writes it back into the target register or memory location.

Three-BUS CISC-Styel Processor
Three-BUS CISC-Styel Processor

Understanding the Architecture Diagram Component-by-Component

1. PC (Program Counter) & Incrementer

  • Function: Tracks the memory address of the instruction currently being executed and determines the address of the next instruction.
  • Connections:
  • Connected to an Incrementer that automatically increases the address value by 1 or 4.
  • Outputs data to Bus B and receives new address values from Bus C.

2. Register File

  • Function: A collection of fast internal storage locations (\(R_0, R_1, R_2\dots\)) used to hold temporary data operands.
  • Connections:
  • Can read and output two separate register values simultaneously onto Bus A and Bus B (allowing two operands to reach the ALU at the same time).
  • Receives processed results from Bus C to store back into a target register.

3. Multiplexer (MUX) & ALU (Arithmetic Logic Unit)

  • Function: The ALU executes arithmetic operations (addition, subtraction) and logical operations (AND, OR).
  • Multiplexer Role: Selects whether Input A of the ALU receives data from Bus A or a fixed Constant 4 (used for stepping through memory/PC increments).
  • Connections:
  • ALU Input A connects to the MUX output (which reads from Bus A).
  • ALU Input B connects directly to Bus B.
  • ALU Output \(R\) connects directly to Bus C.

4. IR (Instruction Register) & Instruction Decoder

  • Function: The IR holds the binary instruction code fetched from main memory. The Instruction Decoder decodes this binary pattern to determine which control signals need to be generated (e.g., addition, subtraction, load, store).
  • Connections: Loads instruction data from Bus C and interfaces with internal control logic to drive Bus A and Bus B operations.

5. MDR (Memory Data Register) & MAR (Memory Address Register)

  • Function: These act as the hardware gateway between the internal processor busses and external main memory (RAM).
  • MAR (Memory Address Register): Holds the memory address where the system needs to read or write data.
  • MDR (Memory Data Register): Holds the actual data payload being transferred to or from main memory.

  • Connections:

  • Both MAR and MDR receive input addresses/data from Bus C.
  • MDR can output stored data back onto Bus A or Bus B.
  • The blue lines at the bottom represent external memory bus connections (Memory Data Lines and Address Lines).

How an Operation Executes in a Single Clock Cycle

For example, to execute the register addition instruction $R_3 = R_1 + R_2$:

  1. Operand \(R_1\) is placed onto Bus A and directed to ALU Input A.
  2. Operand \(R_2\) is placed onto Bus B and directed to ALU Input B.
  3. The ALU performs the addition operation immediately.
  4. The result is placed onto Bus C and written directly into register \(R_3\).

Explain the steps of Three-Bus CISC-style from start to execution.

Explain the steps of Three-Bus CISC-style from start to execution.

āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽā§‡āϰ āϏāĻŦāϗ⧁āϞ⧋ āĻ•āĻŽā§āĻĒā§‹āύ⧇āĻ¨ā§āĻŸā§‡āϰ āϏāĻŽā§āĻ­āĻžāĻŦā§āϝ āϏāĻŦ āĻĄā§‡āϟāĻž āĻĢā§āϞ⧋ āĻŦāĻž āĻĒāĻžāĻĨ āύāĻŋāĻšā§‡ āĻ…ā§āϝāĻžāϰ⧋ (->) āĻĻāĻŋā§Ÿā§‡ āĻĻ⧇āĻ–āĻžāύ⧋ āĻšāϞ⧋:

Three-BUS CISC-Styel Processor

ā§§. Register File (āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰāϏāĻŽā§‚āĻš):

  • āϰāĻŋāĻĄ āĻĒāĻžāĻĨ ā§§: Register file -> Bus A
  • āϰāĻŋāĻĄ āĻĒāĻžāĻĨ ⧍: Register file -> Bus B
  • āϰāĻžāχāϟ āĻĒāĻžāĻĨ: Bus C -> Register file

⧍. PC (Program Counter) āĻ“ Incrementer:

  • āφāωāϟāĻĒ⧁āϟ āĻĒāĻžāĻĨ: PC -> Bus B
  • āχāύāĻĒ⧁āϟ/āφāĻĒāĻĄā§‡āϟ āĻĒāĻžāĻĨ: Bus C -> PC
  • āχāύāĻ•ā§āϰāĻŋāĻŽā§‡āĻ¨ā§āϟ āĻĒāĻžāĻĨ (āϞ⧁āĻĒ): PC -> incrementer -> PC

ā§Š. ALU (Arithmetic Logic Unit) āĻ“ MUX:

  • āχāύāĻĒ⧁āϟ āĻĒāĻžāĻĨ (Bus A āĻĨ⧇āϕ⧇): Bus A -> MUX -> ALU (Input A)
  • āχāύāĻĒ⧁āϟ āĻĒāĻžāĻĨ (Constant 4 āĻĨ⧇āϕ⧇): Constant 4 -> MUX -> ALU (Input A)
  • āχāύāĻĒ⧁āϟ āĻĒāĻžāĻĨ (Bus B āĻĨ⧇āϕ⧇): Bus B -> ALU (Input B)
  • āφāωāϟāĻĒ⧁āϟ/āϰ⧇āϜāĻžāĻ˛ā§āϟ āĻĒāĻžāĻĨ: ALU (Output R) -> Bus C

ā§Ē. IR (Instruction Register) āĻ“ Decoder:

  • āχāύāĻĒ⧁āϟ āĻĒāĻžāĻĨ: Bus C -> IR
  • āĻĄāĻŋāϕ⧋āĻĄ āĻĒāĻžāĻĨ: IR -> Instruction decoder

ā§Ģ. MDR (Memory Data Register):

  • āĻĒā§āϰāϏ⧇āϏāϰ āĻĨ⧇āϕ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āϰāĻžāχāϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ: Bus C -> MDR -> Memory bus (Data lines)
  • āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āĻĒā§āϰāϏ⧇āϏāϰ⧇ āϰāĻŋāĻĄ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ: Memory bus (Data lines) -> MDR -> Bus B

ā§Ŧ. MAR (Memory Address Register):

  • āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āϰāĻŋāϏāĻŋāĻ­ āĻĒāĻžāĻĨ: Bus C -> MAR
  • āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻĒāĻžāĻ āĻžāύ⧋āϰ āĻĒāĻžāĻĨ: MAR -> Address lines
    !!! "Example 01"

    āĻāĻ–āĻžāύ⧇ Add R4, R5, R6 āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻšāĻ“ā§ŸāĻžāϰ āĻļ⧁āϰ⧁ āĻĨ⧇āϕ⧇ āĻļ⧇āώ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻ…āĻ°ā§āĻĄāĻžāϰāĻŋ āĻĢā§āϞ⧋ āĻĻ⧇āĻ“ā§ŸāĻž āĻšāϞ⧋, āϝ⧇āĻ–āĻžāύ⧇ āϏāĻŋāϰāĻŋ⧟āĻžāϞ āĻ…āύ⧁āϝāĻžā§Ÿā§€ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻ•āĻŽā§āĻĒā§‹āύ⧇āĻ¨ā§āϟ āĻĻ⧇āĻ–āĻžāύ⧋ āĻšā§Ÿā§‡āϛ⧇:

    Step 1 (Instruction Fetch - Address Phase):

    • PC -> Bus B -> ALU (Pass) -> Bus C -> MAR -> Address lines
    • (āĻāĻ•āχ āϏāĻŽā§Ÿā§‡ āĻĒā§āϝāĻžāϰāĻžāϞāĻžāϞ āĻ•āĻžāϜ): PC -> incrementer -> PC

    Step 2 (Memory Read Phase):

    • (Wait for MFC) -> Memory -> Memory bus (Data lines) -> MDR

    Step 3 (Instruction Transfer & Decode Phase):

    • MDR -> Bus B -> ALU (Pass) -> Bus C -> IR
    • IR -> Instruction decoder

    Step 4 (Execution Phase - Add R4, R5, R6):

    • Register file (R4) -> Bus A -> MUX -> ALU (Input A)
    • Register file (R5) -> Bus B -> ALU (Input B)
    • ALU (Add) -> Bus C -> Register file (R6)

!!! "Example 02"

āφāĻŽāϰāĻž āϝ⧇ āĻŽāĻžāĻ¸ā§āϟāĻžāϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āύāĻŋāĻŦā§‹ āϤāĻž āĻšāϞ⧋:
👉 **`STORE R3, 50(R2)`**

**āĻāχ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋāϰ āĻŽāĻžāύ⧇ āϕ⧀?**
"R2 āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āĻĨāĻžāĻ•āĻž āĻŽāĻžāύ⧇āϰ āϏāĻžāĻĨ⧇ āϏāϰāĻžāϏāϰāĻŋ '50' āϝ⧋āĻ— āĻ•āϰ⧋āĨ¤ āϝ⧋āĻ— āĻ•āϰ⧇ āϝ⧇ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āĻĒāĻžāĻŦ⧇, āĻŽā§‡āĻŽā§‹āϰāĻŋāϰ āĻ āĻŋāĻ• āϏ⧇āχ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āĻ—āĻŋā§Ÿā§‡ R3 āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āĻŽāĻžāύāϟāĻŋ āϏ⧇āĻ­ (Store) āĻ•āϰ⧇ āφāϏ⧋āĨ¤"

āϚāϞ⧁āύ, āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽā§‡āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻĒāĻžāĻĨ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ āĻāϰ āĻ¸ā§āĻŸā§‡āĻĒ-āĻŦāĻžāχ-āĻ¸ā§āĻŸā§‡āĻĒ āĻĢā§āϞ⧋ āĻĻ⧇āĻ–āĻŋ:

### Phase 1: Instruction Fetch (āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āφāύāĻž)

**Step 1: āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻĒāĻžāĻ āĻžāύ⧋**

* **PC -> Bus B -> ALU (Pass) -> Bus C -> MAR:** PC (Program Counter) āϤāĻžāϰ āĻ•āĻžāϛ⧇ āĻĨāĻžāĻ•āĻž āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ Bus B-āϤ⧇ āĻĻā§‡ā§ŸāĨ¤ ALU āϕ⧋āύ⧋ āĻ•āĻžāϜ āĻ›āĻžā§œāĻžāχ āϤāĻž Bus C āĻšā§Ÿā§‡ MAR-āĻ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤
* **MAR -> Address lines:** MAR āϏ⧇āχ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āĻŽā§‡āĻŽā§‹āϰāĻŋāϰ āĻĻāĻŋāϕ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤
* *(āĻāĻ•āχ āϏāĻŽā§Ÿā§‡)* **PC -> Incrementer -> PC:** āĻŽā§‡āχāύ ALU āϝāĻ–āύ āĻ…āĻ¨ā§āϝ āĻ•āĻžāĻœā§‡ āĻŦā§āϝāĻ¸ā§āϤ, āϤāĻ–āύ āχāύāĻ•ā§āϰāĻŋāĻŽā§‡āĻ¨ā§āϟāĻžāϰ āύ⧀āϰāĻŦ⧇ PC-āĻāϰ āĻŽāĻžāύ ā§Ē āĻŦāĻžā§œāĻŋā§Ÿā§‡ āĻĻā§‡ā§Ÿ, āϝāĻžāϤ⧇ āĻĒāϰ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āϰ⧇āĻĄāĻŋ āĻĨāĻžāϕ⧇āĨ¤

**Step 2: āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āĻĒā§āϰāϏ⧇āϏāϰ⧇ āĻĒā§āϰāĻŦ⧇āĻļ**

* **Memory bus (Data lines) -> MDR:** āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ `STORE R3, 50(R2)` āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋāϰ āĻŦāĻžāχāύāĻžāϰāĻŋ āϕ⧋āĻĄ āĻāϏ⧇ MDR-āĻ āϜāĻŽāĻž āĻšā§ŸāĨ¤

**Step 3: āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻĄāĻŋāϕ⧋āĻĄ āĻŦāĻž āĻ…āύ⧁āĻŦāĻžāĻĻ āĻ•āϰāĻž**

* **MDR -> Bus B -> ALU (Pass) -> Bus C -> IR:** āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ MDR āĻĨ⧇āϕ⧇ Bus B āĻāĻŦāĻ‚ Bus C āĻšā§Ÿā§‡ IR-āĻ (Instruction Register) āφāϏ⧇āĨ¤
* **IR -> Instruction decoder:** IR āĻĨ⧇āϕ⧇ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ⧇ āϝāĻžā§ŸāĨ¤ āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ āĻāϟāĻŋ āĻĒā§œā§‡ āĻŦ⧁āĻāϤ⧇ āĻĒāĻžāϰ⧇: *"āφāĻŽāĻžāϕ⧇ R2 āĻāϰ āϏāĻžāĻĨ⧇ 50 āϝ⧋āĻ— āĻ•āϰ⧇ āĻāĻ•āϟāĻž āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻŦāĻžāύāĻžāϤ⧇ āĻšāĻŦ⧇ āĻāĻŦāĻ‚ āϏ⧇āĻ–āĻžāύ⧇ R3 āĻāϰ āĻĄā§‡āϟāĻž āĻĒāĻžāĻ āĻžāϤ⧇ āĻšāĻŦ⧇āĨ¤"*

---

### Phase 2: Execution & Memory Write (āφāϏāϞ āĻ•āĻžāϜ āĻļ⧁āϰ⧁)

**Step 4: āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻ•ā§āϝāĻžāϞāϕ⧁āϞ⧇āĻļāύ (āφāĻĒāύāĻžāϰ āϏ⧇āχ āĻ¸ā§āĻĒ⧇āĻļāĻžāϞ āĻĒāĻžāĻĨ!)**

* **Instruction decoder -> Bus A:** āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āϭ⧇āϤāϰ āĻĨāĻžāĻ•āĻž āϏāϰāĻžāϏāϰāĻŋ āĻŽāĻžāύ '50'-āϕ⧇ āφāϞāĻžāĻĻāĻž āĻ•āϰ⧇ āϏāϰāĻžāϏāϰāĻŋ Bus A-āϤ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤
* **Register file (R2) -> Bus B:** āĻāĻ•āχ āϏāĻŽā§Ÿā§‡ R2 āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āϤāĻžāϰ āϭ⧇āϤāϰ⧇āϰ āĻŽāĻžāύ Bus B-āϤ⧇ āĻĒāĻžāĻ āĻžā§ŸāĨ¤
* **Bus A & Bus B -> ALU -> Bus C -> MAR:** ALU āĻāχ āĻĻ⧁āĻŸā§‹ āĻŽāĻžāύ (50 + R2) āϝ⧋āĻ— āĻ•āϰ⧇ āϟāĻžāĻ°ā§āϗ⧇āϟ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĨ¤ āĻĢāϞāĻžāĻĢāϞāϟāĻŋ Bus C āĻĻāĻŋā§Ÿā§‡ āϏāϰāĻžāϏāϰāĻŋ MAR-āĻ āĻ—āĻŋā§Ÿā§‡ āϜāĻŽāĻž āĻšā§ŸāĨ¤ (āĻāĻ–āύ MAR āϜāĻžāύ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋāϰ āϕ⧋āĻĨāĻžā§Ÿ āĻĄā§‡āϟāĻž āϰāĻžāĻ–āϤ⧇ āĻšāĻŦ⧇)āĨ¤

**Step 5: āĻĄā§‡āϟāĻž āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āĻĒāĻžāĻ āĻžāύ⧋āϰ āϜāĻ¨ā§āϝ āϰ⧇āĻĄāĻŋ āĻ•āϰāĻž**

* **Register file (R3) -> Bus B:** āĻāĻ–āύ R3 āϤāĻžāϰ āĻĄā§‡āϟāĻž (āϝ⧇āϟāĻž āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āϏ⧇āĻ­ āĻšāĻŦ⧇) Bus B-āϤ⧇ āĻĒāĻžāĻ āĻžā§ŸāĨ¤
* **Bus B -> ALU (Pass) -> Bus C -> MDR:** ALU āĻāχ āĻĄā§‡āϟāĻžāϕ⧇ āϕ⧋āύ⧋ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āύāĻž āĻ•āϰ⧇ Bus C āĻĻāĻŋā§Ÿā§‡ āϏ⧋āϜāĻž MDR-āĻ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤ (āĻāĻ–āύ MDR-āĻāϰ āĻ•āĻžāϛ⧇ āĻĒāĻžāĻ āĻžāύ⧋āϰ āĻŽāϤ⧋ āĻĄā§‡āϟāĻž āϰ⧇āĻĄāĻŋ)āĨ¤

**Step 6: āĻĢāĻžāχāύāĻžāϞ āϰāĻžāχāϟ āĻ…āĻĒāĻžāϰ⧇āĻļāύ (Memory Write)**

* **MAR -> Address lines:** MAR āϤāĻžāϰ āĻ•āĻžāϛ⧇ āĻĨāĻžāĻ•āĻž āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āĻŽā§‡āĻŽā§‹āϰāĻŋāϕ⧇ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻ•āϰ⧇āĨ¤
* **MDR -> Memory bus (Data lines):** MDR āϤāĻžāϰ āĻĄā§‡āϟāĻžāϟāĻŋ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āĻĄā§‡āϟāĻž āϏ⧇āĻ­ āĻšā§Ÿā§‡ āϝāĻžā§Ÿ!

---

### āĻāĻ• āύāϜāϰ⧇ āϕ⧇āύ āĻāχ āωāĻĻāĻžāĻšāϰāĻŖāϟāĻŋ āϏ⧇āϰāĻž:

* **PC āĻāĻŦāĻ‚ Incrementer** āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿā§‡āϛ⧇ (Step 1)āĨ¤
* āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ **Read** āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ (Step 2)āĨ¤
* **IR āĻāĻŦāĻ‚ Decoder** āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿā§‡āϛ⧇ (Step 3)āĨ¤
* Decoder āĻĨ⧇āϕ⧇ **Bus A**-āĻāϰ āĻ¸ā§āĻĒ⧇āĻļāĻžāϞ āĻĒāĻžāĻĨāϟāĻŋ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿā§‡āϛ⧇ (Step 4)āĨ¤
* ALU-āϤ⧇ **āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāϜ (Add)** āĻšā§Ÿā§‡āϛ⧇ (Step 4)āĨ¤
* ALU-āϤ⧇ **Pass-through (āĻĄā§‡āϟāĻž āĻĒāĻžāϰ āĻ•āϰāĻž)** āĻ•āĻžāϜ āĻšā§Ÿā§‡āϛ⧇ (Step 1, 3, 5)āĨ¤
* āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ **Write** āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇ (Step 6)āĨ¤

āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽā§‡ āϝāϤāϗ⧁āϞ⧋ āĻ…ā§āϝāĻžāϰ⧋ āĻŦāĻž āϤ⧀āϰ āϚāĻŋāĻšā§āύ āφāϛ⧇, āĻāχ āĻāĻ•āϟāĻŋāĻŽāĻžāĻ¤ā§āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϤāĻžāϰ āĻĒā§āϰāĻžā§Ÿ āϏāĻŦāϗ⧁āϞ⧋āϕ⧇ āĻ…āĻ¨ā§āϤāϤ āĻāĻ•āĻŦāĻžāϰ āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āϛ⧇!

4. Execution of Add (R3), R1

Enhanced question

Interpret Add (R3), R1 using register-indirect addressing and show its complete micro-operation sequence on a three-bus processor. Explain the datapath resources used.

Using conventional destination-last notation:

\[R1 \leftarrow R1 + M[R3]\]

R3 contains the address of the memory operand. A possible sequence is:

Step Micro-operation Resource/action
T0 MAR ← R3 Address is transferred through the datapath.
T1 MDR ← M[MAR] Memory Read; wait for completion if necessary.
T2 Y ← R1 Save the first ALU operand in an internal register.
T3 Z ← Y + MDR ALU adds the register and memory operands.
T4 R1 ← Z Write result through the C bus.

On a true three-bus design, if MDR and R1 can feed the two source buses directly, T2 and part of T3 may be combined: R1 ← R1 + MDR. Condition flags are updated if specified by the ISA. Any arithmetic overflow must be handled according to the instruction semantics.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Destination-last notation āĻ…āύ⧁āϝāĻžāϝāĻŧā§€ instruction-āϟāĻŋāϰ āĻ…āĻ°ā§āĻĨ:

\[R1 \leftarrow R1 + M[R3]\]

āĻāĻ–āĻžāύ⧇ R3 data āύāϝāĻŧ, memory operand-āĻāϰ address āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤ āĻĒā§āϰāĻĨāĻŽā§‡ MAR ← R3 āĻĻā§āĻŦāĻžāϰāĻž effective address memory interface-āĻ āϝāĻžāϝāĻŧāĨ¤ Memory Read āĻļ⧇āώ⧇ MDR ← M[MAR] āĻšāϝāĻŧāĨ¤ āĻāϰāĻĒāϰ R1-āĻāϰ āĻŽāĻžāύ internal Y register-āĻ āϰāĻžāĻ–āĻž āĻšāϝāĻŧ; ALU Z ← Y + MDR āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰ⧇; āϏāĻ°ā§āĻŦāĻļ⧇āώ⧇ R1 ← Z āĻĻā§āĻŦāĻžāϰāĻž āĻĢāϞ āϞ⧇āĻ–āĻž āĻšāϝāĻŧāĨ¤ āϝāĻĻāĻŋ āϤāĻŋāύ-bus datapath-āĻ R1 āĻ“ MDR āϏāϰāĻžāϏāϰāĻŋ āĻĻ⧁āχ source bus-āĻ āϝ⧇āϤ⧇ āĻĒāĻžāϰ⧇, āϤāĻŦ⧇ addition āĻ“ write-back āφāϰāĻ“ āĻ•āĻŽ internal step-āĻ āĻ•āϰāĻž āϝāĻžāϝāĻŧāĨ¤


5. Explain the MIPS addressing modes with suitable examples.

Explain the MIPS addressing modes with suitable examples.

The MIPS architecture relies on five distinct addressing modes to determine where instruction operands are located in memory or CPU registers. Because MIPS is a Reduced Instruction Set Computer (RISC) architecture, it keeps these modes simple to ensure fast, predictable execution hardware.

Here is the breakdown of each MIPS addressing mode with practical assembly examples.

1. Register Addressing

The operand is located directly inside a CPU register. This is the fastest addressing mode because it does not require any time-consuming memory access.

  • Example: add $t0, $t1, $t2
  • How it works: The processor grabs the values already stored in register $t1 and register $t2, adds them together, and writes the final sum straight into register $t0.

2. Immediate Addressing

The operand is a constant data value embedded directly within the instruction code itself. The constant value is limited to a 16-bit size.

  • Example: addi $t0, $t1, 4
  • How it works: The CPU reads the constant integer 4 from the instruction stream and adds it directly to the value found in register $t1, storing the final outcome into $t0.

3. Base or Displacement Addressing

The data address in memory is calculated by adding a constant offset (displacement) to a base pointer stored in a register. This mode is primarily used by load and store instructions to pull data out of arrays or structs.

  • Example: lw \(t0, 12(\)s0)
  • How it works: The processor calculates the actual memory target location by computing Value in Register $s0 + 12. It then copies the data word found at that specific memory address and places it inside register $t0.

4. PC-Relative Addressing

The target instruction address is calculated by adding a signed constant offset to the current Program Counter (PC). This mode is used strictly for conditional branch instructions.

  • Example: beq $t0, $t1, label
  • How it works: If the data inside $t0 equals the data inside $t1, the CPU jumps to a new execution path. The jump distance is calculated by adding the instruction's relative offset directly to the updating Program Counter (PC + offset).

5. Pseudo-Direct Addressing

The target address is created by combining a 26-bit value embedded in the instruction with the upper 4 bits of the current Program Counter. This mode is utilized exclusively for unconditional jump instructions.

  • Example: j label
  • How it works: The CPU shifts the 26-bit target field left by 2 bits (making it a 28-bit boundary address) and glues the highest 4 bits of the current PC onto the very front to construct a complete 32-bit execution jump target.

MIPS Addressing Modes Summary

Addressing Mode Operand Location Example Instruction Primary Use Case
Register Register file add $t0, $t1, $t2 Standard arithmetic and logic
Immediate Embedded in instruction addi $t0, $t1, 4 Fast math with small constants
Base / Displacement Memory Address (Register + Offset) lw \(t0, 12(\)s0) Array and data structure access
PC-Relative PC Address + Offset beq $t0, $t1, loop Conditional loops and logic branches
Pseudo-Direct PC bits + Instruction bits j cleanup Unconditional jumps to functions

6. Write down the MIPS assembly code 🧑‍đŸ’ģ for the following C code: 🇨đŸ’ģ: f=(a+b)-(c+d); g=f+A[10];.

Write down the MIPS assembly code 🧑‍đŸ’ģ for the following C code: 🇨đŸ’ģ: f=(a+b)-(c+d); g=f+A[10];.

Assume all variables and array elements are 32-bit integers:

C object MIPS register
f, g $s0, $s1
a, b, c, d $s2, $s3, $s4, $s5
Base address of A $s6
add  $t0, $s2, $s3      # t0 = a + b
add  $t1, $s4, $s5      # t1 = c + d
sub  $s0, $t0, $t1      # f  = (a+b) - (c+d)

lw   $t2, 40($s6)       # t2 = A[10]; offset = 10 × 4 bytes
add  $s1, $s0, $t2      # g  = f + A[10]

If overflow trapping is not required, addu and subu may be used. The load uses offset 40, not 10, because MIPS memory is byte-addressed and each integer occupies four bytes.

7. Compilation Process of a C Program

Explain the compilation process of a C program step by step. đŸšļâ€â™‚ī¸ How does a high-level language convert to machine language?.

Figure: translation pipeline

C Program to Machine Execution

  1. Preprocessing: Handles #include, #define and conditional compilation, removes comments and produces an expanded translation unit.
  2. Compilation: Performs lexical, syntax and semantic analysis; creates an intermediate representation; optimizes it; and generates target assembly. Errors such as type mismatch are detected here.
  3. Assembly: Converts mnemonics into binary machine instructions and creates an object file containing code, data, a symbol table and relocation information. External addresses may still be unresolved.
  4. Linking: Combines object files and libraries, resolves external symbols and relocates addresses to form an executable. Static linking copies library code; dynamic linking records references to shared libraries.
  5. Loading: The operating-system loader maps code and data into virtual memory, allocates stack and heap, loads or connects shared libraries, initializes registers and transfers control to the program entry point.

Thus, high-level expressions are gradually lowered into ISA instructions and binary fields. The CPU does not directly understand C; it fetches and executes only the final machine instructions.

8. General Addressing Modes

Enhanced question

Explain the major addressing modes used in computer instruction sets. Derive the effective-address expression for each and give an appropriate assembly-style example.

Let A be an instruction address field, R a register and M[x] memory at address x.

Mode Operand or effective address Example/meaning
Immediate Operand = A MOV R1,#25
Register Operand = R1 ADD R1,R2
Direct/absolute \(EA=A\) LOAD R1,1000
Memory indirect \(EA=M[A]\) LOAD R1,@1000
Register indirect \(EA=R2\) LOAD R1,(R2)
Base/displacement \(EA=R_b+A\) LW R1,12(R2)
Indexed \(EA=A+R_i\) Array access
Base-indexed \(EA=R_b+R_i+A\) Record containing an array
PC-relative \(EA=PC+A\) Conditional branch
Auto-increment \(EA=R;\ R←R+d\) Sequential array/stack access
Auto-decrement \(R←R-d;\ EA=R\) Push operation
Implied/accumulator Operand is implied by opcode CLR A, CMA
Stack Operand is at top of stack PUSH, POP

Complex modes reduce instruction count but increase address-generation complexity. RISC ISAs normally retain register, immediate, base/displacement, PC-relative and jump modes, while CISC ISAs often provide most of the modes above.

9. Instruction and Its Computer Representation

Define a machine instruction. Explain how an instruction is represented, stored, decoded and executed by a computer, using a generic instruction format and a short example.

An instruction is a binary-coded command that tells the processor what operation to perform, where the operands are located and where the result should go. An instruction normally contains:

  • an opcode identifying an operation such as add, load or branch;
  • operand specifiers identifying source and destination registers;
  • an addressing-mode indication, explicit or implied;
  • an immediate, displacement or target field, when required.

A generic representation is:

Opcode Mode Source 1 Source 2 / immediate Destination

The exact bit allocation is defined by the ISA. For example, a 32-bit MIPS R-type instruction contains six-bit opcode and function fields plus three five-bit register numbers. Assembly text such as add $t0,$t1,$t2 is only a human-readable representation; the assembler converts it into a 32-bit pattern. The pattern is stored in memory like other binary data.

During execution, the PC supplies the instruction address, memory returns the bit pattern into the IR, the decoder interprets the opcode and fields, and the control unit activates the datapath. Context and the instruction format give the bits meaning; without ISA rules, a word of bits is neither inherently an instruction nor data.
An instruction (āύāĻŋāĻ°ā§āĻĻ⧇āĻļ) is a fundamental command given to a computer’s Central Processing Unit (CPU) to perform a specific task, such as arithmetic calculation, logical decision-making, or data movement. A complete software program is composed of a sequence of these instructions executed sequentially by the hardware.

A computer represents an instruction in memory as a binary sequence of bits structured according to a defined layout known as an Instruction Format. This format specifies how the bits are divided into different functional fields (āĻ•ā§āώ⧇āĻ¤ā§āϰ):

  1. Opcode (Operation Code / āĻ…āĻĒāĻžāϰ⧇āĻļāύ⧇āϰ āϕ⧋āĻĄ): A binary code field that defines the specific operational task to be performed by the CPU (e.g., ADD, SUB, or data transfer).
  2. Operands (āĻ…āĻĒāĻžāϰ⧇āĻ¨ā§āĻĄ / āĻĄāĻžāϟāĻž āĻŦāĻž āĻ āĻŋāĻ•āĻžāύāĻž): Fields that store the actual data values or memory references (addresses) on which the operation acts.
  3. Addressing Mode (āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāĻŋāĻ‚ āĻŽā§‹āĻĄ / āĻ āĻŋāĻ•āĻžāύāĻž āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻĒāĻĻā§āϧāϤāĻŋ): A control field that specifies how the CPU should locate or interpret the operand address (such as direct, indirect, or immediate).

Types of Instruction Representations (Based on Address Fields)

Instruction formats are primarily categorized by the number of explicit (āĻ¸ā§āĻĒāĻˇā§āϟāĻ­āĻžāĻŦ⧇ āωāĻ˛ā§āϞāĻŋāĻ–āĻŋāϤ) memory or register address fields they contain. This structure directly depends on the underlying CPU Organization:

1. Three-Address Instructions

  • Structure: [ Opcode | Destination Address | Source Address 1 | Source Address 2 ]
  • Representation: Specifies three operands. Two operands act as inputs for the operation, and the result is stored in the third location.
  • CPU Organization: Used in General Register Organizations.
  • Characteristics: Makes assembly programs shorter and easier to write, but requires a larger instruction size (more bits per instruction).
  • Example: R1 ← R2 + R3

2. Two-Address Instructions

  • Structure: [ Opcode | Destination / Operand 1 Address | Source / Operand 2 Address ]
  • Representation: Specifies two address fields. The operation is performed on both operands, and the calculated result overwrites one of the specified destination addresses.
  • CPU Organization: Common in commercial computers.
  • Characteristics: Reduces instruction bit-size compared to three-address formats while maintaining flexible memory/register storage.
  • Example: R1 = R1 + B

3. One-Address Instructions

  • Structure: [ Opcode | Operand Address ]
  • Representation: Specifies only one explicit address field. The second operand and the destination are implicitly (āĻ…āĻ¨ā§āϤāĻ°ā§āύāĻŋāĻšāĻŋāϤāĻ­āĻžāĻŦ⧇) assumed to be a dedicated register called the Accumulator (AC).
  • CPU Organization: Used in Accumulator-based Organizations.
  • Characteristics: Saves memory space because the CPU automatically knows one operand resides in the Accumulator without needing an explicit address.
  • Example: AC = AC + B

4. Zero-Address Instructions

  • Structure: [ Opcode ]
  • Representation: Contains no explicit address or operand fields. Operands are implicitly retrieved from the top of a Stack data structure (TOP).
  • CPU Organization: Used in Stack Organizations.
  • Characteristics: Operates by popping the top two items from the stack, executing the operation, and pushing the final result back onto the stack. Evaluates expressions converted into Postfix Notation (Reverse Polish Notation).
  • Example: ADD (implicitly computes TOP = A + B)
    Instruction Format Full{ }

10. Datapath of a Processor

Explain with block diagram 🔲 the data path đŸ›Ŗī¸ of a processor.

Last Updated : 14 Oct, 2025

In computer architecture, the datapath is a core part of the CPU that executes instructions by processing and transferring data. It includes components like registers, ALUs, multiplexers, and buses, all coordinated by control signals from the control unit.

  • Performs arithmetic, logic, data storage, and transfer operations.
  • Operates under the control unit, which directs data flow through control signals.

Types of Datapath Designs

1. Single-Cycle Datapath

Each instruction is completed in a single clock cycle, performing all steps in one go. It's simple but inefficient due to the long cycle time.

  • All instruction stages (fetch to write-back) occur in one long clock cycle.
  • Executes one instruction at a time with no overlapping.
  • Simple design with no extra registers or complex control.

1

2. Multi-Cycle Datapath

Instructions are broken into multiple steps, each taking one clock cycle. This allows for better efficiency with more complex control logic.

  • Instruction is split across multiple short cycles, using extra registers between stages.
  • Only one instruction is executed at a time, still without overlapping.
  • More efficient than single-cycle but requires complex control logic.

2

Multi-cycle Datapath

3. Pipelined Datapath

Instruction execution is divided into fixed stages, allowing multiple instructions to be processed simultaneously. This improves throughput but introduces complexity.

  • Multiple instructions are executed in parallel, each at a different stage.
  • Uses short clock cycles with extra registers between pipeline stages.
  • High performance but needs hazard detection and handling logic.

20

Pipelined Datapath

Note: Single-cycle uses a longer clock cycle for all instructions while multi-cycle and pipelined designs use shorter, more efficient cycles.

Main Components of a Datapath

Key hardware elements involved in executing instructions by processing and transferring data.

  1. Registers: Temporary storage for data and intermediate results (e.g., PC, IR).
  2. Register File: A collection of registers with multiple read/write ports for fast access.
  3. ALU (Arithmetic Logic Unit): Performs arithmetic and logical operations on data.
  4. Multiplexers (MUX): Select one of several input signals based on control inputs.
  5. Memory: Stores instructions and data for read/write operations during execution.
  6. Sign/Zero Extender: Extends immediate values to match the datapath's bit-width.
  7. Shift Units: Performs bit-level shifts, often used in address or data calculations.
  8. Buses: Shared data lines for transferring information between components.
  9. Control Signals: Guide the operation of all datapath elements during instruction execution.

11. Control Signals for the Datapath

Identify the major control signals in a single-cycle MIPS datapath. Explain what each signal controls and tabulate typical values for R-type, lw, sw, beq and addi.

The main control unit decodes the opcode. ALUOp and, for R-type instructions, the funct field are further decoded by the ALU-control unit.

Signal Function
RegDst Selects rt or rd as the destination.
RegWrite Enables register-file write.
ALUSrc Selects register or sign-extended immediate for ALU input B.
ALUOp Indicates add, subtract or function-field decoding.
MemRead Enables data-memory read.
MemWrite Enables data-memory write.
MemtoReg Selects ALU result or memory data for write-back.
Branch Identifies a conditional branch.
Jump Selects the jump target for PC.
PCSrc Chooses sequential or branch next PC; often Branch ∧ Zero.
ExtOp Controls sign or zero extension of an immediate.

Typical active-high settings (X = do not care):

Instruction RegDst RegWrite ALUSrc ALU action MemRead MemWrite MemtoReg Branch
R-type 1 1 0 funct 0 0 0 0
lw 0 1 1 add 1 0 1 0
sw X 0 1 add 0 1 X 0
beq X 0 0 subtract 0 0 X 1
addi 0 1 1 add 0 0 0 0

These signals must be asserted with correct timing. An incorrect RegWrite or MemWrite can corrupt architectural state.

12. Briefly explain about dynamic scheduler 📅 with block diagram.

Briefly explain about dynamic scheduler 📅 with block diagram.

Dynamic Scheduling with In-Order Commit

# Dynamic Scheduling

## Lesson Context

Scheduling is one of the techniques used to improve the performance of a pipeline processor. The earlier lesson introduced scheduling and static scheduling. This lesson continues with dynamic scheduling.

The techniques discussed for improving pipeline-processor performance are:

1. Instruction execution phases
2. Mechanisms for instruction pipelining
3. Dynamic instruction scheduling techniques

![Official image from the Dynamic Scheduling video](https://i.ytimg.com/vi/WQgN90QRgcA/maxresdefault.jpg?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AH-CYAC0AWKAgwIABABGHIgVChAMA8=&rs=AOn4CLBot3Y9QbBuukUTCwxTLqhMuJtKNA)

## What Is Dynamic Scheduling?

Dynamic scheduling is a **hardware-based approach**.

In dynamic scheduling, the hardware rearranges the execution of instructions to reduce stalls while maintaining the data flow and exception behaviour.

> **Dynamic Scheduling:** The hardware rearranges instruction execution to reduce stalls while maintaining data flow and exception behaviour.

```mermaid
flowchart TD
    A["Instructions"] --> B["Hardware rearranges instruction execution"]
    B --> C["Stalls are reduced"]
    C --> D["Data flow is maintained"]
    C --> E["Exception behaviour is maintained"]
```

## Static Scheduling and Dynamic Scheduling

Static scheduling and dynamic scheduling use different approaches.

| Static Scheduling | Dynamic Scheduling |
|---|---|
| Software-based approach | Hardware-based approach |
| Compiler-based | Hardware-based |
| The compiler schedules or rearranges the instructions | The hardware rearranges instruction execution |
| Used when dependencies are known at compile time | Used when dependencies are not known at compile time |

In static scheduling, compiler techniques are used to schedule or rearrange instructions. The instruction is always scheduled by the compiler.

If dependencies between instructions are known at compile time, there is no need to use a hardware-based approach. The software itself modifies the instructions and minimizes the hazards.

If dependencies are not known at compile time, dynamic scheduling is used.

```mermaid
flowchart TD
    A["Dependencies between instructions"] --> B{"Known at compile time?"}
    B -->|Yes| C["Static Scheduling"]
    C --> D["Compiler rearranges instructions"]
    B -->|No| E["Dynamic Scheduling"]
    E --> F["Hardware rearranges instruction execution"]
```

## Why Is Dynamic Scheduling Used?

Dynamic scheduling is used when the dependencies between instructions are not known at compile time.

The hardware itself rearranges instruction execution:

- To reduce stalls
- To maintain data flow
- To maintain exception behaviour

Dynamic scheduling also simplifies the compiler. This is why dynamic scheduling is preferred over static scheduling in this situation.

```mermaid
flowchart LR
    A["Unknown dependencies at compile time"] --> B["Dynamic Scheduling"]
    B --> C["Hardware rearrangement"]
    C --> D["Reduced stalls"]
    C --> E["Simplified compiler"]
```

## Dynamic Scheduling Schemes

Dynamic scheduling can be implemented using two schemes:

1. **Scoreboarding**
2. **Tomasulo’s Algorithm**

```mermaid
flowchart TD
    A["Dynamic Scheduling"] --> B["Scoreboarding"]
    A --> C["Tomasulo’s Algorithm"]
    B --> D["Allows out-of-order execution"]
    C --> E["Hardware dependence-resolution scheme"]
```

## Scoreboarding

Scoreboarding is a technique that allows instructions to execute **out of order** when there are:

- No structural hazards
- No data dependencies

> **Scoreboarding:** A technique that allows instructions to execute out of order when there are no structural hazards and no data dependencies.

### No Structural Hazards

No structural hazards means that sufficient resources are available.

\[
\text{No Structural Hazards} \Rightarrow \text{Sufficient Resources}
\]

### No Data Dependencies

No data dependencies means that there are no data hazards.

\[
\text{No Data Dependencies} \Rightarrow \text{No Data Hazards}
\]

Therefore, scoreboarding permits out-of-order instruction execution when sufficient resources are available and no data hazards exist.

```mermaid
flowchart TD
    A["Scoreboarding"] --> B{"Sufficient resources?"}
    B -->|No| C["Structural hazard exists"]
    B -->|Yes| D{"No data hazards?"}
    D -->|No| E["Data dependency exists"]
    D -->|Yes| F["Instructions may execute out of order"]
```

## Tomasulo’s Algorithm

Tomasulo’s Algorithm is a **hardware dependence-resolution scheme**.

> **Tomasulo’s Algorithm:** A hardware dependence-resolution scheme used for dynamic scheduling.

The detailed explanation and example of Tomasulo’s Algorithm are continued in the next lesson. Scoreboarding and its example are also explained separately.

## Complete Summary

- Dynamic scheduling is used to improve pipeline-processor performance.
- It is a hardware-based approach.
- Static scheduling is a software-based or compiler-based approach.
- Static scheduling is used when dependencies are known at compile time.
- Dynamic scheduling is used when dependencies are not known at compile time.
- In dynamic scheduling, hardware rearranges instruction execution.
- Hardware rearrangement reduces stalls.
- Data flow and exception behaviour are maintained.
- Dynamic scheduling simplifies the compiler.
- Dynamic scheduling can be implemented using Scoreboarding and Tomasulo’s Algorithm.
- Scoreboarding allows instructions to execute out of order when there are no structural hazards and no data dependencies.
- No structural hazards means sufficient resources are available.
- No data dependencies means there are no data hazards.
- Tomasulo’s Algorithm is a hardware dependence-resolution scheme.

13. Microprogrammed Control Unit for a Branch Instruction

Briefly explain the micro-programmed control unit đŸŽ›ī¸ for the branch instruction.

Q: Briefly explain the micro-programmed control unit for the branch instruction.## ā§§. Introduction (āĻ­ā§‚āĻŽāĻŋāĻ•āĻž)

āĻāĻ•āϟāĻŋ Micro-programmed Control Unit āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻŽā§‡āχāύ āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύāϕ⧇ āĻ•āĻŋāϛ⧁ āϛ⧋āϟ āϛ⧋āϟ āϏāĻžāĻŦ-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύ āĻŦāĻž Micro-instructions-āĻāϰ āϏāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¨ā§āϏ āϰāĻžāύ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāϟ āĻ•āϰ⧇ [COA]āĨ¤ āĻāχ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύāϗ⧁āϞ⧋ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϭ⧇āϤāϰ⧇āϰ āĻāĻ•āϟāĻŋ āĻ¸ā§āĻĨāĻžā§Ÿā§€ āĻŽā§‡āĻŽāϰāĻŋ, āϝāĻžāϕ⧇ Control Memory (ROM) āĻŦāϞ⧇, āϏ⧇āĻ–āĻžāύ⧇ āϜāĻŽāĻž āĻĨāĻžāϕ⧇āĨ¤
āϝāĻ–āύ āϕ⧋āύ⧋ Branch Instruction (āϝ⧇āĻŽāύ: BEQ, BNE, JZ) āφāϏ⧇, āϤāĻ–āύ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āϏ⧋āϜāĻž āϞāĻžāχāύ⧇ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āύāĻž āĻ—āĻŋā§Ÿā§‡, āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āĻļāĻ°ā§āϤ āĻŦāĻž āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύ⧇āϰ (Condition) āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻŽā§‡āĻŽāϰāĻŋāϰ āĻ…āĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇ āϞāĻžāĻĢ āĻĻā§‡ā§Ÿ (Jump āĻ•āϰ⧇)āĨ¤


⧍. āĻŽā§āϝāĻžāϜāĻŋāĻ• āĻŸā§āϰāĻŋāĻ•: "C-A-R-S"

āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻšāϞ⧇ āĻĻā§āϰ⧁āϤ āĻŽāύ⧇ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻļ⧁āϧ⧁ CARS āĻļāĻŦā§āĻĻāϟāĻŋ āĻŽā§āĻ–āĻ¸ā§āĻĨ āϰāĻžāĻ–ā§‹āĨ¤ āĻŦā§āϰāĻžāĻžā§āϚ āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύ āĻšāϞ⧋ āϏ⧋āϜāĻž āύāĻž āĻ—āĻŋā§Ÿā§‡ āϤ⧋āĻŽāĻžāϰ CAR āĻŦāĻž āĻ—āĻžā§œāĻŋāϟāĻŋāϕ⧇ āύāϤ⧁āύ āĻāĻ•āϟāĻŋ āϰāĻžāĻ¸ā§āϤāĻžā§Ÿ āϘ⧁āϰāĻŋā§Ÿā§‡ āύ⧇āĻ“ā§ŸāĻž!

  • C – Condition Codes (āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻĢā§āĻ˛ā§āϝāĻžāĻ—): āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āĻĒā§āϰāĻĨāĻŽā§‡ ALU āĻĨ⧇āϕ⧇ āφāϏāĻž āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻĢā§āĻ˛ā§āϝāĻžāĻ— āϝ⧇āĻŽāĻ¨â€” Zero (Z), Sign (S), āĻŦāĻž Carry (C) āĻšā§‡āĻ• āĻ•āϰ⧇ āĻĻ⧇āϖ⧇ āĻļāĻ°ā§āϤ āĻŽāĻŋāϞ⧇āϛ⧇ āĻ•āĻŋ āύāĻžāĨ¤
  • A – Address Selection (MUX): āĻāĻ•āϟāĻŋ āĻŽāĻžāĻ˛ā§āϟāĻŋāĻĒā§āϞ⧇āĻ•ā§āϏāĻžāϰ (MUX) āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ āĻ¨ā§‡ā§Ÿ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āϕ⧋āĻĨāĻž āĻĨ⧇āϕ⧇ āφāϏāĻŦ⧇ (āĻ¸ā§āĻŦāĻžāĻ­āĻžāĻŦāĻŋāĻ• āϞāĻžāχāύ āύāĻžāĻ•āĻŋ āĻŦā§āϰāĻžāĻžā§āĻšā§‡āϰ āϞāĻžāχāύ)āĨ¤
  • R – ROM (Control Memory): āύāĻŋāĻ°ā§āĻŦāĻžāϚāĻŋāϤ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āϏāϰāĻžāϏāϰāĻŋ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻŽā§‡āĻŽāϰāĻŋ (ROM)-āĻāϰ āϭ⧇āϤāϰ⧇āϰ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύāϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻ•āϰ⧇āĨ¤
  • S – Sequencer (CAR āφāĻĒāĻĄā§‡āϟ): āĻŽāĻžāχāĻ•ā§āϰ⧋-āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āϏāĻŋāĻ•ā§ā§Ÿā§‡āĻ¨ā§āϏāĻžāϰ Control Address Register (CAR)-āĻ āύāϤ⧁āύ āĻŦā§āϰāĻžāĻžā§āϚ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āϞ⧋āĻĄ āĻ•āϰ⧇ āĻĻā§‡ā§Ÿ, āϏāĻžāϧāĻžāϰāĻŖ āύāĻŋ⧟āĻŽā§‡ ā§§ āϝ⧋āĻ— (CAR + 1) āĻ•āϰāĻžāϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤ⧇āĨ¤

ā§Š. Step-by-Step Working Mechanism (āĻ•āĻžāĻ°ā§āϝāĻĒā§āϰāĻŖāĻžāϞ⧀)

  1. Condition Evaluation (āĻļāĻ°ā§āϤ āĻĒāϰ⧀āĻ•ā§āώāĻž): āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ ALU āĻĨ⧇āϕ⧇ āφāϏāĻž āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻŦāĻŋāϟ āĻŦāĻž āĻĢā§āĻ˛ā§āϝāĻžāĻ— (āϝ⧇āĻŽāύ: Zero Flag) āĻĒāϰ⧀āĻ•ā§āώāĻž āĻ•āϰ⧇ āĻĻ⧇āϖ⧇ āĻļāĻ°ā§āϤāϟāĻŋ True āύāĻžāĻ•āĻŋ FalseāĨ¤
  2. Multiplexer Decision (āĻŽāĻžāĻ˛ā§āϟāĻŋāĻĒā§āϞ⧇āĻ•ā§āϏāĻžāϰ⧇āϰ āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ): āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύ āĻĢā§āĻ˛ā§āϝāĻžāϗ⧇āϰ āĻŽāĻžāύ⧇āϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ Address Selection MUX āύāĻŋāĻšā§‡āϰ āĻĻ⧁āϟāĻŋ āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ⧇āϰ āĻāĻ•āϟāĻŋ āĻ¨ā§‡ā§Ÿ:

  3. āĻļāĻ°ā§āϤ False āĻšāϞ⧇ (Z = 0): MUX āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ¸ā§āĻŦāĻžāĻ­āĻžāĻŦāĻŋāĻ• āĻ•ā§āϰāĻŽāĻžāύ⧁āϏāĻžāϰāĻŋāĻ• āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻœā§‡āύāĻžāϰ⧇āϟāϰāϕ⧇ āĻŦ⧇āϛ⧇ āĻ¨ā§‡ā§ŸāĨ¤ āĻĢāϞ⧇ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻšā§Ÿ CAR + 1āĨ¤

  4. āĻļāĻ°ā§āϤ True āĻšāϞ⧇ (Z = 1): MUX āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύ⧇ āĻĨāĻžāĻ•āĻž Branch Target Address-āϟāĻŋāϕ⧇ āĻŦ⧇āϛ⧇ āĻ¨ā§‡ā§ŸāĨ¤
  5. Updating CAR (CAR āφāĻĒāĻĄā§‡āϟ): MUX āĻĨ⧇āϕ⧇ āĻŦāĻžāĻ›āĻžāχāĻ•ā§ƒāϤ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āϏāϰāĻžāϏāϰāĻŋ Control Address Register (CAR)-āĻ āĻĒ⧁āĻļ āĻŦāĻž āϞ⧋āĻĄ āĻ•āϰāĻž āĻšā§ŸāĨ¤
  6. Micro-instruction Fetch (āĻĢā§āϝāĻžāϚ): āϏāĻŦāĻļ⧇āώ⧇, Control Memory (ROM) āĻĨ⧇āϕ⧇ āĻ“āχ āύāϤ⧁āύ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇āϰ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āϰāĻŋāĻĄ āĻ•āϰ⧇ āĻŦā§āϰāĻžāĻžā§āϚ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰāĻž āĻšā§ŸāĨ¤

ā§Ē. Key Hardware Components (āĻŽā§‚āϞ āĻ…āĻ‚āĻļāϏāĻŽā§‚āĻš)

āĻ–āĻžāϤāĻžā§Ÿ āϏāϞāĻŋāĻĄ āĻŽāĻžāĻ°ā§āĻ•āϏ āύāĻŋāĻļā§āϚāĻŋāϤ āĻ•āϰāϤ⧇ āĻāχ ā§ĒāϟāĻŋ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āωāĻĒāĻžāĻĻāĻžāύ⧇āϰ āύāĻžāĻŽ āĻ…āĻŦāĻļā§āϝāχ āωāĻ˛ā§āϞ⧇āĻ– āĻ•āϰāĻŦ⧇:

  • Control Address Register (CAR): āĻāϟāĻŋ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāĻŸā§‡āϰ āύāĻŋāϜāĻ¸ā§āĻŦ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āĻ•āĻžāωāĻ¨ā§āϟāĻžāϰ (PC), āϝāĻž āĻŦāĻ°ā§āϤāĻŽāĻžāύ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāĻ¨ā§āϏāĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āϧāϰ⧇ āϰāĻžāϖ⧇āĨ¤
  • Control Memory (ROM): āϝ⧇āĻ–āĻžāύ⧇ āϏāĻŽāĻ¸ā§āϤ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻŽāĻžāχāĻ•ā§āϰ⧋-āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āĻ¸ā§āĻĨāĻžā§Ÿā§€āĻ­āĻžāĻŦ⧇ āϏāĻ‚āϰāĻ•ā§āώāĻŋāϤ āĻĨāĻžāϕ⧇āĨ¤
  • Status Flags / Condition Codes: ALU āĻĨ⧇āϕ⧇ āφāϏāĻž ā§§-āĻŦāĻŋāĻŸā§‡āϰ āĻĢā§āϞāĻŋāĻĒ-āĻĢā§āϞāĻĒ (Zero, Sign, Carry), āϝāĻž āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞ āĻšā§‡āĻ•āĻŋāĻ‚ā§Ÿā§‡āϰ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āĻĻā§‡ā§ŸāĨ¤
  • Micro-program Sequencer: āϞāϜāĻŋāĻ• āϏāĻžāĻ°ā§āĻ•āĻŋāϟ āĻāĻŦāĻ‚ MUX-āĻāϰ āϏāĻŽāĻ¨ā§āĻŦā§Ÿā§‡ āĻ—āĻ āĻŋāϤ āĻ…āĻ‚āĻļ, āϝāĻž CAR-āĻāϰ āϜāĻ¨ā§āϝ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤

ā§Ģ. Architectural Flow Chart (āϏāĻšāϜ āĻŦā§āϞāĻ• āĻĄāĻžāϝāĻŧāĻžāĻ—ā§āϰāĻžāĻŽ)

(āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻ–āĻžāϤāĻžā§Ÿ āĻĒ⧇āύāϏāĻŋāϞ āĻĻāĻŋā§Ÿā§‡ āĻāϟāĻĒāϟ āĻāχ āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽāϟāĻŋ āĻāρāϕ⧇ āĻĻ⧇āĻŦ⧇, āĻĢ⧁āϞ āĻŽāĻžāĻ°ā§āĻ•āϏ āύāĻŋāĻļā§āϚāĻŋāϤ āĻšāĻŦ⧇)

[ Status Flags (Z, S, C) ]
│
â–ŧ
┌───────────────────────┐ If False (0) ┌───────────────┐
│ Address Selector MUX ├──────────────────────â–ē│ CAR + 1 │
└───────────â”Ŧ───────────┘ └───────â”Ŧ───────┘
│ │
│ If True (1) │
â–ŧ â–ŧ
┌───────────────────────┐ ┌───────────────┐
│ Branch Target Address ├──────────────────────â–ē│ Loads into │
└───────────────────────┘ │ CAR Reg │
└───────â”Ŧ───────┘
│
â–ŧ
┌───────────────┐
│Control Memory │
│ (ROM) │
└───────────────┘

14. What is the purpose of a control unit?

What is the purpose of a control unit?

āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ (Control Unit - CU) āĻāϰ āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻ“ āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ

ā§§. āĻ­ā§‚āĻŽāĻŋāĻ•āĻž āĻāĻŦāĻ‚ āĻŽā§‚āϞ āωāĻĻā§āĻĻ⧇āĻļā§āϝ (Introduction & Core Purpose)

āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ (CU) āĻšāϞ⧋ āϏ⧇āĻ¨ā§āĻŸā§āϰāĻžāϞ āĻĒā§āϰāϏ⧇āϏāĻŋāĻ‚ āχāωāύāĻŋāϟ (CPU) āĻāϰ āĻŽā§‚āϞ āϚāĻžāϞāĻŋāĻ•āĻžāĻļāĻ•ā§āϤāĻŋ āĻŦāĻž "āĻ¸ā§āύāĻžā§Ÿā§āϤāĻ¨ā§āĻ¤ā§āϰ"āĨ¤ āĻāϰ āĻĒā§āϰāϧāĻžāύ āĻ•āĻžāϜ āĻšāϞ⧋ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϏāĻŽāĻ¸ā§āϤ āĻšāĻžāĻ°ā§āĻĄāĻ“āϝāĻŧā§āϝāĻžāϰ⧇āϰ āĻ•āĻžāĻ°ā§āϝāĻ•ā§āϰāĻŽ āĻĒāϰāĻŋāϚāĻžāϞāύāĻž āĻ“ āϏāĻŽāĻ¨ā§āĻŦ⧟ āĻ•āϰāĻžāĨ¤ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āύāĻŋāĻœā§‡ āϕ⧋āύ⧋ āĻĄā§‡āϟāĻž āĻĒā§āϰāϏ⧇āϏāĻŋāĻ‚ āĻŦāĻž āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāϜ āĻ•āϰ⧇ āύāĻž (āϝāĻž āĻŽā§‚āϞāϤ ALU āĻ•āϰ⧇ āĻĨāĻžāϕ⧇)āĨ¤ āĻāϰ āφāϏāϞ āωāĻĻā§āĻĻ⧇āĻļā§āϝ āĻšāϞ⧋ āĻĄā§‡āϟāĻžāϰ āĻĒā§āϰāĻŦāĻžāĻš āύāĻŋ⧟āĻ¨ā§āĻ¤ā§āϰāĻŖ āĻ•āϰāĻž, āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āωāĻĒāĻžāĻĻāĻžāύ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āϏāĻŽāĻ¨ā§āĻŦ⧟ āϏāĻžāϧāύ āĻ•āϰāĻž āĻāĻŦāĻ‚ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽā§‡āϰ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻžāĻŦāϞ⧀ (Instructions) āϕ⧋āύāϟāĻŋāϰ āĻĒāϰ āϕ⧋āύāϟāĻŋ āϏāĻŽā§āĻĒāĻžāĻĻāĻŋāϤ āĻšāĻŦ⧇ āϤāĻž āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰāĻžāĨ¤
āϏāĻšāϜ āĻ•āĻĨāĻžā§Ÿ, āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻŽā§āϝāĻžāύ⧇āϜāĻžāϰ⧇āϰ āĻŽāϤ⧋ āĻ•āĻžāϜ āĻ•āϰ⧇ āϝāĻž āχāĻ¨ā§āϟāĻžāϰāύāĻžāϞ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ, ALU, āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻāĻŦāĻ‚ āχāύāĻĒ⧁āϟ/āφāωāϟāĻĒ⧁āϟ (I/O) āĻĄāĻŋāĻ­āĻžāχāϏāϗ⧁āϞ⧋āϤ⧇ āϏāĻ āĻŋāĻ• āϏāĻŽā§Ÿā§‡ āϏāĻ āĻŋāĻ• āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ (āύāĻŋāϝāĻŧāĻ¨ā§āĻ¤ā§āϰāĻŖ āϏāĻ‚āϕ⧇āϤ) āĻĒāĻžāĻ āĻžā§ŸāĨ¤

⧍. āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāĻŸā§‡āϰ āĻĒā§āϰāϧāĻžāύ āχāύāĻĒ⧁āϟāϏāĻŽā§‚āĻš (Key Inputs to the CU)

āϏāĻ āĻŋāĻ• āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āϤ⧈āϰāĻŋ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ CU āĻŽā§‚āϞāϤ ā§ĒāϟāĻŋ āχāύāĻĒ⧁āĻŸā§‡āϰ āĻ“āĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰ āĻ•āϰ⧇:

  • āĻ•ā§āϞāĻ• āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ (Clock Signal): āĻāϟāĻŋ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ āĻāĻŦāĻ‚ āϏāĻŽā§Ÿ āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤ CU āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽ āĻ•ā§āϞāϕ⧇āϰ āϏāĻžāĻĨ⧇ āϤāĻžāϞ āĻŽāĻŋāϞāĻŋā§Ÿā§‡ āύāĻŋāϖ⧁āρāϤ āϏāĻŽā§Ÿā§‡ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āĻĒāĻžāĻ āĻžā§ŸāĨ¤
  • āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ (IR): āĻŦāĻ°ā§āϤāĻŽāĻžāύ⧇ āϝ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻžāϟāĻŋ āϰāĻžāύ āĻ•āϰāϛ⧇, āϤāĻžāϰ āĻ“āĻĒāϕ⧋āĻĄ (Opcode) āĻāĻ–āĻžāύ⧇ āĻĨāĻžāϕ⧇āĨ¤ CU āĻāχ āϕ⧋āĻĄāϟāĻŋ āĻĒā§œā§‡āχ āĻŦā§‹āĻā§‡ āϤāĻžāϕ⧇ āϕ⧀ āĻ•āĻžāϜ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤
  • āĻĢā§āĻ˛ā§āϝāĻžāĻ—āϏ/āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ (Flags/Status Register): āĻĒā§‚āĻ°ā§āĻŦāĻŦāĻ°ā§āϤ⧀ āĻ—āĻžāĻŖāĻŋāϤāĻŋāĻ• āĻ•āĻžāĻœā§‡āϰ āĻĢāϞāĻžāĻĢāϞ āϕ⧇āĻŽāύ āĻ›āĻŋāϞ (āϝ⧇āĻŽāύ: āĻĢāϞāĻžāĻĢāϞ āĻļā§‚āĻ¨ā§āϝ (Zero) āĻ•āĻŋāύāĻž, āϕ⧋āύ⧋ āĻ•ā§āϝāĻžāϰāĻŋ (Carry) āφāϛ⧇ āĻ•āĻŋāύāĻž, āϏāĻžāχāύ (+) āĻŦāĻž (-) āĻ•āĻŋāύāĻž) āϤāĻž āĻāĻ–āĻžāύ⧇ āĻĨāĻžāϕ⧇āĨ¤ āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύāĻžāϞ āĻŦā§āϰāĻžāĻžā§āϚāĻŋāĻ‚ (āĻļāĻ°ā§āϤāĻžāϧ⧀āύ āĻ•āĻžāϜ) āĻ•āϰāĻžāϰ āϏāĻŽā§Ÿ CU āĻāχ āĻĢā§āĻ˛ā§āϝāĻžāĻ—āϗ⧁āϞ⧋ āĻĻ⧇āϖ⧇ āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ āĻ¨ā§‡ā§ŸāĨ¤
  • āĻŦāĻžāϏ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ (Control Signals from Bus): āĻŦāĻžāĻšā§āϝāĻŋāĻ• āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽ āĻŦāĻžāϏ āĻĨ⧇āϕ⧇ āφāϏāĻž āĻŦāĻŋāĻ­āĻŋāĻ¨ā§āύ āχāĻ¨ā§āϟāĻžāϰāĻžāĻĒā§āϟ āĻŦāĻž āϜāϰ⧁āϰāĻŋ āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¸ā§āϟ CU āĻ—ā§āϰāĻšāĻŖ āĻ•āϰ⧇āĨ¤

āχāύāĻĒ⧁āϟāϏāĻŽā§‚āĻš: āφāωāϟāĻĒ⧁āϟāϏāĻŽā§‚āĻš:
[ āĻ•ā§āϞāĻ• āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ ] --------> +--------+ -------> [ ALU-āϤ⧇ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ ]
[ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ ] --------> | | -------> [ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ ]
[ āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ āĻĢā§āĻ˛ā§āϝāĻžāĻ—āϏ ] --------> | CU | -------> [ āĻŽā§‡āĻŽā§‹āϰāĻŋ āϰāĻŋāĻĄ/āϰāĻžāχāϟ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ ]
[ āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽ āĻŦāĻžāϏ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ ] --------> +--------+ -------> [ I/O āĻĄāĻŋāĻ­āĻžāχāϏ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ ]

alt text

ā§Š. āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϏāĻžāχāϕ⧇āϞ āĻŦāĻž āĻŽā§‡āĻļāĻŋāύ āϏāĻžāχāϕ⧇āϞ (The Machine Cycle)

āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāĻŸā§‡āϰ āĻŽā§‚āϞ āωāĻĻā§āĻĻ⧇āĻļā§āϝāϟāĻŋ āĻŽā§‚āϞāϤ ā§ĒāϟāĻŋ āϧāĻžāĻĒ⧇ āϚāĻ•ā§āϰāĻžāĻ•āĻžāϰ⧇ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšā§Ÿ:
ā§§. āĻĢ⧇āϚ (Fetch): āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āĻĒā§āϰāĻĨāĻŽā§‡ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āĻ•āĻžāωāĻ¨ā§āϟāĻžāϰ (PC) āĻĨ⧇āϕ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āĻĒā§œā§‡āĨ¤ āĻāϰāĻĒāϰ āϏ⧇āχ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏāϟāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻŦāĻžāϏ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ RAM āĻĨ⧇āϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϟāĻŋ (Instruction) āĻĄā§‡āϟāĻž āĻŦāĻžāϏ⧇āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āύāĻŋā§Ÿā§‡ āφāϏ⧇ āĻāĻŦāĻ‚ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ (IR) āϜāĻŽāĻž āĻ•āϰ⧇āĨ¤ āĻāϰāĻĒāϰ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ•āĻžāĻœā§‡āϰ āϜāĻ¨ā§āϝ PC-āĻāϰ āĻŽāĻžāύ ā§§ āĻŦāĻžā§œāĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤
⧍. āĻĄāĻŋāϕ⧋āĻĄ (Decode): IR-āĻ āϜāĻŽāĻž āĻšāĻ“ā§ŸāĻž āĻŦāĻžāχāύāĻžāϰāĻŋ āϕ⧋āĻĄāϟāĻŋāϕ⧇ CU-āĻāϰ āϭ⧇āϤāϰ⧇āϰ āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ āϏāĻžāĻ°ā§āĻ•āĻŋāϟ āϭ⧇āϙ⧇ āĻŦāĻŋāĻļā§āϞ⧇āώāĻŖ āĻ•āϰ⧇āĨ¤ āĻāϟāĻŋ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻžāϟāĻŋāϰ āĻŽā§‚āϞ āĻ•āĻžāϜ (Opcode) āĻāĻŦāĻ‚ āĻĄā§‡āϟāĻžāϰ āĻ‰ā§ŽāϏ (Operands) āφāϞāĻžāĻĻāĻž āĻ•āϰ⧇ āϚāĻŋāĻšā§āύāĻŋāϤ āĻ•āϰ⧇ (āϝ⧇āĻŽāύ: ADD, SUB āĻŦāĻž JUMP)āĨ¤
ā§Š. āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāϟ (Execute): āĻāχ āϧāĻžāĻĒ⧇ CU āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āĻĒāĻĨāϗ⧁āϞ⧋ āϏāϚāϞ āĻ•āϰ⧇āĨ¤ āϝ⧇āĻŽāĻ¨â€”ALU-āϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻĻā§‡ā§Ÿ āϝ⧋āĻ— āĻŦāĻž āĻŦāĻŋāϝāĻŧā§‹āĻ— āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻāĻŦāĻ‚ āϏāĻ‚āĻļā§āϞāĻŋāĻˇā§āϟ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰāϗ⧁āϞ⧋āϰ āϗ⧇āϟ āϖ⧁āϞ⧇ āĻĻā§‡ā§Ÿ āϝāĻžāϤ⧇ āĻĄā§‡āϟāĻž āφāĻĻāĻžāύ-āĻĒā§āϰāĻĻāĻžāύ āĻšāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤
ā§Ē. āĻ¸ā§āĻŸā§‹āϰ/āϰāĻžāχāϟ-āĻŦā§āϝāĻžāĻ• (Store): āĻ•āĻžāϜ āĻļ⧇āώ āĻšāĻ“ā§ŸāĻžāϰ āĻĒāϰ āĻĢāϞāĻžāĻĢāϞāϟāĻŋ āĻĒ⧁āύāϰāĻžā§Ÿ āϕ⧋āύ⧋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻŦāĻž āĻāĻ•ā§āϏāϟāĻžāĻ°ā§āύāĻžāϞ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ (RAM) āϏāĻ‚āϰāĻ•ā§āώāĻŖ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ CU āĻĒā§āĻ°ā§Ÿā§‹āϜāĻ¨ā§€ā§Ÿ āϰāĻžāχāϟ (Write) āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āĻĒāĻžāĻ āĻžā§ŸāĨ¤


ā§Ē. āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰāĻžāϞ āĻĄāĻŋāϜāĻžāχāύ: āĻšāĻžāĻ°ā§āĻĄāĻ“āϝāĻŧā§āϝāĻžāĻ°ā§āĻĄ āĻŦāύāĻžāĻŽ āĻŽāĻžāχāĻ•ā§āϰ⧋āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽāĻĄ (Hardwired vs Microprogrammed)

āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āϕ⧀āĻ­āĻžāĻŦ⧇ āĻļāĻžāϰ⧀āϰāĻŋāĻ•āĻ­āĻžāĻŦ⧇ āϤ⧈āϰāĻŋ āĻ•āϰāĻž āĻšā§Ÿā§‡āϛ⧇, āϤāĻžāϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ āĻāϕ⧇ āĻĻ⧁āϟāĻŋ āĻ­āĻžāϗ⧇ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§ŸāĨ¤ āĻĒāϰ⧀āĻ•ā§āώāĻžā§Ÿ āĻ­āĻžāϞ⧋ āĻŽāĻžāĻ°ā§āĻ•āϏ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ āĻāχ āϤ⧁āϞāύāĻžāϟāĻŋ āĻĻ⧇āĻ“ā§ŸāĻž āĻ…āĻ¤ā§āϝāĻ¨ā§āϤ āϜāϰ⧁āϰāĻŋ:

āĻŦ⧈āĻļāĻŋāĻˇā§āĻŸā§āϝ āĻšāĻžāĻ°ā§āĻĄāĻ“āϝāĻŧā§āϝāĻžāĻ°ā§āĻĄ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ (Hardwired CU) āĻŽāĻžāχāĻ•ā§āϰ⧋āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽāĻĄ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ (Microprogrammed CU)
āĻ—āĻ āύ āĻĒā§āϰāĻŖāĻžāϞ⧀ āĻāϟāĻŋ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āϏāĻžāĻ°ā§āĻ•āĻŋāϟ (āϞāϜāĻŋāĻ• āϗ⧇āϟ, āĻĢā§āϞāĻŋāĻĒ-āĻĢā§āϞāĻĒ, āĻĄāĻŋāϕ⧋āĻĄāĻžāϰ) āĻĻāĻŋā§Ÿā§‡ āĻ¸ā§āĻĨāĻžā§Ÿā§€āĻ­āĻžāĻŦ⧇ āϤ⧈āϰāĻŋāĨ¤ āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āĻŽāĻŋāύāĻŋ-āϏāĻĢāϟāĻ“ā§Ÿā§āϝāĻžāϰ āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽā§‡āϰ āĻŽāϤ⧋āĨ¤ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞāϗ⧁āϞ⧋ āĻŦāĻžāχāύāĻžāϰāĻŋ āĻĒā§āϝāĻžāϟāĻžāĻ°ā§āύ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ (ROM) āϕ⧋āĻĄ āφāĻ•āĻžāϰ⧇ āϜāĻŽāĻž āĻĨāĻžāϕ⧇āĨ¤
āĻ•āĻžāĻœā§‡āϰ āĻĒā§āϰāĻ•ā§āϰāĻŋ⧟āĻž āĻ¸ā§āĻŸā§‡āϟ āĻŽā§‡āĻļāĻŋāύ⧇āϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ⧇āϰ āĻ“āĻĒāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋ āĻ•āϰ⧇ āϏāϰāĻžāϏāϰāĻŋ āĻ“ āϤāĻžā§ŽāĻ•ā§āώāĻŖāĻŋāĻ•āĻ­āĻžāĻŦ⧇ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āϤ⧈āϰāĻŋ āĻ•āϰ⧇āĨ¤ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āĻāϕ⧇āϰ āĻĒāϰ āĻāĻ• āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻĢ⧇āϚ āĻāĻŦāĻ‚ āĻĄāĻŋāϕ⧋āĻĄ āĻ•āϰ⧇ āĻ•āĻžāϜ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰ⧇āĨ¤
āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ āĻ…āĻ¤ā§āϝāĻ¨ā§āϤ āĻĻā§āϰ⧁āϤāĻ—āĻžāĻŽā§€ (āĻ•āĻžāϰāĻŖ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āϏāϰāĻžāϏāϰāĻŋ āχāϞ⧇āĻ•āĻŸā§āϰāύāĻŋāĻ• āϏāĻžāĻ°ā§āĻ•āĻŋāĻŸā§‡āϰ āϭ⧇āϤāϰ āĻĻāĻŋā§Ÿā§‡ āϝāĻžā§Ÿ)āĨ¤ āϤ⧁āϞāύāĻžāĻŽā§‚āϞāĻ• āϧ⧀āϰāĻ—āϤāĻŋāϏāĻŽā§āĻĒāĻ¨ā§āύ (āĻ•āĻžāϰāĻŖ āĻĒā§āϰāϤāĻŋāĻŦāĻžāϰ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āĻŽāĻžāχāĻ•ā§āϰ⧋-āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻĒ⧜āϤ⧇ āϏāĻŽā§Ÿ āϞāĻžāϗ⧇)āĨ¤
āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύāĻļā§€āϞāϤāĻž āĻ…āύāĻŽāĻ¨ā§€ā§Ÿ (Rigid)āĨ¤ āĻāĻ•āĻŦāĻžāϰ āϤ⧈āϰāĻŋ āĻšā§Ÿā§‡ āϗ⧇āϞ⧇ āĻāϰ āĻĄāĻŋāϜāĻžāχāύ āĻŦāĻž āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻž āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻĒ⧁āϰ⧋ āϚāĻŋāĻĒ āύāϤ⧁āύ āĻ•āϰ⧇ āĻĄāĻŋāϜāĻžāχāύ āĻ•āϰāϤ⧇ āĻšā§ŸāĨ¤ āύāĻŽāĻ¨ā§€ā§Ÿ (Flexible)āĨ¤ ROM-āĻ āĻĨāĻžāĻ•āĻž āĻŽāĻžāχāĻ•ā§āϰ⧋āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āφāĻĒāĻĄā§‡āϟ āĻ•āϰ⧇ āϏāĻšāĻœā§‡āχ āύāϤ⧁āύ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻž āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻž āϝāĻžā§ŸāĨ¤
āϜāϟāĻŋāϞāϤāĻž āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻžāϰ āϏāĻ‚āĻ–ā§āϝāĻž āĻŦāĻžā§œāϞ⧇ āĻāχ āϏāĻžāĻ°ā§āĻ•āĻŋāĻŸā§‡āϰ āϜāϟāĻŋāϞāϤāĻž āĻœā§āϝāĻžāĻŽāĻŋāϤāĻŋāĻ• āĻšāĻžāϰ⧇ āĻŦā§‡ā§œā§‡ āϝāĻžā§ŸāĨ¤ āĻ…āĻ¤ā§āϝāĻ¨ā§āϤ āϏ⧁āĻļ⧃āĻ™ā§āĻ–āϞ āĻāĻŦāĻ‚ āĻŦ⧜ āĻ“ āϜāϟāĻŋāϞ āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇āϰ āϜāĻ¨ā§āϝ āĻĄāĻŋāϜāĻžāχāύ āĻ•āϰāĻž āϏāĻšāϜāĨ¤
āĻŦā§āϝāĻŦāĻšāĻžāϰ āϏāĻžāϧāĻžāϰāĻŖāϤ RISC (Reduced Instruction Set Computer) āĻĒā§āϰāϏ⧇āϏāϰ⧇ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ, āϝ⧇āĻ–āĻžāύ⧇ āĻ—āϤāĻŋ āϏāĻŦāĻšā§‡ā§Ÿā§‡ āϗ⧁āϰ⧁āĻ¤ā§āĻŦāĻĒā§‚āĻ°ā§āĻŖāĨ¤ āϏāĻžāϧāĻžāϰāĻŖāϤ CISC (Complex Instruction Set Computer) āĻĒā§āϰāϏ⧇āϏāϰ⧇ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ, āϝ⧇āĻ–āĻžāύ⧇ āĻ…āύ⧇āĻ• āϜāϟāĻŋāϞ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻž āĻĨāĻžāϕ⧇āĨ¤

ā§Ģ. āφāϧ⧁āύāĻŋāĻ• āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇ āωāĻ¨ā§āύāϤ āĻĻāĻžā§ŸāĻŋāĻ¤ā§āĻŦāϏāĻŽā§‚āĻš (Advanced Responsibilities)

āĻŦāĻ°ā§āϤāĻŽāĻžāύ āϏāĻŽā§Ÿā§‡āϰ āφāϧ⧁āύāĻŋāĻ• āĻāĻŦāĻ‚ āĻļāĻ•ā§āϤāĻŋāĻļāĻžāϞ⧀ āĻĒā§āϰāϏ⧇āϏāϰāϗ⧁āϞ⧋āϤ⧇ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāĻŸā§‡āϰ āĻ•āĻžāĻœā§‡āϰ āĻĒāϰāĻŋāϧāĻŋ āφāϰāĻ“ āĻŦā§‡ā§œā§‡āϛ⧇:

  • āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ āϏāĻŽāĻ¨ā§āĻŦ⧟ (Pipelining Coordination): āφāϧ⧁āύāĻŋāĻ• āĻĒā§āϰāϏ⧇āϏāϰ⧇ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāύāĻž āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāϟ āĻšāĻ“ā§ŸāĻžāϰ āϏāĻŽā§Ÿ āφāϰ⧇āĻ•āϟāĻŋ āĻĄāĻŋāϕ⧋āĻĄ āĻāĻŦāĻ‚ āĻ…āĻ¨ā§āϝ āĻāĻ•āϟāĻŋ āĻĢ⧇āϚ āĻšāϤ⧇ āĻĨāĻžāϕ⧇āĨ¤ āĻāχ āϏāĻŽāĻžāĻ¨ā§āϤāϰāĻžāϞ āĻ•āĻžāĻœā§‡āϰ āĻŽāĻžāĻā§‡ āϝ⧇āύ āϕ⧋āύ⧋ āϏāĻ‚āϘāĻ°ā§āώ āĻŦāĻž āĻĄā§‡āϟāĻž āĻœā§āϝāĻžāĻŽ (Pipeline Hazard) āύāĻž āĻšā§Ÿ, āϤāĻž CU āϤāĻĻāĻžāϰāĻ•āĻŋ āĻ•āϰ⧇āĨ¤
  • āχāĻ¨ā§āϟāĻžāϰāĻžāĻĒā§āϟ āĻāĻŦāĻ‚ āĻāĻ•ā§āϏ⧇āĻĒāĻļāύ āĻšā§āϝāĻžāĻ¨ā§āĻĄāϞāĻŋāĻ‚: āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ āϚāϞāĻžāϰ āϏāĻŽā§Ÿ āϕ⧋āύ⧋ āϜāϰ⧁āϰāĻŋ āĻ¤ā§āϰ⧁āϟāĻŋ āĻŦāĻž āĻŦāĻžāĻšā§āϝāĻŋāĻ• āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ (āϝ⧇āĻŽāύ- āĻŽāĻžāωāϏ āĻ•ā§āϞāĻŋāĻ•) āφāϏāϞ⧇ CU āϚāϞāĻŽāĻžāύ āĻ•āĻžāϜāϟāĻŋ āύāĻŋāϰāĻžāĻĒāĻĻ āϜāĻžā§ŸāĻ—āĻžā§Ÿ āϏ⧇āĻ­ āĻ•āϰ⧇ āχāĻ¨ā§āϟāĻžāϰāĻžāĻĒā§āϟ āϏāĻžāĻ°ā§āĻ­āĻŋāϏ āϰ⧁āϟāĻŋāύ (ISR)-āĻ āϚāϞ⧇ āϝāĻžā§Ÿ āĻāĻŦāĻ‚ āϏ⧇āχ āĻ•āĻžāϜ āĻļ⧇āώ⧇ āφāĻŦāĻžāϰ āφāϗ⧇āϰ āĻ•āĻžāĻœā§‡ āĻĢāĻŋāϰ⧇ āφāϏ⧇āĨ¤
  • āĻĒā§āϝāĻžāϰāĻžāϞāĻžāϞāĻŋāϜāĻŽ āĻŽā§āϝāĻžāύ⧇āϜāĻŽā§‡āĻ¨ā§āϟ: āϏ⧁āĻĒāĻžāϰāĻ¸ā§āϕ⧇āϞāĻžāϰ āĻĒā§āϰāϏ⧇āϏāϰ⧇ āĻāĻ•āϏāĻžāĻĨ⧇ āĻāĻ•āĻžāϧāĻŋāĻ• āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰāĻžāύ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āϕ⧋āύ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϟāĻŋ āĻ•āĻžāϰ āĻ“āĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰāĻļā§€āϞ āϤāĻž āϝāĻžāϚāĻžāχ āĻ•āϰ⧇ CU āĻ¸ā§āĻŦāĻžāϧ⧀āύ āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϗ⧁āϞ⧋āϕ⧇ āφāϞāĻžāĻĻāĻž āφāϞāĻžāĻĻāĻž āĻĒā§āϰāϏ⧇āϏāĻŋāĻ‚ āχāωāύāĻŋāĻŸā§‡ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤

ā§Ŧ. āωāĻĒāϏāĻ‚āĻšāĻžāϰ (Conclusion)

āĻĒāϰāĻŋāĻļ⧇āώ⧇ āĻŦāϞāĻž āϝāĻžā§Ÿ, āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āĻšāϞ⧋ āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇āϰ āϚāĻžāϞāĻŋāĻ•āĻžāĻļāĻ•ā§āϤāĻŋāĨ¤ āĻāϟāĻŋ āĻ›āĻžā§œāĻž āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ⧇āϰ āĻŦāĻžāĻ•āĻŋ āĻ…āĻ‚āĻļāϗ⧁āϞ⧋ āĻĒā§āϰāĻžāĻŖāĻšā§€āύ āϜ⧜ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āĻ›āĻžā§œāĻž āĻ•āĻŋāϛ⧁āχ āύ⧟āĨ¤ āĻŦāĻžāχāύāĻžāϰāĻŋ āϕ⧋āĻĄāϕ⧇ āύāĻŋāϖ⧁āρāϤ āχāϞ⧇āĻ•āĻŸā§āϰāύāĻŋāĻ• āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ⧇ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āχ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āχāωāύāĻŋāϟ āĻāĻ•āϟāĻŋ āύāĻŋāĻˇā§āĻ•ā§āϰāĻŋ⧟ āϏāĻŋāĻ¸ā§āĻŸā§‡āĻŽāϕ⧇ āĻāĻ•āϟāĻŋ āϏāĻ•ā§āϰāĻŋ⧟ āĻ“ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽāϝ⧋āĻ—ā§āϝ āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ⧇ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰ āĻ•āϰ⧇āĨ¤

Mnemonic

Control Unit (CU) āĻšāϞ⧋ CPU-āĻāϰ ManagerāĨ¤ āĻāϟāĻŋ āύāĻŋāĻœā§‡ āĻšāĻŋāϏāĻžāĻŦ āĻ•āϰ⧇ āύāĻž; āĻŦāϰāĻ‚ ALU, Register, Memory āĻ“ I/O Device-āϕ⧇ Control Signal āĻĻāĻŋāϝāĻŧ⧇ āĻ•āĻžāϜ āĻ•āϰāĻžāϝāĻŧāĨ¤

CU āĻĒā§āϰāϧāĻžāύāϤ Clock Signal, Instruction Register (IR), Status Flags āĻāĻŦāĻ‚ Bus Signal āĻĻ⧇āϖ⧇ āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ āύ⧇āϝāĻŧāĨ¤
āĻāϰ āĻ•āĻžāϜ āϚāĻžāϰ āϧāĻžāĻĒ⧇ āĻšāϝāĻŧ:
Fetch → Decode → Execute → Store
āĻ…āĻ°ā§āĻĨāĻžā§Ž Instruction āφāύ⧇, āĻŦ⧁āĻā§‡, āĻ•āĻžāϜ āĻ•āϰāĻžāϝāĻŧ āĻāĻŦāĻ‚ āĻĢāϞāĻžāĻĢāϞ āϏāĻ‚āϰāĻ•ā§āώāĻŖ āĻ•āϰ⧇āĨ¤
CU āĻĻ⧁āχ āϧāϰāύ⧇āϰ:
* Hardwired CU: āĻĻā§āϰ⧁āϤ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž āĻ•āĻ āĻŋāύāĨ¤
* Microprogrammed CU: āϤ⧁āϞāύāĻžāĻŽā§‚āϞāĻ• āϧ⧀āϰ, āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻšāĻœā§‡ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύāϝ⧋āĻ—ā§āϝāĨ¤
āφāϧ⧁āύāĻŋāĻ• āĻĒā§āϰāϏ⧇āϏāϰ⧇ CU Pipelining, Interrupt āĻāĻŦāĻ‚ Parallel Instruction Execution āύāĻŋāϝāĻŧāĻ¨ā§āĻ¤ā§āϰāĻŖ āĻ•āϰ⧇āĨ¤

🧠 āĻŸā§āϰāĻŋāĻ• ā§§: āĻŽā§‚āϞ āĻĨāĻŋāĻŽ = "CU āĻšāϞ⧋ āĻŸā§āϰāĻžāĻĢāĻŋāĻ• āĻĒ⧁āϞāĻŋāĻļ / āĻŽā§āϝāĻžāύ⧇āϜāĻžāϰ"

āĻŽāύ⧇ āϰāĻžāĻ–āĻŦ⧇āύ, CU āύāĻŋāĻœā§‡ āϕ⧋āύ⧋ āĻ•āĻžāϜ (āϝ⧋āĻ—/āĻŦāĻŋāϝāĻŧā§‹āĻ—) āĻ•āϰ⧇ āύāĻžāĨ¤ āĻāϟāĻŋ āĻŸā§āϰāĻžāĻĢāĻŋāĻ• āĻĒ⧁āϞāĻŋāĻļ⧇āϰ āĻŽāϤ⧋ āĻļ⧁āϧ⧁ āĻŦāĻžāρāĻļāĻŋ āĻŦāĻžāϜāĻŋā§Ÿā§‡ (Control Signal) āĻŦāϞ⧇ āĻĻā§‡ā§Ÿâ€” āĻĄā§‡āϟāĻž āϕ⧋āĻĨāĻžā§Ÿ āϝāĻžāĻŦ⧇, āĻŽā§‡āĻŽā§‹āϰāĻŋ āϕ⧀ āĻ•āϰāĻŦ⧇ āφāϰ ALU āĻ•āĻ–āύ āĻ•āĻžāϜ āĻ•āϰāĻŦ⧇āĨ¤

🔑 āĻŸā§āϰāĻŋāĻ• ⧍: ā§ĒāϟāĻŋ āχāύāĻĒ⧁āϟ (āĻŽāύ⧇ āϰāĻžāĻ–āĻžāϰ āϏ⧂āĻ¤ā§āϰ: C-I-F-B āĻŦāĻž āϏāĻŋāĻĢ-āĻŦāĻŋ)

āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻ–āĻžāϤāĻžāϝāĻŧ āχāύāĻĒ⧁āĻŸā§‡āϰ āĻĒā§Ÿā§‡āĻ¨ā§āϟ āĻāϞ⧇ C-I-F-B āĻŽāύ⧇ āĻ•āϰāĻŦ⧇āύ:

  • C = Clock (āĻ•ā§āϞāĻ• āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ - āϟāĻžāχāĻŽāĻŋāĻ‚ āĻŽā§‡āϞāĻžā§Ÿ)
  • I = IR (āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ - āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻĒā§œā§‡)
  • F = Flags (āĻĢā§āĻ˛ā§āϝāĻžāĻ—/āĻ¸ā§āĻŸā§āϝāĻžāϟāĻžāϏ - āφāϗ⧇āϰ āĻ•āĻžāĻœā§‡āϰ āϰ⧇āϜāĻžāĻ˛ā§āϟ āĻĻ⧇āϖ⧇)
  • B = Bus (āĻŦāĻžāϏ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ - āĻŦāĻžāχāϰ⧇āϰ āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¸ā§āϟ āĻļā§‹āύ⧇)

🔄 āĻŸā§āϰāĻŋāĻ• ā§Š: āĻŽā§‡āĻļāĻŋāύ āϏāĻžāχāϕ⧇āϞ⧇āϰ ā§ĒāϟāĻŋ āϧāĻžāĻĒ (āĻŽāύ⧇ āϰāĻžāĻ–āĻžāϰ āϏ⧂āĻ¤ā§āϰ: F-D-E-S)

āĻāχ āϏāĻŋāϰāĻŋ⧟āĻžāϞāϟāĻŋ āĻ­ā§‹āϞāĻž āϝāĻžāĻŦ⧇ āύāĻžāĨ¤ F-D-E-S:
ā§§. Fetch (āύāĻŋā§Ÿā§‡ āφāϏ⧋) → āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āφāύ⧋āĨ¤
⧍. Decode (āĻŦā§‹āĻā§‹) → āύāĻŋāĻ°ā§āĻĻ⧇āĻļāϟāĻž āϭ⧇āϙ⧇ āĻŦā§‹āĻā§‹ āϕ⧀ āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤
ā§Š. Execute (āĻ•āĻžāϜ āĻ•āϰ⧋) → ALU-āϕ⧇ āĻĻāĻŋā§Ÿā§‡ āĻ•āĻžāϜāϟāĻž āĻ•āϰāĻžāĻ“āĨ¤
ā§Ē. Store (āϰ⧇āϖ⧇ āĻĻāĻžāĻ“) → āĻĢāϞāĻžāĻĢāϞ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻŦāĻž āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āϏ⧇āĻ­ āĻ•āϰ⧋āĨ¤

⚡ āĻŸā§āϰāĻŋāĻ• ā§Ē: Hardwired vs Microprogrammed (āϞāϜāĻŋāĻ•: "āωāϏāĻžāχāύ āĻŦā§‹āĻ˛ā§āϟ āĻŦāύāĻžāĻŽ āĻ¸ā§āĻŽāĻžāĻ°ā§āϟāĻĢā§‹āύ")

āĻĒāĻžāĻ°ā§āĻĨāĻ•ā§āϝ āφāϏāϞ⧇ āĻāχ āĻĻ⧁āχ āϞāĻžāχāύ⧇ āĻ›āĻ• āĻŦāĻžāύāĻŋā§Ÿā§‡ āĻĢ⧇āϞāĻŦ⧇āύ:

  • Hardwired (āωāϏāĻžāχāύ āĻŦā§‹āĻ˛ā§āϟ): āϞāϜāĻŋāĻ• āϗ⧇āϟ/āϏāĻžāĻ°ā§āĻ•āĻŋāϟ āĻĻāĻŋā§Ÿā§‡ āĻŦāĻžāύāĻžāύ⧋āĨ¤ āϤāĻžāχ āĻ¸ā§āĻĒāĻŋāĻĄ āϖ⧁āĻŦ āĻĢāĻžāĻ¸ā§āϟāĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āĻŦāĻĻāϞāĻžāύ⧋ āϝāĻžā§Ÿ āύāĻž (Rigid/āĻ…āύāĻŽāύ⧀āϝāĻŧ)āĨ¤ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ RISC āĻĒā§āϰāϏ⧇āϏāϰ⧇āĨ¤
  • Microprogrammed (āĻ¸ā§āĻŽāĻžāĻ°ā§āϟāĻĢā§‹āύ): ROM-āĻ āϕ⧋āĻĄ āĻšāĻŋāϏ⧇āĻŦ⧇ āĻĨāĻžāϕ⧇āĨ¤ āĻ¸ā§āĻĒāĻŋāĻĄ āĻāĻ•āϟ⧁ āĻ¸ā§āϞ⧋āĨ¤ āĻ•āĻŋāĻ¨ā§āϤ⧁ āϏāĻšāĻœā§‡āχ āφāĻĒāĻĄā§‡āϟ āĻŦāĻž āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāĻž āϝāĻžā§Ÿ (Flexible/āύāĻŽāύ⧀āϝāĻŧ)āĨ¤ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšā§Ÿ CISC āĻĒā§āϰāϏ⧇āϏāϰ⧇āĨ¤

🚀 āĻŸā§āϰāĻŋāĻ• ā§Ģ: āφāϧ⧁āύāĻŋāĻ• āĻ•āĻžāϜ (āĻŽāύ⧇ āϰāĻžāĻ–āĻžāϰ āϏ⧂āĻ¤ā§āϰ: P-I-P)

āĻ…ā§āϝāĻžāĻĄāĻ­āĻžāĻ¨ā§āϏāĻĄ āĻ•āĻžāϜāϗ⧁āϞ⧋ āĻŽāύ⧇ āϰāĻžāĻ–āϤ⧇ PIP āĻļāĻŦā§āĻĻāϟāĻŋ āĻŽāύ⧇ āϰāĻžāϖ⧁āύ:

  • P = Pipelining (āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ - āĻāĻ•āĻžāϧāĻŋāĻ• āύāĻŋāĻ°ā§āĻĻ⧇āĻļ āĻāĻ•āϏāĻžāĻĨ⧇ āϚāĻžāϞāĻžāύ⧋)
  • I = Interrupts (āχāĻ¨ā§āϟāĻžāϰāĻžāĻĒā§āϟ - āĻŽāĻžāĻāĻĒāĻĨ⧇ āϜāϰ⧁āϰāĻŋ āĻ•āĻžāϜ āϏāĻžāĻŽāϞāĻžāύ⧋)
  • P = Parallelism (āĻĒā§āϝāĻžāϰāĻžāϞāĻžāϞāĻŋāϜāĻŽ - āϏāĻŽāĻžāĻ¨ā§āϤāϰāĻžāϞ āĻ•āĻžāϜ āĻŽā§āϝāĻžāύ⧇āϜ āĻ•āϰāĻž)

Hardwired and Micro-programmed Control Unit

15. Word, Address and Memory Access Time

Define Word, 🔤 Address, 📍 and Memory Access Time.

ā§§. āĻ“ā§ŸāĻžāĻ°ā§āĻĄ (Word) 🔤

  • āϏāĻ‚āĻœā§āĻžāĻž (Definition): āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ āφāĻ°ā§āĻ•āĻŋāĻŸā§‡āĻ•āϚāĻžāϰ⧇ āĻāĻ•āϟāĻŋ 'āĻ“ā§ŸāĻžāĻ°ā§āĻĄ' āĻšāϞ⧋ āĻĄā§‡āϟāĻžāϰ āĻāĻŽāύ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϏāĻžāχāϜ āĻŦāĻž āĻĻ⧈āĻ°ā§āĻ˜ā§āϝ (Bit length), āϝāĻž āĻāĻ•āϟāĻŋ āĻĒā§āϰāϏ⧇āϏāϰ āĻŦāĻž CPU āĻāĻ•āĻŦāĻžāϰ⧇ (Single operation-āĻ) āĻĒā§āϰāϏ⧇āϏ, āĻŸā§āϰāĻžāĻ¨ā§āϏāĻĢāĻžāϰ āĻŦāĻž āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āϰāĻŋāĻĄ/āϰāĻžāχāϟ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤
  • āϏāĻšāϜ āωāĻĻāĻžāĻšāϰāĻŖ: āĻāĻ•āϟāĻŋ ā§Šā§¨-āĻŦāĻŋāϟ (32-bit) āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϜāĻ¨ā§āϝ ā§§ āĻ“ā§ŸāĻžāĻ°ā§āĻĄ = ā§Šā§¨ āĻŦāĻŋāϟ (āĻŦāĻž ā§Ē āĻŦāĻžāχāϟ)āĨ¤ āĻāĻ•āχāĻ­āĻžāĻŦ⧇ āĻāĻ•āϟāĻŋ ā§Ŧā§Ē-āĻŦāĻŋāϟ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ ā§§ āĻ“ā§ŸāĻžāĻ°ā§āĻĄ = ā§Ŧā§Ē āĻŦāĻŋāϟāĨ¤ āĻāϟāĻŋ āĻŽā§‚āϞāϤ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āϏāĻžāχāϜ āύāĻŋāĻ°ā§āϧāĻžāϰāĻŖ āĻ•āϰ⧇āĨ¤

⧍. āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ (Address) 📍

  • āϏāĻ‚āĻœā§āĻžāĻž (Definition): āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ āĻšāϞ⧋ āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ⧇āϰ āĻĒā§āϰāϧāĻžāύ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻŦāĻž RAM-āĻāϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ¸ā§āĻŸā§‹āϰ⧇āϜ āϞ⧋āϕ⧇āĻļāύ āĻŦāĻž āϘāϰ⧇āϰ āϜāĻ¨ā§āϝ āĻŦāϰāĻžāĻĻā§āĻĻāĻ•ā§ƒāϤ āĻāĻ•āϟāĻŋ āĻ…āύāĻ¨ā§āϝ āĻŦāĻž āχāωāύāĻŋāĻ• āĻŦāĻžāχāύāĻžāϰāĻŋ āύāĻžāĻŽā§āĻŦāĻžāϰ (Unique identifier)āĨ¤
  • āϏāĻšāϜ āωāĻĻāĻžāĻšāϰāĻŖ: āϝ⧇āĻŽāύ āφāĻŽāĻžāĻĻ⧇āϰ āĻĒā§āϰāĻ¤ā§āϝ⧇āϕ⧇āϰ āĻŦāĻžā§œāĻŋāϰ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āĻ āĻŋāĻ•āĻžāύāĻž āĻĨāĻžāϕ⧇ āϝāĻžāϤ⧇ āϚāĻŋāĻ āĻŋāĻĒāĻ¤ā§āϰ āϏāĻ āĻŋāĻ• āϜāĻžā§ŸāĻ—āĻžā§Ÿ āĻĒ⧌āρāĻ›āĻžā§Ÿ, āĻ āĻŋāĻ• āϤ⧇āĻŽāύāĻŋ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻĄā§āϰ⧇āϏ⧇āϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ CPU āĻŦ⧁āĻāϤ⧇ āĻĒāĻžāϰ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋāϰ āĻ āĻŋāĻ• āϕ⧋āύ āϘāϰ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āĻĒ⧜āϤ⧇ (Read) āĻšāĻŦ⧇ āĻŦāĻž āϕ⧋āύ āϘāϰ⧇ āĻĄā§‡āϟāĻž āϏ⧇āĻ­ (Write) āĻ•āϰāϤ⧇ āĻšāĻŦ⧇āĨ¤

ā§Š. āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āϟāĻžāχāĻŽ (Memory Access Time) âąī¸

  • āϏāĻ‚āĻœā§āĻžāĻž (Definition): CPU āϝāĻ–āύ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āϕ⧋āύ⧋ āĻĄā§‡āϟāĻž āĻĒāĻžāĻ“ā§ŸāĻžāϰ āϜāĻ¨ā§āϝ āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¸ā§āϟ āĻĒāĻžāĻ āĻžā§Ÿ, āϏ⧇āχ āϰāĻŋāĻ•ā§‹ā§Ÿā§‡āĻ¸ā§āϟ āĻĒāĻžāĻ āĻžāύ⧋āϰ āĻŽā§āĻšā§‚āĻ°ā§āϤ āĻĨ⧇āϕ⧇ āĻļ⧁āϰ⧁ āĻ•āϰ⧇ āĻĄā§‡āϟāĻžāϟāĻŋ āĻĒ⧁āϰ⧋āĻĒ⧁āϰāĻŋāĻ­āĻžāĻŦ⧇ CPU-āĻāϰ āĻ•āĻžāϛ⧇ āĻāϏ⧇ āĻĒ⧌āρāĻ›āĻžāύ⧋ āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āϝ⧇ āĻŽā§‹āϟ āϏāĻŽā§Ÿ āϞāĻžāϗ⧇, āϤāĻžāϕ⧇ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āϟāĻžāχāĻŽ āĻŦāϞ⧇āĨ¤
  • āϏāĻšāϜ āĻ•āĻĨāĻžā§Ÿ: āĻŽā§‡āĻŽā§‹āϰāĻŋ āϰāĻŋāĻĄ āĻŦāĻž āϰāĻžāχāϟ āĻ•āĻŽāĻžāĻ¨ā§āĻĄ āĻĻ⧇āĻ“ā§ŸāĻžāϰ āĻĒāϰ āĻ•āĻžāϜāϟāĻŋ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāϤ⧇ āϝāϤāϟ⧁āϕ⧁ āϏāĻŽā§Ÿ āĻŦā§āϝ⧟ āĻšā§ŸāĨ¤ āĻāϟāĻŋ āϏāĻžāϧāĻžāϰāĻŖāϤ āĻ¨ā§āϝāĻžāύ⧋āϏ⧇āϕ⧇āĻ¨ā§āĻĄ (Nanoseconds - ns) āĻāĻ•āϕ⧇ āĻĒāϰāĻŋāĻŽāĻžāĻĒ āĻ•āϰāĻž āĻšā§ŸāĨ¤ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻ…ā§āϝāĻžāĻ•ā§āϏ⧇āϏ āϟāĻžāχāĻŽ āϝāϤ āĻ•āĻŽ āĻšāĻŦ⧇, āĻ•āĻŽā§āĻĒāĻŋāωāϟāĻžāϰ⧇āϰ āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ āĻŦāĻž āĻĒāĻžāϰāĻĢāϰāĻŽā§āϝāĻžāĻ¨ā§āϏ āϤāϤ āĻŦ⧇āĻļāĻŋ āĻšāĻŦ⧇āĨ¤

Part C — Pipelining and Hazards

16. How Pipelining Increases Processor Performance

How does the pipeline 🚰 increase the performance 🚀 of a processor? 🧠 Explain.

ā§§. āĻŽā§‚āϞ āϧāĻžāϰāĻŖāĻž (The Core Concept)

āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ āĻŦāĻž āĻĒāĻžāϰāĻĢāϰāĻŽā§āϝāĻžāĻ¨ā§āϏ āĻŦāĻžā§œāĻžā§Ÿ āĻāĻ•āχ āϏāĻŽā§Ÿā§‡ āĻāĻ•āĻžāϧāĻŋāĻ• āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ•āĻžāϜ āϏāĻŽāĻžāĻ¨ā§āϤāϰāĻžāϞāĻ­āĻžāĻŦ⧇ (Overlapping Execution) āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰāĻžāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡āĨ¤
āĻāϟāĻŋ āĻŽā§‚āϞāϤ āĻĢā§āϝāĻžāĻ•ā§āϟāϰāĻŋāϰ āĻ…ā§āϝāĻžāϏ⧇āĻŽā§āĻŦāϞāĻŋ āϞāĻžāχāύ⧇āϰ (Assembly Line) āĻŽāϤ⧋ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤ āĻāĻ•āϟāĻŋ āĻ•āĻžāϰāĻ–āĻžāύāĻžā§Ÿ āϝ⧇āĻŽāύ āĻāĻ•āϟāĻŋ āĻ—āĻžā§œāĻŋ āĻĒ⧁āϰ⧋āĻĒ⧁āϰāĻŋ āϤ⧈āϰāĻŋ āĻšāĻ“ā§ŸāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āĻ—āĻžā§œāĻŋāϰ āĻ•āĻžāϜ āφāϟāϕ⧇ āϰāĻžāĻ–āĻž āĻšā§Ÿ āύāĻž (āĻŦāϰāĻ‚ āĻĒā§āϰāĻĨāĻŽ āĻ—āĻžā§œāĻŋāϟāĻŋ āϰāĻ‚ āĻ•āϰāĻžāϰ āϘāϰ⧇ āϗ⧇āϞ⧇, āĻĻā§āĻŦāĻŋāĻ¤ā§€ā§Ÿ āĻ—āĻžā§œāĻŋāϟāĻŋ āĻŦāĻĄāĻŋ āϤ⧈āϰāĻŋāϰ āϘāϰ⧇ āĻĸ⧁āϕ⧇ āĻĒā§œā§‡), āĻĒā§āϰāϏ⧇āϏāϰ⧇āĻ“ āĻ āĻŋāĻ• āĻāĻ•āχāĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻšā§ŸāĨ¤


⧍. āĻāϟāĻŋ āϕ⧀āĻ­āĻžāĻŦ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇? (How It Works)

āĻāĻ•āϟāĻŋ āϏāĻžāϧāĻžāϰāĻŖ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϏāĻžāχāϕ⧇āϞāϕ⧇ āĻ•ā§Ÿā§‡āĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āϧāĻžāĻĒ⧇ āĻ­āĻžāĻ— āĻ•āϰāĻž āĻšā§Ÿ (āϝ⧇āĻŽāύ ā§ĢāϟāĻŋ āϧāĻžāĻĒ):

  1. Fetch (IF): āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĨ⧇āϕ⧇ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āύāĻŋā§Ÿā§‡ āφāϏāĻžāĨ¤
  2. Decode (ID): āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āĻŦāĻŋāĻļā§āϞ⧇āώāĻŖ āĻ•āϰāĻžāĨ¤
  3. Execute (EX): āĻ•āĻžāϜ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻ•āϰāĻž (ALU-āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡)āĨ¤
  4. Memory Access (MEM): āĻŽā§‡āĻŽā§‹āϰāĻŋ āϰāĻŋāĻĄ āĻŦāĻž āϰāĻžāχāϟ āĻ•āϰāĻžāĨ¤
  5. Write-back (WB): āĻĢāϞāĻžāĻĢāϞ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇ āϏ⧇āĻ­ āĻ•āϰāĻžāĨ¤

  6. āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ āĻ›āĻžā§œāĻž (Non-Pipelined): āĻāĻ•āϟāĻŋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ ā§ĢāϟāĻŋ āϧāĻžāĻĒ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻļ⧇āώ āύāĻž āĻšāĻ“ā§ŸāĻž āĻĒāĻ°ā§āϝāĻ¨ā§āϤ āĻĒā§āϰāϏ⧇āϏāϰ āĻĒāϰāĻŦāĻ°ā§āϤ⧀ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ•āĻžāϜ āĻļ⧁āϰ⧁ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇ āύāĻžāĨ¤ āĻĢāϞ⧇ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻŦ⧇āĻļāĻŋāϰāĻ­āĻžāĻ— āĻ…āĻ‚āĻļ āĻ…āϞāϏ (Idle) āĻŦāϏ⧇ āĻĨāĻžāϕ⧇āĨ¤

  7. āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ āϏāĻš (Pipelined): āϝāĻ–āύ ā§§āĻŽ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ Fetch āϧāĻžāĻĒ āĻĒāĻžāϰ āĻšā§Ÿā§‡ Decode āϧāĻžāĻĒ⧇ āϝāĻžā§Ÿ, āĻ āĻŋāĻ• āϤāĻ–āύāχ ⧍⧟ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ Fetch āϧāĻžāĻĒ⧇ āĻĒā§āϰāĻŦ⧇āĻļ āĻ•āϰ⧇āĨ¤ āĻāĻ­āĻžāĻŦ⧇ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āĻ…āĻ‚āĻļ āϏāĻŦāϏāĻŽā§Ÿ āĻŦā§āϝāĻ¸ā§āϤ āĻĨāĻžāϕ⧇āĨ¤

ā§Š. āĻĒāĻžāϰāĻĢāϰāĻŽā§āϝāĻžāĻ¨ā§āϏ āĻŦ⧃āĻĻā§āϧāĻŋāϰ āĻŽā§‚āϞ āĻ•āĻžāϰāĻŖāϏāĻŽā§‚āĻš (Why Performance Increases)

  • āωāĻšā§āϚ āĻĨā§āϰ⧁āĻĒ⧁āϟ (Higher Throughput): āĻĒā§āϰāϤāĻŋ āĻ•ā§āϞāĻ• āϏāĻžāχāϕ⧇āϞ⧇ āĻĒā§āϰāϏ⧇āϏāϰ āĻĨ⧇āϕ⧇ āĻšā§‚ā§œāĻžāĻ¨ā§āϤāĻ­āĻžāĻŦ⧇ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāĻ“ā§ŸāĻž āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āϏāĻ‚āĻ–ā§āϝāĻž (Throughput) āĻ…āύ⧇āĻ• āĻŦā§‡ā§œā§‡ āϝāĻžā§ŸāĨ¤ āφāĻĻāĻ°ā§āĻļ āĻ…āĻŦāĻ¸ā§āĻĨāĻžā§Ÿ, āĻĒā§āϰāϤāĻŋ āĻ•ā§āϞāĻ• āϏāĻžāχāϕ⧇āϞ⧇ āĻāĻ•āϟāĻŋ āĻ•āϰ⧇ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšā§ŸāĨ¤
  • āĻšāĻžāĻ°ā§āĻĄāĻ“āϝāĻŧā§āϝāĻžāϰ⧇āϰ āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ āĻŦā§āϝāĻŦāĻšāĻžāϰ (Hardware Utilization): āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϕ⧋āύ⧋ āĻ…āĻ‚āĻļ āĻ…āϞāϏ āĻŦāϏ⧇ āĻĨāĻžāϕ⧇ āύāĻžāĨ¤ Fetch Unit, Decoder, āĻāĻŦāĻ‚ ALU āĻāĻ•āχ āϏāĻžāĻĨ⧇ āφāϞāĻžāĻĻāĻž āφāϞāĻžāĻĻāĻž āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻ•āĻžāϜ āĻ•āϰāϤ⧇ āĻĨāĻžāϕ⧇āĨ¤
  • āĻĻā§āϰ⧁āϤ āĻ•ā§āϞāĻ• āĻ¸ā§āĻĒāĻŋāĻĄ (Faster Clock Cycles): āϝ⧇āĻšā§‡āϤ⧁ āĻĒ⧁āϰ⧋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻŦ⧜ āĻ•āĻžāϜāϟāĻŋ āϛ⧋āϟ āϛ⧋āϟ āϏāĻŽāĻžāύ āĻ…āĻ‚āĻļ⧇ (Stages) āĻ­āĻžāĻ— āĻšā§Ÿā§‡ āϝāĻžā§Ÿ, āϤāĻžāχ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϧāĻžāĻĒ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāϤ⧇ āϖ⧁āĻŦ āĻ•āĻŽ āϏāĻŽā§Ÿ āϞāĻžāϗ⧇āĨ¤ āĻāϰ āĻĢāϞ⧇ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻ•ā§āϞāĻ• āĻĢā§āϰāĻŋāϕ⧋āϝāĻŧ⧇āĻ¨ā§āϏāĻŋ āĻŦāĻž āĻ¸ā§āĻĒāĻŋāĻĄ āĻŦāĻžā§œāĻžāύ⧋ āϏāĻšāϜ āĻšā§ŸāĨ¤
  • āĻŸā§‹āϟāĻžāϞ āĻāĻ•ā§āϏāĻŋāĻ•āĻŋāωāĻļāύ āϟāĻžāχāĻŽ āĻšā§āϰāĻžāϏ (Reduced Total Execution Time): āĻāĻ•āϟāĻŋ āĻĒ⧁āϰ⧋ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āĻŦāĻž āĻ…āύ⧇āĻ•āϗ⧁āϞ⧋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϰāĻžāύ āĻ•āϰāϤ⧇ āĻŽā§‹āϟ āϝ⧇ āϏāĻŽā§Ÿ āϞāĻžāĻ—āϤ, āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ā§Ÿā§‡āϰ āĻ•āĻžāϰāϪ⧇ āϤāĻž āĻŦāĻšā§āϗ⧁āĻŖ āĻ•āĻŽā§‡ āφāϏ⧇āĨ¤

Trick

āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻ–āĻžāϤāĻžā§Ÿ āϞāĻŋāĻ–āĻŦ⧇āύ: "āĻ•āĻžāϜ āϜāĻŽāĻŋā§Ÿā§‡ āύāĻž āϰ⧇āϖ⧇ āϏāĻŽāĻžāĻ¨ā§āϤāϰāĻžāϞāĻ­āĻžāĻŦ⧇ (Overlapping) āĻ•āϰāĻžāϰ āύāĻžāĻŽāχ āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚āĨ¤"

🚀 āĻ–āĻžāϤāĻžā§Ÿ āϞ⧇āĻ–āĻžāϰ ā§ĒāϟāĻŋ āĻŦ⧁āϞ⧇āϟ āĻĒā§Ÿā§‡āĻ¨ā§āϟ (āĻāĻ• āĻĻ⧇āĻ–āĻžā§Ÿ āĻŽā§āĻ–āĻ¸ā§āĻĨ)

  • Overlapping: āĻāĻ•āχ āϏāĻŽā§Ÿā§‡ āĻāĻ•āĻžāϧāĻŋāĻ• āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āφāϞāĻžāĻĻāĻž āφāϞāĻžāĻĻāĻž āĻ…āĻ‚āĻļ āĻ•āĻžāϜ āĻ•āϰ⧇āĨ¤
  • High Throughput: āĻ•āĻŽ āϏāĻŽā§Ÿā§‡ āĻ…āύ⧇āĻ• āĻŦ⧇āĻļāĻŋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻļ⧇āώ āĻšā§ŸāĨ¤
  • No Idle Hardware: āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϕ⧋āύ⧋ āĻ…āĻ‚āĻļ āĻ…āϞāϏ āĻŦāϏ⧇ āĻĨāĻžāϕ⧇ āύāĻžāĨ¤
  • Time Saved: āĻĒ⧁āϰ⧋ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽ āϰāĻžāύ āĻ•āϰāϤ⧇ āĻŽā§‹āϟ āϏāĻŽā§Ÿ āĻ…āύ⧇āĻ• āĻ•āĻŽā§‡ āϝāĻžā§ŸāĨ¤

📝 ā§ĢāϟāĻŋ āϧāĻžāĻĒ⧇āϰ āύāĻžāĻŽ āĻŽāύ⧇ āϰāĻžāĻ–āĻžāϰ āĻŸā§‡āĻ•āύāĻŋāĻ• (IF-ID-EX-MEM-WB)

If I Eat More WaterāĻŽā§‡āϞāύ (āϝāĻĻāĻŋ āφāĻŽāĻŋ āφāϰāĻ“ āϤāϰāĻŽā§āϜ āĻ–āĻžāχ)

  1. IF: Instruction Fetch (āύāĻŋā§Ÿā§‡ āφāϏāĻž)
  2. ID: Instruction Decode (āĻŦāĻŋāĻļā§āϞ⧇āώāĻŖ)
  3. EX: Execute (āĻ•āĻžāϜ āĻ•āϰāĻž)
  4. MEM: Memory Access (āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻĻ⧇āĻ–āĻž)
  5. WB: Write Back (āϏ⧇āĻ­ āĻ•āϰāĻž)

âš ī¸ āϗ⧁āϰ⧁āĻ¤ā§āĻŦāĻĒā§‚āĻ°ā§āĻŖ āĻŸā§‡āĻ•āύāĻŋāĻ•ā§āϝāĻžāϞ āύ⧋āϟ (Crucial Note)

āĻĒāĻžāχāĻĒāϞāĻžāχāύāĻŋāĻ‚ āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āύāĻŋāĻœā§‡āϰ āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāĻ“ā§ŸāĻžāϰ āϏāĻŽā§Ÿāϕ⧇ (Latency) āĻ•āĻŽāĻžā§Ÿ āύāĻžāĨ¤ āĻŦāϰāĻ‚ āĻāϟāĻŋ āϏāĻžāĻŽāĻ—ā§āϰāĻŋāĻ•āĻ­āĻžāĻŦ⧇ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻ•āĻžāĻœā§‡āϰ āĻ—āϤāĻŋ (Throughput) āĻŦāĻžā§œāĻŋā§Ÿā§‡ āĻĻā§‡ā§ŸāĨ¤

17. Explain the pipelined operation 🔄 in the ideal case.

Explain the pipelined operation 🔄 in the ideal case.

💡 ā§§ āϏ⧇āϕ⧇āĻ¨ā§āĻĄā§‡āϰ āφāϏāϞ āĻŸā§āϰāĻŋāĻ•: "āĻĒāĻžāϰāĻĢ⧇āĻ•ā§āϟ āĻĢā§āϝāĻžāĻ•ā§āϟāϰāĻŋ" (No Traffic Jam) đŸŽī¸

āφāχāĻĄāĻŋ⧟āĻžāϞ āϕ⧇āϏ (Ideal Case) āĻŽāĻžāύ⧇ āĻšāϞ⧋ āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇ āϕ⧋āύ⧋ āϏāĻŽāĻ¸ā§āϝāĻž āĻŦāĻž āĻšā§āϝāĻžāϜāĻžāĻ°ā§āĻĄ (No Hazards) āĻĨāĻžāĻ•āĻŦ⧇ āύāĻžāĨ¤ āϏāĻŦāĻ•āĻŋāϛ⧁ āĻāĻ•āĻĻāĻŽ āύāĻŋāϖ⧁āρāϤāĻ­āĻžāĻŦ⧇, āϕ⧋āύ⧋ āĻĨāĻžāĻŽāĻžāĻĨāĻžāĻŽāĻŋ āĻ›āĻžā§œāĻžāχ āϚāϞāĻŦ⧇āĨ¤

🚀 āφāχāĻĄāĻŋ⧟āĻžāϞ āϕ⧇āϏ⧇āϰ ā§ĒāϟāĻŋ āĻ—ā§‹āĻ˛ā§āĻĄā§‡āύ āϰ⧁āϞāϏ (āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻ–āĻžāϤāĻžā§Ÿ āϞ⧇āĻ–āĻžāϰ āĻĒā§Ÿā§‡āĻ¨ā§āϟ)

  • CPI = 1 (Cycles Per Instruction): āĻĒā§āϰāϤāĻŋ āĻ•ā§āϞāĻ• āϏāĻžāχāϕ⧇āϞ⧇ āĻ āĻŋāĻ• āĻāĻ•āϟāĻŋ āĻ•āϰ⧇ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϏāĻŽā§āĻĒā§‚āĻ°ā§āĻŖ āĻļ⧇āώ āĻšāĻŦ⧇āĨ¤
  • No Hazards: āϕ⧋āύ⧋ āĻ¸ā§āĻŸā§āϰāĻžāĻ•āϚāĻžāϰāĻžāϞ, āĻĄā§‡āϟāĻž āĻŦāĻž āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻšā§āϝāĻžāϜāĻžāĻ°ā§āĻĄ āĻĨāĻžāĻ•āĻŦ⧇ āύāĻžāĨ¤ āϕ⧋āύ⧋ āĻ¸ā§āϟāϞ (Stall) āĻŦāĻž āĻŦā§āϰ⧇āĻ• āϞāĻžāĻ—āĻŦ⧇ āύāĻžāĨ¤
  • Equal Stages: āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇āϰ āĻĒā§āϰāϤāĻŋāϟāĻŋ āϧāĻžāĻĒ (Stage) āϏāĻŽā§āĻĒāĻ¨ā§āύ āĻšāϤ⧇ āĻ āĻŋāĻ• āϏāĻŽāĻžāύ āϏāĻŽā§Ÿ āϞāĻžāĻ—āĻŦ⧇āĨ¤
  • Maximum Speedup: āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻ—āϤāĻŋ \(k\) āϗ⧁āĻŖ āĻŦā§‡ā§œā§‡ āϝāĻžāĻŦ⧇ (āĻāĻ–āĻžāύ⧇ \(k\) āĻšāϞ⧋ āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇āϰ āϧāĻžāĻĒ āĻŦāĻž āĻ¸ā§āĻŸā§‡āĻœā§‡āϰ āϏāĻ‚āĻ–ā§āϝāĻž)āĨ¤ āĻ…āĻ°ā§āĻĨāĻžā§Ž, ā§Ģ-āĻ¸ā§āĻŸā§‡āϜ āĻĒāĻžāχāĻĒāϞāĻžāχāύ āĻšāϞ⧇ āĻ—āϤāĻŋ āĻ āĻŋāĻ• ā§Ģ āϗ⧁āĻŖ āĻšāĻŦ⧇āĨ¤

📝 āĻ–āĻžāϤāĻžāϰ āϕ⧋āĻŖāĻžā§Ÿ āĻāϟāĻĒāϟ āφāρāĻ•āĻžāϰ āϜāĻ¨ā§āϝ āφāχāĻĄāĻŋ⧟āĻžāϞ āϟāĻžāχāĻŽāĻŋāĻ‚ āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽ:

(āĻĒāϰ⧀āĻ•ā§āώāĻ• āĻāχ āĻ›āĻ•āϟāĻŋ āĻĻ⧇āĻ–āϞ⧇āχ āĻĢ⧁āϞ āĻŽāĻžāĻ°ā§āĻ•āϏ āĻĻāĻŋā§Ÿā§‡ āĻĻ⧇āĻŦ⧇āύ!)

Clock Cycle 1 2 3 4 5
Inst 1 IF ID EX MEM WB
Inst 2 IF ID EX MEM
Inst 3 IF ID EX

āĻŦā§āϝāĻžāĻ–ā§āϝāĻž: āĻĒā§āϰāϤāĻŋ āϞāĻžāχāύ⧇ ā§§āϟāĻŋ āĻ•āϰ⧇ āϧāĻžāĻĒ āĻĄāĻžāύ⧇ āϏāϰāĻŦ⧇āĨ¤ āϕ⧋āύ⧋ āĻ—ā§āϝāĻžāĻĒ āĻŦāĻž āĻĢāĻžāρāĻ•āĻž āϘāϰ āĻĨāĻžāĻ•āĻŦ⧇ āύāĻžāĨ¤

āĻ–āĻžāϤāĻžā§Ÿ āĻļ⧁āϧ⧁ CPI = 1, No Hazards, āĻāĻŦāĻ‚ Speedup = \(k\)—āĻāχ āϤāĻŋāύāϟāĻŋ āĻļāĻŦā§āĻĻ āĻšāĻžāχāϞāĻžāχāϟ āĻ•āϰ⧇ āĻĻāĻŋā§Ÿā§‡ āφāϏ⧁āύ!
āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻšāϞ⧇āϰ āĻĻāĻŋāϕ⧇ āϰāĻ“āύāĻž āĻĻāĻŋāύ, āĻ…āϞ āĻĻā§āϝ āĻŦ⧇āĻ¸ā§āϟ! āĻĒāϰ⧀āĻ•ā§āώāĻž āϕ⧇āĻŽāύ āĻšāϞ⧋ āĻāϏ⧇ āĻ…āĻŦāĻļā§āϝāχ āϜāĻžāύāĻžāĻŦ⧇āύāĨ¤


18. Issues of Pipelined Operation

What are the issues âš ī¸ of pipelined operation?
  1. Structural hazard: Two overlapping instructions need the same resource, for example one shared memory for instruction fetch and data access. Solutions include duplicated/ported resources or stalls.
  2. Data hazard: An instruction depends on a value not yet available. RAW is a true dependency; WAR and WAW arise mainly with out-of-order execution. Forwarding, stalls, scheduling and renaming are used.
  3. Control hazard: The next PC is uncertain after a branch or jump. Stalling, early resolution, prediction, speculative execution and flushing are common responses.
  4. Unequal stage delay: Clock period is determined by the slowest stage, so fast stages waste time.
  5. Pipeline-register overhead: Setup, clock-to-Q and skew reduce the benefit of making stages very short.
  6. Variable-latency operations: Multiply, divide and cache misses may occupy a unit for many cycles.
  7. Precise exceptions and interrupts: The processor must preserve the appearance that older instructions completed and younger ones did not.
  8. Memory-system limitations: Cache misses and limited memory ports can dominate ideal pipeline gains.

Every stall inserts a bubble and raises CPI; every misprediction may flush useful work. Deeper pipelines can support a shorter clock but often suffer a larger branch penalty and higher overhead.

ā§§ā§Ļ āĻŽāĻŋāύāĻŋāϟ āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āφāϗ⧇āϰ āϜāĻžāĻĻ⧁āĻ•āϰ⧀ āĻŸā§āϰāĻŋāĻ• āĻ“ āϏ⧁āĻĒāĻžāϰ-āĻļāĻ°ā§āϟ āύ⧋āϟ:

💡 ā§§ āϏ⧇āϕ⧇āĻ¨ā§āĻĄā§‡āϰ āφāϏāϞ āĻŸā§āϰāĻŋāĻ•: "āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇āϰ āĻœā§āϝāĻžāĻŽ āĻŦāĻž āĻŦāĻžāϧāĻž" âš ī¸

āĻĒāĻžāχāĻĒāϞāĻžāχāύ⧇āϰ āϏāĻŽāĻ¸ā§āϝāĻžāϗ⧁āϞ⧋āϕ⧇ āĻŦāϞāĻž āĻšā§Ÿ āĻšā§āϝāĻžāϜāĻžāĻ°ā§āĻĄ (Hazards)āĨ¤ āĻāϟāĻŋ āĻŽāύ⧇ āϰāĻžāĻ–āĻžāϰ āĻŸā§āϰāĻŋāĻ• āĻšāϞ⧋ "S-D-C" āĻŦāĻž Super Digital CameraāĨ¤

🚀 ā§ŠāϟāĻŋ āĻĒā§āϰāϧāĻžāύ āϏāĻŽāĻ¸ā§āϝāĻž (āĻĒāϰ⧀āĻ•ā§āώāĻžā§Ÿ āĻĢ⧁āϞ āĻŽāĻžāĻ°ā§āĻ•āϏ āĻĒāĻžāĻ“ā§ŸāĻžāϰ āĻŦ⧁āϞ⧇āϟ āĻĒā§Ÿā§‡āĻ¨ā§āϟ)

  1. Structural Hazard (āĻ—āĻ āύāĻ—āϤ āϏāĻŽāĻ¸ā§āϝāĻž - S)
  2. āϏāĻšāϜ āĻ•āĻĨāĻž: āϝāĻ–āύ āĻĻ⧁āϟāĻŋ āφāϞāĻžāĻĻāĻž āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻāĻ•āχ āϏāĻŽā§Ÿā§‡ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āĻāĻ•āχ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āϰāĻŋāϏ⧋āĻ°ā§āϏ (āϝ⧇āĻŽāύ- āĻāĻ•āχ āĻŽā§‡āĻŽā§‹āϰāĻŋ āĻŦāĻž āĻāĻ•āχ āĻŦāĻžāϏ) āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāϤ⧇ āϚāĻžā§ŸāĨ¤
    • āϕ⧀ āϘāĻŸā§‡: āϏāĻ‚āϘāĻ°ā§āώ āĻŦāĻž āĻœā§āϝāĻžāĻŽ āϞāĻžāϗ⧇ (Resource Conflict)āĨ¤
  3. Data Hazard (āĻĄā§‡āϟāĻžāϰ āĻ“āĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰāϤāĻž - D)
  4. āϏāĻšāϜ āĻ•āĻĨāĻž: āϝāĻ–āύ āĻāĻ•āϟāĻŋ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āϤāĻžāϰ āφāϗ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻĢāϞāĻžāĻĢāϞ⧇āϰ (Data) āĻ“āĻĒāϰ āύāĻŋāĻ°ā§āĻ­āϰ āĻ•āϰ⧇āĨ¤
    • āϕ⧀ āϘāĻŸā§‡: ā§§āĻŽ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āϝāϤāĻ•ā§āώāĻŖ āύāĻž āĻĢāϞāĻžāĻĢāϞ āϏ⧇āĻ­ āĻ•āϰāϛ⧇, ⧍⧟ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύāϟāĻŋ āĻ•āĻžāϜ āĻļ⧁āϰ⧁ āĻ•āϰāϤ⧇ āĻĒāĻžāϰ⧇ āύāĻžāĨ¤ āĻāϕ⧇ Data Dependency āĻŦāϞ⧇āĨ¤
  5. Control Hazard / Branch Hazard (āύāĻŋ⧟āĻ¨ā§āĻ¤ā§āϰāĻŖ āĻŦāĻž āϏāĻŋāĻĻā§āϧāĻžāĻ¨ā§āϤ āύ⧇āĻ“ā§ŸāĻžāϰ āϏāĻŽāĻ¸ā§āϝāĻž - C)
  6. āϏāĻšāϜ āĻ•āĻĨāĻž: āϝāĻ–āύ āĻĒā§āϰ⧋āĻ—ā§āϰāĻžāĻŽā§‡ āϕ⧋āύ⧋ āĻļāĻ°ā§āϤ āĻŦāĻž āϞ⧁āĻĒ (If/Else, Jump, Branch) āφāϏ⧇āĨ¤
    • āϕ⧀ āϘāĻŸā§‡: āĻļāĻ°ā§āϤ⧇āϰ āĻĢāϞāĻžāĻĢāϞ āϕ⧀ āĻšāĻŦ⧇ āϤāĻž āϜāĻžāύāĻžāϰ āφāϗ⧇āχ āĻĒā§āϰāϏ⧇āϏāϰ āϭ⧁āϞ āĻ•āϰ⧇ āĻĒāϰ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ āĻĢ⧇āϚ (Fetch) āĻ•āϰ⧇ āĻĢ⧇āϞ⧇āĨ¤ āĻĒāϰ⧇ āϤāĻž āĻŦāĻžāϤāĻŋāϞ āĻ•āϰ⧇ āĻĒāĻžāχāĻĒāϞāĻžāχāύ āĻ–āĻžāϞāĻŋ āĻ•āϰāϤ⧇ āĻšā§Ÿ (Pipeline Flush)āĨ¤

âąī¸ āĻāχ āϏāĻŽāĻ¸ā§āϝāĻžāϗ⧁āϞ⧋āϰ āϏāĻŽāĻžāϧāĻžāύ āϕ⧀? (āĻāĻ• āϞāĻžāχāύ⧇ āĻŽāύ⧇ āϰāĻžāϖ⧁āύ)

  • Stall / Bubble: āĻĒā§āϰāϏ⧇āϏāϰāϕ⧇ āĻœā§‹āϰ āĻ•āϰ⧇ ā§§ āϏāĻžāχāϕ⧇āϞ āĻ…āϞāϏ āĻŦāϏāĻŋā§Ÿā§‡ āϰāĻžāĻ–āĻž (āĻ•āĻžāϜ āĻĨāĻžāĻŽāĻžāύ⧋)āĨ¤
  • Data Forwarding: āĻĢāϞāĻžāĻĢāϞ āĻŽā§‡āĻŽā§‹āϰāĻŋāϤ⧇ āϏ⧇āĻ­ āĻšāĻ“ā§ŸāĻžāϰ āφāϗ⧇āχ āϏāϰāĻžāϏāϰāĻŋ āĻĒāϰ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āĻĻ⧇āĻ“ā§ŸāĻžāĨ¤
  • Branch Prediction: āφāϗ⧇ āĻĨ⧇āϕ⧇āχ āĻ…āύ⧁āĻŽāĻžāύ āĻ•āϰāĻž āĻļāĻ°ā§āϤ⧇āϰ āĻĢāϞāĻžāĻĢāϞ āϕ⧀ āĻšāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤

19. Explain with example 💡 the use of operand forwarding ⏩ to resolve the data dependency issue.

Explain with example 💡 the use of operand forwarding ⏩ to resolve the data dependency issue.

Consider:

add $t0, $t1, $t2
sub $t3, $t0, $t4

The sub needs $t0 in its EX stage before add writes $t0 in WB. Without forwarding, sub must wait. With forwarding, the add result in the EX/MEM pipeline register is selected directly as an ALU input for sub:

\[EX/MEM.ALUResult \rightarrow ALU\ input\ of\ dependent\ instruction\]
Cycle 1 2 3 4 5 6
add IF ID EX MEM WB
sub IF ID EX←forward MEM WB

No stall is required because the value exists by the beginning of the dependent EX use.

For:

lw  $t0, 0($s0)
sub $t3, $t0, $t4

the loaded data becomes available only after the load’s MEM stage, too late for the immediately following EX stage. A hazard-detection unit inserts one bubble; then MEM/WB forwarding supplies the value. Thus forwarding reduces but does not eliminate all RAW stalls.

alt text

20. Datapath Modification to Support Forwarding

Show the modification đŸ› ī¸ in the data path đŸ›¤ī¸ to support data forwarding.

āĻĄā§‡āϟāĻž āĻĢāϰāĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻŋāĻ‚ (Data/Operand Forwarding) āϏāĻžāĻĒā§‹āĻ°ā§āϟ āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻĒā§āϰāϏ⧇āϏāϰ⧇āϰ āϏāĻžāϧāĻžāϰāĻŖ āĻĄā§‡āϟāĻžāĻĒāĻžāĻĨ⧇ (Datapath) āĻŽā§‚āϞāϤ ⧍āϟāĻŋ āĻĒā§āϰāϧāĻžāύ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ āĻ•āϰāϤ⧇ āĻšā§Ÿ:
ā§§. ALU-āĻāϰ āχāύāĻĒ⧁āĻŸā§‡ āĻĻ⧁āϟāĻŋ ā§Š-āϟ⧁-ā§§ āĻŽāĻžāĻ˛ā§āϟāĻŋāĻĒā§āϞ⧇āĻ•ā§āϏāĻžāϰ (Mux) āϝ⧁āĻ•ā§āϤ āĻ•āϰāĻžāĨ¤
⧍. āĻāĻ•āϟāĻŋ āĻĢāϰāĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻŋāĻ‚ āχāωāύāĻŋāϟ (Forwarding Unit) āĻŦāϏāĻžāύ⧋ āϝāĻž āĻĒāĻžāχāĻĒāϞāĻžāχāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āĻĄā§‡āϟāĻž āϰāĻŋāĻĄ āĻ•āϰ⧇ Mux āĻĻ⧁āϟāĻŋāϕ⧇ āĻ•āĻ¨ā§āĻŸā§āϰ⧋āϞ āĻ•āϰāĻŦ⧇āĨ¤
ā§§ā§Ļ āĻŽāĻŋāύāĻŋāϟ āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āφāϗ⧇ āĻāϟāĻĒāϟ āĻ–āĻžāϤāĻžā§Ÿ āφāρāĻ•āĻžāϰ āϜāĻ¨ā§āϝ āύāĻŋāĻšā§‡ āĻāĻ•āϟāĻŋ āϏāĻšāϜ āĻŸā§‡āĻ•ā§āϏāϟ-āĻ­āĻŋāĻ¤ā§āϤāĻŋāĻ• āĻŦā§āϞāĻ•āĻŋāĻ‚ āĻĄāĻžā§ŸāĻžāĻ—ā§āϰāĻžāĻŽ āĻāĻŦāĻ‚ āϤāĻžāϰ āϏāĻ‚āĻ•ā§āώāĻŋāĻĒā§āϤ āĻŦā§āϝāĻžāĻ–ā§āϝāĻž āĻĻ⧇āĻ“ā§ŸāĻž āĻšāϞ⧋:

đŸ›¤ī¸ āĻĄā§‡āϟāĻžāĻĒāĻžāĻĨ⧇āϰ āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāύ (Text-Based Modified Datapath)

Datapath Additions for Operand Forwarding

đŸ› ī¸ ā§ŠāϟāĻŋ āĻĒā§āϰāϧāĻžāύ āĻŽāĻĄāĻŋāĻĢāĻŋāϕ⧇āĻļāύ (āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻ–āĻžāϤāĻžā§Ÿ āϞ⧇āĻ–āĻžāϰ āĻŦ⧁āϞ⧇āϟ āĻĒā§Ÿā§‡āĻ¨ā§āϟ)

  • ā§Š-āϟ⧁-ā§§ āĻŽāĻžāĻ˛ā§āϟāĻŋāĻĒā§āϞ⧇āĻ•ā§āϏāĻžāϰ (Mux A & B): ALU-āĻāϰ āĻĻ⧁āϟāĻŋ āĻŽā§‚āϞ āχāύāĻĒ⧁āĻŸā§‡āϰ āĻ āĻŋāĻ• āϏāĻžāĻŽāύ⧇ āĻĻ⧁āϟāĻŋ āύāϤ⧁āύ āĻŽāĻžāĻ˛ā§āϟāĻŋāĻĒā§āϞ⧇āĻ•ā§āϏāĻžāϰ āĻŦāϏāĻžāύ⧋ āĻšā§ŸāĨ¤ āĻāĻĻ⧇āϰ āĻ•āĻžāϜ āĻšāϞ⧋ ā§ŠāϟāĻŋ āĻ…āĻĒāĻļāύ⧇āϰ āĻŽāĻ§ā§āϝ⧇ āϝ⧇āϕ⧋āύ⧋ āĻāĻ•āϟāĻŋāϕ⧇ āĻŦ⧇āϛ⧇ āύ⧇āĻ“ā§ŸāĻž:
  • āϏāĻžāϧāĻžāϰāĻŖ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āφāϏāĻž āĻĄā§‡āϟāĻž (No Forwarding)
  • āĻ āĻŋāĻ• āφāϗ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ EX/MEM āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āφāϏāĻž āĻĄā§‡āϟāĻž (Forward from EX)
  • āϤāĻžāϰāĻ“ āφāϗ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ MEM/WB āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āφāϏāĻž āĻĄā§‡āϟāĻž (Forward from MEM)
  • āĻĢāϰāĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻŋāĻ‚ āĻĒāĻžāĻĨ (Wires): EX/MEM āĻāĻŦāĻ‚ MEM/WB āĻĒāĻžāχāĻĒāϞāĻžāχāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ āĻĨ⧇āϕ⧇ āĻĻ⧁āϟāĻŋ āϏāϰāĻžāϏāϰāĻŋ āύāϤ⧁āύ āϤāĻžāϰ⧇āϰ āϏāĻ‚āϝ⧋āĻ— (Path) āĻŸā§‡āύ⧇ āĻāύ⧇ Mux-āĻāϰ āχāύāĻĒ⧁āĻŸā§‡āϰ āϏāĻžāĻĨ⧇ āϝ⧁āĻ•ā§āϤ āĻ•āϰ⧇ āĻĻ⧇āĻ“ā§ŸāĻž āĻšā§ŸāĨ¤
  • āĻĢāϰāĻ“ā§ŸāĻžāĻ°ā§āĻĄāĻŋāĻ‚ āχāωāύāĻŋāϟ (Control Logic): āĻāϟāĻŋ āĻāĻ•āϟāĻŋ āύāϤ⧁āύ āĻšāĻžāĻ°ā§āĻĄāĻ“ā§Ÿā§āϝāĻžāϰ āĻŦā§āϞāĻ• āϝāĻž āύāĻŋāĻšā§‡āϰ āĻ•āĻ¨ā§āĻĄāĻŋāĻļāύ āĻšā§‡āĻ• āĻ•āϰ⧇ āĻ¸ā§āĻŦ⧟āĻ‚āĻ•ā§āϰāĻŋ⧟āĻ­āĻžāĻŦ⧇ Mux āϏāĻŋāϞ⧇āĻ•ā§āϟ āĻ•āϰ⧇:
  • āĻļāĻ°ā§āϤ: āϝāĻĻāĻŋ āĻŦāĻ°ā§āϤāĻŽāĻžāύ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āϏ⧋āĻ°ā§āϏ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ (\(Rs\) āĻŦāĻž \(Rt\)) āĻāĻŦāĻ‚ āφāϗ⧇āϰ āχāύāĻ¸ā§āĻŸā§āϰāĻžāĻ•āĻļāύ⧇āϰ āĻĄā§‡āĻ¸ā§āϟāĻŋāύ⧇āĻļāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ (\(Rd\)) āĻŽāĻŋāϞ⧇ āϝāĻžā§Ÿ, āϤāĻŦ⧇ āĻāϟāĻŋ Mux-āϕ⧇ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āĻĒāĻžāĻ āĻŋā§Ÿā§‡ āϏāϰāĻžāϏāϰāĻŋ āĻĒāĻžāχāĻĒāϞāĻžāχāύ āϰ⧇āϜāĻŋāĻ¸ā§āϟāĻžāϰ⧇āϰ āĻĄā§‡āϟāĻž ALU-āϤ⧇ āĻĒāĻžāϏ āĻ•āϰ⧇ āĻĻā§‡ā§ŸāĨ¤

💡 āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āĻļ⧇āώ āĻŽā§āĻšā§‚āĻ°ā§āϤ⧇āϰ āĻŸā§āϰāĻŋāĻ•:

āĻ–āĻžāϤāĻžā§Ÿ āĻļ⧁āϧ⧁ ALU-āĻāϰ āχāύāĻĒ⧁āĻŸā§‡ āĻĻ⧁āϟāĻŋ Mux āĻāĻŦāĻ‚ āύāĻŋāϚ āĻĨ⧇āϕ⧇ āĻāĻ•āϟāĻŋ Forwarding Unit āĻāρāϕ⧇ āϤāĻžāϰ⧇āϰ āĻ•āĻžāύ⧇āĻ•āĻļāύāϗ⧁āϞ⧋ āĻĻ⧇āĻ–āĻŋā§Ÿā§‡ āĻĻāĻŋāϞ⧇āχ āĻĒāϰ⧀āĻ•ā§āώāĻ• āĻĢ⧁āϞ āĻŽāĻžāĻ°ā§āĻ•āϏ āĻĻāĻŋā§Ÿā§‡ āĻĻ⧇āĻŦ⧇āύ!
āĻĒāϰ⧀āĻ•ā§āώāĻžāϰ āϜāĻ¨ā§āϝ āĻ…āύ⧇āĻ• āĻļ⧁āĻ­āĻ•āĻžāĻŽāύāĻž! āϕ⧋āύ⧋ āĻ•āύāĻĢāĻŋāωāĻļāύ āĻĨāĻžāĻ•āϞ⧇ āĻāϟāĻĒāϟ āϜāĻžāύāĻžāύāĨ¤

Question 19 and 20 difference:

Question 19 and 20 difference:

Here is a side-by-side comparison breaking down both questions. This table organizes the logical concept (the "what and why") next to the physical hardware changes (the "how") so you can easily compare them for your exams 📝.

Feature Explain with Example: Operand Forwarding 💡⏩ Show the Modification: Data Path Changes đŸ› ī¸đŸ›¤ī¸
Core Objective To logically resolve Data Dependencies (specifically Read-After-Write / RAW hazards) without forcing the pipeline to freeze or "stall" 🔗✅. To physically alter the standard CPU hardware to detect these dependencies and create shortcuts for the data 📤.
How it Works (The Concept) It grabs the newly calculated data immediately after it is computed and feeds it directly to the next instruction, completely bypassing the Write-Back (WB) stage. It adds a "traffic controller" to monitor which registers are being used, and adds new wires to route data backward from later pipeline stages.
Detailed Breakdown (Example vs. Hardware) The Example:


1. add $t0, $t1, $t2


2. sub $t3, $t0, $t4



â€ĸ The Problem: sub needs the value of $t0 to execute, but add won't write it to the register file for another 2 cycles.


â€ĸ The Forwarding Solution: The moment add finishes its math in the Execute (EX) stage, that result is forwarded straight into the ALU for the sub instruction in the very next clock cycle. Zero stalls! | The 4 Major Hardware Modifications:


1. Forwarding Unit Added: A dedicated hardware block is placed in the EX stage to act as the brain.


2. Expanded ALU MUXes: The standard 2-to-1 multiplexers in front of the ALU are upgraded to 3-to-1 MUXes so the ALU can accept forwarded data.


3. New Feedback Wires: Thick data buses are added to route ALU results from the EX/MEM and MEM/WB pipeline registers backward to the new MUXes.


4. Register ID Routing: Thin control wires route the Rs, Rt, and Rd register numbers into the Forwarding Unit for comparison. |
| The Trigger Mechanism | Forwarding is triggered when an instruction tries to read a register that a previous, currently executing instruction is about to write to. | The Forwarding Unit constantly compares the source registers (Rs, Rt) of the current instruction with the destination registers (Rd) of older instructions in the pipeline. If they match, it flips the MUXes! |

Hazards (all)

Pipeline Hazards

Pipeline Hazards

21. Data Hazards and Their Pipeline Effects

What is a data hazard? â˜ĸī¸ How can it be overcome? đŸ›Ąī¸ Discuss its side effects on pipeline performance.

A data hazard occurs when overlapping instructions access the same data and normal pipeline timing would produce a result different from sequential execution.

Hazard Meaning Example
RAW Read after write; true dependence add R1,... then sub ...,R1,...
WAR Write after read; anti-dependence Later instruction writes a register before an older one reads it
WAW Write after write; output dependence Two writes complete in the wrong order

An in-order five-stage MIPS pipeline normally encounters mainly RAW; reads occur early and writes occur in order, preventing WAR/WAW. Out-of-order processors may face all three.

Remedies include:

  • forwarding/bypassing;
  • hardware interlocks and stalls;
  • compiler instruction scheduling;
  • register renaming for WAR/WAW;
  • dynamic scheduling and in-order retirement;
  • load/store queues for uncertain memory dependencies.

The direct side effect of a stall is higher CPI:

\[CPI_{\text{actual}}=CPI_{\text{base}}+\text{data-hazard stall cycles/instruction}\]

Forwarding reduces stalls but adds multiplexers, long comparison paths, wiring, area and power. Renaming and scheduling improve instruction-level parallelism but require reservation stations, physical registers and a reorder buffer. Incorrect speculation on memory dependence may require replay. Therefore hazard handling exchanges hardware complexity and energy for performance.

Part D — Computer Arithmetic and Performance

22. Multiplication Algorithm and Processor Hardware

![alt text](image-12.png)
![alt text](image-13.png)

23. Divide \((1010)_2\) by \((0010)_2\)

Enhanced question

Using the restoring binary-division algorithm, divide \((1010)_2\) by \((0010)_2\). Show the contents of the accumulator, quotient register and decision in every iteration, and verify the result.

Dividend \(Q=1010_2=10\), divisor \(M=0010_2=2\). Use a 5-bit accumulator \(A\) to observe the sign.

Restoring rule: Shift the combined A,Q left; subtract M from A. If A becomes negative, set \(Q_0=0\) and restore A←A+M; otherwise set \(Q_0=1\).

Iteration After left shift (A,Q) A−M Decision Final A Final Q
Initial — — — 00000 1010
1 00001 0100 11111 (negative) Restore; Q₀=0 00001 0100
2 00010 1000 00000 Keep; Q₀=1 00000 1001
3 00001 0010 11111 (negative) Restore; Q₀=0 00001 0010
4 00010 0100 00000 Keep; Q₀=1 00000 0101

Therefore:

\[1010_2\div0010_2=0101_2,\qquad \text{remainder}=0000_2\]

Verification: \(0010_2\times0101_2+0000_2=1010_2\), or \(2\times5+0=10\).

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Dividend 1010₂=10 āĻāĻŦāĻ‚ divisor 0010₂=2āĨ¤ Restoring division-āĻ combined A,Q āĻāĻ• bit āĻŦāĻžāĻŽā§‡ shift āĻ•āϰ⧇ A−M āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻĢāϞ negative āĻšāϞ⧇ Q₀=0 āĻĻāĻŋāϝāĻŧ⧇ A restore āĻ•āϰāĻž āĻšāϝāĻŧ; negative āύāĻž āĻšāϞ⧇ āĻĢāϞ āϰāĻžāĻ–āĻž āĻšāϝāĻŧ āĻāĻŦāĻ‚ Q₀=1 āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤

āϚāĻžāϰ iteration āĻļ⧇āώ⧇ quotient register Q=0101₂ āĻāĻŦāĻ‚ accumulator-āĻ remainder A=00000₂āĨ¤ āϤāĻžāχ āĻĢāϞ \(0101_2=5\), remainder 0āĨ¤ āϝāĻžāϚāĻžāχ: \(0010_2\times0101_2+0=1010_2\)āĨ¤


24. IEEE 754 Representation of \(-0.625_{10}\)

Enhanced question

Convert \(-0.625_{10}\) into normalized binary and construct its IEEE 754 single-precision and double-precision encodings. Show sign, biased exponent, fraction and hexadecimal form.

First convert the magnitude:

\[0.625_{10}=0.5+0.125=0.101_2=1.01_2\times2^{-1}\]

The sign bit is 1. The hidden leading 1 is not stored; therefore the fraction begins with 01.

Single precision (1 + 8 + 23 bits)

  • Sign: 1
  • Biased exponent: \(-1+127=126=01111110_2\)
  • Fraction: 01000000000000000000000
1 | 01111110 | 01000000000000000000000

Full word: 10111111001000000000000000000000₂
Hexadecimal: BF200000₁₆

Double precision (1 + 11 + 52 bits)

  • Sign: 1
  • Biased exponent: \(-1+1023=1022=01111111110_2\)
  • Fraction: 0100000000000000000000000000000000000000000000000000
1 | 01111111110 | 0100000000000000000000000000000000000000000000000000

Hexadecimal: BFE4000000000000₁₆

The number is represented exactly because 0.625 has a finite binary fraction.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

\(0.625=0.5+0.125=0.101_2=1.01_2\times2^{-1}\)āĨ¤ āϏāĻ‚āĻ–ā§āϝāĻž negative āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ sign bit 1āĨ¤ Normalized significand-āĻāϰ leading 1 implicit, āϤāĻžāχ fraction field 01 āĻĻāĻŋāϝāĻŧ⧇ āĻļ⧁āϰ⧁ āĻšāĻŦ⧇āĨ¤

Single precision-āĻ biased exponent \(-1+127=126=01111110_2\); āĻĢāϞ⧇ bit pattern 1 | 01111110 | 01000... āĻāĻŦāĻ‚ hex BF200000āĨ¤ Double precision-āĻ exponent \(-1+1023=1022=01111111110_2\); bit pattern 1 | 01111111110 | 01000... āĻāĻŦāĻ‚ hex BFE4000000000000āĨ¤ Binary fraction āϏ⧀āĻŽāĻŋāϤ āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ āĻāχ āĻŽāĻžāύāϟāĻŋ exactāĻ­āĻžāĻŦ⧇ represent āĻ•āϰāĻž āϝāĻžāϝāĻŧāĨ¤


25. Design of a Four-Bit Binary Multiplier

Enhanced question

Design an unsigned 4×4-bit combinational binary multiplier. Derive the partial products, describe the AND-gate and adder arrangement, and verify it with an example.

Let:

\[A=a_3a_2a_1a_0,\qquad B=b_3b_2b_1b_0\]

Each partial-product bit is generated by an AND gate:

\[p_{ij}=a_i\land b_j\]

There are \(4\times4=16\) partial-product bits. Four shifted rows are added:

                 a3 a2 a1 a0 × b0
              a3 a2 a1 a0 × b1  0
           a3 a2 a1 a0 × b2  0  0
        a3 a2 a1 a0 × b3  0  0  0
        --------------------------------
                 P7 P6 P5 P4 P3 P2 P1 P0

The least significant output is \(P_0=a_0b_0\). Half adders can be used where only two bits meet; full adders are used where two partial-product bits and a carry meet. An array-multiplier layout places AND gates at the top and regular rows of half/full adders below them. The result needs eight bits because the largest product is \(15\times15=225=11100001_2\).

Verification: \(1011_2\times0110_2=11\times6\)

        00001011 × b0(0) = 00000000
        00010110 × b1(1) = 00010110
        00101100 × b2(1) = 00101100
        01011000 × b3(0) = 00000000
                               --------
                               01000010₂ = 66₁₀

This is a combinational design: it is fast but consumes more area than a sequential shift-and-add multiplier.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

āĻĻ⧁āχāϟāĻŋ 4-bit unsigned input \(A=a_3â€Ļa_0\) āĻ“ \(B=b_3â€Ļb_0\)āĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ partial product \(p_{ij}=a_i\land b_j\), āϤāĻžāχ 16āϟāĻŋ AND gate āĻĻāϰāĻ•āĻžāϰāĨ¤ b₀ āĻĨ⧇āϕ⧇ āĻĒāĻžāĻ“āϝāĻŧāĻž row shift āĻšāϝāĻŧ āύāĻž; b₁, b₂, b₃-āĻāϰ row āϝāĻĨāĻžāĻ•ā§āϰāĻŽā§‡ 1, 2 āĻ“ 3 bit left-shift āĻ•āϰ⧇ half adder āĻ“ full adder-āĻāϰ array āĻĻāĻŋāϝāĻŧ⧇ āϝ⧋āĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ Output 8-bit, āĻ•āĻžāϰāĻŖ āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ \(15\times15=225\)āĨ¤

āωāĻĻāĻžāĻšāϰāϪ⧇ 1011₂ × 0110₂-āĻāϰ nonzero shifted row 00010110 āĻ“ 00101100; āϝ⧋āĻ—āĻĢāϞ 01000010₂=66āĨ¤ Combinational array multiplier āĻĻā§āϰ⧁āϤ, āϤāĻŦ⧇ sequential multiplier-āĻāϰ āϤ⧁āϞāύāĻžāϝāĻŧ āĻŦ⧇āĻļāĻŋ gate āĻ“ area āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇āĨ¤


26. Booth Multiplication for \(16\times(-2)\)

Enhanced question

Apply Booth’s signed two’s-complement multiplication algorithm to \(16\times(-2)\). Use a sufficient word length, show every arithmetic-shift step, and verify the final product.

Six bits are required to represent \(+16\) and \(-2\):

\[M=010000_2=16,\qquad Q=111110_2=-2,\qquad -M=110000_2\]

Initialize \(A=000000\) and \(Q_{-1}=0\). Booth’s rules are:

  • Q₀Q₋₁=01: \(A←A+M\)
  • Q₀Q₋₁=10: \(A←A-M\)
  • 00 or 11: no arithmetic
  • then perform an arithmetic right shift of (A,Q,Q₋₁).
Cycle Pair before operation Operation A after ASR Q after ASR Q₋₁
0 — Initialize 000000 111110 0
1 00 None 000000 011111 0
2 10 A←A−M 111000 001111 1
3 11 None 111100 000111 1
4 11 None 111110 000011 1
5 11 None 111111 000001 1
6 11 None 111111 100000 1

The 12-bit product is the concatenation:

\[AQ=111111100000_2\]

Its two’s-complement magnitude is 000000100000₂=32, so \(AQ=-32\), correctly equal to \(16\times(-2)\). Booth encoding is efficient here because the run of 1s in the negative multiplier requires only one subtraction.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

\(+16\) āĻ“ \(-2\) āĻĒā§āϰāĻ•āĻžāĻļ⧇āϰ āϜāĻ¨ā§āϝ 6-bit āύ⧇āĻ“āϝāĻŧāĻž āĻšāϞ⧋: M=010000, Q=111110, −M=110000; āĻļ⧁āϰ⧁āϤ⧇ A=000000, Q₋₁=0āĨ¤ Booth rule āĻ…āύ⧁āϝāĻžāϝāĻŧā§€ pair 01 āĻšāϞ⧇ A+M, 10 āĻšāϞ⧇ A−M, 00/11 āĻšāϞ⧇ āϕ⧋āύ⧋ arithmetic āύāϝāĻŧ; āϤāĻžāϰāĻĒāϰ combined (A,Q,Q₋₁) arithmetic right shift āĻšāϝāĻŧāĨ¤

āĻ›āϝāĻŧ cycle āĻļ⧇āώ⧇ A,Q = 111111 100000; āĻ…āĻ°ā§āĻĨāĻžā§Ž 12-bit product 111111100000₂āĨ¤ āĻāϰ two’s-complement magnitude 32, āϤāĻžāχ signed āĻĢāϞ \(-32\), āϝāĻž \(16\times(-2)\)-āĻāϰ āϏāĻ āĻŋāĻ• āĻŽāĻžāύāĨ¤ Multiplier-āĻ āϧāĻžāϰāĻžāĻŦāĻžāĻšāĻŋāĻ• 1 āĻĨāĻžāĻ•āĻžāϝāĻŧ Booth algorithm āĻ•āĻŽ addition/subtraction-āĻ āĻ•āĻžāϜāϟāĻŋ āĻ•āϰ⧇āĨ¤


27. Measuring Computer Performance

Enhanced question

Explain how computer performance is evaluated using execution time, clock rate, instruction count, CPI and MIPS. Derive the CPU-time equation and illustrate it with a numerical example.

The most reliable measure for one program is execution time. If clock rate is \(f\), clock-cycle time is \(1/f\). The fundamental equation is:

\[T_{CPU}=IC\times CPI\times T_{cycle} =\frac{IC\times CPI}{\text{Clock rate}}\]

where:

  • IC = dynamic instruction count;
  • CPI = average clock cycles per instruction;
  • clock rate = cycles per second.

Performance is \(1/T_{CPU}\). Speedup of machine X over Y is \(T_Y/T_X\).

MIPS means millions of instructions per second:

\[MIPS=\frac{\text{Clock rate}}{CPI\times10^6} =\frac{IC}{T_{CPU}\times10^6}\]

Example: A program executes \(600\) million instructions on a 3 GHz processor with CPI 1.5:

\[T_{CPU}=\frac{600\times10^6\times1.5}{3\times10^9}=0.3\text{ s}\]
\[MIPS=\frac{3\times10^9}{1.5\times10^6}=2000\text{ MIPS}\]

MIPS can be misleading across different ISAs because one ISA may complete more work per instruction. Clock rate alone is also insufficient: a higher-frequency processor may have higher CPI or execute more instructions. Real elapsed time on representative workloads is the final criterion.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

āĻāĻ•āϟāĻŋ program-āĻāϰ āϏāĻ°ā§āĻŦā§‹āĻ¤ā§āϤāĻŽ performance measure āĻšāϞ⧋ execution timeāĨ¤ āĻŽā§ŒāϞāĻŋāĻ• CPU equation:

\[T_{CPU}=\frac{IC\times CPI}{Clock\ Rate}\]

āĻāĻ–āĻžāύ⧇ IC dynamic instruction count, CPI āĻĒā§āϰāϤāĻŋ instruction-āĻāϰ āĻ—āĻĄāĻŧ cycle āĻāĻŦāĻ‚ clock rate āĻĒā§āϰāϤāĻŋ second-āĻāϰ cycleāĨ¤ Performance \(1/T_{CPU}\), āφāϰ speedup āĻšāϞ⧋ āĻĒ⧁āϰ⧋āύ⧋ āĻ“ āύāϤ⧁āύ execution time-āĻāϰ āĻ…āύ⧁āĻĒāĻžāϤāĨ¤

MIPS \(=\frac{Clock\ rate}{CPI\times10^6}\)āĨ¤ āωāĻĻāĻžāĻšāϰāϪ⧇ 600 million instruction, 3 GHz āĻāĻŦāĻ‚ CPI 1.5 āĻšāϞ⧇ CPU time 0.3 s āĻāĻŦāĻ‚ 2000 MIPSāĨ¤ āϤāĻŦ⧇ āĻ­āĻŋāĻ¨ā§āύ ISA-āϤ⧇ instruction-āĻāϰ āĻ•āĻžāĻœā§‡āϰ āĻĒāϰāĻŋāĻŽāĻžāĻŖ āĻ­āĻŋāĻ¨ā§āύ āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ MIPS āĻŦāĻŋāĻ­ā§āϰāĻžāĻ¨ā§āϤāĻŋāĻ•āϰ āĻšāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ āĻāĻ•āχāĻ­āĻžāĻŦ⧇ āĻļ⧁āϧ⧁ clock rate āĻĻāĻŋāϝāĻŧ⧇āĻ“ performance āĻŦāĻŋāϚāĻžāϰ āĻ•āϰāĻž āϝāĻžāϝāĻŧ āύāĻž; representative program-āĻāϰ āĻĒā§āϰāĻ•ā§ƒāϤ execution time āϤ⧁āϞāύāĻž āĻ•āϰāϤ⧇ āĻšāϝāĻŧāĨ¤


28. Comparative Performance of P1, P2 and P3

Enhanced question

For processors P1 (3 GHz, CPI 1.5), P2 (2.5 GHz, CPI 1.0) and P3 (4 GHz, CPI 2.5), calculate instruction rate, cycles and instruction count for a 12-second execution. Then determine the clock rate required for each processor to reduce execution time by 25% when CPI rises by 15%.

(i) Instructions per second

\[IPS=\frac{Clock\ rate}{CPI}\]
Processor Calculation Instruction rate
P1 \(3/1.5\) \(2.0\times10^9\) instr/s
P2 \(2.5/1.0\) \(2.5\times10^9\) instr/s
P3 \(4/2.5\) \(1.6\times10^9\) instr/s

P2 has the highest instruction rate.

(ii) Cycles and instructions in 12 seconds

\[Cycles=T\times Clock\ rate,\qquad IC=\frac{Cycles}{CPI}\]
Processor Cycles in 12 s Instructions
P1 \(12\times3=36\) billion \(36/1.5=24\) billion
P2 \(12\times2.5=30\) billion \(30/1.0=30\) billion
P3 \(12\times4=48\) billion \(48/2.5=19.2\) billion

(iii) New clock rate

The same program has the same instruction count. Required time:

\[T_{new}=0.75T_{old}\]

and

\[CPI_{new}=1.15CPI_{old}\]

Using \(T=IC\times CPI/f\):

\[f_{new}=f_{old}\times\frac{1.15}{0.75} =1.5333f_{old}\]
Processor Required rate
P1 \(3\times1.5333=\mathbf{4.60\ GHz}\)
P2 \(2.5\times1.5333=\mathbf{3.833\ GHz}\)
P3 \(4\times1.5333=\mathbf{6.133\ GHz}\)

Although execution time is reduced by only 25%, the clock must rise by 53.33% because the 15% CPI increase works against the improvement.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Instruction rate āĻšāϞ⧋ clock rate/CPIāĨ¤ āϤāĻžāχ P1 = 2.0 billion, P2 = 2.5 billion āĻāĻŦāĻ‚ P3 = 1.6 billion instruction/s; āϏāĻ°ā§āĻŦā§‹āĻšā§āϚ P2āĨ¤

12 second-āĻ cycle āϏāĻ‚āĻ–ā§āϝāĻž \(T\times f\): P1 = 36 billion, P2 = 30 billion, P3 = 48 billionāĨ¤ CPI āĻĻāĻŋāϝāĻŧ⧇ āĻ­āĻžāĻ— āĻ•āϰāϞ⧇ instruction count āϝāĻĨāĻžāĻ•ā§āϰāĻŽā§‡ 24 billion, 30 billion āĻāĻŦāĻ‚ 19.2 billionāĨ¤

āύāϤ⧁āύ time āĻĒ⧁āϰ⧋āύ⧋āϰ 75% āĻāĻŦāĻ‚ CPI āĻĒ⧁āϰ⧋āύ⧋āϰ 115%āĨ¤ āĻāĻ•āχ instruction count āϧāϰ⧇:

\[f_{new}=f_{old}\times\frac{1.15}{0.75}=1.5333f_{old}\]

āϤāĻžāχ P1-āĻāϰ 4.60 GHz, P2-āĻāϰ 3.833 GHz āĻāĻŦāĻ‚ P3-āĻāϰ 6.133 GHz āĻĻāϰāĻ•āĻžāϰāĨ¤ CPI āĻŦ⧇āĻĄāĻŧ⧇ āϝāĻžāĻ“āϝāĻŧāĻžāϰ āύ⧇āϤāĻŋāĻŦāĻžāϚāĻ• āĻĒā§āϰāĻ­āĻžāĻŦ āĻ•āĻžāϟāĻžāϤ⧇ clock rate āĻŽā§‹āϟ 53.33% āĻŦāĻžāĻĄāĻŧāĻžāϤ⧇ āĻšāϝāĻŧāĨ¤


Part E — Parallelism and Memory

29. Flynn’s Classification of Parallel Hardware

Enhanced question

Explain Flynn’s taxonomy of computer organizations in detail. Compare SISD, SIMD, MISD and MIMD according to instruction and data streams, execution model, applications and examples.

Figure: Flynn taxonomy

Flynn’s Classification

Michael Flynn classified computers by the number of simultaneous instruction streams and data streams.

Class Instruction streams Data streams Description and examples
SISD 1 1 One processor executes one instruction sequence on one data sequence. Traditional scalar uniprocessor; simple microcontroller. Internal pipelining does not necessarily change its Flynn class.
SIMD 1 Many One control unit applies the same operation to many data elements in parallel. Vector processors, GPU warps conceptually, multimedia vector extensions and image-processing arrays.
MISD Many 1 Different operations process the same data stream. Rare as a general-purpose machine; fault-tolerant redundant pipelines and certain systolic/stream-processing interpretations are cited.
MIMD Many Many Independent processors execute different instruction streams on different data. Multicore CPUs, multiprocessor servers, clusters and cloud systems.

MIMD is further divided into:

  • Shared-memory systems: processors communicate through a common address space. Uniform-memory-access (UMA) and non-uniform-memory-access (NUMA) machines are examples.
  • Distributed-memory systems: each node has private memory and communicates using messages, as in a cluster.

SIMD is efficient when the same computation is applied to large arrays, but branch divergence and irregular memory access reduce utilization. MIMD handles diverse and independent tasks but needs synchronization, communication and consistency control. Flynn’s taxonomy describes stream organization; it does not alone describe memory hierarchy or performance.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Flynn taxonomy āĻāĻ•āχ āϏāĻŽāϝāĻŧ⧇ instruction stream āĻ“ data stream-āĻāϰ āϏāĻ‚āĻ–ā§āϝāĻžāϰ āĻ­āĻŋāĻ¤ā§āϤāĻŋāϤ⧇ hardware āĻļā§āϰ⧇āĻŖāĻŋāĻŦāĻĻā§āϧ āĻ•āϰ⧇āĨ¤

  • SISD: āĻāĻ•āϟāĻŋ instruction stream āĻāĻ•āϟāĻŋ data stream-āĻāϰ āĻ“āĻĒāϰ āϚāϞ⧇; traditional scalar processor āĻŦāĻž microcontrollerāĨ¤
  • SIMD: āĻāĻ•āϟāĻŋ instruction āĻŦāĻšā§ data element-āĻāϰ āĻ“āĻĒāϰ āĻāĻ•āϏāĻ™ā§āϗ⧇ āĻĒā§āϰāϝāĻŧā§‹āĻ— āĻšāϝāĻŧ; vector processor, GPU āĻāĻŦāĻ‚ image-processing arrayāĨ¤
  • MISD: āĻŦāĻšā§ instruction āĻāĻ•āχ data stream āĻĒā§āϰāĻ•ā§āϰāĻŋāϝāĻŧāĻž āĻ•āϰ⧇; āϏāĻžāϧāĻžāϰāĻŖ-purpose system-āĻ āĻŦāĻŋāϰāϞ, fault-tolerant redundant pipeline-āĻ āϧāĻžāϰāĻŖāĻžāϟāĻŋ āĻĻ⧇āĻ–āĻž āϝāĻžāϝāĻŧāĨ¤
  • MIMD: āĻ¸ā§āĻŦāĻžāϧ⧀āύ processor āĻ­āĻŋāĻ¨ā§āύ instruction āĻ“ āĻ­āĻŋāĻ¨ā§āύ data āύāĻŋāϝāĻŧ⧇ āĻ•āĻžāϜ āĻ•āϰ⧇; multicore CPU, multiprocessor server āĻ“ clusterāĨ¤

MIMD shared-memory UMA/NUMA āĻ…āĻĨāĻŦāĻž message-passing distributed-memory āĻšāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤ SIMD regular array computation-āĻ āĻ•āĻžāĻ°ā§āϝāĻ•āϰ, āĻ•āĻŋāĻ¨ā§āϤ⧁ divergent branch āĻ“ irregular memory access efficiency āĻ•āĻŽāĻžāϝāĻŧāĨ¤ MIMD flexible, āϤāĻŦ⧇ synchronization, communication āĻāĻŦāĻ‚ memory consistency āĻĻāϰāĻ•āĻžāϰāĨ¤


30. Cache Memory, Hit, Miss and Miss Penalty

Enhanced question

Define cache memory and explain locality, cache hit, cache miss, hit rate, miss rate and miss penalty. Derive average memory access time and solve a numerical example.

Cache memory is a small, fast memory placed between the CPU and slower main memory. It keeps copies of recently or nearby used memory blocks. Its success depends on:

  • Temporal locality: recently accessed data is likely to be reused.
  • Spatial locality: nearby addresses are likely to be accessed.

A cache hit occurs when the requested block is found in cache. A cache miss occurs when it is absent and must be obtained from the next memory level. Miss penalty is the additional time to fetch, install and deliver the missing block. If \(h\) is hit rate, miss rate is \(1-h\).

\[AMAT=Hit\ time+Miss\ rate\times Miss\ penalty\]

Example: hit time = 1 ns, hit rate = 95%, miss penalty = 60 ns:

\[AMAT=1+0.05\times60=4\text{ ns}\]

Misses are often described as compulsory (first access), capacity (working set too large) and conflict (mapping collision). Larger blocks can exploit spatial locality but increase transfer cost and may cause pollution. Cache performance therefore depends on size, block size, associativity, replacement and write policy.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Cache memory CPU āĻ“ āϤ⧁āϞāύāĻžāĻŽā§‚āϞāĻ• āϧ⧀āϰ main memory-āĻāϰ āĻŽāĻžāĻā§‡āϰ āϛ⧋āϟ āĻ“ āĻĻā§āϰ⧁āϤ memory, āϝāĻž āϏāĻŽā§āĻĒā§āϰāϤāĻŋ āĻŦāĻž āĻ•āĻžāĻ›āĻžāĻ•āĻžāĻ›āĻŋ āĻŦā§āϝāĻŦāĻšā§ƒāϤ block-āĻāϰ copy āϰāĻžāϖ⧇āĨ¤ Temporal locality āĻ…āύ⧁āϝāĻžāϝāĻŧā§€ āϏāĻžāĻŽā§āĻĒā§āϰāϤāĻŋāĻ• data āφāĻŦāĻžāϰ āĻŦā§āϝāĻŦāĻšā§ƒāϤ āĻšāϤ⧇ āĻĒāĻžāϰ⧇; spatial locality āĻ…āύ⧁āϝāĻžāϝāĻŧā§€ āĻ•āĻžāĻ›āĻžāĻ•āĻžāĻ›āĻŋ address āĻŦā§āϝāĻŦāĻšāĻžāϰ⧇āϰ āϏāĻŽā§āĻ­āĻžāĻŦāύāĻž āĻĨāĻžāϕ⧇āĨ¤

Requested block cache-āĻ āĻĨāĻžāĻ•āϞ⧇ hit, āύāĻž āĻĨāĻžāĻ•āϞ⧇ missāĨ¤ Miss āĻšāϞ⧇ āύāĻŋāĻšā§‡āϰ memory level āĻĨ⧇āϕ⧇ block āĻāύ⧇ cache-āĻ āĻŦāϏāĻŋāϝāĻŧ⧇ CPU-āϤ⧇ āĻĻāĻŋāϤ⧇ āϝ⧇ āĻ…āϤāĻŋāϰāĻŋāĻ•ā§āϤ āϏāĻŽāϝāĻŧ āϞāĻžāϗ⧇ āϤāĻž miss penaltyāĨ¤ \(AMAT=Hit\ time+Miss\ rate\times Miss\ penalty\)āĨ¤ Hit time 1 ns, hit rate 95% āĻāĻŦāĻ‚ penalty 60 ns āĻšāϞ⧇ AMAT \(=1+0.05\times60=4\) nsāĨ¤ Miss compulsory, capacity āĻŦāĻž conflict āϧāϰāύ⧇āϰ āĻšāϤ⧇ āĻĒāĻžāϰ⧇āĨ¤


31. Write-Through and Write-Back Cache Policies

Enhanced question

Explain and compare write-through and write-back cache policies. Include write-hit and write-miss behavior, the role of write buffers and dirty bits, and the advantages and disadvantages of each.

Write-through

Every cache write is also sent immediately to the next memory level. A write buffer allows the CPU to continue while the lower-level write completes.

Advantages:

  • cache and lower memory remain consistent;
  • simple replacement because a cache block is never dirty;
  • easier I/O coherence and recovery.

Disadvantages:

  • high memory/bus write traffic;
  • repeated writes to the same block all reach lower memory;
  • CPU may stall if the write buffer becomes full.

Write-back

A write updates only the cache and sets the block’s dirty bit. The block is written to the next level only when evicted.

Advantages:

  • multiple writes are combined into one lower-level transfer;
  • lower bandwidth and usually better performance/energy.

Disadvantages:

  • more complex control, coherence and recovery;
  • dirty eviction has an additional penalty;
  • lower memory may temporarily contain stale data.

On a write miss, a cache may use write-allocate (fetch the block, then write it) or no-write-allocate/write-around (write lower memory without filling the cache). Write-back commonly pairs with write-allocate; write-through often pairs with no-write-allocate, although other combinations are possible.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Write-through-āĻ cache write-āĻāϰ āϏāĻ™ā§āϗ⧇ āϏāĻ™ā§āϗ⧇ lower memory-āϤ⧇āĻ“ write āĻĒāĻžāĻ āĻžāύ⧋ āĻšāϝāĻŧāĨ¤ Write buffer latency āφāĻĄāĻŧāĻžāϞ āĻ•āϰ⧇āĨ¤ āĻāϤ⧇ memory consistent āĻĨāĻžāϕ⧇ āĻāĻŦāĻ‚ replacement āϏāĻšāϜ, āĻ•āĻŋāĻ¨ā§āϤ⧁ bus traffic āĻŦ⧇āĻļāĻŋ āĻšāϝāĻŧ āĻ“ buffer āĻĒā§‚āĻ°ā§āĻŖ āĻšāϞ⧇ stall āϞāĻžāϗ⧇āĨ¤

Write-back-āĻ āĻĒā§āϰāĻĨāĻŽā§‡ āĻļ⧁āϧ⧁ cache update āĻšāϝāĻŧ āĻāĻŦāĻ‚ dirty bit set āĻšāϝāĻŧ; block evict āĻšāϞ⧇ lower memory-āϤ⧇ āϞ⧇āĻ–āĻž āĻšāϝāĻŧāĨ¤ āĻāϤ⧇ āĻāĻ•āχ block-āĻāϰ āĻŦāĻšā§ write āĻāĻ• transfer-āĻ āĻŽāĻŋāϞāĻŋāϝāĻŧ⧇ bandwidth āĻ“ energy āϏāĻžāĻļā§āϰāϝāĻŧ āĻšāϝāĻŧāĨ¤ āϤāĻŦ⧇ dirty eviction penalty, coherence, recovery āĻāĻŦāĻ‚ control complexity āĻŦāĻžāĻĄāĻŧ⧇; lower memory āϏāĻžāĻŽāϝāĻŧāĻŋāĻ•āĻ­āĻžāĻŦ⧇ stale āĻĨāĻžāϕ⧇āĨ¤

Write miss-āĻ write-allocate block cache-āĻ āĻāύ⧇ write āĻ•āϰ⧇; no-write-allocate lower memory-āϤ⧇ āϏāϰāĻžāϏāϰāĻŋ write āĻ•āϰ⧇āĨ¤ āϏāĻžāϧāĻžāϰāĻŖāϤ write-back-āĻāϰ āϏāĻ™ā§āϗ⧇ write-allocate āĻāĻŦāĻ‚ write-through-āĻāϰ āϏāĻ™ā§āϗ⧇ no-write-allocate āĻĻ⧇āĻ–āĻž āϝāĻžāϝāĻŧāĨ¤


32. RTL for addu, addi, lw, sw and beq

Enhanced question

Write and explain the Register Transfer Logic (RTL) for the MIPS instructions addu, addi, lw, sw and beq, including common instruction fetch and effective-address/branch calculations.

Let R[x] denote register contents and M[x] a 32-bit memory word. Common fetch:

IR ← M[PC]
PC ← PC + 4

Instruction-specific RTL:

Instruction RTL
addu rd,rs,rt R[rd] ← R[rs] + R[rt] (32-bit addition, no overflow exception)
addi rt,rs,imm R[rt] ← R[rs] + SignExt(imm16) (signed overflow may trap)
lw rt,imm(rs) EA ← R[rs] + SignExt(imm16); R[rt] ← M[EA]
sw rt,imm(rs) EA ← R[rs] + SignExt(imm16); M[EA] ← R[rt]
beq rs,rt,imm if R[rs]=R[rt], PC ← PC + (SignExt(imm16) << 2)

In the beq expression, PC has already been advanced by four in the fetch step. The left shift multiplies the signed word offset by four to form a byte displacement. lw/sw require an aligned effective address in classic MIPS for a normal word access.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Common fetch-āĻ IR←M[PC] āĻāĻŦāĻ‚ PC←PC+4āĨ¤ addu āĻĻ⧁āχ source register āϝ⧋āĻ— āĻ•āϰ⧇ rd-āϤ⧇ āϞ⧇āϖ⧇ āĻāĻŦāĻ‚ overflow exception āĻĻ⧇āϝāĻŧ āύāĻžāĨ¤ addi sign-extended 16-bit immediate register-āĻāϰ āϏāĻ™ā§āϗ⧇ āϝ⧋āĻ— āĻ•āϰ⧇ rt-āϤ⧇ āϞ⧇āϖ⧇āĨ¤ lw/sw āĻĒā§āϰāĻĨāĻŽā§‡ \(EA=R[rs]+SignExt(imm)\) āϤ⧈āϰāĻŋ āĻ•āϰ⧇; lw memory word rt-āϤ⧇ āφāύ⧇, sw rt-āĻāϰ āĻŽāĻžāύ memory-āϤ⧇ āϞ⧇āϖ⧇āĨ¤ beq-āϤ⧇ register āϏāĻŽāĻžāύ āĻšāϞ⧇ already advanced PC-āĻāϰ āϏāĻ™ā§āϗ⧇ sign-extended immediate āĻĻ⧁āχ bit shift āĻ•āϰ⧇ āϝ⧋āĻ— āĻ•āϰāĻž āĻšāϝāĻŧāĨ¤ āĻāχ shift word offset-āϕ⧇ byte displacement-āĻ āϰ⧂āĻĒāĻžāĻ¨ā§āϤāϰ āĻ•āϰ⧇āĨ¤


33. Basic Connection of Memory to the Processor

Enhanced question

Describe the basic electrical and logical connection between processor and memory. Explain the roles of MAR, MDR, address/data/control buses and the read/write timing sequence.

Figure: processor–memory interface

Basic Processor–Memory Connection

The processor communicates with memory through an address path, a data path and control signals. MAR or an address latch holds the requested address; MDR or a data buffer holds the word being transferred.

Read sequence:

  1. CPU places an address on the address bus.
  2. It asserts Memory Read and appropriate byte enables.
  3. Memory decodes the address, selects a row/column and drives data.
  4. Ready/valid indicates completion; CPU captures data in MDR/register.

Write sequence:

  1. CPU places address and write data on their buses.
  2. It asserts Memory Write and byte enables.
  3. Selected memory cells store the data.
  4. Memory acknowledges completion.

The address bus is usually processor-to-memory; the data bus is bidirectional; control lines coordinate direction, timing and transfer size. Modern CPUs normally connect to caches and an integrated memory controller rather than raw DRAM. The controller schedules DRAM commands, refresh and multiple outstanding requests.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Processor address, data āĻ“ control path āĻĻāĻŋāϝāĻŧ⧇ memory-āĻāϰ āϏāĻ™ā§āϗ⧇ āϝ⧋āĻ—āĻžāϝ⧋āĻ— āĻ•āϰ⧇āĨ¤ MAR requested address āĻāĻŦāĻ‚ MDR transferred data āϧāϰ⧇āĨ¤ Read-āĻāϰ āϏāĻŽāϝāĻŧ CPU address āĻ“ Read signal āĻĻ⧇āϝāĻŧ; memory address decode āĻ•āϰ⧇ data bus-āĻ word āϰāĻžāϖ⧇; Ready/valid signal āĻĒ⧇āϞ⧇ CPU data āĻ—ā§āϰāĻšāĻŖ āĻ•āϰ⧇āĨ¤ Write-āĻāϰ āϏāĻŽāϝāĻŧ CPU address āĻ“ data āĻĻ⧇āϝāĻŧ, Write āĻ“ byte-enable assert āĻ•āϰ⧇, memory selected cell update āĻ•āϰ⧇ āĻāĻŦāĻ‚ completion āϜāĻžāύāĻžāϝāĻŧāĨ¤

Address bus āϏāĻžāϧāĻžāϰāĻŖāϤ CPU āĻĨ⧇āϕ⧇ memory-āϰ āĻĻāĻŋāϕ⧇; data bus bidirectional; control bus direction, timing āĻ“ transfer size āϏāĻŽāĻ¨ā§āĻŦāϝāĻŧ āĻ•āϰ⧇āĨ¤ āφāϧ⧁āύāĻŋāĻ• CPU āϏāϰāĻžāϏāϰāĻŋ raw DRAM āύāϝāĻŧ, cache āĻ“ memory controller-āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ āϝ⧁āĻ•ā§āϤ āĻšāϝāĻŧ; controller DRAM command, refresh āĻ“ concurrent request āĻĒāϰāĻŋāϚāĻžāϞāύāĻž āĻ•āϰ⧇āĨ¤


34. Internal Organization of Bit Cells in a Memory Chip

Enhanced question

Explain the internal organization of memory bit cells into rows, columns and arrays. Compare SRAM and DRAM cells and describe row decoding, column selection, sense amplification and read/write operation.

Figure: memory-chip organization

Internal Organization of a Memory Chip

Memory cells are arranged as a rectangular array. A row decoder activates one word line. Cells on that row connect to vertical bit lines. Sense amplifiers detect small read signals, and a column decoder/multiplexer selects the bits forming the external word.

SRAM cell: Commonly a six-transistor bistable latch plus access transistors. It retains data while powered, needs no refresh and reads quickly, but occupies more area and costs more per bit. SRAM is used for caches.

DRAM cell: Commonly one transistor and one capacitor. Charge represents a bit. It is dense and inexpensive, but charge leaks and requires refresh. Reading is destructive in the sense that the small charge must be sensed and restored. DRAM is used for main memory.

For a read, precharged bit lines are connected to the selected cells; sense amplifiers detect and amplify the difference. For a write, write drivers force bit-line values while the word line is active. Large chips use multiple banks and hierarchical decoders to reduce delay and allow overlapping operations.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Memory bit cell row āĻ“ column-āĻāϰ rectangular array-āϤ⧇ āϏāĻžāϜāĻžāύ⧋ āĻĨāĻžāϕ⧇āĨ¤ Row decoder āĻāĻ•āϟāĻŋ word line āϏāĻ•ā§āϰāĻŋāϝāĻŧ āĻ•āϰ⧇; selected cell bit line-āĻāϰ āϏāĻ™ā§āϗ⧇ āϝ⧁āĻ•ā§āϤ āĻšāϝāĻŧāĨ¤ Sense amplifier āĻ•ā§āώ⧁āĻĻā§āϰ voltage difference āĻļāύāĻžāĻ•ā§āϤ āĻ“ amplify āĻ•āϰ⧇; column decoder/multiplexer external word-āĻāϰ bit āύāĻŋāĻ°ā§āĻŦāĻžāϚāύ āĻ•āϰ⧇āĨ¤

SRAM āϏāĻžāϧāĻžāϰāĻŖāϤ six-transistor bistable cell; power āĻĨāĻžāĻ•āϞ⧇ refresh āĻ›āĻžāĻĄāĻŧāĻž data āϧāϰ⧇, āĻĻā§āϰ⧁āϤ āĻ•āĻŋāĻ¨ā§āϤ⧁ area āĻ“ cost āĻŦ⧇āĻļāĻŋ—āϤāĻžāχ cache-āĻ āĻŦā§āϝāĻŦāĻšā§ƒāϤāĨ¤ DRAM āϏāĻžāϧāĻžāϰāĻŖāϤ one-transistor/one-capacitor cell; dense āĻ“ āϏāĻ¸ā§āϤāĻž, āĻ•āĻŋāĻ¨ā§āϤ⧁ charge leak āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ refresh āĻĻāϰāĻ•āĻžāϰ āĻāĻŦāĻ‚ read-āĻāϰ āĻĒāϰ data restore āĻ•āϰāϤ⧇ āĻšāϝāĻŧ—āϤāĻžāχ main memory-āϤ⧇ āĻŦā§āϝāĻŦāĻšā§ƒāϤāĨ¤ āĻŦāĻĄāĻŧ chip āĻŦāĻšā§ bank āĻ“ hierarchical decoder āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰ⧇ delay āĻ•āĻŽāĻžāϝāĻŧāĨ¤


35. Design a \(2M\times32\) Module from \(512K\times8\) SRAM Chips

Enhanced question

Design a \(2M\times32\)-bit memory module using \(512K\times8\)-bit SRAM chips. Calculate the number of chips and banks, show address decoding and data-bus connections, and state total capacity.

Required organization: \(2M\) words × 32 bits.
One chip: \(512K\) words × 8 bits.

1. Width expansion

\[\frac{32}{8}=4\text{ chips in parallel per bank}\]

The four chips provide data bytes D7–D0, D15–D8, D23–D16 and D31–D24.

2. Depth expansion

\[\frac{2M}{512K}=4\text{ banks}\]

3. Total chips

\[4\text{ chips/bank}\times4\text{ banks}=\boxed{16\text{ chips}}\]

A \(2M=2^{21}\)-word module needs 21 address lines A20â€ĻA0. Each \(512K=2^{19}\)-word chip receives A18â€ĻA0. The high-order lines A20,A19 feed a 2-to-4 decoder; one decoder output enables each bank. OE and WE may be common, but only the selected bank’s chip-enable is active.

Figure: bank organization

2M×32 Module Using 512K×8 SRAM Chips

Total capacity:

\[2^{21}\times32=2^{26}\text{ bits}=64\text{ Mibits}=8\text{ MiB}\]

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

āĻāĻ•āϟāĻŋ chip 512K×8; module āĻĻāϰāĻ•āĻžāϰ 2M×32āĨ¤ Width 32 āĻ•āϰāĻžāϰ āϜāĻ¨ā§āϝ āĻĒā§āϰāϤāĻŋ bank-āĻ \(32/8=4\)āϟāĻŋ chip parallel āϞāĻžāĻ—āĻŦ⧇āĨ¤ Depth \(2M/512K=4\), āϤāĻžāχ 4āϟāĻŋ bankāĨ¤ āĻŽā§‹āϟ chip \(4\times4=16\)āĨ¤

2M=2²š word āĻšāĻ“āϝāĻŧāĻžāϝāĻŧ module address line 21āϟāĻŋ (A20â€ĻA0)āĨ¤ āĻĒā§āϰāϤāĻŋāϟāĻŋ chip-āĻ 512K=2š⁚ location, āϤāĻžāχ A18â€ĻA0 āϏāĻŦ chip-āĻ common āϝāĻžāϝāĻŧāĨ¤ āωāĻĒāϰ⧇āϰ A20,A19 āĻāĻ•āϟāĻŋ 2-to-4 decoder-āĻ āĻ—āĻŋāϝāĻŧ⧇ āĻāĻ•āϟāĻŋ bank select āĻ•āϰ⧇āĨ¤ Selected bank-āĻāϰ āϚāĻžāϰ chip 32-bit data bus-āĻāϰ āϚāĻžāϰāϟāĻŋ byte lane āϚāĻžāϞāĻžāϝāĻŧāĨ¤ āĻŽā§‹āϟ capacity \(2^{21}\times32=64\) Mibit = 8 MiBāĨ¤


36. Virtual Memory and the Need for Mapping Functions

Enhanced question

Define virtual memory and explain address translation using pages, frames, page tables and the TLB. Then explain why a mapping function is required in cache memory and compare direct, associative and set-associative mapping.

Virtual memory gives each process a large, private, contiguous virtual address space even though physical memory is smaller and shared. A virtual address is divided into a virtual page number (VPN) and page offset. The page table maps the VPN to a physical frame number; the offset is unchanged. A TLB caches recent translations. If a valid translation is absent from the page table because the page is not resident, a page fault allows the OS to bring it from secondary storage.

Benefits include protection, process isolation, relocation, controlled sharing and demand paging.

Cache memory is much smaller than main memory, so a mapping function is required to determine where a main-memory block may be placed and how it will be found:

Mapping Placement Main property
Direct mapped One line: line = block mod number_of_lines Fast and cheap, but conflict misses can be high
Fully associative Any cache line Fewest placement conflicts, but expensive parallel tag search
Set associative Any line in one set: set = block mod number_of_sets Compromise between cost and conflicts

A cache address is interpreted using tag, index/set and block-offset fields. The index selects candidate line(s); stored tag(s) determine whether the desired block is present; offset selects the requested byte/word.

Virtual-memory mapping and cache mapping solve related but distinct problems: page translation maps a process’s virtual page to a physical frame, while cache mapping places a memory block in a limited on-chip cache. Their interaction leads to physically indexed/tagged, virtually indexed/tagged or VIPT cache designs, each with timing and aliasing trade-offs.

āĻŦāĻžāĻ‚āϞāĻž āωāĻ¤ā§āϤāϰ

Virtual memory āĻĒā§āϰāϤāĻŋāϟāĻŋ process-āϕ⧇ āĻŦāĻĄāĻŧ, private āĻ“ āϧāĻžāϰāĻžāĻŦāĻžāĻšāĻŋāĻ• virtual address space āĻĻ⧇āϝāĻŧ, āϝāĻĻāĻŋāĻ“ physical memory āϛ⧋āϟ āĻ“ sharedāĨ¤ Virtual address-āĻāϰ VPN page table-āĻāϰ āĻŽāĻžāĻ§ā§āϝāĻŽā§‡ physical frame number-āĻ translate āĻšāϝāĻŧ; page offset āĻ…āĻĒāϰāĻŋāĻŦāĻ°ā§āϤāĻŋāϤ āĻĨāĻžāϕ⧇āĨ¤ TLB āϏāĻžāĻŽā§āĻĒā§āϰāϤāĻŋāĻ• translation cache āĻ•āϰ⧇āĨ¤ Page memory-āϤ⧇ āύāĻž āĻĨāĻžāĻ•āϞ⧇ page fault āĻšāϝāĻŧ āĻāĻŦāĻ‚ OS secondary storage āĻĨ⧇āϕ⧇ āϤāĻž āφāύ⧇āĨ¤ āĻāϤ⧇ protection, isolation, relocation, sharing āĻ“ demand paging āϏ⧁āĻŦāĻŋāϧāĻž āĻĒāĻžāĻ“āϝāĻŧāĻž āϝāĻžāϝāĻŧāĨ¤

Cache main memory-āĻāϰ āĻšā§‡āϝāĻŧ⧇ āϛ⧋āϟ, āϤāĻžāχ memory block cache-āĻāϰ āϕ⧋āĻĨāĻžāϝāĻŧ āĻĨāĻžāĻ•āĻŦ⧇ āϤāĻž āύāĻŋāĻ°ā§āϧāĻžāϰāϪ⧇ mapping function āĻĻāϰāĻ•āĻžāϰāĨ¤ Direct mapping-āĻ block-āĻāϰ āĻāĻ•āϟāĻŋāĻŽāĻžāĻ¤ā§āϰ line; fully associative-āĻ āϝ⧇āϕ⧋āύ⧋ line; set-associative-āĻ āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ set-āĻāϰ āϝ⧇āϕ⧋āύ⧋ way āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻ•āϰāĻž āϝāĻžāϝāĻŧāĨ¤ Address-āĻāϰ index candidate set āύāĻŋāĻ°ā§āĻŦāĻžāϚāύ āĻ•āϰ⧇, tag block āĻŽāĻŋāϞāĻŋāϝāĻŧ⧇ āĻĻ⧇āϖ⧇ āĻāĻŦāĻ‚ offset āύāĻŋāĻ°ā§āĻĻāĻŋāĻˇā§āϟ byte/word āĻŦ⧇āϛ⧇ āύ⧇āϝāĻŧāĨ¤

Virtual-memory mapping virtual page-āϕ⧇ physical frame-āĻ āĻ…āύ⧁āĻŦāĻžāĻĻ āĻ•āϰ⧇; cache mapping physical/virtual memory block-āϕ⧇ āϏ⧀āĻŽāĻŋāϤ cache line-āĻ āĻ¸ā§āĻĨāĻžāĻĒāύ āĻ•āϰ⧇āĨ¤ āĻĻ⧁āχāϟāĻŋ āϏāĻŽā§āĻĒāĻ°ā§āĻ•āĻŋāϤ āĻšāϞ⧇āĻ“ āĻāĻ•āχ āĻ•āĻžāϜ āύāϝāĻŧāĨ¤


Final Exam-Writing Checklist

For a strong 20-mark answer:

  1. Write the enhanced definition/introduction first.
  2. Draw the diagram before the long explanation and label every path.
  3. Use a comparison table where the question asks for differences.
  4. State assumptions, especially notation, word size, signedness and addressing mode.
  5. Show formulas before substituting numerical values.
  6. Preserve leading zeros in binary arithmetic.
  7. End with a one- or two-sentence result/conclusion.

āĻŦāĻžāĻ‚āϞāĻžāϝāĻŧ āϞāĻŋāĻ–āϞ⧇āĻ“ standard technical terms—āϝ⧇āĻŽāύ datapath, control signal, cache miss, forwarding, CPI, ISA—English-āĻ āϰāĻžāĻ–āϞ⧇ āωāĻ¤ā§āϤāϰ āĻŦ⧇āĻļāĻŋ āύāĻŋāĻ°ā§āϭ⧁āϞ āĻ“ āĻĒāĻžāĻ ā§āϝāĻŦāχāϏāĻŽā§āĻŽāϤ āĻšāϝāĻŧāĨ¤ Diagram-āĻāϰ label-āĻ“ English-āĻ āϰāĻžāĻ–āϞ⧇ āĻĒāϰ⧀āĻ•ā§āώāϕ⧇āϰ āĻ•āĻžāϛ⧇ āϏāĻšāĻœā§‡ āĻŦā§‹āϧāĻ—āĻŽā§āϝ āĻšāĻŦ⧇āĨ¤


End of answer bank