← RTL Design Interviews · SoC Architecture Interviews

Interview Question · Defend an Architecture

Choose a Cache for a Loop

L1 JuniorL3 Seniordefend an architecture

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?

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.

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?

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?

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?

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?

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?

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?

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