Measure an AHB pipeline. Count completed transfers, wait states, the edges where two transfers overlap, and the addresses a slow subordinate holds.
Hardware context: A one-manager AHB bus observed by a pipeline meter. Implement a pipeline meter that counts transfers, waits, overlapping phases and held addresses.
Lesson P4.1 drew AHB as two phases that overlap. A pipeline meter proves it on a real run. It counts how often a new address is taken in the same edge that an old data phase ends.
Write module ahb_pipe_meter. It watches HTRANS, HWRITE and HREADY of a one-manager bus. From those three it must know which transfer is in its data phase at every edge. Nobody tells it.
The fixture plays address phases of every kind: single transfers, bursts with BUSY cycles, IDLE gaps, and subordinates that insert wait states. HWRITE is random on IDLE and BUSY.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
hclk | 1 | stimulus, the same for every design |
hresetn | 1 | stimulus, the same for every design |
htrans | 2 | stimulus, the same for every design |
hwrite | 1 | stimulus, the same for every design |
hready | 1 | stimulus, the same for every design |
your transfers | 8 | stimulus, the same for every design |
your overlaps | 8 | stimulus, the same for every design |
Full specification
module ahb_pipe_meter (
input logic hclk,
input logic hresetn, // active low
input logic [1:0] htrans, // 0 IDLE, 1 BUSY, 2 NONSEQ, 3 SEQ
input logic hwrite,
input logic hready,
output logic [7:0] transfers, // NONSEQ and SEQ transfers whose data phase ended
output logic [7:0] writes, // ... of which writes
output logic [7:0] waits, // edges with HREADY low during a transfer's data phase
output logic [7:0] overlaps, // edges where a data phase ends and a new transfer's address is taken
output logic [7:0] held // edges where a NONSEQ or SEQ address phase waits with HREADY low
);
// your meter
endmodule
| Count | Adds one at an edge where |
|---|---|
| transfers | HREADY is 1 and the data phase that ends is a NONSEQ or SEQ transfer. |
| writes | The same, and that transfer's HWRITE was 1 in its address phase. |
| waits | HREADY is 0 and a NONSEQ or SEQ transfer is in its data phase. |
| overlaps | A transfer's data phase ends and a NONSEQ or SEQ address is taken at the same edge. |
| held | HREADY is 0 and HTRANS is NONSEQ or SEQ: an address phase that has to wait. |
An address phase is taken at an edge where HREADY is 1. Its data phase ends at the next edge where HREADY is 1. While HRESETn is 0, every count is 0 and no data phase is in progress. The result is {transfers, writes, waits, overlaps, held} in bits 39 to 0.
Examples
Example 1
Full Speed- Input
Address phases in order: NONSEQ write, NONSEQ write, NONSEQ write, NONSEQ write; then IDLE to edge 64 HWRITE is random on IDLE and BUSY.
- Output
transfers = 4, writes = 4, waits = 0, overlaps = 3, held = 0
Four writes in four edges. At the second, third and fourth address phase the previous data phase ends: three overlaps. The last data phase ends against an IDLE.
Example 2
No Overlap at All- Input
Address phases in order: NONSEQ write, IDLE, NONSEQ read, IDLE, NONSEQ read; then IDLE to edge 64 HWRITE is random on IDLE and BUSY.
- Output
transfers = 3, writes = 1, waits = 0, overlaps = 0, held = 0
Each transfer is followed by IDLE, so every data phase ends against an IDLE address phase: three transfers, no overlap.
Example 3
BUSY Is Not a Transfer- Input
Address phases in order: NONSEQ write, SEQ write (1 wait), BUSY, SEQ write, BUSY, BUSY, SEQ write (2 waits); then IDLE to edge 64 HWRITE is random on IDLE and BUSY.
- Output
transfers = 4, writes = 4, waits = 3, overlaps = 1, held = 0
BUSY cycles hold a burst open but carry no data. Their data phase is a zero-wait OKAY that counts as nothing.
Constraints and Contract
- Keep the module name and the ports. Counts stay below 256.
- There are no ERROR responses: every data phase ends with OKAY.
- Every input is always 0 or 1.
Hints
Hint 1
Keep one bit, and HWRITE, for the transfer in its data phase. Update them only at edges where HREADY is 1.
Hint 2
At an edge with HREADY high, first finish the old data phase, then start the new one from HTRANS.
Hint 3
HTRANS[1] is 1 exactly for NONSEQ and SEQ.
What the grader checks: Your meter replays nine traces of 64 edges: five directed and four seeded mixes of IDLE, BUSY, NONSEQ, SEQ and wait states. Its counts are compared with an independent model of the pipeline.
9 checks on Icarus · browser samples / server checks. Run the examples first, then check the full regression. Full checks use the server judge. Downloads contain public samples only. A passing result establishes the tested cases, not a proof for all possible inputs.
See all 1 steps and the final capstone