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¶
- Classes of computers
- Layers of computer system architecture
- Throughput and response time
- Basic functional units of a computer
- Bus structure of a processor
- Instruction Set Architecture and MIPS formats
- RISC versus CISC
Part B â Instructions, ISA, Datapath and Control¶
- Execution of
Load R2, LOC - Characteristics of a RISC processor
- Three-bus CISC-style processor organization
- Execution of
Add (R3), R1 - MIPS addressing modes
- MIPS code for two C statements
- Compilation of a C program
- General addressing modes
- Instruction and its computer representation
- Processor datapath
- Datapath control signals
- Dynamic scheduling
- Microprogrammed control for a branch
- Purpose of the control unit
- Word, address and memory access time
Part C â Pipelining and Hazards¶
- Pipeline performance
- Ideal pipelined operation
- Pipeline issues
- Operand forwarding
- Datapath modification for forwarding
- Data hazards and their performance effects
Part D â Computer Arithmetic and Performance¶
- Multiplication algorithm and hardware
- Binary division
- IEEE 754 representation of â0.625
- Four-bit binary multiplier
- Booth multiplication: 16 Ã (â2)
- Measuring computer performance
- Comparative processor-performance problem
Part E â Parallelism and Memory¶
- Flynnâs classification
- Cache memory, hit, miss and miss penalty
- Write-through and write-back
- RTL for selected MIPS instructions
- Processorâmemory connection
- Internal organization of memory bit cells
- Design of a 2MÃ32 memory module
- 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¶
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.
- Application layer: Contains programs that solve usersâ problems, such as browsers, word processors and database systems.
- High-level language and library layer: Programmers express algorithms using C, C++, Java or libraries. Compilers translate this representation toward the ISA.
- Operating-system layer: Manages processes, memory, files, security and I/O devices. It provides system calls and makes hardware resources appear orderly and shareable.
- 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.
- 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.
- Digital-logic layer: Implements the microarchitecture using gates, adders, decoders, multiplexers, registers and state machines.
- 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:
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:
Throughput (bandwidth) is the number of tasks completed per unit 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 āĻšāϞ⧠āĻāĻāĻāĻŋ āĻāĻžāĻ āĻāĻŽāĻž āĻĻā§āĻāϝāĻŧāĻž āĻĨā§āĻā§ āĻĢāϞ āĻĒāĻžāĻāϝāĻŧāĻž āĻĒāϰā§āϝāύā§āϤ āĻŽā§āĻ āϏāĻŽāϝāĻŧ:
āĻāϰ āĻŽāϧā§āϝ⧠CPU execution, memory/I/O wait, OS overhead āĻāĻŦāĻ queueing delay āĻ āύā§āϤāϰā§āĻā§āĻā§āϤāĨ¤ āĻāĻāĻāĻŋ āĻāĻžāĻā§āϰ performance execution time-āĻāϰ āĻŦā§āϝāϏā§āϤāĻžāύā§āĻĒāĻžāϤāĻŋāĻāĨ¤
Throughput āĻŦāĻž bandwidth āĻšāϞ⧠āĻāĻāĻ āϏāĻŽāϝāĻŧā§ āϏāĻŽā§āĻĒāύā§āύ āĻāĻžāĻā§āϰ āϏāĻāĻā§āϝāĻž:
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¶
A stored-program computer contains five fundamental units:
- Input unit: Accepts programs and data from keyboards, sensors, networks or storage and converts them into binary form.
- 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.
- Arithmetic and Logic Unit (ALU): Performs arithmetic, logic, comparison and shift operations. Condition flags may record zero, carry, sign and overflow.
- 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.
- 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¶
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.

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.

* 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¶

