Count where one hundred reads are served, add up the cycles, and find the average access time with and without a second cache.
Hardware context: A cache of four lines in front of a memory, with an optional second level. Sizing a memory hierarchy for a workload
A program makes 100 reads. Every read looks in the level-1 cache, which takes 1 cycle. The level-1 cache hits on 90 of them. Each level-1 miss looks in the level-2 cache, which takes 5 more cycles. Of those, 2 miss in level 2 as well and go to memory, which takes 50 more cycles. All values are exercise values.
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 as whole numbers, and cycles as whole numbers. Enter an average access time in tenths of a cycle: 2.5 cycles is 25. Enter a rate in percent.
| Entry | Your decision |
|---|---|
| L1_MISSES | How many of the 100 reads miss in level 1? |
| L2_LOOKUPS | How many reads look in level 2? |
| MEMORY_READS | How many reads go all the way to memory? |
| L1_CYCLES | Cycles spent in level 1, over all 100 reads? |
| L2_CYCLES | Cycles spent in level 2? |
| MEMORY_CYCLES | Cycles spent on memory? |
| TOTAL_CYCLES | Cycles for all 100 reads? |
| AVERAGE_TENTHS | The average access time, in tenths of a cycle? |
| NO_L2_TENTHS | The average with the level-2 cache taken out, in tenths of a cycle? Every level-1 miss then goes to memory. |
| TO_MEMORY_PERCENT | With both levels, what percent of all reads reach memory? |
| AVERAGE_VARIANT | Now L2_MISSES of the 10 level-2 lookups miss, from 0 to 10. Give the average access time in tenths of a cycle. |
Examples
Example 1
L1 MISSES- Input
How many of the 100 reads miss in level 1?
- Output
matches = 1
100 reads less 90 hits leaves 10 misses.
Example 2
L2 LOOKUPS- Input
How many reads look in level 2?
- Output
matches = 1
Only a level-1 miss goes on to level 2, so 10.
Example 3
MEMORY READS- Input
How many reads go all the way to memory?
- Output
matches = 1
The 2 reads that miss in level 2 as well.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For AVERAGE_VARIANT, enter a constant expression using L2_MISSES. Only this entry changes with the parameter. The supported integer range is 0 through 10, inclusive.
Hints
Hint 1
Write down how many reads reach each level before any multiplication.
Hint 2
A read pays for every level it visits, in turn.
Hint 3
Add all cycles, then divide by the number of reads.
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