Following a Transfer Across a Bridge
A bridge turns one protocol into another. Each side can obey its own rules while the conversion between them is wrong. Follow one transfer from AHB to APB and back, and see what a checker on both sides must compare.
You Will Be Able To
- Say why a protocol checker on each side of a bridge cannot see a conversion error.
- Follow one AHB transfer into its APB transfer: address, strobes, data, wait states, the answer.
- Name what an end-to-end bridge checker remembers and when it compares.
- Read the asynchronous bridge's handshake, and say why a checker can compare its two clocks' sides.
- Lesson
- V7.2
- Time
- 26 min
- Runs on
- Your browser
- Check
- 5 questions
Picture a bridge that writes byte lane 1 when the AHB side asked for lane 2. The AHB side is legal and the APB side is legal. Both bus checkers stay silent.
- Cycle 0
Cycle 0: the bridge takes an AHB byte write to 0x1000_402D, byte lane 1 of TB_ARG.
- Cycle 1
Cycle 1: the APB setup cycle. PADDR is the word address, 0x1000_402C. PSTRB is 0010: lane 1 only. hready is low: the AHB side waits.
- Cycle 2
Cycle 2: the access cycle, and the completer is ready. The APB write ends, and hready rises in the same cycle.
- Cycle 3
Cycle 3: a word read of CHIP_ID is taken.
- Cycle 5
Cycle 5: an access cycle with PREADY low, a wait state. PSTRB is 0000, as for every read.
- Cycle 6
Cycle 6: PREADY rises; PRDATA goes straight to hrdata, 0x2A53_10C5, and hready rises.
The chip's own bridge RTL (tools/soc/ap_soc/rtl/ap_ahb_apb_bridge.sv) on Icarus Verilog version 12.0. A small bench written for this lab drives it (record-v7-labs.mjs, section bridge). The completer is a model that waits as the bench chooses.
Before You Start
Read The Fabric as the Thing Under Test and Bridges: From the Fast Bus to APB first.
For the two buses and for checkers, see APB in One Picture and Passive Checkers: Bind and Listen.
| Question | |
|---|---|
| 1 | Why can each side of a bridge be legal while the bridge is wrong? |
| 2 | What does ap_soc's bridge do with an AHB address, size and data? |
| 3 | What must an end-to-end checker remember, and when does it compare? |
| 4 | How does an error on the APB side come back to the AHB manager? |
| 5 | How can one checker compare two sides on unrelated clocks? |
The Idea: A Bridge Is Checked End to End
A protocol checker knows one bus. On AHB it checks that an address phase holds through wait states and that ERROR takes two cycles. On APB it checks that setup comes before access. None of that says whether the APB transfer is the one the AHB manager asked for.
That is the bridge's real job, and it can fail quietly. It can send the right data to the wrong register, name the wrong byte lane, or drop an error. Every rule on both sides still holds. Only a checker that sees both sides can compare what went in with what came out.
ap_soc has two bridges in a row. The AHB-to-APB bridge turns each AHB transfer into one APB transfer. The asynchronous bridge then carries APB transfers for the slow blocks across into clk_aon, a clock unrelated to clk_sys. Each needs its own end-to-end check.
- Bus
- Peripheral
- Monitor
- Data
- Control
- Two conversions
AHB becomes APB at the first bridge. The second carries APB across into a slower, unrelated clock.
- A checker per bridge
Each checker sees what went in and what came out, so it can check the conversion itself.
Read the diagram as text
- Matrix: target port 3
- AHB-to-APB bridge: one transfer at a time
- Fast APB: clk_sys
- Asynchronous bridge: request and acknowledge
- Slow APB: clk_aon
- Checker A: soc_tb.ahb_bridge + soc_tb.fast_apb
- Checker B: soc_tb.async_input + soc_tb.aon_apb
- Matrix → AHB-to-APB bridge: AHB
- AHB-to-APB bridge → Fast APB: APB
- Fast APB → Asynchronous bridge: APB slot
- Asynchronous bridge → Slow APB: APB
- Checker A → AHB-to-APB bridge: watches both sides
- Checker B → Asynchronous bridge: watches both sides
Checker sites of the bench (tools/soc/ap_soc/bench/soc_tb/README.md, "Interconnect and boot experiments (E19)"; tools/soc-checker.mjs).
New Words
| Word | Meaning |
|---|---|
| Bridge | A block that takes transfers of one bus and makes transfers of another. |
| Protocol conversion | Turning one transfer's address, size, data and answer into the other bus's form. |
| End-to-end check | A check that compares what went into a path with what came out of it. |
| Byte strobes (PSTRB) | Four APB bits naming the bytes a write changes; 0 for a read. |
| Wait state | A cycle in which a completer is not ready, so the transfer is held. |
| Clock-domain crossing | A path between logic on two unrelated clocks. |
| Four-phase handshake | Request up, acknowledge up, request down, acknowledge down: how the asynchronous bridge passes each transfer. |
The Smallest Example: Strobes from a Size
APB names the bytes of a write with four strobes. AHB names them with a size and the low bits of the address. ap_soc's bridge works one out from the other (facts 27.7). Here is the rule, by hand.
| AHB write | Size | Address bits 1:0 | PADDR | PSTRB |
|---|---|---|---|---|
| a word at 0x1000_402C | 2 (word) | 00 | 0x1000_402C | 1111 |
| a byte at 0x1000_402D | 0 (byte) | 01 | 0x1000_402C | 0010 |
| a half-word at 0x1000_402E | 1 (half) | 10 | 0x1000_402C | 1100 |
| a byte at 0x1000_402C | 0 (byte) | 00 | 0x1000_402C | 0001 |
PADDR is the word address in every row. The example below runs a bridge with a bug against this rule.
A bridge that looks only at the address gets two of these wrong: the half-word and the byte at offset 0. Both still make legal APB writes. Only a check that knows the AHB side catches them.
The Rules
Rule 1: Check the conversion, not only each side.
Bus checkers on both sides pass a bridge that sends a legal transfer to the wrong place. An end-to-end check compares the two.
Rule 2: Remember what went in.
Keep each accepted transfer until its partner comes out: one entry for ap_soc's bridge, a queue for a bridge that holds several.
Rule 3: Compare where the other side first shows it.
The APB setup cycle is the first that carries the address, direction and strobes. Compare there, and the end of the transfer for the data and the answer.
Rule 4: Check the answer on its way back.
Read data must come back unchanged, and an APB error must become the AHB ERROR. A bridge that drops an error makes software read a wrong value as right.
Rule 5: Across clocks, compare at a moment both sides hold still.
The asynchronous bridge holds the fast transfer while the slow one runs. A checker on the slow clock can read the fast side then, because the design promises it.
Rule 6: Bind a checker at both sides of every bridge.
Each bridge is a checker site. The checker runs in every test, with every manager, at no cost to the test.
Sources for These Rules
Protocol conversion and error checking as interconnect challenges, and the interconnect response checker: MEHTA-DV 14.2 and 14.5. It also names protocol checkers on each bus as one part of the response check.
The bridge of ap_soc has one setup and one access cycle. PADDR is the word address. PSTRB comes from the size and the low address bits, and is 0 for a read. PSLVERR becomes the two-cycle ERROR and costs 3. See facts 27.7 and tools/soc/ap_soc/rtl/ap_ahb_apb_bridge.sv.
APB strobes and the setup and access phases: AMBA APB, IHI 0024E 3.1 to 3.4. The asynchronous bridge's four-phase handshake and its stated promise: facts 27.7; it was proved on SymbiYosys at stage E3 (plan §3.10).
The checker sites, and the rule that the first site's clock samples a report: the bench README, "Interconnect and boot experiments (E19)".
The Lab: The Chip's Bridge, Cycle by Cycle
The trace at the top is the chip's own bridge RTL, run on Icarus with a small driver and a completer model. Read it against the rules.
assign take = hsel && hready && htrans[ap_ahb_pkg::ACTIVE_BIT];
assign psel = (state_q == STATE_SETUP) || (state_q == STATE_ACCESS);
assign paddr = {word_q, 2'b00};
assign pstrb = write_q ? strb_q : 4'h0;
assign hreadyout = (state_q == STATE_IDLE) || (state_q == STATE_ERROR) || (done && !pslverr);In cycle 0 the bridge takes the byte write (take: hsel, hready and a transfer). In cycle 1, the setup cycle, PADDR is 0x1000_402C and PSTRB is 0010. That is the word address and lane 1, as the table above says (rule 3). hready is low while the APB side works, so the AHB data phase holds.
The read shows a wait. In cycle 5 the access cycle has PREADY low, so the bridge holds PSEL and PENABLE and the AHB side keeps waiting. In cycle 6 PREADY rises and PRDATA, 0x2A53_10C5, appears on hrdata in that same cycle (rule 4). PSTRB stays 0000 throughout the read.
| Access of the seat | Latency (cycles) | Answer |
|---|---|---|
| Fast APB: CHIP_ID | 2 | OKAY |
| Slow APB: ap_pwrctl STATUS | 11 | OKAY |
| A hole of the APB window | 3 | ERROR |
Recorded on ap_soc v1.5 (Verilator 5.052 2026-09-05), section routes of record-v7-labs.mjs: the same runs as lesson V7.1.
Inside the chip, the fast APB read costs 2 cycles: setup and access, as in the trace. A slow read costs 11. The fast side holds its access phase while the asynchronous bridge hands the transfer across and the answer back (rule 5). The hole costs 3: setup, then the two-cycle ERROR.
Where do the slow read's cycles go? The trace below is the asynchronous bridge alone, asked for two reads back to back. It passes each transfer with a four-phase handshake: req up, ack up, req down, ack down.
- Cycle 1
Cycle 1: phase 1. The fast side copies the transfer into payload flops and raises req.
- Cycle 3
Cycle 3: req has passed two flip-flops on clk_aon. The slow side copies the payload.
- Cycle 5
Cycles 5 and 6: an ordinary APB setup and access on the slow bus.
- Cycle 9
Cycle 9: phase 2 is seen. The slow side saved the answer and raised ack; two flip-flops later clk_sys sees it.
- Cycle 10
Cycle 10: phase 3. PREADY, with the saved answer 0x40, and req falls. Read 1 took 11 cycles from its setup.
- Cycle 12
Cycle 12: read 2 is asked for at once. But ack is still high: phase 4 has not finished.
- Cycle 16
Cycle 16: ack fell in cycle 15, so req can rise again. Read 2 took 13 cycles: two more, spent finishing read 1's handshake.
The chip's own bridge RTL (tools/soc/ap_soc/rtl/ap_apb_async_bridge.sv) on Icarus Verilog version 12.0. The clocks are those of facts 27.1: clk_sys 10 ns, clk_aon 14 ns. A small bench written for this lab drives it (record-v7-labs.mjs, section async); the slow completer answers with no wait.
Read 1 shows the four phases at work. Most of its 11 cycles are flip-flops of the two synchronizers, plus two slow-bus cycles of 14 ns each. Then look at read 2. It was asked for in cycle 12, but req could not rise until cycle 16. A new transfer starts only after ack has fallen, so read 2 took 13.
That is what "one transfer in flight" means here. It is not only one at a time: the handshake must return to zero before the next transfer may start. For a checker it is good news. Each slow transfer has exactly one fast transfer waiting for it, so the checker needs no queue (rule 2).
An end-to-end checker for the first bridge needs few parts. It holds one remembered address phase, compares it at the next setup cycle, and compares the data at the end. Problem V7.2.1 asks you to build it.
Why It Is Built This Way
Why does ap_soc's bridge hold the AHB side for the whole APB transfer? It is the simplest legal bridge: one transfer at a time. The response that comes back always belongs to the one waiting manager. A bridge that accepts a second transfer early is faster and needs a queue, and its checker needs a queue too.
Why can a checker on clk_aon read signals of clk_sys? Normally that would be a crossing bug. Here the fast side holds still until the slow side has answered, as the trace showed. That promise was proved formally at stage E3, and the checker leans on it.
Traps
The two-legal-sides trap: every bus checker of the bench is silent, so the bridge "must be right". A bridge that swaps two registers, or sets a bit no register keeps, passes every protocol rule. Only an end-to-end check sees it.
The readback trap: a test writes a slow register and reads it back. A crossing that sets a bit the register does not keep still reads back right. Compare the transfer on the far side.
The wrong-moment trap: a checker compares the APB address with the AHB address bus at the setup cycle. By then the AHB bus may show the next transfer. Remember the accepted address phase.
The lost-error trap: a test sends an access that must fail and checks only that the run went on. If the bridge drops PSLVERR, the manager reads 0 and carries on. Check the ERROR itself.
At Scale
This section looks ahead. ap_soc has two simple bridges that hold one transfer each.
Bridges with queues
Bridges between AXI and AHB or APB accept several transfers before the first answers. Their checkers keep a queue per ID and match each answer to its request.
Width and burst conversion
A 64-bit bus to a 32-bit one splits each transfer in two; a burst may become singles. The checker rebuilds the original from the pieces.
Protocol checkers from vendors
Large teams buy checked monitors for each bus and write only the end-to-end comparison. That comparison still has to know the bridge's own rules.
Try It
Run it: two of the four conversions are wrong, though each is a legal APB write.
Fix the bridge (the predict question below). What is the last line?
Which conversion would a checker that compares only the address miss?
AHB 1000402c size 2 -> APB 1000402c pstrb 1111 AHB 1000402d size 0 -> APB 1000402c pstrb 0010 AHB 1000402e size 1 -> APB 1000402c pstrb 0100: expected 1100 AHB 1000402c size 0 -> APB 1000402c pstrb 1111: expected 0001 2 of 4 conversions wrongCheck Yourself
Common Mistakes
Wrong Trust a bridge because both bus checkers are silent.
A legal transfer to the wrong register breaks no protocol rule.
Fix Bind an end-to-end checker across every bridge.
Wrong Compare the APB address with whatever is on the AHB address bus.
The AHB bus may already show the next transfer.
Fix Remember the accepted address phase and compare it at the APB setup cycle.
Wrong Check a slow register by reading it back.
A wrong bit outside its fields reads back right.
Fix Compare the transfer on both sides of the crossing.
Remember
- Bus checkers on each side cannot see a conversion error; an end-to-end check can.
- ap_soc's bridge: word PADDR, PSTRB from size and address (0 on reads), one transfer at a time, PSLVERR becomes ERROR.
- Remember the accepted transfer, compare at the APB setup cycle, then check the data and the answer at the end.
- Across the asynchronous bridge, compare at a moment the design promises both sides hold still.