Price a walk of twelve words through four block sizes, and choose the block by cycles.
Hardware context: One cache of 16 words as a counting model, cut into blocks of 1 to 16 words, with a next-line prefetch. Choosing the block size and the prefetch of a cache
A direct-mapped cache holds 8 words in all. It can be built with blocks of 1, 2, 4 or 8 words, so it has 8, 4, 2 or 1 lines. A program reads words 0 to 11 in a row, once, on the empty cache. A hit takes 1 cycle. A miss takes 5 cycles plus 2 cycles for each word of the block, in all. With next-line prefetch, a miss also brings in the block after the one that missed, at no cost in cycles.
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 counts and cycles as whole numbers.
| Entry | Your decision |
|---|---|
| LINES_BLOCK_2 | How many lines has the cache with blocks of 2 words? |
| MISS_CYCLES_BLOCK_4 | How many cycles does one miss take with blocks of 4 words? |
| MISSES_BLOCK_1 | How many of the twelve reads miss with blocks of 1 word? |
| MISSES_BLOCK_4 | How many reads miss with blocks of 4 words? |
| CYCLES_BLOCK_1 | How many cycles do the twelve reads take with blocks of 1 word? |
| CYCLES_BLOCK_2 | And with blocks of 2 words? |
| CYCLES_BLOCK_4 | And with blocks of 4 words? |
| CYCLES_BLOCK_8 | And with blocks of 8 words? |
| BEST_BLOCK | Which block size, in words, takes the fewest cycles? |
| CYCLES_BLOCK_2_PREFETCH | Blocks of 2 words, now with next-line prefetch: how many cycles? |
| PREFETCH_MISSES | The program now reads COUNT words in a row, where COUNT is a multiple of 4. Blocks have 2 words, with next-line prefetch. Give the number of misses. |
Examples
Example 1
LINES BLOCK 2- Input
How many lines has the cache with blocks of 2 words?
- Output
matches = 1
8 words in blocks of 2 words: 4 lines.
Example 2
MISS CYCLES BLOCK 4- Input
How many cycles does one miss take with blocks of 4 words?
- Output
matches = 1
5 cycles plus 2 for each of 4 words: 13.
Example 3
MISSES BLOCK 1- Input
How many of the twelve reads miss with blocks of 1 word?
- Output
matches = 1
Each word is its own block, and each is read for the first time: 12.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For PREFETCH_MISSES, enter a constant expression using COUNT. Only this entry changes with the parameter. The supported integer range is 4 through 100, inclusive.
Hints
Hint 1
For each block size, cut the twelve words into blocks. The first read of each block misses.
Hint 2
Work out the cycles of one miss for that block size.
Hint 3
Misses times their price, plus one cycle for each hit.
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 1 problem on this path