Top Banner Ad

BCS302 — Unit 3: Control Unit

Table of Contents (34 sections)

BCS302 · COMPUTER ORGANIZATION AND ARCHITECTURE · Unit 3

Control Unit

Unit Scope & Exam Weightage: Unit 3 covers how the CPU coordinates instruction execution—from instruction formats and register-level micro-operations to Hardwired vs. Microprogrammed Control Units, Pipelining, and RISC/CISC. In AKTU 70-mark exams, 14 to 21 marks consistently come from this unit (typically 1–2 short 2-mark questions in Section A + 1–2 long 7-mark questions in Sections B & C).


Front Page: Importance-Wise Topic Roadmap (2023–26 PYQs)

Priority Topic (Exact Syllabus) PYQs Asked Marks Weightage Tag
1 Hardwired vs. Microprogrammed Control & Microprogram Sequencing 4 (2023-24, 2024-25, 2025-26) 7m × 3 + 2m × 1 Survival Mode Predicted
2 Pipelining (Stages, Speedup Numericals, Hazards & Parallelism) 3 (2023-24, 2024-25, 2025-26) 7m × 3 High-Yield Numerical
3 Instruction Cycles & Sub-Cycles (Fetch, Decode, Indirect, Execute, Interrupt) 2 (2023-24 ×2) 7m + 2m Core Concept
4 Micro-Operations (Register Transfer, Arithmetic, Logic, Shift) 2 (2024-25, 2025-26) 7m + 2m Core Concept
5 Horizontal vs. Vertical Microprogramming 1 (2024-25) 7m Easy Comparison
6 Instruction Types & Formats (3/2/1/0-Address) 1 (2025-26) 7m Worked Examples
7 Reduced Instruction Set Computer (RISC vs. CISC) 1 (2025-26) 7m Easy Comparison
8 Program Control & Execution of a Complete Instruction Integrated in #1, #3, #4 — Supporting RTL

