S3.19.1 Pick the Block Size

MediumImplement22 minIcarus Verilog · serverReview the topic

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

SignalWidthRole
question8input of each check
Full specification

Enter counts and cycles as whole numbers.

EntryYour decision
LINES_BLOCK_2How many lines has the cache with blocks of 2 words?
MISS_CYCLES_BLOCK_4How many cycles does one miss take with blocks of 4 words?
MISSES_BLOCK_1How many of the twelve reads miss with blocks of 1 word?
MISSES_BLOCK_4How many reads miss with blocks of 4 words?
CYCLES_BLOCK_1How many cycles do the twelve reads take with blocks of 1 word?
CYCLES_BLOCK_2And with blocks of 2 words?
CYCLES_BLOCK_4And with blocks of 4 words?
CYCLES_BLOCK_8And with blocks of 8 words?
BEST_BLOCKWhich block size, in words, takes the fewest cycles?
CYCLES_BLOCK_2_PREFETCHBlocks of 2 words, now with next-line prefetch: how many cycles?
PREFETCH_MISSESThe 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

Report a problem with this page

Your code SystemVerilogSaved locally
Ln 1, Col 1Tab indents · Ctrl/⌘ + Enter runs samples
Not run yet

LINES BLOCK 2

Input
How many lines has the cache with blocks of 2 words?
Expected output
matches = 1

8 words in blocks of 2 words: 4 lines.

Run samples executes all 3 public checks. Check all tests runs 11 checks on the server.

Icarus Verilog · server