Design Trade-offs & What Comes Next
Day 5 of 5 — where senior interviewers push past the basics
This is where interviews stop testing whether you built the pipeline and start testing whether you understand its limits. These five questions are the ones that separate "I completed the project" from "I understand the architecture space around it."
In This Post
- Q26. What's the simplest change to reduce the branch penalty, and what does it cost?
- Q27. If you added a multi-cycle execution unit (like a multiplier), what new hazard would appear, and how would you handle it?
- Q28. How would you add exception handling, e.g. for an illegal instruction or a misaligned memory access?
- Q29. This is a scalar, in-order pipeline. What's the next architectural step up, and why is it harder?
- Q30. What's the single most important concept a fresher should walk away with from a project like this?
Q26What's the simplest change to reduce the branch penalty, and what does it cost?
Resolve branches in ID instead of EX (see Part 3, Q17). The cost: an extra comparator and extra forwarding logic have to reach an earlier pipeline stage, increasing ID's critical path and complexity, in exchange for saving one cycle per taken branch.
Q27If you added a multi-cycle execution unit (like a multiplier), what new hazard would appear, and how would you handle it?
A structural/data hazard: a multi-cycle EX stage means the pipeline can no longer assume every instruction completes EX in one cycle. You'd need to stall (or add another pipeline stage) until the multi-cycle operation finishes, and update the hazard-detection and forwarding logic to account for a variable-latency source.
Q28How would you add exception handling, e.g. for an illegal instruction or a misaligned memory access?
Each stage needs the ability to flag an exception. On detection, you'd flush all younger instructions in the pipeline — similar to a branch flush, but clearing everything behind the faulting instruction, not just two stages — save the faulting PC, and redirect the PC to a trap handler address, while making sure any older, already-committed instruction ahead of the fault is unaffected.
Q29This is a scalar, in-order pipeline. What's the next architectural step up, and why is it harder?
Superscalar (fetch/decode/execute multiple instructions per cycle) or out-of-order execution. Both are harder because the hazard and forwarding logic — already the trickiest part of a scalar pipeline — gets multiplied across several instructions per stage. Out-of-order execution additionally requires tracking completion and commit order separately (e.g. via a reorder buffer) so results still appear to retire in program order even though they didn't execute that way.
Q30What's the single most important concept a fresher should walk away with from a project like this?
That pipelining's performance benefit and its correctness challenges are the same coin: overlapping instruction execution is what makes it fast, and exactly that overlap is what creates every hazard you have to solve. Forwarding, stalling, and flushing aren't extra complexity bolted onto pipelining — they're the necessary, inseparable other half of it.
Quick Recap
- Earlier branch resolution trades ID-stage complexity for a shorter penalty
- Multi-cycle execution units turn EX into a structural + data hazard source
- Exception handling is a wider flush: clear everything younger, redirect to a trap handler
- Superscalar and out-of-order execution scale the same hazard problems to N instructions
- Pipelining's speed and its hazards are inseparable — that's the whole idea
RISC-V Interview Q&A — 5-Day Series
- Day 1
Fundamentals - Day 2
Data Hazards - Day 3
Control Hazards - Day 4
Decode & Verify - Day 5
Trade-offs
Note: links for days not yet published will go live as each post is released —
swap the href="#" placeholders for the real post URLs once published.

Comments
Post a Comment