Reservation stations
What Problem Do They Solve?
Traditional in-order pipelines stall when:
- RAW hazards: Instruction needs a result that's not ready
- WAR/WAW hazards: False dependencies on register names
- Structural hazards: Multiple instructions want the same execution unit
Why not just use a centralized instruction queue? A single queue creates a bottleneck—every instruction must check every other instruction's dependencies. Reservation stations distribute this work: each station independently tracks only its own operands.
Architecture Components
Key Structures
-
Reservation Stations (RS): Bufers holding waiting instructions
Op: Operation to perform (ADD, MUL, LOAD, etc.)Vj, Vk: Source operand values (when available)Qj, Qk: Tags of reservation stations producing operands (when pending)Busy: Station occupied flagA: Address field (for loads/stores)
-
Common Data Bus (CDB): Broadcast network
- Functional units broadcast results with their RS tag
- All RS and register file snoop simultaneously
- Why broadcast? Avoids point-to-point connections
-
Register Status Table: Maps each register to the RS tag producing its next value
- Empty entry = value ready in register file
- Tag present = waiting for that RS
Tomasulo's Algorithm Flow
Stage 1: Issue
- Decode instruction
- Allocate a free reservation station
- If operand in register file: copy value to
Vj/Vk - If operand pending: copy producing RS tag to
Qj/Qk - Update register status to point to this RS (for WAW elimination)
Stage 2: Execute
- Wait until
Qj = Qk = 0(all operands ready) - Issue to functional unit
- Load/store: compute address when base ready, then access memory
Stage 3: Write Result
- Broadcast on CDB with RS tag
- All RS check
Qj/Qk—if match, capture value and clear tag - Register file updates if status matches this RS tag
- Free the reservation station
Worked Example: Instruction Sequence
1. MUL R1, R2, R3 ; R1 = R2 * R3
2. ADD R4, R1, R5 ; R4 = R1 + R5 (RAW on R1)
3. SUB, R6, R7 ; R1 = R6 - R7 (WAW on R1)
4. ADD R8, R1, R9 ; R8 = R1 + R9 (RAW on new R1)Cycle 1: Issue MUL
- Allocate RS: Mult1
Mult1: {Op=MUL, Vj=R2_val, Vk=R3_val, Qj=0, Qk=0}Status[R1] = Mult1
Cycle 2: Issue ADD (inst 2)
- Allocate RS: Add1
- R1 not ready →
Add1: {Op=ADD, Vj=?, Vk=R5_val, Qj=Mult1, Qk=0} Status[R4] = Add1
Cycle 3: Issue SUB (inst 3)
- Allocate RS: Add2
Add2: {Op=SUB, Vj=R6_val, Vk=R7_val, Qj=0, Qk=0}- Key:
Status[R1] = Add2(overwrites Mult1!)- Why this matters: Inst 4 will now wait for Add2, not Mult1
Cycle 4: Issue ADD (inst 4)
Add3: {Op=ADD, Vj=?, Vk=R9_val, Qj=Add2, Qk=0}- Reads
Status[R1] = Add2(not Mult1)
Cycle 10: Mult1 completes
- Broadcasts on CDB with tag Mult1
- Add1 captures result:
Qj=0, V<result> - Register file ignores (Status[R1] ≠ Mult1)
- Why ignore? The WAW means this is a "dead" value
Cycle 12: Add2 completes
- Broadcasts with tag Add2
- Add3 captures:
Qj=0 - Register file writes R1 (Status[R1] = Add2 matches)
Common Mistakes
Active Recall Checks
Recall Explain to a 12-year-old
Imagine you're doing homework, but some problems need answers from earlier problems. Normally you'd wait, doing nothing. Reservation stations are like having separate desks for each problem. You write down the problem, and if answer is missing, you write "waiting for desk3's answer." When desk 3 shouts its answer, you fill it in and solve immediately. No waiting in line! You can even have two problems waiting for the same answer—both hear the shout. That's how a CPU does multiple things at once without getting confused about which results go where.
Connections
- 5.3.05-Dynamic-scheduling: Reservation stations enable dynamic scheduling
- 5.3.04-Scoreboarding: Earlier centralized approach; RS distribute dependency tracking
- 5.3.07-Reorder-buffer: Modern extension to RS for precise exceptions
- 5.2.03-Register-renaming: RS implement dynamic renaming; explicit PRF is alternative
- 4.6.02-Pipeline-hazards: RS eliminate certain classes of pipeline stalls
- 5.3.09-Load-store-queues: Memory equivalent of RS for disambiguation
Design Tradeoffs
RS Count per FU:
- More RS → more parallelism, larger area/power
- Too few → issue stalls despite free FUs
- Typical: 5-10 RS per integer, 8-15 for FP
CDB Width:
- One bus: simple, cheap structural bottleneck
- Multiple: higher throughput, complex arbitration, wiring
Tag Bits:
- bits per tag
- Example: 64 total RS → 6-bit tags
- Every operand field needs this overhead
#flashcards/hardware
What do reservation stations decouple? :: Instruction issue from execution—instructions can be issued even when operands aren't ready, waiting in RS until operands arrive.
What three fields track operand status in a reservation station?
How do reservation stations eliminate WAW hazards?
What is the Common Data Bus (CDB) and why broadcast?
When does a reservation station free itself?
What happens when a RS broadcasts but the register status doesn't match its tag?
Why can't reservation stations eliminate memory dependencies?
How many bits are needed for RS tags?
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Reservation stations ek bahut smart idea hai jo CPU ko out-of-order execution karne deta hai. Socho ki instructionsek restaurant ke orders hain aur operands (data) ingredients hain. Agar ingredients ready nahi hai, toh normally pora kitchen ruk jayega. Lekin reservation stations ka concept yeh hai ki har chef station (RS) apna order hold karta hai aur jab uske sare ingredients aa jate hain tab turant execute karta hai—kisi central queue mein wait karne ki zarurat nahi.
Iska sabse bada fayda yeh hai ki false dependencies (jaise WAR aur WAW hazards) automatically eliminate ho jate hain through register renaming. Jab instruction issue hoti hai, RSek tag assign karta hai aur baki sare instructionsuss tag ko track karte hain—actual register name ko nahi. Isse multiple instructions parallel mein kaam kar sakti hain bina ek dusre ko block kiye. Common Data Bus (CDB) pe jab result broadcast hota hai with its tag, toh waiting RS apna operand capture karlete hain. Yeh mechanism modern high-performance processors ka backbone hai—Intel, AMD, ARM sab use karte hain.
Engineering perspective se dekho toh RS design mein trade-off hai: zyada RS means zyada parallelism but zyada area aur power consumption bhi. Typically5-10 RS per functional unit hote hain. CDB ek structural bottleneck ban sakta hai kyunki ek cycle mein sirf ek result broadcast ho sakta hai classic Tomasulo design mein, isliye modern CPUs multiple bypass networks use karti hain. Yeh concept samajhna zaroori hai kyunki yeh dikhata hai ki kaise hardware dynamically dependencies resolve karta hai without programmer kouch karna pade.