Run one trace of ten reads through four cache lines arranged in three ways, and count what each arrangement costs.
Hardware context: Eight cache lines arranged as sets and ways, as a counting model, and the compare-and-select logic of 1, 2, 4 and 8 ways through synthesis. Choosing the number of ways of a cache
A cache has four lines, and each line holds one block. The lines can be arranged as 4 sets of 1 way (direct-mapped), as 2 sets of 2 ways, or as 1 set of 4 ways (fully associative). The set of a block is its block number modulo the number of sets. A miss uses an empty way of its set first. When the set is full, it replaces the block of that set that was used longest ago. The cache starts empty. The trace of block numbers is: 0, 4, 0, 4, 2, 6, 0, 2, 8, 8.
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 set numbers, counts and widths as whole numbers. Block numbers have 8 bits.
| Entry | Your decision |
|---|---|
| DM_SET_OF_6 | With 4 sets of 1 way, which set does block 6 use? |
| TWO_WAY_SET_OF_6 | With 2 sets of 2 ways, which set does block 6 use? |
| FULL_SETS | How many sets has the fully associative arrangement? |
| DM_HITS | How many of the ten reads hit with 4 sets of 1 way? |
| TWO_WAY_HITS | How many of the ten reads hit with 2 sets of 2 ways? |
| FULL_HITS | How many of the ten reads hit with 1 set of 4 ways? |
| FULL_LAST_OUT | With 1 set of 4 ways, which block is replaced when block 8 arrives? |
| FULL_COMPARATORS | How many tag comparators does the fully associative arrangement need? |
| TWO_WAY_TAG_BITS | Block numbers have 8 bits. How many bits has the tag with 2 sets of 2 ways? |
| FULL_TAG_BITS | And how many bits has the tag with 1 set of 4 ways? |
| PING_PONG_HITS | A new trace reads blocks 0 and 4 in turn, ROUNDS times each, on the empty cache with 2 sets of 2 ways. Give the number of hits. With 4 sets of 1 way the same trace would have none. |
Examples
Example 1
DM SET OF 6- Input
With 4 sets of 1 way, which set does block 6 use?
- Output
matches = 1
6 modulo 4 is 2.
Example 2
TWO WAY SET OF 6- Input
With 2 sets of 2 ways, which set does block 6 use?
- Output
matches = 1
6 modulo 2 is 0.
Example 3
FULL SETS- Input
How many sets has the fully associative arrangement?
- Output
matches = 1
All four lines are the four ways of one set.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For PING_PONG_HITS, enter a constant expression using ROUNDS. Only this entry changes with the parameter. The supported integer range is 1 through 50, inclusive.
Hints
Hint 1
For each arrangement, write the set of every block in the trace.
Hint 2
Follow each set alone, and keep its blocks in order of last use.
Hint 3
Count one comparator for each way, and take the set number out of the block number to get the tag.
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 2 problems on this path