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
| Signal | Width | Role |
|---|---|---|
question | 8 | input of each check |
Full specification
| Read | Box (address) | Address in binary |
|---|---|---|
| 1 | 20 | 010 100 |
| 2 | 21 | 010 101 |
| 3 | 20 | 010 100 |
| 4 | 28 | 011 100 |
| 5 | 21 | 010 101 |
| 6 | 20 | 010 100 |
| 7 | 52 | 110 100 |
| 8 | 20 | 010 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.
| Entry | Your decision |
|---|---|
| LINE_20 | Line number used by box 20. |
| TAG_20 | Tag of box 20. |
| READ_1 | Read 1, of box 20: hit (1) or miss (0)? |
| LINE_28 | Line number used by box 28. |
| TAG_28 | Tag of box 28. |
| READ_3 | Read 3, of box 20: hit (1) or miss (0)? |
| READ_4 | Read 4, of box 28: hit (1) or miss (0)? |
| READ_5 | Read 5, of box 21: hit (1) or miss (0)? |
| READ_6 | Read 6, of box 20: hit (1) or miss (0)? |
| HITS | Number of hits among the eight reads. |
| END_TAG | Tag stored in line 4 after read 8. |
| CYCLES | Cycles that the eight reads cost in all. |
| CYCLES_FOR_SLOW | How 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