Decide for five caches whether the index can come from the page offset, and repair the ones that fail.
Hardware context: A direct-mapped cache with blocks of 16 bytes, indexed with virtual address bits while the TLB translates and tagged with the frame number, as test code. Sizing a level-1 cache that is looked up during address translation
A level-1 cache is looked up while the TLB translates. So its index may use only bits of the page offset: the index bits and the block-offset bits together may be no more than the offset bits of a page. Pages have 4096 bytes unless a question says otherwise. The size of a cache is its sets times its ways times its block size. An index bit that does not fit must come from the page number, and each such bit doubles the number of sets in which one block of a shared frame can be found.
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 bit counts, set counts and ways as whole numbers. For a yes or no question, enter 1 for yes and 0 for no.
| Entry | Your decision |
|---|---|
| PAGE_OFFSET_BITS | How many offset bits has a page of 4096 bytes? |
| BLOCK_OFFSET_BITS | How many block-offset bits has a block of 64 bytes? |
| MAX_SETS | With blocks of 64 bytes, how many sets may the cache have at most? |
| FITS_64_SETS | A cache has 64 sets of 64 bytes, direct-mapped: 4 KiB. Can it index early? |
| FITS_128_SETS | A cache has 128 sets of 64 bytes, direct-mapped: 8 KiB. Can it index early? |
| EXTRA_BITS_16K | A direct-mapped cache of 16 KiB has 256 sets of 64 bytes. How many of its index bits come from the page number? |
| PLACES_16K | In how many sets of that cache can one block of a shared frame be found? |
| MIN_WAYS_32K | A cache of 32 KiB with blocks of 64 bytes must index early. How many ways does it need at least? |
| SETS_16K_4_WAYS | A cache of 16 KiB has 4 ways and blocks of 64 bytes. How many sets has it? |
| FITS_16K_PAGES | Pages now have 16384 bytes. A direct-mapped cache has 256 sets of 64 bytes. Can it index early? |
| MAX_KIB | Pages have 4096 bytes. Give the largest size, in KiB, of a cache with WAYS ways that can still index early. |
Examples
Example 1
PAGE OFFSET BITS- Input
How many offset bits has a page of 4096 bytes?
- Output
matches = 1
Two to the power 12 is 4096.
Example 2
BLOCK OFFSET BITS- Input
How many block-offset bits has a block of 64 bytes?
- Output
matches = 1
Two to the power 6 is 64.
Example 3
MAX SETS- Input
With blocks of 64 bytes, how many sets may the cache have at most?
- Output
matches = 1
Twelve offset bits less 6 block-offset bits leave 6 index bits: 64 sets.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For MAX_KIB, enter a constant expression using WAYS. Only this entry changes with the parameter. The supported integer range is 1 through 32, inclusive.
Hints
Hint 1
Write the page offset bits, the block-offset bits and the index bits of each cache.
Hint 2
The cache can index early when index plus block offset is no more than the page offset.
Hint 3
To grow a cache that must index early, keep the sets and add ways.
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