Key points
- An APB transfer ends only in a cycle where
PSEL,PENABLEandPREADYare all 1.PREADYmay have any value in the SETUP cycle, so it must not be read there. We built a Requester that deliberately does so, and it wrongly judged 7,488 of 15,000 transfers (49.9%) finished in SETUP. PSLVERRandPRDATAare valid only in the last cycle. Against a Completer that, against the recommendation, wigglesPSLVERRin wait cycles, a Requester that scansPSLVERRthroughout ACCESS reported the 1,503 real errors plus 4,466 false ones, while a Requester that reads only the last cycle had 0 wrong verdicts.- We encoded the rules as a checker and ran 1,000 random traces (100,000 transfers, 266,634 cycles). There were 0 violations, the final registers and read data matched the reference model every time, and every transfer length was 1 + waits + 1. The 8 kinds of violation we injected were caught at every site (666 to 1,000 each). All 15
PSTRBbyte selections matched the reference too.
Part 1 covered the signals and the state diagram. This part looks at how one transfer runs on top of that: the cycle order of writes and reads, inserting waiting with PREADY, the PSLVERR error response, and sparse writes that pick bytes with PSTRB. The basis is E 3.1 to 3.4 and Appendix A. Terms are as in Part 1: Requester (commonly the master, usually a bridge) and Completer (commonly the slave, a peripheral). The code is transfer.py in this article's folder and the shared ../common/apb.py, run on a Mac (Apple M1 Max) with Python 3.12.13. Random seeds are fixed.
Cycles are read as in Part 1. Cycle c runs from edge c to just before edge c+1, values change right after an edge, and the value of a cycle is sampled at edge c+1.
1. Write transfer
A write with no waiting (E 3.1.1, Figure 3-1) takes two cycles.
| Cycle | PSEL |
PENABLE |
State | What happens |
|---|---|---|---|---|
| 0 | 0 | 0 | IDLE | |
| 1 | 1 | 0 | SETUP | PADDR, PWRITE, PWDATA must be valid |
| 2 | 1 | 1 | ACCESS | PREADY=1, so the data is accepted at edge 3 |
| 3 | 0 | 0 | IDLE | transfer over |
In the SETUP cycle (1) the Requester raises PSEL, and address, direction and data must already be valid. In the next cycle (2) PENABLE rises, and in that cycle the Completer raises PREADY to say it will take the data at edge 3. Address, data and the other control signals must stay stable until the transfer finishes. When it finishes PENABLE drops. PSEL stays up only if another transfer to the same peripheral follows right away.
In a write with wait states (E 3.1.2, Figure 3-2) the Completer lowers PREADY in an ACCESS cycle to extend the transfer. The figure below is the case with two waits.

Follow (a) by hand. Cycle 1 is SETUP, cycles 2, 3 and 4 are ACCESS. PREADY is 0 in cycles 2 and 3, so there are two waits, and it is 1 in cycle 4, so the transfer ends at edge 5. The length is SETUP 1 + ACCESS 3 = 4 cycles.
While PREADY is 0 during ACCESS, these signals must stay unchanged (E 3.1.2 and 4.1): PADDR, PWRITE, PSELx, PENABLE, PWDATA, PSTRB, PPROT, PAUSER, PWUSER. And PREADY can take any value while PENABLE is 0. The specification gives the reason for this freedom: a peripheral with a fixed two-cycle access can tie PREADY HIGH. But this freedom means a Requester must not look at PREADY alone to decide that a transfer is done.
The completion condition is PSEL, PENABLE and PREADY all 1 in the same cycle. To test this we built a wrong Requester that decides "already done" if PREADY is 1 in the SETUP cycle. We wiggled PREADY randomly (legally) in SETUP cycles, and in 15,000 transfers 7,488 (49.9%) were wrongly judged finished in SETUP. The near-half probability is because PREADY is a random 0/1. A bug like this stays hidden if you test only against a Completer whose PREADY is always 0 in SETUP.
2. Read transfer
A read (E 3.3) differs only in that PWRITE is 0 and the Completer supplies PRDATA instead of PWDATA. Timing of address, PWRITE, PSEL and PENABLE is the same as a write. The specification says the Completer must provide the data before the transfer ends. Appendix A is more concrete: PRDATA must be valid only in the last cycle, where PSEL, PENABLE and PREADY are all 1.
Figure (b) shows this. In the wait cycles PRDATA is a grey undefined stretch, and only in the last cycle (cycle 4) does it become Data 1. The Requester samples PRDATA at edge 5. Reading PRDATA during waiting gives garbage. In the model we deliberately filled PRDATA with random values in wait cycles.
The list of signals to hold during ACCESS differs between reads and writes. The read list in 3.3.2 is PADDR, PWRITE, PSEL, PENABLE, PPROT, PAUSER, without the write-data signals, which is natural since a read has no write data. The combined list in 4.1 (PWDATA for writes only) merges the two, and the list used by the checker is this one.
There is no limit on how long waiting can last. The specification says any number of additional cycles can be added, from zero upwards (3.3.2). So a Requester cannot unblock itself from a Completer whose PREADY never comes, and if a timeout is needed it must be designed on the system side. (No timeout rule appears in E.)
3. Error response: PSLVERR
PSLVERR (E 3.4) is an optional signal that reports a transfer error, used for both reads and writes. The rules:
| Rule | Content |
|---|---|
| Valid when | only in the last cycle, where PSEL, PENABLE and PREADY are all 1 |
| Other cycles | recommended LOW, not required |
| Write error | does not mean the register is unchanged. The peripheral decides and either is allowed |
| Read error | the data may be invalid. It need not be zero |
| Requester | may still use the PRDATA of a read error. A Completer must not design on the assumption that an error stops the read |
| Support | a Completer need not support PSLVERR. Then the Requester input is tied LOW |

