Tutorials

Protocols

Learn More

In a write transfer, the Requester drives the address, direction, write data, and any write-side attributes. PWRITE is HIGH. The Completer accepts the write at the completion of the Access phase.

Two types of write transfer:
• With no wait states
• With wait states

With no wait states

apb-write-transfer-no-wait-states

In the waveform:

  1. At the Setup cycle (occurs at T1), PSEL is asserted.
  2. PADDRPWRITE, and PWDATA are valid.
  3. At the next cycle, PENABLE is asserted to start Access (at T2).
  4. Since PREADY is HIGH, the transfer completes at the next rising edge.
  5. PENABLE is deasserted after completion.
  6. PSEL is deasserted unless another transfer follows.

This is the shortest APB transfer: one Setup cycle and one Access cycle.

with wait states

apb-write-transfer-with-wait-states

If the Completer is not ready, it drives PREADY LOW during Access. The Requester must keep the transfer stable until PREADY becomes HIGH.

During a write wait state, these signals remain unchanged:

  • PADDR
  • PWRITE
  • PSELx
  • PENABLE
  • PWDATA
  • PSTRB, if present
  • PPROT, if present
  • PAUSER, if present
  • PWUSER, if present

PREADY can take any value when PENABLE is LOW that ensures that peripherals that have a fixed two cycle access can tie PREADY HIGH.

Byte write example

For a 32-bit peripheral register, a full write updates all four bytes. A sparse write updates only selected byte lanes using PSTRB. If a design does not support sparse writes, it must document the supported access types.

Example intent:

PSTRBMeaning on 32-bit PWDATA
4’b1111Update all bytes
4’b0001Update byte lane 0 only
4’b0011Update byte lanes 0 and 1
4’b1100Update byte lanes 2 and 3
4’b0000No byte lane marked valid; behavior should be defined by the implementation

Write strobes and byte lanes

PSTRB is an optional APB4/APB5 signal used for sparse writes. It marks which byte lanes of PWDATA contain valid write information.

Each PSTRB corresponds to 1 byte of the write data bus.

apb-pstrb-byte-lane-mapping

For a 32-bit data bus:

  • PSTRB[0] corresponds to PWDATA[7:0]
  • PSTRB[1] corresponds to PWDATA[15:8]
  • PSTRB[2] corresponds to PWDATA[23:16]
  • PSTRB[3] corresponds to PWDATA[31:24]

In general: PSTRB[n] corresponds to PWDATA[(8*n + 7):(8*n)]

Important PSTRB rules

  1. PSTRB is used only for write transfers.
  2. For read transfers, the Requester must drive all PSTRB bits LOW.
  3. If PSTRB is not present, sparse writes are not supported through that interface.
  4. If a Completer supports only selected access sizes or strobe patterns, that must be documented for software.

PSTRB compatibility

When connecting APB interfaces, the presence of PSTRB matters. A Requester with PSTRB can connect to a Completer without PSTRB only if sparse writes are not required. A Requester without PSTRB can connect to a Completer with PSTRB by treating all write byte lanes as valid.

This is a compatibility rule, not a performance feature. It is about preventing software and hardware from disagreeing about which bytes are updated.