∑GateAndNet
Practice MCQs
GATE CS / Computer Organization & Architecture
Edit
INTERMEDIATE🔥 High-Yield Exam Topic 4 min read 4 views

5-Stage Instruction Pipelining, Hazards & Cache Mapping Bit Math

Clock cycle formulas, stall penalties, operand forwarding, and Direct vs K-Way Set-Associative Tag/Index/Offset splits.

Physical Address Bit Split for Cache Mapping

Suppose Main Memory has 2m2^m bytes (mm-bit physical address), Cache size =C= C bytes, and Block (Line) size =B=2b= B = 2^b bytes:

  • Number of Cache Lines: L=C/BL = C / B
  • Block Offset bits: b=log⁡2Bb = \log_2 B
Mapping SchemeSets (SS)Index / Set BitsTag BitsComparator Count
Direct MappedLLlog⁡2L\log_2 Lm−log⁡2L−bm - \log_2 L - b11
KK-Way Set AssociativeL/KL / Klog⁡2(L/K)\log_2(L / K)m−log⁡2(L/K)−bm - \log_2(L/K) - bKK
Fully Associative1100 bitsm−bm - bLL
📐 Key Formula

Tag Directory Size: Always multiply the number of Cache Lines (LL) by (Tag bits + Valid bit + Dirty bit + LRU bits)! Increasing associativity KK by a factor of 22 decreases Set Index by 11 bit and increases Tag by 11 bit.

Data Hazard Classification

For instruction II followed by instruction JJ:

  • RAW (Read After Write — True Dependency): JJ reads a register before II writes it. Solved via Operand Forwarding (except Load-Use hazard which still costs 11 stall cycle!).
  • WAR (Anti-Dependency) & WAW (Output Dependency): Name dependencies — eliminated completely by Register Renaming in out-of-order processors.
📐 Quick Revision Formula Sheet
Pipelined Execution Time (n instructions, k stages)
Tpipe=(k+n−1+Total Stalls)×τcycleT_{\text{pipe}} = (k + n - 1 + \text{Total Stalls}) \times \tau_{\text{cycle}}
💡 Cycle time tau = max(stage delays) + register latch delay
Average CPI with Stalls
CPIavg=1+Stall Cycles per Instruction\text{CPI}_{\text{avg}} = 1 + \text{Stall Cycles per Instruction}
💡 Ideal steady-state CPI = 1
#COA#Pipelining#Cache Memory#NAT

🎯 Practice PYQs on This Topic (4)

Q1.GATE CS 2024 NATNATMEDIUM
+2 Marks • No Negative

A computer has a 3232-bit physical address space and a 4-way set-associative cache of total capacity 64 KB64\text{ KB} with a cache block size of 64 bytes64\text{ bytes}. How many bits are in the Tag field of the physical address?

Q2.GATE CS COAMCQMEDIUM
+2 Marks • -0.67 Neg

A 64 KB64\text{ KB} 4-way set-associative cache has block (line) size of 64 bytes64\text{ bytes} in a system with a 3232-bit physical address. How many bits are in the Tag field?

Q3.GATE CS COAMCQEASY
+1 Marks • -0.33 Neg

In a standard in-order 5-stage RISC instruction pipeline (IF, ID, EX, MEM, WB), which data hazard can actually occur and require stalling or operand forwarding?

Q4.GATE CS COAMCQMEDIUM
+2 Marks • -0.67 Neg

An L1 cache has access time 2 ns2\text{ ns} and hit ratio 95%95\%. Main memory access penalty on a cache miss (including block fill) is 60 ns60\text{ ns}. Under simultaneous/hierarchical model Tavg=Tc+(1−h)TmT_{\text{avg}} = T_c + (1 - h)T_m, what is the Average Memory Access Time?

Previous TopicBoolean Minimization, K-Maps, Multiplexers & Sequential Flip-Flop CountersNext Topic Addressing Modes, Hardwired vs Microprogrammed Control Unit & DMA I/O