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.

One AHB Transfer, and the APB Transfer It BecomesThe chip's AHB-to-APB bridge, one value per clock. A byte write with no wait, then a word read with one wait cycle.
01234567htransNSEQIDLENSEQIDLEhaddr1000402dx10004000xhreadypselpenablepreadypaddrx1000402cx10004000xpstrbx2x0xhrdatax2a5310c5xwrite takenread taken
Scroll horizontally ↔
  1. Cycle 0

    Cycle 0: the bridge takes an AHB byte write to 0x1000_402D, byte lane 1 of TB_ARG.

  2. 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.

  3. Cycle 2

    Cycle 2: the access cycle, and the completer is ready. The APB write ends, and hready rises in the same cycle.

  4. Cycle 3

    Cycle 3: a word read of CHIP_ID is taken.

  5. Cycle 5

    Cycle 5: an access cycle with PREADY low, a wait state. PSTRB is 0000, as for every read.

  6. 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.

Five questions this page answers
Question
1Why can each side of a bridge be legal while the bridge is wrong?
2What does ap_soc's bridge do with an AHB address, size and data?
3What must an end-to-end checker remember, and when does it compare?
4How does an error on the APB side come back to the AHB manager?
5How 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.

Both Sides of Each Bridge Are Checker SitesA learner checker can watch the bridge's AHB port and the fast APB bus together. Or it can watch both sides of the asynchronous bridge.
  • Bus
  • Peripheral
  • Monitor
  • Data
  • Control
Both Sides of Each Bridge Are Checker SitesA learner checker can watch the bridge's AHB port and the fast APB bus together. Or it can watch both sides of the asynchronous bridge. bus Matrix target port 3 bus AHB-to-APBbridge one transfer at atime peripheral Fast APB clk_sys bus Asynchronousbridge request andacknowledge peripheral Slow APB clk_aon monitor Checker A soc_tb.ahb_bridge +soc_tb.fast_apb monitor Checker B soc_tb.async_input +soc_tb.aon_apb AHBAPBAPB slotAPBwatches both sideswatches both sides
  1. bus Matrixtarget port 3
    • AHB → AHB-to-APB bridge
  2. bus AHB-to-APB bridgeone transfer at a time
    • APB → Fast APB
  3. peripheral Fast APBclk_sys
    • APB slot → Asynchronous bridge
  4. bus Asynchronous bridgerequest and acknowledge
    • APB → Slow APB
  5. peripheral Slow APBclk_aon
  6. monitor Checker Asoc_tb.ahb_bridge + soc_tb.fast_apb
    • watches both sides → AHB-to-APB bridge
  7. monitor Checker Bsoc_tb.async_input + soc_tb.aon_apb
    • watches both sides → Asynchronous bridge
  1. Two conversions

    AHB becomes APB at the first bridge. The second carries APB across into a slower, unrelated clock.

  2. 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

New words on this page
WordMeaning
BridgeA block that takes transfers of one bus and makes transfers of another.
Protocol conversionTurning one transfer's address, size, data and answer into the other bus's form.
End-to-end checkA 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 stateA cycle in which a completer is not ready, so the transfer is held.
Clock-domain crossingA path between logic on two unrelated clocks.
Four-phase handshakeRequest 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.

From AHB size and address to PSTRB
AHB writeSizeAddress bits 1:0PADDRPSTRB
a word at 0x1000_402C2 (word)000x1000_402C1111
a byte at 0x1000_402D0 (byte)010x1000_402C0010
a half-word at 0x1000_402E1 (half)100x1000_402C1100
a byte at 0x1000_402C0 (byte)000x1000_402C0001

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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

Five lines of ap_ahb_apb_bridge.sv. They say when it takes a transfer and when PSEL is high. Then come PADDR, PSTRB, and when the AHB side goes on.
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.

The same bridges inside the chip, from the seat
Access of the seatLatency (cycles)Answer
Fast APB: CHIP_ID2OKAY
Slow APB: ap_pwrctl STATUS11OKAY
A hole of the APB window3ERROR

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.

Two Slow Reads Across the Asynchronous BridgeThe chip's asynchronous bridge alone, one value per clk_sys cycle: two reads of ap_pwrctl STATUS asked for back to back. The slow side's signals are shown as clk_sys sees them.
012345678910111213141516171819202122232425psel (fast)penable (fast)reqreq at clk_aonpsel (slow)penable (slow)ack at clk_syspready (fast)read 1 askedread 2 asked
Scroll horizontally ↔
  1. Cycle 1

    Cycle 1: phase 1. The fast side copies the transfer into payload flops and raises req.

  2. Cycle 3

    Cycle 3: req has passed two flip-flops on clk_aon. The slow side copies the payload.

  3. Cycle 5

    Cycles 5 and 6: an ordinary APB setup and access on the slow bus.

  4. 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.

  5. Cycle 10

    Cycle 10: phase 3. PREADY, with the saved answer 0x40, and req falls. Read 1 took 11 cycles from its setup.

  6. Cycle 12

    Cycle 12: read 2 is asked for at once. But ack is still high: phase 4 has not finished.

  7. 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

ap_soc~12 blocks
Phone-class SoChundreds of blocks

This section looks ahead. ap_soc has two simple bridges that hold one transfer each.

  1. 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.

  2. 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.

  3. 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?

RUNIcarus Verilog · in your browser
Edit the code, then run it
Expected: 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 wrong

Check Yourself

Predict the outputNow the bridge makes PSTRB from the size and the address. What is the last line printed?
// One AHB write in, one APB write out. A scoreboard remembers the AHB transfer and compares the APB one.
// PSTRB must name the bytes of the size and the address. bug = 0: the bridge looks at the address only.
module tb;
  function automatic bit [3:0] lanes(input bit [1:0] size, input bit [1:0] low);
    if (size == 0) return 4'b0001 << low;
    if (size == 1) return low[1] ? 4'b1100 : 4'b0011;
    return 4'b1111;
  endfunction
  function automatic bit [3:0] bridge_strobes(input bit [1:0] size, input bit [1:0] low);
    if (0) return low == 0 ? 4'b1111 : 4'b0001 << low;
    return lanes(size, low);
  endfunction
  int bad = 0;
  task automatic transfer(input bit [31:0] haddr, input bit [1:0] size);
    bit [31:0] paddr = {haddr[31:2], 2'b00};
    bit [3:0] pstrb = bridge_strobes(size, haddr[1:0]);
    if (pstrb != lanes(size, haddr[1:0])) begin bad++; $display("AHB %h size %0d -> APB %h pstrb %b: expected %b", haddr, size, paddr, pstrb, lanes(size, haddr[1:0])); end
    else $display("AHB %h size %0d -> APB %h pstrb %b", haddr, size, paddr, pstrb);
  endtask
  initial begin
    transfer(32'h1000_402c, 2);   // a word
    transfer(32'h1000_402d, 0);   // a byte in lane 1
    transfer(32'h1000_402e, 1);   // the high half-word
    transfer(32'h1000_402c, 0);   // a byte in lane 0
    $display("%0d of 4 conversions wrong", bad);
  end
endmodule
ConceptIn the lab trace, in which cycle could a checker first compare the APB address with the AHB transfer?
ConceptWhy can a checker on clk_aon read the fast side of the asynchronous bridge?
ConceptA bridge drops PSLVERR. What does the AHB manager see?
ConceptWhat must a bridge checker remember?

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.

Practice

Report a problem with this page