As the name implies, this structure utilizes two separate buses to improve efficiency:
- Memory Bus: Used primarily by the processor to fetch instructions and transfer data to and from the memory unit.
-
I/O Bus: Used by the processor to fetch data from input devices and send data to output devices.
-
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.
- 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:

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

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, orjump). 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
addifor add immediate, orlwfor 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.

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"āĨ¤ āĻ
āϰā§āĻĨāĻžā§, āĻŽā§āĻŽāϰāĻŋ āĻŦāĻž āϰā§āĻāĻŋāϏā§āĻāĻžāϰā§āϰ āĻāĻāĻžāϰ āϝāϤ āĻā§āĻ āĻšāĻŦā§, āĻĒā§āϰāϏā§āϏāϰ āϏā§āĻāĻžāύ āĻĨā§āĻā§ āϤāϤ āĻĻā§āϰā§āϤ āĻĄā§āĻāĻž āĻā§āĻāĻā§ āĻŦā§āϰ āĻāϰāϤ⧠āĻĒāĻžāϰāĻŦā§āĨ¤ āϏā§āĻĒāĻŋāĻĄ āĻŦāĻž āĻĻā§āϰā§āϤāĻāϤāĻŋāϰ āĻāύā§āϝāĻ āĻāϤ⧠āĻā§āĻŦ āĻŦā§āĻļāĻŋ āϰā§āĻāĻŋāϏā§āĻāĻžāϰ āϰāĻžāĻāĻž āĻšā§āύāĻŋāĨ¤

