S0.7.1 Hit or Miss

EasyImplement12 minIcarus Verilog · serverReview the topic

Split addresses into line and tag, and decide hit or miss for eight reads of a small cache.

Hardware context: Eight-line cache in front of a 64-box memory. Reasoning about cache behaviour of a loop

The cache of lesson S0.7 has eight lines and sits in front of a memory of 64 boxes. The bottom three bits of a six-bit address are the line number. The top three bits are the tag. The cache starts empty. A program makes the eight reads below, in order.

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
ReadBox (address)Address in binary
120010 100
221010 101
320010 100
428011 100
521010 101
620010 100
752110 100
820010 100

For a hit-or-miss entry, enter 1 for a hit and 0 for a miss. A hit costs 1 cycle and a miss costs 10.

EntryYour decision
LINE_20Line number used by box 20.
TAG_20Tag of box 20.
READ_1Read 1, of box 20: hit (1) or miss (0)?
LINE_28Line number used by box 28.
TAG_28Tag of box 28.
READ_3Read 3, of box 20: hit (1) or miss (0)?
READ_4Read 4, of box 28: hit (1) or miss (0)?
READ_5Read 5, of box 21: hit (1) or miss (0)?
READ_6Read 6, of box 20: hit (1) or miss (0)?
HITSNumber of hits among the eight reads.
END_TAGTag stored in line 4 after read 8.
CYCLESCycles that the eight reads cost in all.
CYCLES_FOR_SLOWHow many cycles do the eight reads cost in all, if a miss costs SLOW cycles and a hit still costs 1?

Examples

Example 1

LINE 20
Input
Line number used by box 20.
Output
matches = 1

The bottom three bits of 010 100 are 100, which is 4.

Example 2

TAG 20
Input
Tag of box 20.
Output
matches = 1

The top three bits are 010, which is 2.

Example 3

READ 1
Input
Read 1, of box 20: hit (1) or miss (0)?
Output
matches = 1

The cache starts empty, so the first read of any box is a miss.

Constraints and Contract

  • Keep the parameter and named constants. Use the numeric codes and units on this page.
  • For CYCLES_FOR_SLOW, enter a constant expression using SLOW. Only this entry changes with the parameter. The supported integer range is 2 through 17, inclusive.

Hints

Hint 1

The bottom three bits pick the line. The top three bits are the tag.

Hint 2

For each line, write down the tag it holds now. Every line starts empty.

Hint 3

A read is a hit only if its line holds its tag. On a miss, write the new tag into the line.

What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.

13 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

LINE 20

Input
Line number used by box 20.
Expected output
matches = 1

The bottom three bits of 010 100 are 100, which is 4.

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

Icarus Verilog · server