Build an APB5 bridge stage that carries every user signal and the wake-up request across. Keep each one valid in its own cycles.
Hardware context: An APB5 link with wake-up and user signals between a requester and a clock-gated completer. Implement an APB5 bridge stage that carries every user signal and the wake-up request.
Lesson P3.13 said that a bridge should make room for all four user signals, even if most completers ignore them. This bridge splits a long APB5 bus into two segments, and it must not lose a bit of sideband on the way.
Write module apb5_user_bridge. For every upstream transfer it runs one downstream transfer, holding the upstream one with PREADY low. PAUSER, and PWUSER for writes, must reach the completer unchanged through setup and access. PRDATA, PSLVERR, PRUSER and PBUSER must come back in the upstream completion cycle.
The completer behind the bridge waits for PWAKEUP before it raises PREADY, as the specification permits. Some upstream requesters never raise PWAKEUP. The bridge must still give its own downstream transfers a PWAKEUP that follows the rules.
Signals in the Timeline
| Signal | Width | Role |
|---|---|---|
transfers | 4 | input of each check |
Full specification
module apb5_user_bridge (
input logic pclk,
input logic presetn, // active low
// upstream: an APB5 completer port
input logic psel,
input logic penable,
input logic pwrite,
input logic [7:0] paddr,
input logic [31:0] pwdata,
input logic pwakeup,
input logic [7:0] pauser,
input logic [15:0] pwuser,
output logic pready,
output logic [31:0] prdata,
output logic pslverr,
output logic [15:0] pruser,
output logic [7:0] pbuser,
// downstream: an APB5 requester port
output logic m_psel,
output logic m_penable,
output logic m_pwrite,
output logic [7:0] m_paddr,
output logic [31:0] m_pwdata,
output logic m_pwakeup,
output logic [7:0] m_pauser,
output logic [15:0] m_pwuser,
input logic m_pready,
input logic [31:0] m_prdata,
input logic m_pslverr,
input logic [15:0] m_pruser,
input logic [7:0] m_pbuser
);
// your bridge
endmodule
| Downstream | Rule |
|---|---|
| transfer | One per upstream transfer: a setup cycle, then access until m_pready. Address, direction and data are the upstream ones. |
| m_pauser, m_pwuser | The upstream values, the same at every edge of the downstream transfer (PWUSER only matters in writes). |
| m_pwakeup | Once it is high together with m_psel, it stays high until m_pready. The completer gives no m_pready while it is low. |
| Upstream completion | Must carry |
|---|---|
| prdata, pslverr | The downstream transfer's data and response. |
| pruser | For a read, the downstream PRUSER of that transfer. |
| pbuser | For every transfer, the downstream PBUSER of that transfer. |
The result is {done, errs, bad, pruser_sum, pbuser_sum, ram_sum}. bad counts every downstream rule broken and every unknown PRUSER or PBUSER at an upstream completion. The sums add the user values your bridge returned.
Examples
Example 1
The Sideband Both Ways- Input
write 0x08 = aabbccdd, PWUSER 1234, PAUSER 3c, 1 idle; read 0x08, PAUSER 3d, 1 idle Upstream PWAKEUP: a cycle before each transfer; the completer waits 0 cycles and for PWAKEUP before PREADY
- Output
done = 2, errs = 'b00000000, bad = 0, pruser_sum = 0x8f7, pbuser_sum = 0x88, ram_sum = 0x1dcd53
The write carries PAUSER 3c and PWUSER 1234 to the completer. The read returns PRUSER 08f7 and PBUSER 04; the write returned PBUSER 84.
Example 2
No PWAKEUP Upstream- Input
write 0x0c = 12345678, PWUSER 2222, PAUSER 11, 1 idle; read 0x0c, PAUSER 12, 1 idle; read 0x10, PAUSER 13, 1 idle Upstream PWAKEUP: never raised; the completer waits 1 cycle and for PWAKEUP before PREADY
- Output
done = 3, errs = 'b00000000, bad = 0, pruser_sum = 0x1de2, pbuser_sum = 0x94, ram_sum = 0x9356ed
The requester never raises PWAKEUP. The completer waits for it, so the bridge must raise its own for each downstream transfer, or the bus hangs.
Example 3
Errors Keep Their Sideband- Input
write 0x44 = 1, PWUSER 6666, PAUSER 55, 1 idle; read 0x48, PAUSER 56, 1 idle; read 0x14, PAUSER 57, 1 idle Upstream PWAKEUP: never raised; the completer waits 1 cycle and for PWAKEUP before PREADY
- Output
done = 3, errs = 'b00000011, bad = 0, pruser_sum = 0x5da2, pbuser_sum = 0xd0, ram_sum = 0x680078
Offsets from 0x40 fail with PSLVERR, but PBUSER is still valid at completion and must come back.
Constraints and Contract
- Keep the module name and the ports. The upstream requester is correct and holds its transfer as long as PREADY is low.
- The fixture drives its outputs after each rising edge and samples yours just before the next one.
- Do not reach outside your ports.
Hints
Hint 1
The upstream request is stable until you raise PREADY, so it can drive the downstream request directly.
Hint 2
Four states: idle, downstream setup, downstream access, upstream done.
Hint 3
Downstream PWAKEUP can be the upstream one OR "the bridge is busy". Then it is high through every downstream transfer.
What the grader checks: Your bridge runs eight scripts of up to eight transfers, with and without upstream PWAKEUP and with zero to two wait states. The downstream rules, the returned sideband and the data are compared with a model.
8 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 2 steps and the final capstone