Recover the cost of a short routine from paired snapshots, including a counter that crosses zero.
Hardware context: ap_soc performance monitoring. Core and peripheral performance analysis
These exercise snapshots use eight-bit wrapping counters. During each interval both increments total less than 256. Each pair reads cycles first and retired instructions second.
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
Report CPI in tenths, truncating only the final result. Enter 255 when no instruction retires.
| Entry | Your decision |
|---|---|
| CLOCKS | Start (12,4), stop (30,10). How many cycles elapsed? |
| WORK | Same interval. How many instructions retired? |
| COST | Same interval. What is CPI in tenths? |
| WRAP | Start (250,20), stop (10,24). CPI in tenths? |
| BOTH | Start (252,254), stop (3,2). CPI in tenths? |
| IDLE | Start (60,13), stop (81,13). CPI in tenths? |
| COMBINED | Two successive windows use 6 and 18 cycles for 3 and 3 retirements. Combined CPI in tenths? |
| MISS | Three fetches miss. One waits four extra cycles. How many miss starts does the selected event count? |
| REDIRECT | Four branches retire. Two redirect fetch after a wrong prediction. Count mispredictions. |
| WRITES | APB write trace: one setup, three selected access edges with ready low, one with ready high. Count writes. |
| RETRY | High, low, high again reads give 5, 0, 6. Enter 1 to retry or 0 to use the sample. |
| WEIGHTED | Two successive windows use 8 and 9 cycles for 2 and 9 retirements. Combined CPI in tenths? |
| REPLAY | A replay takes 11 + WAIT cycles for four retirements. CPI in tenths? |
Examples
Example 1
CLOCKS- Input
Start (12,4), stop (30,10). How many cycles elapsed?
- Output
value = 18
The clock advanced from 12 to 30.
Example 2
WORK- Input
Same interval. How many instructions retired?
- Output
value = 6
Six instructions retired between the snapshots.
Example 3
COST- Input
Same interval. What is CPI in tenths?
- Output
value = 30
Eighteen cycles shared by six instructions gives 3.0 cycles each.
Constraints and Contract
- Keep the parameter and named constants. Use the numeric codes and units on this page.
- For REPLAY, enter a constant expression using WAIT. Only this entry changes with the parameter. The supported integer range is 0 through 7, inclusive.
Hints
Hint 1
Pair snapshots from the same workload.
Hint 2
Use modular differences for each counter.
Hint 3
Divide elapsed cycles by completed instructions.
What the grader checks: Each check compares the full eight-bit answer. Parameter trials change one condition and keep the other decisions fixed.
16 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