āĻāĻĒāύāĻžāϰ āĻĻā§āĻā§āĻž āϏā§āϞāĻžāĻāĻĄ āĻāĻŦāĻ āĻāĻŋāĻĄāĻŋāĻāĻāĻŋ āĻĨā§āĻā§ 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:
- Data Transfer Instructions: Move data between registers, memory, and I/O devices without modifying the content.
- Data Manipulation Instructions: Perform computational tasks on data, subdivided into Arithmetic, Logical, and Shift instructions.
- 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]
- Instruction Fetch: Instruction is transferred from memory to the Instruction Register (IR).
- Instruction Decode: Decoder separates the Opcode (
ADD) from Operands (\(A, B, C\)). - Operand Fetch: Operands \(A\) and \(B\) are retrieved based on the addressing mode.
- 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:
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 |
+-----------------------+
CALL Target:- Pushes the current return address (\(PC + 1\)) onto the Stack (\(M[SP] \leftarrow PC\)).
-
Loads the target subroutine address into the Program Counter (\(PC \leftarrow 3000\)).
-
RET(Return): - 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
-
- Register to Register
-
- Register to Memory
-
- Memory to Register
-
- Input to Register/Memory (from peripheral)
-
- Register/Memory to Output (to peripheral)
-
- Stack Operations
- a. PUSH (Store to stack)
-
b. POP (Retrieve from stack)
-
B. Based on Addressing Mode Variations (Example: MOV)
-
- Immediate Move (MOV R1, 500)
-
- Direct Move (MOV R1, X)
-
- Indirect Move
-
- Base Addressing Move
-
(Note: 7 to 8 variations exist based on mode)
-
C. Core Mnemonic List
-
- MOV (Move/Copy)
-
- LD / LOAD (Load to Register/Accumulator)
-
- ST / STORE (Store to Memory)
-
- XCHG (Exchange/Swap)
-
- IN (Input)
-
- OUT (Output)
-
- SET (Set to 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
-
- ADD (Addition)
-
- SUB (Subtraction)
-
- MUL (Multiplication)
-
- DIV (Division)
-
B. Incremental Operations
-
- INC (Increment by 1)
-
- DEC (Decrement by 1)
-
C. Operations with Flags
-
- ADC (Add with Carry)
-
- SBB / SUBB (Subtract with Borrow)
-
D. Sign Manipulation
-
- NEG (Negate - create 2's complement)
-
II. LOGICAL INSTRUCTIONS
- Function: Perform bitwise operations on binary data.
- A. Boolean Logic Operations
-
- NOT / COMPLEMENT (1's Complement)
-
- AND (Bitwise multiplication / Masking)
-
- OR (Bitwise addition / Selective setting)
-
- XOR (Modulo-2 addition / Swapping/Testing parity)
-
B. Flag Manipulation
-
- CLC (Clear Carry flag to 0)
-
- STC (Set Carry flag to 1)
-
- CMC (Complement Carry flag)
-
C. Machine Control
-
- EI (Enable Interrupts)
-
- DI (Disable Interrupts)
-
- CLR (Clear/Reset register bits)
-
III. SHIFT INSTRUCTIONS
- Function: Move bits left or right within a register.
- A. Logical Shifts
-
- Logical Shift Left (LSL)
-
- Logical Shift Right (LSR)
-
B. Arithmetic Shifts
-
- Arithmetic Shift Left (ASL) â (Often identical to LSL)
-
- Arithmetic Shift Right (ASR)
-
C. Rotate / Circular Shifts
-
- Rotate Left (ROL)
-
- Rotate Right (ROR)
-
D. Rotate through Carry
-
- Rotate Left through Carry (RCL)
-
- 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.
-
- JMP / JUMP (Direct jump to address)
-
- BRA / BRANCH (Jump relative to current location)
-
- SKP / SKIP (Skip the very next instruction)
-
- CALL (Invoke subroutine/function; save return address)
-
- RET / RETURN (Return from subroutine; retrieve return address)
-
B. Conditional Transfer
- Function: Jump only if a specific condition is met.
-
- Branch on Register Comparison
-
a. BE / BZ (Branch if Equal/Zero)
-
b. BNE / BNZ (Branch if Not Equal/Not Zero)
-
- Branch on Processor Flags
-
(Note: Examples include Branch if Carry, Branch if No Overflow, etc.)
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:
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.
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$:
- Operand \(R_1\) is placed onto Bus A and directed to ALU Input A.
- Operand \(R_2\) is placed onto Bus B and directed to ALU Input B.
- The ALU performs the addition operation immediately.
- 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.
āĻĄāĻžā§āĻžāĻā§āϰāĻžāĻŽā§āϰ āϏāĻŦāĻā§āϞ⧠āĻāĻŽā§āĻĒā§āύā§āύā§āĻā§āϰ āϏāĻŽā§āĻāĻžāĻŦā§āϝ āϏāĻŦ āĻĄā§āĻāĻž āĻĢā§āϞ⧠āĻŦāĻž āĻĒāĻžāĻĨ āύāĻŋāĻā§ āĻ ā§āϝāĻžāϰ⧠(->) āĻĻāĻŋā§ā§ āĻĻā§āĻāĻžāύ⧠āĻšāϞā§:
ā§§. 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:
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-āĻāĻŋāϰ āĻ āϰā§āĻĨ:
āĻāĻāĻžāύ⧠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¶
- Preprocessing: Handles
#include,#defineand conditional compilation, removes comments and produces an expanded translation unit. - 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.
- 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.
- 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.
- 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 (āĻā§āώā§āϤā§āϰ):
- 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).
- Operands (āĻ āĻĒāĻžāϰā§āύā§āĻĄ / āĻĄāĻžāĻāĻž āĻŦāĻž āĻ āĻŋāĻāĻžāύāĻž): Fields that store the actual data values or memory references (addresses) on which the operation acts.
- 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 computesTOP = 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.
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.
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.
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.
- Registers: Temporary storage for data and intermediate results (e.g., PC, IR).
- Register File: A collection of registers with multiple read/write ports for fast access.
- ALU (Arithmetic Logic Unit): Performs arithmetic and logical operations on data.
- Multiplexers (MUX): Select one of several input signals based on control inputs.
- Memory: Stores instructions and data for read/write operations during execution.
- Sign/Zero Extender: Extends immediate values to match the datapath's bit-width.
- Shift Units: Performs bit-level shifts, often used in address or data calculations.
- Buses: Shared data lines for transferring information between components.
- 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
## 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

## 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 (āĻāĻžāϰā§āϝāĻĒā§āϰāĻŖāĻžāϞā§)¶
- Condition Evaluation (āĻļāϰā§āϤ āĻĒāϰā§āĻā§āώāĻž): āĻāύā§āĻā§āϰā§āϞ āĻāĻāύāĻŋāĻ ALU āĻĨā§āĻā§ āĻāϏāĻž āύāĻŋāϰā§āĻĻāĻŋāώā§āĻ āϏā§āĻā§āϝāĻžāĻāĻžāϏ āĻŦāĻŋāĻ āĻŦāĻž āĻĢā§āϞā§āϝāĻžāĻ (āϝā§āĻŽāύ: Zero Flag) āĻĒāϰā§āĻā§āώāĻž āĻāϰ⧠āĻĻā§āĻā§ āĻļāϰā§āϤāĻāĻŋ True āύāĻžāĻāĻŋ FalseāĨ¤
-
Multiplexer Decision (āĻŽāĻžāϞā§āĻāĻŋāĻĒā§āϞā§āĻā§āϏāĻžāϰā§āϰ āϏāĻŋāĻĻā§āϧāĻžāύā§āϤ): āĻāύā§āĻĄāĻŋāĻļāύ āĻĢā§āϞā§āϝāĻžāĻā§āϰ āĻŽāĻžāύā§āϰ āĻāĻĒāϰ āĻāĻŋāϤā§āϤāĻŋ āĻāϰ⧠Address Selection MUX āύāĻŋāĻā§āϰ āĻĻā§āĻāĻŋ āϏāĻŋāĻĻā§āϧāĻžāύā§āϤā§āϰ āĻāĻāĻāĻŋ āύā§ā§:
-
āĻļāϰā§āϤ False āĻšāϞ⧠(Z = 0): MUX āĻĒāϰāĻŦāϰā§āϤ⧠āϏā§āĻŦāĻžāĻāĻžāĻŦāĻŋāĻ āĻā§āϰāĻŽāĻžāύā§āϏāĻžāϰāĻŋāĻ āĻ ā§āϝāĻžāĻĄā§āϰā§āϏ āĻā§āύāĻžāϰā§āĻāϰāĻā§ āĻŦā§āĻā§ āύā§ā§āĨ¤ āĻĢāϞ⧠āĻ ā§āϝāĻžāĻĄā§āϰā§āϏ āĻšā§ CAR + 1āĨ¤
- āĻļāϰā§āϤ True āĻšāϞ⧠(Z = 1): MUX āĻŦāϰā§āϤāĻŽāĻžāύ āĻŽāĻžāĻāĻā§āϰā§-āĻāύā§āϏāĻā§āϰāĻžāĻāĻļāύ⧠āĻĨāĻžāĻāĻž Branch Target Address-āĻāĻŋāĻā§ āĻŦā§āĻā§ āύā§ā§āĨ¤
- Updating CAR (CAR āĻāĻĒāĻĄā§āĻ): MUX āĻĨā§āĻā§ āĻŦāĻžāĻāĻžāĻāĻā§āϤ āĻ ā§āϝāĻžāĻĄā§āϰā§āϏāĻāĻŋ āϏāϰāĻžāϏāϰāĻŋ Control Address Register (CAR)-āĻ āĻĒā§āĻļ āĻŦāĻž āϞā§āĻĄ āĻāϰāĻž āĻšā§āĨ¤
- 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 āĻĄāĻŋāĻāĻžāĻāϏ āĻāύā§āĻā§āϰā§āϞ ]
ā§Š. āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύ āϏāĻžāĻāĻā§āϞ āĻŦāĻž āĻŽā§āĻļāĻŋāύ āϏāĻžāĻāĻā§āϞ (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 (āĻĒā§āϝāĻžāϰāĻžāϞāĻžāϞāĻŋāĻāĻŽ - āϏāĻŽāĻžāύā§āϤāϰāĻžāϞ āĻāĻžāĻ āĻŽā§āϝāĻžāύā§āĻ āĻāϰāĻž)
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)¶
āĻāĻāĻāĻŋ āϏāĻžāϧāĻžāϰāĻŖ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύ āϏāĻžāĻāĻā§āϞāĻā§ āĻā§ā§āĻāĻāĻŋ āύāĻŋāϰā§āĻĻāĻŋāώā§āĻ āϧāĻžāĻĒā§ āĻāĻžāĻ āĻāϰāĻž āĻšā§ (āϝā§āĻŽāύ ā§ĢāĻāĻŋ āϧāĻžāĻĒ):
- Fetch (IF): āĻŽā§āĻŽā§āϰāĻŋ āĻĨā§āĻā§ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύ āύāĻŋā§ā§ āĻāϏāĻžāĨ¤
- Decode (ID): āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύāĻāĻŋ āĻŦāĻŋāĻļā§āϞā§āώāĻŖ āĻāϰāĻžāĨ¤
- Execute (EX): āĻāĻžāĻ āϏāĻŽā§āĻĒāύā§āύ āĻāϰāĻž (ALU-āĻāϰ āĻŽāĻžāϧā§āϝāĻŽā§)āĨ¤
- Memory Access (MEM): āĻŽā§āĻŽā§āϰāĻŋ āϰāĻŋāĻĄ āĻŦāĻž āϰāĻžāĻāĻ āĻāϰāĻžāĨ¤
-
Write-back (WB): āĻĢāϞāĻžāĻĢāϞ āϰā§āĻāĻŋāϏā§āĻāĻžāϰ⧠āϏā§āĻ āĻāϰāĻžāĨ¤
-
āĻĒāĻžāĻāĻĒāϞāĻžāĻāύāĻŋāĻ āĻāĻžā§āĻž (Non-Pipelined): āĻāĻāĻāĻŋ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύā§āϰ ā§ĢāĻāĻŋ āϧāĻžāĻĒ āϏāĻŽā§āĻĒā§āϰā§āĻŖ āĻļā§āώ āύāĻž āĻšāĻā§āĻž āĻĒāϰā§āϝāύā§āϤ āĻĒā§āϰāϏā§āϏāϰ āĻĒāϰāĻŦāϰā§āϤ⧠āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύā§āϰ āĻāĻžāĻ āĻļā§āϰ⧠āĻāϰāϤ⧠āĻĒāĻžāϰ⧠āύāĻžāĨ¤ āĻĢāϞ⧠āĻĒā§āϰāϏā§āϏāϰā§āϰ āĻŦā§āĻļāĻŋāϰāĻāĻžāĻ āĻ āĻāĻļ āĻ āϞāϏ (Idle) āĻŦāϏ⧠āĻĨāĻžāĻā§āĨ¤
- āĻĒāĻžāĻāĻĒāϞāĻžāĻāύāĻŋāĻ āϏāĻš (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āĻŽā§āϞāύ (āϝāĻĻāĻŋ āĻāĻŽāĻŋ āĻāϰāĻ āϤāϰāĻŽā§āĻ āĻāĻžāĻ)
- IF: Instruction Fetch (āύāĻŋā§ā§ āĻāϏāĻž)
- ID: Instruction Decode (āĻŦāĻŋāĻļā§āϞā§āώāĻŖ)
- EX: Execute (āĻāĻžāĻ āĻāϰāĻž)
- MEM: Memory Access (āĻŽā§āĻŽā§āϰāĻŋ āĻĻā§āĻāĻž)
- 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?
- 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.
- Data hazard: An instruction depends on a value not yet available.
RAWis a true dependency;WARandWAWarise mainly with out-of-order execution. Forwarding, stalls, scheduling and renaming are used. - Control hazard: The next PC is uncertain after a branch or jump. Stalling, early resolution, prediction, speculative execution and flushing are common responses.
- Unequal stage delay: Clock period is determined by the slowest stage, so fast stages waste time.
- Pipeline-register overhead: Setup, clock-to-Q and skew reduce the benefit of making stages very short.
- Variable-latency operations: Multiply, divide and cache misses may occupy a unit for many cycles.
- Precise exceptions and interrupts: The processor must preserve the appearance that older instructions completed and younger ones did not.
- 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āĨ¤¶
đ ā§ŠāĻāĻŋ āĻĒā§āϰāϧāĻžāύ āϏāĻŽāϏā§āϝāĻž (āĻĒāϰā§āĻā§āώāĻžā§ āĻĢā§āϞ āĻŽāĻžāϰā§āĻāϏ āĻĒāĻžāĻā§āĻžāϰ āĻŦā§āϞā§āĻ āĻĒā§ā§āύā§āĻ)¶
- Structural Hazard (āĻāĻ āύāĻāϤ āϏāĻŽāϏā§āϝāĻž - S)
- āϏāĻšāĻ āĻāĻĨāĻž: āϝāĻāύ āĻĻā§āĻāĻŋ āĻāϞāĻžāĻĻāĻž āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύ āĻāĻāĻ āϏāĻŽā§ā§ āĻĒā§āϰāϏā§āϏāϰā§āϰ āĻāĻāĻ āĻšāĻžāϰā§āĻĄāĻā§ā§āϝāĻžāϰ āϰāĻŋāϏā§āϰā§āϏ (āϝā§āĻŽāύ- āĻāĻāĻ āĻŽā§āĻŽā§āϰāĻŋ āĻŦāĻž āĻāĻāĻ āĻŦāĻžāϏ) āĻŦā§āϝāĻŦāĻšāĻžāϰ āĻāϰāϤ⧠āĻāĻžā§āĨ¤
- āĻā§ āĻāĻā§: āϏāĻāĻāϰā§āώ āĻŦāĻž āĻā§āϝāĻžāĻŽ āϞāĻžāĻā§ (Resource Conflict)āĨ¤
- Data Hazard (āĻĄā§āĻāĻžāϰ āĻāĻĒāϰ āύāĻŋāϰā§āĻāϰāϤāĻž - D)
- āϏāĻšāĻ āĻāĻĨāĻž: āϝāĻāύ āĻāĻāĻāĻŋ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύ āϤāĻžāϰ āĻāĻā§āϰ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύā§āϰ āĻĢāϞāĻžāĻĢāϞā§āϰ (Data) āĻāĻĒāϰ āύāĻŋāϰā§āĻāϰ āĻāϰā§āĨ¤
- āĻā§ āĻāĻā§: ā§§āĻŽ āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύāĻāĻŋ āϝāϤāĻā§āώāĻŖ āύāĻž āĻĢāϞāĻžāĻĢāϞ āϏā§āĻ āĻāϰāĻā§, ⧍⧠āĻāύāϏā§āĻā§āϰāĻžāĻāĻļāύāĻāĻŋ āĻāĻžāĻ āĻļā§āϰ⧠āĻāϰāϤ⧠āĻĒāĻžāϰ⧠āύāĻžāĨ¤ āĻāĻā§ Data Dependency āĻŦāϞā§āĨ¤
- Control Hazard / Branch Hazard (āύāĻŋā§āύā§āϤā§āϰāĻŖ āĻŦāĻž āϏāĻŋāĻĻā§āϧāĻžāύā§āϤ āύā§āĻā§āĻžāϰ āϏāĻŽāϏā§āϝāĻž - C)
- āϏāĻšāĻ āĻāĻĨāĻž: āϝāĻāύ āĻĒā§āϰā§āĻā§āϰāĻžāĻŽā§ āĻā§āύ⧠āĻļāϰā§āϤ āĻŦāĻž āϞā§āĻĒ (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:
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:
| 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:
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.
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)¶
đ ī¸ ā§ŠāĻāĻŋ āĻĒā§āϰāϧāĻžāύ āĻŽāĻĄāĻŋāĻĢāĻŋāĻā§āĻļāύ (āĻĒāϰā§āĻā§āώāĻžāϰ āĻāĻžāϤāĻžā§ āϞā§āĻāĻžāϰ āĻŦā§āϞā§āĻ āĻĒā§ā§āύā§āĻ)¶
- ā§Š-āĻā§-ā§§ āĻŽāĻžāϞā§āĻāĻŋāĻĒā§āϞā§āĻā§āϏāĻžāϰ (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)¶
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:
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¶


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:
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:
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
Full word: 10111111001000000000000000000000â
Hexadecimal: BF200000ââ
Double precision (1 + 11 + 52 bits)¶
- Sign:
1 - Biased exponent: \(-1+1023=1022=01111111110_2\)
- Fraction:
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:
Each partial-product bit is generated by an AND gate:
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\):
Initialize \(A=000000\) and \(Q_{-1}=0\). Boothâs rules are:
QâQââ=01: \(AâA+M\)QâQââ=10: \(AâA-M\)00or11: 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:
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:
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:
Example: A program executes \(600\) million instructions on a 3 GHz processor with CPI 1.5:
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:
āĻāĻāĻžāύ⧠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¶
| 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¶
| 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:
and
Using \(T=IC\times CPI/f\):
| 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 āϧāϰā§:
āϤāĻžāĻ 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¶
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\).
Example: hit time = 1 ns, hit rate = 95%, miss penalty = 60 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:
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¶
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:
- CPU places an address on the address bus.
- It asserts Memory Read and appropriate byte enables.
- Memory decodes the address, selects a row/column and drives data.
- Ready/valid indicates completion; CPU captures data in MDR/register.
Write sequence:
- CPU places address and write data on their buses.
- It asserts Memory Write and byte enables.
- Selected memory cells store the data.
- 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¶
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¶
The four chips provide data bytes D7âD0, D15âD8, D23âD16 and D31âD24.
2. Depth expansion¶
3. Total 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¶
Total capacity:
āĻŦāĻžāĻāϞāĻž āĻāϤā§āϤāϰ¶
āĻāĻāĻāĻŋ 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:
- Write the enhanced definition/introduction first.
- Draw the diagram before the long explanation and label every path.
- Use a comparison table where the question asks for differences.
- State assumptions, especially notation, word size, signedness and addressing mode.
- Show formulas before substituting numerical values.
- Preserve leading zeros in binary arithmetic.
- 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











