Count the clock cycles of a hit and of a miss, state by state, and see what the block size and a slow memory do to them.
Hardware context: A direct-mapped cache with its controller in front of a memory on the bus, acted out edge by edge as a script. Designing and timing the miss path of a cache
A cache controller has three states. A request is seen in IDLE, which takes 1 cycle. COMPARE takes 1 cycle: on a hit the request is done there. On a miss the controller goes to ALLOCATE and fetches the block over the bus. The bus overlaps its phases: the address of a word goes out while the data of the word before comes back. So a block of W words takes W + 1 cycles. Then COMPARE runs once more, hits, and the request is done.
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 cycles and counts as whole numbers. Enter an average in tenths of a cycle: 3.8 cycles is 38.
| Entry | Your decision |
|---|---|
| HIT_CYCLES | How many cycles does a read that hits take, from IDLE to done? |
| ALLOCATE_CYCLES | How many cycles does ALLOCATE take for a block of 4 words? |
| MISS_CYCLES | How many cycles does a read that misses take, with blocks of 4 words? |
| PENALTY | How many more cycles than a hit is that? |
| ALLOCATE_8 | How many cycles does ALLOCATE take for a block of 8 words? |
| MISS_8 | And how many cycles does a miss take with blocks of 8 words? |
| TRACE_CYCLES | A program makes 10 reads with blocks of 4 words. Three miss. How many cycles in all? |
| AVERAGE_TENTHS | What is the average for one read, in tenths of a cycle? |
| SLOW_ALLOCATE | A slower memory holds every data phase for one extra cycle. How many cycles does ALLOCATE take now, for 4 words? |
| FIRST_WORD | A read of byte address 0x1a4 misses. Blocks are 16 bytes and words are 4 bytes. What is the number of the first word that is fetched? Enter it in decimal. |
| MISS_VARIANT | Now a block has WORDS words, from 1 to 16, on the first memory. Give the cycles of a read that misses. |
Examples
Example 1
HIT CYCLES- Input
How many cycles does a read that hits take, from IDLE to done?
- Output
matches = 1
One cycle in IDLE and one in COMPARE.
Example 2
ALLOCATE CYCLES- Input
How many cycles does ALLOCATE take for a block of 4 words?
- Output
matches = 1
Four addresses and four data words, overlapped: 4 + 1.
Example 3
MISS CYCLES- Input
How many cycles does a read that misses take, with blocks of 4 words?
- Output
matches = 1
IDLE 1, COMPARE 1, ALLOCATE 5, COMPARE again 1.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For MISS_VARIANT, enter a constant expression using WORDS. Only this entry changes with the parameter. The supported integer range is 1 through 16, inclusive.
Hints
Hint 1
Write the states that a request passes through, in order.
Hint 2
Only ALLOCATE depends on the block and on the memory.
Hint 3
A miss passes through COMPARE twice.
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 4 problems on this path