2-Hour Last-Night Survival Checklist:

  1. Control Unit (#1 Priority): Practice the Hardwired Control Unit block diagram, Microprogram Sequencer diagram, and the 8-point Hardwired vs. Microprogrammed table.
  2. Pipeline Numericals (#2 Priority): Memorize Tnon=n⋅k⋅τT_{\text{non}} = n \cdot k \cdot \tau, Tpipe=(k+n−1)τT_{\text{pipe}} = (k + n - 1)\tau, Speedup SS, Efficiency η\eta, and the 3 Hazards (Structural, Data, Control).
  3. Quick 7-Mark Wins: Instruction Cycle 5-phase flowchart, 4 Micro-operation types with RTL, Horizontal vs. Vertical bit-layout SVG, and 3/2/1/0-address format conversion.

1. Instruction Types, Formats & Addressing

Instruction (2 Marks): A binary code stored in memory that directs the CPU to perform a specific operation. It consists of an Opcode (what to do), Operand / Address fields (where the data is), and an optional Mode bit (I) (direct vs. indirect addressing).

1.1 Generic Instruction Bit Layout

Mode (I)
1 bit
Opcode (Operation)
4–8 bits
Address 1 (Operand / Reg)
Register or Memory
Address 2 (Operand / Dest)
Optional
  • Mode bit (II): I=0⇒I = 0 \Rightarrow Direct addressing (address field holds operand address); I=1⇒I = 1 \Rightarrow Indirect addressing (address field points to a memory location holding the Effective Address).
  • Opcode: kk-bit opcode supports up to 2k2^k distinct operations.

1.2 Types of Instructions (Functional Classification)

  1. Data Transfer Instructions: Copy data between registers, memory, and stack without modifying values.
    • LOAD (Memory → Register/AC), STORE (Register/AC → Memory), MOV (Reg ↔ Reg), XCHG (Swap), IN / OUT (I/O ports), PUSH / POP (Stack).
  2. Data Manipulation Instructions: Transform data using the ALU.
    • Arithmetic: ADD, SUB, MUL, DIV, INC, DEC, NEG (2's complement), ADDC (add with carry).
    • Logical & Bit Manipulation: AND, OR, XOR, NOT, CLR (clear bits), SET (set bits), TEST (bitwise AND setting flags only).
    • Shift & Rotate: SHL, SHR (logical), ASHL, ASHR (arithmetic), ROL, ROR (circular), RCL, RCR (rotate through carry).
  3. Program Control Instructions: Alter sequential execution (PC) based on conditions or calls.
    • JMP (Unconditional Jump), JZ / JNZ / JC (Conditional Branch), CMP (Compare via A - B flags), CALL (Jump to subroutine), RET (Return from subroutine).
  4. Machine & Interrupt Control: HLT (Halt CPU), NOP (No Operation), EI / DI (Enable/Disable Interrupts), WAIT.

1.3 Instruction Formats (By Number of Address Fields)

Most CPUs fall into 3-Address, 2-Address, 1-Address (Accumulator), or 0-Address (Stack) organizations. Let's evaluate:

Worked Example: Evaluate X=(A+B)×(C+D)X = (A + B) \times (C + D) using all 4 instruction formats (assuming memory operands A,B,C,D,XA, B, C, D, X).

Format CPU Organization Assembly Code for X=(A+B)×(C+D)X = (A + B) \times (C + D) Instructions Memory/Word Trade-off
3-Address General-Purpose Registers ADD R1, A, B
ADD R2, C, D
MUL X, R1, R2
3 Shortest program, longest instruction word (needs 3 address fields).
2-Address General-Purpose Registers (1st operand is overwritten) MOV R1, A
ADD R1, B
MOV R2, C
ADD R2, D
MUL R1, R2
MOV X, R1
6 Balanced instruction length; used in x86 and many commercial CPUs.
1-Address Single Accumulator (AC) (implied 2nd operand & destination) LOAD A
ADD B
STORE T
LOAD C
ADD D
MUL T
STORE X
7 Short instruction word, but requires temporary memory T and extra memory traffic.
0-Address Stack (TOS = Top of Stack; postfix/RPN order) PUSH A
PUSH B
ADD
PUSH C
PUSH D
ADD
MUL
POP X
8 Arithmetic instructions (ADD, MUL) need zero address bits; only PUSH/POP carry addresses.

1.4 Quick Addressing Modes Reference (Supports Instruction Formats)

  • Immediate: Operand is inside the instruction itself (MOV R1, #25). Fastest, no extra memory read.
  • Direct (Absolute): Address field = Effective Address (EA=AEA = A).
  • Indirect: Address field points to memory containing EAEA (EA=M[A]EA = M[A]).
  • Register / Register Indirect: Operand is in register RR, or EA=(R)EA = (R).
  • Indexed / Base-Register: EA=A+(XR)EA = A + (XR) (used for arrays) or EA=Base+OffsetEA = \text{Base} + \text{Offset} (used for relocatable code).
  • PC-Relative: EA=PC+OffsetEA = \text{PC} + \text{Offset} (used for short loops and branches).

After-Topic PYQ:

  • 2025-26 (Sec B Q2d, 7 Marks): "Explain different types of instructions. Explain various instruction formats with suitable examples."

2. Instruction Cycle, Sub-Cycles & Complete Execution

Instruction Cycle (2 Marks): The complete sequence of steps the CPU performs to fetch and execute a single machine instruction: Fetch → Decode → Indirect (optional) → Execute → Interrupt Check.

2.1 Five Phases of an Instruction Cycle

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '17px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart TD
    F["1. Fetch Sub-Cycle<br/>MAR ← PC ; MBR ← M[MAR] ; PC ← PC + 1"] --> D["2. Decode Sub-Cycle<br/>IR ← MBR ; CU decodes Opcode & Mode (I)"]
    D -->|"I = 1 (Indirect)"| IND["3. Indirect Sub-Cycle<br/>MAR ← IR[Addr] ; MAR ← M[MAR] (EA)"]
    D -->|"I = 0 (Direct)"| E["4. Execute Sub-Cycle<br/>ALU / Memory Read-Write / Branch"]
    IND --> E
    E -->|"Interrupt Pending (IEN=1 & R=1)"| INT["5. Interrupt Sub-Cycle<br/>Save Return PC to Stack ; PC ← ISR Addr"]
    E -->|"No Interrupt"| F
    INT --> F
  1. Fetch Sub-Cycle (T0−T2T_0 - T_2):
    • T0T_0: MAR ← PC (Place instruction address on address bus).
    • T1T_1: MBR ← M[MAR], PC ← PC + 1 (Read instruction from memory and point PC to next instruction).
    • T2T_2: IR ← MBR (Move instruction into Instruction Register).
  2. Decode Sub-Cycle (T3T_3):
    • Control Unit decodes IR[Opcode] and inspects mode bit I and operand fields.
  3. Indirect Sub-Cycle (only if I=1I = 1):
    • MAR ← IR[Addr], then MBR ← M[MAR], then MAR ← MBR to obtain the true Effective Address (EA).
  4. Execute Sub-Cycle:
    • Performs the actual operation depending on opcode (e.g., memory read + ALU add, store to memory, or update PC for branch).
  5. Interrupt Sub-Cycle (at end of Execute):
    • CPU checks if Interrupt Enable (IEN) is set and an interrupt request (R = 1) is pending.
    • If yes: MBR ← PC (save return address), MAR ← Save_Addr / SP, M[MAR] ← MBR, PC ← ISR_Address (jump to Interrupt Service Routine), IEN ← 0.

2.2 Execution of a Complete Instruction (Single-Bus CPU Organization)

In a Single-Bus CPU, all registers (PC, MAR, MDR, IR, R0..Rn) and the ALU (via temporary registers Y and Z) share one internal data bus. Control signals (R_in, R_out, Read, Write, WMFC = Wait for Memory Function Completed) gate data onto/off the bus.

Complete Control Sequence for ADD (R3), R1 (Add contents of memory location pointed to by R3 to R1, store result in R1):

Step Action / Micro-Operation Active Control Signals
1 MAR ← PC PC_out, MAR_in, Read, Select4, Add, Z_in
2 PC ← PC + 4, wait for memory Z_out, PC_in, Y_in, WMFC
3 IR ← MDR (Instruction loaded) MDR_out, IR_in
4 MAR ← R3 (Address of operand) R3_out, MAR_in, Read
5 Y ← R1, wait for memory R1_out, Y_in, WMFC
6 Z ← Y + MDR (ALU Add) MDR_out, SelectY, Add, Z_in
7 R1 ← Z, End instruction Z_out, R1_in, End

2.3 Program Control & Status Flags (PSW)

Program Control instructions alter PC based on Processor Status Word (PSW) condition flags updated by the ALU:

  • Z (Zero): Set to 1 if ALU output =0= 0.

  • S / N (Sign/Negative): Copy of MSB of ALU result (1 = negative in 2's complement).

  • C (Carry): Set to 1 if carry-out from MSB occurs.

  • V (Overflow): Set to 1 on signed overflow: V=Cin(MSB)⊕Cout(MSB)V = C_{\text{in(MSB)}} \oplus C_{\text{out(MSB)}}.

  • Subroutine Call (CALL addr) & Return (RET):

    • CALL: SP ← SP - 1; M[SP] ← PC; PC ← addr
    • RET: PC ← M[SP]; SP ← SP + 1

After-Topic PYQs:

  • 2023-24 (Sec C Q5a, 7 Marks): "Explain the different cycles of an instruction execution."
  • 2023-24 (Sec A Q1c, 2 Marks): "What are the different phases of an instruction cycle?"

3. Micro-Operations (Register Transfer Level)

Micro-Operation (2 Marks): An elementary, atomic operation executed on data stored in one or more CPU registers during a single clock pulse (e.g., R3 ← R1 + R2). A macro-instruction is decomposed into a sequence of micro-operations.

3.1 Four Categories of Micro-Operations

Category Purpose Key RTL Examples
1. Register Transfer Copy binary data between registers/memory unchanged MAR ← PC, DR ← M[AR], M[AR] ← DR
2. Arithmetic Perform numeric operations on signed/unsigned integers R3 ← R1 + R2, R3 ← R1 + R2' + 1 (Subtract), R1 ← R1 + 1, R1 ← R1 - 1
3. Logic Bitwise manipulation treating each bit independently R1 ← R1 ∧ R2 (AND), R1 ← R1 ∨ R2 (OR), R1 ← R1 ⊕ R2 (XOR), R1 ← R1' (NOT)
4. Shift Serial bit movement left/right inside a register shl R1, shr R1, cil R1, cir R1, ashl R1, ashr R1

3.2 Important Logic Micro-Operations (4-Bit Worked Examples)

Suppose register A = 1010 and mask register B = 1100:

  1. Selective-Set (A ← A ∨ B, OR): Sets bits in A wherever B has 1.
    • 1010 ∨ 1100 = 1110
  2. Selective-Complement (A ← A ⊕ B, XOR): Flips bits in A wherever B has 1.
    • 1010 ⊕ 1100 = 0110
  3. Selective-Clear (A ← A ∧ B'): Clears bits in A wherever B has 1.
    • 1010 ∧ 0011 = 0010
  4. Mask (A ← A ∧ B, AND): Clears bits in A wherever B has 0 (keeps only masked bits).
    • 1010 ∧ 1100 = 1000
  5. Clear (A ← A ⊕ A): Resets register A to 0000.

3.3 Shift Micro-Operations (With Sign-Bit Rules)

Let 4-bit register R = 1011 (in signed 2's complement, MSB 1 = negative, value -5):

  • Logical Shift (shl / shr): Vacated bit filled with 0.
    • shl(1011) = 0110, shr(1011) = 0101 (Note: MSB 1 lost — wrong for negative signed division!).
  • Circular / Rotate (cil / cir): Bit shifted out wraps around to the other end (no bits lost).
    • cil(1011) = 0111, cir(1011) = 1101.
  • Arithmetic Shift (ashl / ashr): Preserves the sign bit for signed multiplication/division by 2.
    • ashr(1011): Sign bit 1 stays at MSB and shifts right → 1101 (-3, divides signed number by 2).
    • ashl(1011): Shifts left with 0 at LSB; overflow flag Vs=Rn−1⊕Rn−2V_s = R_{n-1} \oplus R_{n-2} triggers if the sign bit changes!

After-Topic PYQs:

  • 2025-26 (Sec C Q4a, 7 Marks): "What are micro-operations? Explain different types of micro-operations."
  • 2024-25 (Sec A Q1e, 2 Marks): "Discuss the micro operations in computer architecture?"

4. Hardwired vs. Microprogrammed Control & Sequencing Survival Mode Predicted

This is the highest-weightage topic in Unit 3 (asked in 2023-24, 2024-25, and 2025-26).

4.1 Hardwired Control Unit

A Hardwired Control Unit generates control signals directly using fixed combinational logic circuits (gates, decoders, encoders, flip-flops). It acts as a hardware finite-state machine driven by the opcode, clock step counter, and status flags.

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '17px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart TD
    IR["IR (Opcode & Mode I)"] --> IDEC["Instruction Decoder<br/>(Lines D0..Dk)"]
    SC["Step Counter (SC)"] --> TDEC["Timing Decoder<br/>(Steps T0..Tn)"]
    IDEC --> MAT["Combinational Control Matrix<br/>(AND / OR Gate Network)"]
    TDEC --> MAT
    FLG["Status Flags (Z, C, N, V)<br/>& External Inputs"] --> MAT
    MAT --> OUT["Control Signals (C0..Ck)<br/>to CPU Registers, ALU & Bus"]

Components of Hardwired Control Unit (Write All 5 in 7-Mark Answers!)

  1. Instruction Register (IR): Stores the fetched instruction; feeds opcode bits to the Instruction Decoder and mode bit II to the logic matrix.
  2. Instruction Decoder: An nn-to-2n2^n decoder that activates a single instruction line (D0,D1,…,DkD_0, D_1, \dots, D_k) corresponding to the current opcode.
  3. Sequence Counter (SC) & Timing Decoder: A modulo-mm counter (INR increments each clock; CLR resets to 0 at end of instruction) feeding a timing decoder to produce T0,T1,…,Tm−1T_0, T_1, \dots, T_{m-1}.
  4. Condition / Status Flags (Z, C, N, V) & External Inputs: Allow conditional branching (e.g., JZ only loads PC if Z = 1).
  5. Combinational Control Logic Matrix: Boolean AND/OR gate network combining (Di,Tj,Flags)(D_i, T_j, \text{Flags}) to assert exact control signals, e.g.:
    • PC_out = T0
    • MAR_in = T0 + D_LOAD · T3 + D_ADD · T3
    • CLR_SC = D_ADD · T5 + D_JMP · T3
  • Advantages: Maximum speed (pure combinational gate delay, no memory lookup); minimal silicon area for small ISAs (RISC).
  • Disadvantages: Inflexible (adding/fixing an instruction requires physical hardware redesign); very complex Boolean minimization for large CISC instruction sets.

4.2 Microprogrammed Control Unit & Microprogram Sequencing

Microprogrammed Control Unit (2 Marks): A control unit where control signals are stored as binary control words (microinstructions) inside a special high-speed Control Memory (ROM/WCS). Executing a machine instruction means running a sequence of microinstructions called a microroutine.

Core Terminology

  • Control Word: A binary string where bits represent active control signals for one clock cycle.
  • Microinstruction: One word in Control Memory containing control bits + next-address/sequencing bits.
  • Microroutine: A sequence of microinstructions implementing one machine-level instruction (e.g., ADD microroutine, FETCH microroutine).
  • Control Address Register (CAR): Holds the address of the next microinstruction to be read from Control Memory.
  • Control Data Register (CDR / MIR): Holds the currently fetched microinstruction while its control signals drive the CPU.

Microprogram Sequencer (How Complex Instructions Execute)

%%{init: {'theme': 'base', 'look': 'handDrawn', 'themeVariables': {'fontFamily': "'Nunito', sans-serif", 'fontSize': '17px', 'primaryColor': '#EFEAD6', 'primaryBorderColor': '#0F766E', 'lineColor': '#23211C'}}}%%
flowchart TD
    EXT["IR Opcode<br/>Mapping Logic"] --> MUX["4-to-1 Address<br/>Selector MUX"]
    INC["Incrementer<br/>(CAR + 1)"] --> MUX
    SBR["Subroutine Reg<br/>(SBR)"] --> MUX
    BRA["Branch Addr<br/>(from CMDR)"] --> MUX
    MUX --> CAR["Control Address<br/>Register (CAR)"]
    CAR --> CM["Control Memory<br/>(ROM / WCS)"]
    CM --> CMDR["Control Data Reg<br/>(CMDR / MIR)"]
    CMDR -->|"Control Bits"| SIG["Control Signals<br/>to CPU / ALU"]
    CMDR -->|"Cond + Branch"| IL["Input Logic &<br/>Status MUX"]
    FLAGS["CPU Flags<br/>(Z, C, N, V)"] --> IL
    IL -->|"Select S1, S0"| MUX

Step-by-Step Working of Microprogram Sequencing:

  1. Fetch Microroutine: Starts at CAR = 0. Sequencer uses CAR + 1 to step through MAR ← PC, MBR ← M[MAR]; PC ← PC + 1, IR ← MBR.
  2. Opcode Mapping: At the end of Fetch, the Mapping Logic converts the IR opcode (e.g., 4-bit opcode 0101 → 7-bit control address 0 0101 00) and loads it into CAR via the MUX.
  3. Microroutine Execution & Sequencing: For each microinstruction read into CMDR, the Input Logic checks status flags (Z, C, N, V) and the microinstruction's condition bits to set MUX select lines (S1,S0)(S_1, S_0), choosing the next CAR address from 4 sources:
    • CAR + 1: Normal sequential step inside the microroutine.
    • Branch Address (CMDR[Addr]): Conditional/unconditional jump within the microroutine (loops, e.g., iterative MUL/DIV).
    • Subroutine Register (SBR): CALL saves CAR + 1 into SBR for shared routines (like Effective Address calculation); RET restores SBR into CAR.
    • External Mapping (IR): Jumps back to the Fetch routine or next instruction's starting address.

4.3 Hardwired vs. Microprogrammed Control (8-Point Exam Table)

Feature Hardwired Control Unit Microprogrammed Control Unit
Core Mechanism Combinational logic gates, decoders, flip-flops Microinstructions stored in Control Memory (ROM)
Speed Fastest (gate propagation delay only) Slower (Control Memory read cycle delay)
Flexibility / Updates Rigid — requires hardware rewiring Highly flexible — update microcode in ROM/WCS
Design Complexity Very complex for large ISAs Systematic, modular, software-like
Cost (for complex ISA) High (many gates & interconnections) Lower & regular ROM structure
Debugging & Testing Difficult (must probe hardware) Easy (simulate/patch microprograms)
Instruction Set Target RISC (simple, fixed-length) CISC (complex, multi-cycle instructions)
Chip Area Smaller for simple ISAs Requires dedicated Control Memory ROM

After-Topic PYQs:

  • 2025-26 (Sec C Q3b, 7 Marks): "Explain the design and working of a hardwired control unit. Discuss about its advantages and disadvantages." Survival Mode Predicted
  • 2024-25 (Sec C Q5b, 7 Marks): "Explain the concept of microprogram sequencing and how it enables the execution of complex instructions through a sequence of microinstructions?" Survival Mode Predicted
  • 2023-24 (Sec C Q5b, 7 Marks): "Differentiate between hardwired and micro programmed control unit. Explain each component of hardwired control unit organization." Survival Mode Predicted
  • 2023-24 (Sec A Q1d, 2 Marks): "How does control unit of a computer works?"

5. Horizontal vs. Vertical Microprogramming

Microinstructions are organized in Control Memory using two main encoding schemes:

Horizontal Microinstruction Format (Wide Word — No Decoder):

C1 | C2 | C3 | ... | C48 (Direct 1-Bit Control Signals) Cond Bits Next Address

Vertical Microinstruction Format (Compact Word — Needs Decoder):

ALU Op (4 bits → 16 ops) Reg Select (3 bits → 8 regs) Branch / Cond (4 bits)
  • Horizontal Microprogramming: Each control signal gets its own dedicated bit (e.g., 48–100+ bits wide). Multiple independent micro-operations can fire simultaneously in one clock cycle without external decoders.
  • Vertical Microprogramming: Mutually exclusive control signals are grouped and encoded into short kk-bit fields (e.g., 4 bits encode 24=162^4 = 16 ALU ops), requiring external hardware decoders to expand them back into control lines.
Feature Horizontal Microprogramming Vertical Microprogramming
Control Word Width Long / Wide (many bits) Short / Compact (fewer bits)
External Decoders Not required (direct 1-bit/signal) Required (kk-to-2k2^k decoders)
Parallelism High (many signals active at once) Low (1 encoded op per field)
Execution Speed Faster (no decoder delay) Slower (decoder propagation delay)
Control Memory Size Large (wastes bits when signals are 0) Small (memory efficient)
Ease of Programming Harder to write manually Easier (looks like assembly fields)

Bonus Examiner Point: Mention Nanoprogramming (2-level control memory): compact vertical microinstructions in Control Memory point to wide horizontal nanoinstructions in a small Nano-Memory, saving ROM space while keeping horizontal speed.

After-Topic PYQ:

  • 2024-25 (Sec B Q2c, 7 Marks): "Describe the concept of horizontal and vertical microprogramming in control unit design?"

6. Instruction Pipelining, Hazards & Parallel Processing

Instruction Pipelining (2 Marks): An implementation technique where multiple instructions are overlapped in execution—like an assembly line—by dividing the datapath into kk independent stages separated by inter-stage pipeline registers.

6.1 The 5 Classic Pipeline Stages & Pipeline Registers

  1. IF (Instruction Fetch): Fetch instruction from I-Cache using PC; update PC ← PC + 4. (Writes to IF/ID register).
  2. ID (Instruction Decode & Register Read): Decode opcode in IR and read source registers (R1, R2). (Writes to ID/EX register).
  3. EX (Execute / Address Calculation): ALU computes arithmetic/logic result or Effective Address (Base + Offset). (Writes to EX/MEM register).
  4. MEM (Memory Access): LOAD reads data from D-Cache; STORE writes data to D-Cache; other instructions pass through. (Writes to MEM/WB register).
  5. WB (Write Back): Write ALU result or loaded memory data back into destination register.

6.2 5-Stage Pipeline Space-Time Diagram

Instruction T1 T2 T3 T4 T5 T6 T7
Inst 1 IF ID EX MEM WB — —
Inst 2 — IF ID EX MEM WB —
Inst 3 — — IF ID EX MEM WB

Pipeline Performance Formulas (kk stages, nn instructions, clock cycle τ\tau):

τ=max⁡(t1,t2,…,tk)+tlatch\tau = \max(t_1, t_2, \dots, t_k) + t_{\text{latch}} Tnon-pipe=n⋅tn(or n⋅k⋅τ)Tpipe=(k+n−1)τT_{\text{non-pipe}} = n \cdot t_n \quad (\text{or } n \cdot k \cdot \tau) \qquad T_{\text{pipe}} = (k + n - 1)\tau S=Tnon-pipeTpipe=n⋅kk+n−1η=Sk=nk+n−1H=nTpipeS = \frac{T_{\text{non-pipe}}}{T_{\text{pipe}}} = \frac{n \cdot k}{k + n - 1} \qquad \eta = \frac{S}{k} = \frac{n}{k + n - 1} \qquad H = \frac{n}{T_{\text{pipe}}}

As n→∞n \to \infty, ideal maximum speedup Smax⁡→kS_{\max} \to k and throughput H→1τH \to \frac{1}{\tau}.

6.3 Pipeline Hazards & Mitigation Techniques

  1. Structural Hazard (Resource Conflict): Two instructions in different stages need the same hardware simultaneously (e.g., IF fetching an instruction and MEM reading data from a single shared memory).
    • Solutions: Separate Instruction Cache (I-Cache) & Data Cache (D-Cache) (Harvard architecture), dual-port register file, or insert 1 stall cycle.
  2. Data Hazard (Data Dependency): An instruction needs a register value not yet written back by an earlier in-flight instruction.
    • RAW (Read After Write — True Dependency): I1: ADD R1, R2, R3 followed by I2: SUB R4, R1, R5 (I2 reads R1 before I1 writes R1).
    • WAR (Write After Read — Anti-Dependency): I2 writes a register before I1 reads it (occurs in out-of-order execution).
    • WAW (Write After Write — Output Dependency): I2 writes same destination register before I1 finishes writing.
    • Solutions: Operand Forwarding / Bypassing (route EX/MEM or MEM/WB output directly back to ALU input), Pipeline Stalls (NOP bubbles) for Load-Use hazards, and Compiler Instruction Scheduling.
  3. Control / Branch Hazard: A branch instruction (JMP, BEQ) changes PC, making already-fetched sequential instructions invalid.
    • Solutions: Pipeline Flush / Freeze, Delayed Branching (fill delay slot with independent instruction), Static/Dynamic Branch Prediction (1-bit / 2-bit saturating counter + Branch Target Buffer).

6.4 Parallel Processing Overview (Flynn's Classification)

To scale beyond a single pipeline, processors use Parallel Processing:

  • SISD (Single Instruction, Single Data): Conventional sequential uniprocessor.
  • SIMD (Single Instruction, Multiple Data): Vector/array processors & GPU cores applying one instruction across many data elements simultaneously.
  • MISD (Multiple Instruction, Single Data): Theoretical / fault-tolerant redundant pipelines.
  • MIMD (Multiple Instruction, Multiple Data): Modern multi-core CPUs and multiprocessors executing independent threads simultaneously.

After-Topic PYQs:

  • 2025-26 (Sec C Q3a, 7 Marks): "Explain instruction pipelining. A pipeline has 5 stages and each stage takes 20 ns. (i) Calculate the time required to execute 10 instructions without pipelining. (ii) Calculate the execution time with pipelining. (iii) Find the speedup."
  • 2024-25 (Sec C Q3a, 7 Marks): "Provide a detailed overview of processor organization, covering topics such as instruction fetch, decode, execute cycles, pipelining, and parallel processing techniques?"
  • 2023-24 (Sec B Q2c, 7 Marks): "What is pipelining? What are the different stages of pipelining? Explain in detail."

7. RISC vs. CISC Architecture

RISC (Reduced Instruction Set Computer): A CPU architecture built around a small, highly optimized set of fixed-length instructions that execute in a single clock cycle using hardwired control and Load/Store memory access.

7.1 Key Features & Advantages of RISC

  • Fixed-Length Instructions (typically 32 bits) → fast, uniform decoding (1 cycle).
  • Load/Store Architecture: Only LOAD and STORE access memory; all ALU operations work purely on registers.
  • Large Register File & Register Windowing: Overlapping register windows pass parameters between CALL/RET without pushing/popping to slow memory.
  • Hardwired Control Unit: No Control Memory overhead; enables high clock speeds and deep pipelining.
  • Simple Addressing Modes: Usually 3–5 basic modes (Register, Immediate, Base+Offset).

7.2 RISC vs. CISC (10-Point Comparison Table)

Feature RISC (Reduced Instruction Set) CISC (Complex Instruction Set)
Instruction Set Size Small (30–100 simple instructions) Large (200–400+ complex instructions)
Instruction Length Fixed (e.g., 32 bits) Variable (e.g., 1 to 15 bytes)
Control Unit Hardwired Microprogrammed
Memory Access Load/Store only Direct memory-to-memory operations
Cycles per Instruction Mostly 1 cycle (CPI ≈ 1) Multi-cycle (CPI > 1)
Register Count Large (32–128+ general registers) Small (8–16 general registers)
Addressing Modes Few (3–5) Many (12–24)
Pipelining Very easy & high efficiency Complex due to variable lengths
Code Density Lower (more instructions per task) Higher (fewer, denser instructions)
Compiler vs. Hardware Shifts complexity to Compiler Shifts complexity to Hardware
Examples ARM, MIPS, RISC-V, SPARC Intel x86, Motorola 68000, VAX

After-Topic PYQ:

  • 2025-26 (Sec B Q2e, 7 Marks): "Explain the concept of RISC architecture. Discuss its features and advantages. Compare RISC with CISC architecture."

Solved Exam-Ready Questions

Solved Q1 (2025-26 Sec C Q3a — 7 Marks | Pipeline Numerical)

Q: Explain instruction pipelining. A pipeline has 5 stages and each stage takes 20 ns. (i) Calculate the time required to execute 10 instructions without pipelining. (ii) Calculate the execution time with pipelining. (iii) Find the speedup.

Solution:

  • Instruction Pipelining: Splitting instruction execution into kk independent stages (IF, ID, EX, MEM, WB) separated by pipeline registers so multiple instructions overlap simultaneously.
  • Given: k=5k = 5 stages, τ=20 ns\tau = 20\text{ ns}, n=10n = 10 instructions.
  • (i) Execution time without pipelining:
Tnon-pipe=n×k×τ=10×5×20 ns=1000 nsT_{\text{non-pipe}} = n \times k \times \tau = 10 \times 5 \times 20\text{ ns} = \mathbf{1000\text{ ns}}
  • (ii) Execution time with pipelining:
Tpipe=(k+n−1)τ=(5+10−1)×20 ns=14×20 ns=280 nsT_{\text{pipe}} = (k + n - 1)\tau = (5 + 10 - 1) \times 20\text{ ns} = 14 \times 20\text{ ns} = \mathbf{280\text{ ns}}
  • (iii) Speedup (SS) & Efficiency (η\eta):
S=Tnon-pipeTpipe=1000280=257≈3.57S = \frac{T_{\text{non-pipe}}}{T_{\text{pipe}}} = \frac{1000}{280} = \frac{25}{7} \approx \mathbf{3.57} η=Sk=3.575≈71.4%\eta = \frac{S}{k} = \frac{3.57}{5} \approx \mathbf{71.4\%}

Solved Q2 (Non-Uniform Stage Pipeline with Latch Delay — 7 Marks | Practice Numerical)

Q: A 4-stage pipeline has stage delays of 15 ns, 20 ns, 25 ns, 18 ns and an inter-stage latch delay of 2 ns. Find the clock period τ\tau, execution time for 100 instructions, and speedup over a non-pipelined 78 ns CPU.

Solution:

  • Clock period (τ\tau): Determined by the slowest stage plus latch overhead:
τ=max⁡(15,20,25,18)+2=25+2=27 ns\tau = \max(15, 20, 25, 18) + 2 = 25 + 2 = \mathbf{27\text{ ns}}
  • Pipelined execution time for n=100n = 100 instructions (k=4k = 4):
Tpipe=(k+n−1)τ=(4+100−1)×27=103×27=2781 nsT_{\text{pipe}} = (k + n - 1)\tau = (4 + 100 - 1) \times 27 = 103 \times 27 = \mathbf{2781\text{ ns}}
  • Non-pipelined execution time:
Tnon-pipe=100×78 ns=7800 nsT_{\text{non-pipe}} = 100 \times 78\text{ ns} = \mathbf{7800\text{ ns}}
  • Speedup (SS):
S=78002781≈2.80S = \frac{7800}{2781} \approx \mathbf{2.80}

Solved Q3 (2023-24 Sec C Q5b — 7 Marks | Survival Mode)

Q: Differentiate between hardwired and microprogrammed control unit. Explain each component of hardwired control unit organization.

Answer Structure (Examiner Key Points):

  1. Comparison Table (8 points: Mechanism, Speed, Flexibility, Complexity, Cost, Debugging, Target ISA, Area — see Section 4.3).
  2. Hardwired Control Unit Block Diagram (draw Section 4.1 SVG).
  3. 5 Components Explained:
    • Instruction Register (IR): Supplies opcode & mode bit I.
    • Instruction Decoder: Converts nn-bit opcode into 2n2^n instruction lines (D0…DkD_0 \dots D_k).
    • Sequence Counter (SC) & Timing Decoder: Generates clock timing steps T0,T1,…,Tm−1T_0, T_1, \dots, T_{m-1}.
    • Status Flags (Z, C, N, V): Enable conditional execution & branching.
    • Combinational Control Matrix: AND/OR gate network generating control outputs C0…CkC_0 \dots C_k.

Solved Q4 (2024-25 Sec C Q5b — 7 Marks | Survival Mode)

Q: Explain the concept of microprogram sequencing and how it enables the execution of complex instructions through a sequence of microinstructions?

Answer Structure:

  1. Concept: Complex instructions (e.g., MUL, string/memory ops) are broken into a microroutine of elementary microinstructions stored in Control Memory (ROM).
  2. Sequencer Block Diagram (draw Section 4.2 Mermaid diagram: MUX → CAR → Control Memory → CMDR + Input Logic + SBR).
  3. 4 Sequencing Mechanisms:
    • Increment (CAR + 1): Sequential step execution.
    • Branching (Conditional/Unconditional): Loops and flag-based jumps inside complex microroutines.
    • Subroutine Call/Return (SBR): Reuses common sub-sequences (like Effective Address fetch).
    • Opcode Mapping: Maps IR opcode to the starting address of the instruction's microroutine.

Solved Q5 (2025-26 Sec B Q2d — 7 Marks | Instruction Formats)

Q: Evaluate Y=(A−B)/(C+D×E)Y = (A - B) / (C + D \times E) using 3-address, 2-address, 1-address, and 0-address instruction formats.

Solution:

  • 3-Address: SUB R1, A, B ; MUL R2, D, E ; ADD R2, R2, C ; DIV Y, R1, R2 (4 instructions)
  • 2-Address: MOV R1, A ; SUB R1, B ; MOV R2, D ; MUL R2, E ; ADD R2, C ; DIV R1, R2 ; MOV Y, R1 (7 instructions)
  • 1-Address (AC): LOAD D ; MUL E ; ADD C ; STORE T ; LOAD A ; SUB B ; DIV T ; STORE Y (8 instructions)
  • 0-Address (Stack): PUSH A ; PUSH B ; SUB ; PUSH C ; PUSH D ; PUSH E ; MUL ; ADD ; DIV ; POP Y (10 instructions)

Practice Questions (Self-Test)

  1. (2 Marks) Define control word, microroutine, and control memory.
  2. (2 Marks) Given R = 1011, show the 4-bit outputs for shl R, cir R, and ashr R. (Ans: 0110, 1101, 1101)
  3. (2 Marks) List the 3 types of pipeline hazards and one hardware/software fix for each.
  4. (7 Marks) Explain selective-set, selective-complement, selective-clear, and mask micro-operations with A = 1101 and B = 1010.
  5. (7 Marks) Explain Single-Bus CPU organization and write the step-by-step control sequence for executing LOAD R1, (R2).
  6. (7 Marks — Numerical) A 6-stage instruction pipeline operates at 250 MHz250\text{ MHz} (τ=4 ns\tau = 4\text{ ns}). Calculate the speedup and throughput for executing 50 instructions compared to a non-pipelined processor taking 24 ns per instruction. (Hint: Tnon=1200 nsT_{\text{non}} = 1200\text{ ns}, Tpipe=55×4=220 nsT_{\text{pipe}} = 55 \times 4 = 220\text{ ns}, S≈5.45S \approx 5.45.)