GateMCQSCIENTIFIC PREP LAB
PlanSign Up
INTERMEDIATEFrequently Tested 4 min read 23 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.
Key Formulas Summary
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}}
Note: 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}
Note: Ideal steady-state CPI = 1
#COA#Pipelining#Cache Memory#NAT

Practice Questions on This Chapter (6)

Q1GATE CS 2024 NATNATMEDIUM
+2M • 0 Neg

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?

Q2GATE CS COAMCQMEDIUM
+2M • -0.67

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?

⚡ Click an option above to verify instantly
Q3GATE CS COAMCQEASY
+1M • -0.33

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?

⚡ Click an option above to verify instantly
Q4GATE CS COAMCQMEDIUM
+2M • -0.67

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?

⚡ Click an option above to verify instantly
Q5GATE CS 2024 Set-2NATMEDIUM
+2M • 0 Neg

A non-pipelined processor runs at 2.5 GHz2.5\text{ GHz} (T=0.4 nsT = 0.4\text{ ns}) with average CPI=4\text{CPI} = 4. A 5-stage pipelined version has stage delays 150,120,160,140,130 ps150, 120, 160, 140, 130\text{ ps} plus pipeline latch overhead 40 ps40\text{ ps}, and achieves CPIpipe=1.25\text{CPI}_{\text{pipe}} = 1.25 due to stalls. What is the speedup of the pipelined processor over the non-pipelined processor?

Q6GATE CS 2019NATMEDIUM
+2M • 0 Neg

A processor has an L1 cache with hit time 2 ns2\text{ ns} and hit rate 95%95\%, an L2 cache with hit time 10 ns10\text{ ns} and local hit rate 80%80\%, and main memory access penalty 100 ns100\text{ ns} (hierarchical inclusive serial lookup: L2 accessed only on L1 miss; RAM accessed only on L2 miss). What is the Average Memory Access Time (AMAT) in nanoseconds?

Previous TopicCombinational Adders, Carry-Lookahead & Bitwise Manipulation Logics (Animated)Next Topic Addressing Modes, Hardwired vs Microprogrammed Control Unit & DMA I/O