Tutorials

Protocols

Learn More

AHB supports different transfer sizes on the same data bus. HSIZE defines the number of bytes in the transfer.

HSIZE[2:0]Transfer sizeBytesDescription
0008 bits1Byte transfer. Uses one byte lane selected by the address.
00116 bits2Halfword transfer. Uses two adjacent byte lanes and should be 2-byte aligned.
01032 bits4Word transfer. Uses four byte lanes and should be 4-byte aligned.
01164 bits8Doubleword transfer. Uses eight byte lanes on a 64-bit or wider data bus.
100128 bits1616-byte transfer. Requires a data bus or width adapter that supports this size.
101256 bits3232-byte transfer. Used only in systems with very wide data paths.
110512 bits6464-byte transfer. Requires explicit wide-bus support.
1111024 bits128128-byte transfer. Largest encoded AHB transfer size; legal only when supported by the implementation.

The transfer size must be legal for the configured data bus. For example, a 32-bit data bus can naturally carry byte, halfword, and word transfers, but not a 64-bit single-beat transfer without width adaptation.

Address alignment

Address alignment means the start address must match the size of the transfer. In simple terms, an N-byte transfer must start on an N-byte boundary.

Rule: HADDR % number_of_transfer_bytes == 0

Equivalently, the lower address bits that select bytes inside the transfer must be zero. This lets the Subordinate select a clean group of byte lanes for the transfer.

TransferBytesRequired low address bitsAligned examplesNot aligned
Byte1None0x10000x10010x1002Not applicable
Halfword2HADDR[0] = 00x10000x10020x10040x10010x1003
Word4HADDR[1:0] = 000x10000x10040x10080x10020x1006
Doubleword8HADDR[2:0] = 0000x10000x10080x10100x10040x100C
16-byte transfer16HADDR[3:0] = 00000x10000x10100x10200x10080x1018

For example, on a 64-bit data bus:

AccessMeaning
Byte at 0x1003Valid. One byte lane is active.
Halfword at 0x1002Valid. Two adjacent byte lanes are active.
Halfword at 0x1003Not aligned, because HADDR[0] is 1.
Word at 0x1004Valid. Four adjacent byte lanes are active.
Word at 0x1002Not aligned, because HADDR[1:0] is not 00.
Doubleword at 0x1000Valid. All eight byte lanes of a 64-bit bus are active.

AHB burst transfers must also obey this rule for every beat in the burst. The address increment is based on HSIZE, so a word burst increments by 4 bytes, a halfword burst increments by 2 bytes, and so on. For IDLE transfers, the specification recommends using aligned addresses to avoid unnecessary simulation warnings.

In practical RTL, unaligned accesses should be handled according to the design contract. A memory system might reject them, adapt them, or document that they are unsupported. Verification should include alignment tests because address and byte-lane bugs are common.

Write strobes

HWSTRB is an optional AHB5 feature. It lets a Manager update only selected bytes during a write transfer. It has one bit per byte lane of HWDATA.

HWSTRB[n] corresponds to HWDATA[(8n)+7:(8n)]. If HWSTRB[n] is HIGH, byte lane n is written. If it is LOW, that byte lane is not written.

ahb-hwstrb-byte-lane-mapping

The important point is that HWSTRB does not decide the transfer size. HSIZE and HADDR first decide which byte lanes are active for the transfer. HWSTRB then decides which of those active lanes are actually updated.

Sparse writes

A sparse write is a write transfer where at least one active byte lane has its strobe deasserted. The transfer is still a valid write transfer, but only the bytes with asserted strobes are updated.

For example, assume a 32-bit data bus and an aligned word write where byte lanes 0, 1, 2, and 3 are active:

HWSTRBActive byte lanes
1111All four bytes are written.
0001Only byte lane 0 is written. This is a sparse write.
0010Only byte lane 1 is written. This is a sparse write.
0100Only byte lane 2 is written. This is a sparse write.
1000Only byte lane 3 is written. This is a sparse write.
0101Byte lanes 0 and 2 are written. This is a sparse write.
0000No bytes are written. This is permitted.

Sparse writes are useful for byte-enable style memory updates, register fields, and masked writes where software wants to update part of a word without modifying the other bytes.

Write strobe rules

RuleMeaning
HSIZE and HADDR define active byte lanesFor transfers narrower than the data bus, the address and transfer size determine which lanes belong to the transfer.
Active-lane strobes can be HIGH or LOWIf an active lane strobe is HIGH, that byte is written. If it is LOW, that byte is not written, creating a sparse write.
Inactive-lane strobes can be HIGH or LOWThe receiver must still use HSIZE and HADDR to identify inactive lanes. An inactive lane must not be written just because its strobe is HIGH.
All strobes LOW is legalThe transfer completes, but no bytes are written.
Strobe-to-data-lane mapping is independent of endiannessHWSTRB[n] always maps to byte lane n of HWDATA; endianness changes byte significance, not the strobe bit mapping.
Read transfers should deassert strobesReads do not use write data byte lanes, so the recommended value is all strobes LOW.
Write burst strobes can change per beatEach beat of a write burst can use a different HWSTRB value.
Strobes follow write-data timingHWSTRB is associated with the write data phase and must remain stable during write wait states.

This separation prevents a common bug: do not treat HWSTRB alone as the byte-lane mask. The legal byte lanes come from HSIZE and HADDR; the write strobes only enable or suppress writes inside that legal lane group.

Strobe interoperability

ConnectionPractical behavior
Manager with HWSTRB to Subordinate with HWSTRBSparse writes are supported.
Manager with HWSTRB to Subordinate without HWSTRBSafe only if sparse writes are not required.
Manager without HWSTRB to Subordinate with HWSTRBTreat all write byte lanes as active.
Neither side has HWSTRBEvery write is effectively a full-lane write for its transfer size.