Figure (a) is a write error (Figure 3-6). One wait is inserted in cycle 2, and in cycle 3 PREADY and PSLVERR go to 1 together, so it ends with an error at edge 4. Figure (b) is a read error (Figure 3-7), with PRDATA grey throughout. An error response means "no valid read data is available" (E 3.4.2).
Through a bridge the error is passed upward (3.4.3). An AXI-to-APB bridge maps PSLVERR back to RRESP for reads and BRESP for writes, and an AHB-to-APB bridge maps it to HRESP for both reads and writes.
We ran two model tests.
When it is valid: we built a Completer that, against the recommendation, wiggles PSLVERR randomly in wait cycles (not a rule violation). Of 15,000 transfers the real errors were 1,503. A wrong Requester that scans PSLVERR throughout ACCESS reported 1,503 + 4,466 = 5,969 errors, 4,466 of them false. A Requester that reads only the last cycle had 0 verdicts that differed from the reference model.
Write error and registers: we assumed two registers (addresses 16 and 20) are protected and always give an error. We built a Completer that changes the register on an errored write and one that does not, and the checker accepted both with 0 violations. The final register values differed in 300 of 300 tests. This is why the specification allows either. So a Requester (software) must not assume anything about a register after an errored write.
4. Byte selection: PSTRB
PSTRB (E 3.2) appeared in APB4. There is one strobe bit per 8 bits of the write data bus, and PSTRB[n] corresponds to PWDATA[8n+7:8n]. A 1 means that byte lane holds valid data, and in a write only those bytes are updated, a sparse write. In a read the Requester must drive every bit of PSTRB LOW.

