Run a trace of ten reads through a small cache, and name every miss by its cause.
Hardware context: One cache as a counting model, with a fully associative shadow cache of the same size beside it. Sizing a cache from a trace before it is built
A direct-mapped cache has four lines, and each line holds one block. The line of a block is its block number modulo 4. To name the misses, keep a second cache on paper: four lines, fully associative, and when it is full it gives up the block that was used longest ago. Both caches start empty. The trace of block numbers is: 2, 6, 2, 3, 4, 5, 6, 2, 3, 10.
This worksheet uses named constants. The first three entries show how to record your decisions.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
Enter the kind of a read as a code: 0 for a hit, 1 for a compulsory miss, 2 for a capacity miss, 3 for a conflict miss. Enter counts as whole numbers.
| Entry | Your decision |
|---|---|
| READ_1_KIND | The first read, of block 2: which code? |
| READ_2_KIND | The second read, of block 6: which code? |
| READ_3_KIND | The third read, of block 2: which code? |
| READ_7_KIND | The seventh read, of block 6: which code? |
| READ_8_KIND | The eighth read, of block 2: which code? |
| READ_9_KIND | The ninth read, of block 3: which code? |
| COMPULSORY | How many of the ten reads are compulsory misses? |
| CAPACITY | How many are capacity misses? |
| CONFLICT | How many are conflict misses? |
| CONFLICT_TWO_WAYS | The same four lines become 2 sets of 2 ways. How many conflict misses are left? |
| PING_PONG_CONFLICTS | A new trace reads blocks 0 and 4 in turn, ROUNDS times each, on the empty direct-mapped cache. Give the number of conflict misses. |
Examples
Example 1
READ 1 KIND- Input
The first read, of block 2: which code?
- Output
matches = 1
No block was read before this one: compulsory, code 1.
Example 2
READ 2 KIND- Input
The second read, of block 6: which code?
- Output
matches = 1
Block 6 is new: compulsory, code 1.
Example 3
READ 3 KIND- Input
The third read, of block 2: which code?
- Output
matches = 1
Block 6 pushed block 2 out of line 2. The second cache holds only blocks 2 and 6, so it still has block 2: conflict, code 3.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For PING_PONG_CONFLICTS, enter a constant expression using ROUNDS. Only this entry changes with the parameter. The supported integer range is 1 through 50, inclusive.
Hints
Hint 1
Follow the direct-mapped cache line by line, and keep the second cache as a list in order of last use.
Hint 2
For each miss ask: was the block read before? Does the second cache still hold it?
Hint 3
Add up each code, and check that the four counts make ten.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
11 checks on Icarus Verilog · server. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain your source only; samples require the simulation service. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 2 problems on this path