← RTL Design Interviews · SoC Architecture Interviews
Interview Question · Defend an Architecture
Choose a Cache for a Loop
The Question
The interviewer asks
A proposed cache holds 16 words. A loop walks 32 array words and touches one of four distant counters after each word. What would you compare?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Hold data capacity and the address trace fixed. Vary block size and ways per set. With multiple ways, hold the rule for choosing a victim fixed. Count misses, time each refill, and check the cost of the hit path. Adjacent array reads can share a refill while distant counters compete for lines.
Self-Check
Tick each key point you covered in your answer.
What Interviewers Want to Hear (Junior)
Derive the set and tag before explaining a replacement.
What Interviewers Want to Hear (Senior)
Separate mapping conflicts from insufficient capacity and price each avoided miss.
Choose Your Follow-up
I’ve answered the opening question
Choose the route closest to your reasoning. Answer the follow-up aloud, then open the closing question.
I blamed the address pattern.
S3.3 uses ten address bits, four direct-mapped lines and 16 bytes per block. Why does 0x1ac hit after 0x1a4, yet 0x2a8 evicts that line?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Four low bits select a byte in the block, the next two select a line, and four remain for the tag. The first two addresses have tag 6 and index 2. The third has tag a and index 2, so the next read of 0x1a0 misses.
Self-Check
Tick each key point you covered in your answer.
Defend the Extra Comparators
Switch to the S3.6 loop over two eight-word arrays for four passes. Would adding ways help equally at eight and sixteen lines?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Eight lines cannot hold the 16 blocks the loop reuses, even with unrestricted placement. At sixteen lines, two ways remove 48 conflict misses. In the S3.4 cost table, moving from one to two ways raises cell count from 58 to 165. The longest path grows from seven gates to eight. Check that the saved misses repay the slower hit path.
Self-Check
Tick each key point you covered in your answer.
I wanted two ways.
For blocks 0,4,0,4,1,2,3,0,1 the S3.6 direct map records five compulsory, two conflict and one capacity miss. Which disappear with two ways?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Blocks 0 and 4 can coexist, removing the two conflict misses. The five first references still miss. Five distinct blocks pass through four lines before the later reuse of 0. Even the fully associative comparison cache lost it.
Self-Check
Tick each key point you covered in your answer.
Defend the Extra Comparators
Switch to the S3.6 loop over two eight-word arrays for four passes. Would adding ways help equally at eight and sixteen lines?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Eight lines cannot hold the 16 blocks the loop reuses, even with unrestricted placement. At sixteen lines, two ways remove 48 conflict misses. In the S3.4 cost table, moving from one to two ways raises cell count from 58 to 165. The longest path grows from seven gates to eight. Check that the saved misses repay the slower hit path.
Self-Check
Tick each key point you covered in your answer.
I enlarged each block.
With no prefetch, two-word blocks take 664 cycles and four-word blocks take 800. Does fetching the next line early change the choice?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Next-line prefetch cuts 664 cycles to 564 for two-word blocks and 800 to 616 for four-word blocks. Four-word blocks gain more cycles but still finish later. Compare total time on the same trace, including the cost of fetched neighbors.
Self-Check
Tick each key point you covered in your answer.
Defend the Extra Comparators
Switch to the S3.6 loop over two eight-word arrays for four passes. Would adding ways help equally at eight and sixteen lines?
You have two and a half minutes. Speak or type, then press Get Feedback under your answer. No credits needed.
Speech-to-text runs in your browser. Chrome and Edge may send audio to their own speech service.
You can edit your answer before you send it. Feedback uses AI and checks your answer only against our written answer. No credits are used and your answer is not saved.
Reveal the Model Answer
Eight lines cannot hold the 16 blocks the loop reuses, even with unrestricted placement. At sixteen lines, two ways remove 48 conflict misses. In the S3.4 cost table, moving from one to two ways raises cell count from 58 to 165. The longest path grows from seven gates to eight. Check that the saved misses repay the slower hit path.
Self-Check
Tick each key point you covered in your answer.
What People Get Wrong
Common wrong answers and why they fail.
Misconception
The same set index guarantees a hit.
The selected set still needs a valid matching tag.
Source S3.3, valid and tag comparison.
Half-Truth
Always choose the design with fewer misses.
Fetching extra words can lengthen every remaining miss.
Source S3.19, miss costs for two block sizes.
Learn It, Then Prove It
- Lesson S3.3The Direct-Mapped Cache in RTL
- Lesson S3.4Set-Associative Caches: Sets, Ways and Their Cost
- Lesson S3.6Cache Performance: The Three Kinds of Miss
- Lesson S3.16Replacement: LRU, FIFO, Random and the Pseudo-LRU Tree
- Lesson S3.19Block Size and Next-Line Prefetch
- Lesson S3.20Second-Level Caches, Split Caches and Choosing a Cache
- Problem S3.3.1Split the Address for This Cache
- Problem S3.4.1Hits for Three Shapes
- Problem S3.6.1Name the Miss