We ran all 15 non-empty PSTRB values on a 32-bit bus. We wrote AA BB CC DD over the old value 11 22 33 44 and compared with a reference computed on a byte list, and all 15 matched. For example 0110 gives 11 BB CC 44.
PSTRB is optional, so each side may or may not have it, giving four combinations (Table 3-1).
| Requester \ Completer | no PSTRB |
has PSTRB |
|---|---|---|
no PSTRB |
compatible. no sparse writes | compatible. tie PSTRB to PWRITE |
has PSTRB |
compatible. sparse writes not possible | compatible |
All say "compatible" but mean different things. If the Requester lacks PSTRB and the Completer has it, tie the whole PSTRB input to the PWRITE output. Then every lane is valid in a write and all are LOW in a read. Conversely, if the Completer lacks PSTRB, sparse writes are not supported. If the Requester sends a sparse write anyway, the Completer will write the whole word. In the model, writing the 14 sparse patterns to a Completer without PSTRB (all lanes written) overwrote 28 unselected bytes in total. That is why the specification says the access types a peripheral supports must be documented for the programmer (3.2.1).
We also checked the behaviour without PSTRB in the random tests. In the 281 traces without PSTRB the final registers also matched the reference model (all bytes written).
5. Practice: rule checker and random traces
The checker (check in common/apb.py) looks at four rules.
| Rule | Content |
|---|---|
STATE |
state diagram violation (Part 1): skipping SETUP, SETUP for two cycles, leaving ACCESS while PREADY=0, and so on |
STABLE |
PADDR, PWRITE, PPROT, PSTRB, PAUSER and, for a write, PWDATA and PWUSER change from SETUP to ACCESS or within ACCESS |
STRB_RD |
PSTRB is not 0 in a read |
VALID_X |
a value is undefined when it must be valid (Appendix A) |
(The STATE of Part 1 also covers PENABLE=1 with PSEL=0.) The core is:
if st[c] == ACCESS and prev in (SETUP, ACCESS):
fields = STABLE_ALL + (STABLE_WR if tr["PWRITE"][c] else [])
for f in fields:
if f in tr and tr[f][c] != tr[f][c - 1]:
bad.append(("STABLE", c)); break
if st[c] != IDLE:
if "PSTRB" in tr and not tr["PWRITE"][c] and tr["PSTRB"][c]:
bad.append(("STRB_RD", c))
The Requester-Completer model (simulate) builds a Completer with 16 registers. Per trace it mixes data width (8, 16, 32 bits), wait probability (0, 0.2, 0.5), probability of IDLE between transfers (0, 0.3) and the presence of PSTRB. Everything that need not be held is deliberately filled with random garbage: PREADY in SETUP and IDLE cycles, PRDATA during waits, unselected bytes of write data, and so on. The reference model is separate (ref_run). It applies the transfers in order and computes the final registers and read data.
| Item | Result |
|---|---|
| traces / transfers / cycles | 1,000 / 100,000 (49,950 reads, 50,050 writes) / 266,634 |
| rule violations | 0 |
| traces whose final registers differ from the reference | 0 |
| traces whose read data differ from the reference | 0 |
| traces whose error count differs from the reference | 0 (17,122 error transfers) |
| transfers whose length is not 1 + waits + 1 | 0 (43,925 waits in total) |
SETUP cycles with PREADY=1 |
49,942 / 100,000 (all legal) |
That PREADY is 1 in about half the SETUP cycles and there are still 0 violations shows that the freedom of 3.1.2 is correctly reflected in the checker.
The mutation test injects one violation at a time into a legal trace (30 transfers).
| Injected violation | Injected | Caught |
|---|---|---|
PENABLE raised early in SETUP |
1,000 | 1,000 |
| SETUP stretched to two cycles | 1,000 | 1,000 |
PADDR changes during ACCESS |
1,000 | 1,000 |
PWDATA changes during ACCESS |
1,000 | 1,000 |
PSTRB is not 0 in a read |
1,000 | 1,000 |
PSEL dropped while PREADY=0 (abort) |
666 | 666 |
ACCESS left while PREADY=0 |
666 | 666 |
PREADY is X in ACCESS |
1,000 | 1,000 |
Abort and ignoring a wait have 666 because traces without waits have no place to inject them. 0 false positives (1,000 legal traces, 0 violations) and 0 missed violations were both confirmed. Some rules this checker cannot catch. For example, "whether the Completer changes the register on an error" cannot be decided from the waveform alone.
6. Design checklist: transfer
| Item | Rule |
|---|---|
| Start | with PSEL, PADDR, PWRITE and (for a write) PWDATA of the written lanes are valid |
| Completion | PSEL, PENABLE and PREADY all 1 in the same cycle. Recognised at the next edge |
PREADY |
any value while PENABLE=0. Do not read it in SETUP |
| Waiting | zero or more, no limit. While waiting, do not change address, direction, write data, PSTRB, PPROT or user signals |
| Back to back | the cycle after the completion cycle is SETUP right away. PSEL stays up if it is the same peripheral |
PRDATA |
valid only in the last cycle. Do not sample it while waiting |
PSLVERR |
valid only in the last cycle. LOW recommended in other cycles |
| Errored write | whether the register changed depends on the peripheral. Do not assume |
| Errored read | the data may be invalid. A Requester may still use it |
PSTRB |
all 0 in a read. In a write only lanes with PSTRB[n]=1 are updated |
Side without PSTRB |
if only the Requester lacks it, tie to PWRITE. If only the Completer lacks it, no sparse writes |
| Signals not required to be valid | driving zero is recommended (Appendix A) |
| Bridges | AXI returns errors on RRESP and BRESP, AHB on HRESP |
For verification, attach the four rules above as always-on monitors, and let the Requester meet a Completer whose PREADY in SETUP and IDLE is 0, one where it is 1, one where it is random, and one with long waits. The bug of reading PREADY in SETUP stays hidden if the Requester meets only Completers whose PREADY is always 0 in SETUP.
Summary
- A transfer is one SETUP cycle and one or more ACCESS cycles. Completion is
PSEL & PENABLE & PREADY, andPREADYcan be anything whilePENABLE=0. A Requester that readsPREADYin SETUP wrongly ended 7,488 of 15,000 transfers. - While waiting, do not change address, direction, write data,
PSTRB, protection or user signals.PRDATAandPSLVERRare valid only in the last cycle. ScanningPSLVERRin wait cycles produced 4,466 false errors. - Whether a write that ended with
PSLVERRchanged the register is not specified. Both implementations passed the checker and the final values differed in 300/300. - All 15
PSTRBvalues matched the reference. Sending sparse writes to a Completer withoutPSTRBoverwrote 28 unselected bytes across the 14 patterns. 1,000 random traces had 0 violations and all 8 injected violation kinds were caught.
Next: Part 3 covers the signals about transfer attributes. How PPROT separates normal and privileged, secure and non-secure, data and instruction; the RME support of APB5 that separates Root and Realm address spaces with PNSE; the wake-up signal PWAKEUP; user signals; and the parity protection that catches an error on a single wire.
References
- Arm, AMBA APB Protocol Specification, ARM IHI 0024 Issue E (2023-02-28). 3.1 Write transfers (3.1.1, 3.1.2), 3.2 Write strobes (3.2.1
PSTRBpresence and compatibility), 3.3 Read transfers (3.3.1, 3.3.2), 3.4 Error response (3.4.1, 3.4.2, 3.4.3 Mapping ofPSLVERR), 4.1 Operating states, Appendix A Validity rules, Appendix B Table B-1. - Code and results of this article:
transfer.py,../common/apb.py,../common/specfigs.py,results.json,figs_kit.py.


RISC-V