AXI4 Unaligned Transfer Behavior with 32-bit Data on 64-bit Bus
In AXI4-based systems, unaligned transfers occur when the starting address of a data transfer does not match the natural alignment boundary of the data width. For example, transferring 32-bit data on a 64-bit bus starting at address 0x001 is an unaligned transfer because the address 0x001 is not a multiple of the 64-bit bus width (8 bytes). This misalignment creates complexities in how the AXI4 protocol handles data packing, address generation, and byte strobes (WSTRB).
When a 32-bit transfer begins at address 0x001 on a 64-bit bus, the lower 8 bits of the address (0x001) indicate that the data is not aligned to the 64-bit boundary. The AXI4 protocol splits the transfer into two parts: the first part covers the unaligned portion (3 bytes in this case), and the second part covers the remaining aligned data. The byte strobes (WSTRB) are used to indicate which bytes within the 64-bit data bus are valid. For the first transfer, only WSTRB[3:1] would be active, corresponding to the 3 bytes of valid data starting at address 0x001. The remaining 5 bytes of the 64-bit bus are unused in this transfer.
The AXI4 protocol supports three burst types: INCR (incremental), FIXED, and WRAP. Each burst type behaves differently with unaligned transfers. For INCR bursts, the address increments after each transfer, allowing the system to handle unaligned transfers by splitting them into aligned portions. For FIXED bursts, the address remains constant, making all transfers unaligned if the starting address is unaligned. WRAP bursts do not support unaligned starting addresses, as they are designed for circular buffer operations that require alignment.
The primary challenge in unaligned transfers is ensuring that all data is correctly transferred without loss or corruption. This requires careful management of the address generation, byte strobes, and data packing logic. Additionally, the system must handle cases where the unaligned portion of the transfer spans multiple beats, requiring precise control over the AXI4 signals.
Misaligned Address Handling and AWBURST Signal Configuration
The root cause of unaligned transfer issues lies in the configuration of the AWBURST signal and the starting address. The AWBURST signal determines the burst type (INCR, FIXED, or WRAP), which directly impacts how the address is generated and how data is packed into the bus. For example, if the AWBURST signal is set to INCR and the starting address is 0x001, the first transfer will only use 3 bytes of the 64-bit bus, as the address is not aligned to the 64-bit boundary. Subsequent transfers will use the full 64-bit bus, as the address increments to aligned boundaries.
In the case of FIXED bursts, the address remains constant, meaning all transfers will be unaligned if the starting address is unaligned. This can lead to inefficient use of the bus bandwidth, as only a portion of the bus is used for each transfer. WRAP bursts, on the other hand, require aligned starting addresses, as they are designed for circular buffer operations where the address wraps around after reaching a boundary.
Another potential cause of issues is the incorrect configuration of the byte strobes (WSTRB). The WSTRB signal must accurately reflect which bytes within the 64-bit bus are valid for each transfer. For unaligned transfers, the WSTRB signal must be carefully calculated to ensure that only the valid bytes are transferred. If the WSTRB signal is incorrectly configured, data may be lost or corrupted during the transfer.
The AXI4 protocol also requires that the address and control signals remain stable throughout the burst. If the address or control signals change during the burst, the transfer may fail or produce incorrect results. This is particularly important for unaligned transfers, where the address generation logic must handle the transition from unaligned to aligned addresses correctly.
Implementing Correct Address Generation and Byte Strobe Management
To resolve unaligned transfer issues, the address generation logic must be designed to handle unaligned starting addresses correctly. For INCR bursts, the address should increment after each transfer, ensuring that subsequent transfers are aligned to the bus width. For example, if the starting address is 0x001 and the burst length is 4, the addresses for the transfers should be 0x001, 0x004, 0x008, and 0x00C. This ensures that only the first transfer is unaligned, while the remaining transfers are aligned to the 64-bit boundary.
The byte strobes (WSTRB) must also be correctly configured to reflect the valid bytes for each transfer. For the first transfer at address 0x001, the WSTRB signal should be set to indicate that only the upper 3 bytes of the 64-bit bus are valid. For subsequent transfers, the WSTRB signal should indicate that all 8 bytes are valid. This ensures that the correct data is transferred without loss or corruption.
In addition to address generation and byte strobe management, the system must also handle cases where the unaligned portion of the transfer spans multiple beats. For example, if the transfer size is larger than the bus width, the system must ensure that the data is correctly split across multiple beats and that the address and control signals remain stable throughout the burst.
To verify the correct handling of unaligned transfers, the system should be tested with a variety of starting addresses, burst lengths, and burst types. This includes testing with unaligned starting addresses, as well as edge cases where the transfer size is larger than the bus width. The verification environment should include checks for correct address generation, byte strobe configuration, and data integrity.
In summary, unaligned transfers in AXI4-based systems require careful management of the address generation, byte strobes, and data packing logic. By correctly configuring the AWBURST signal and ensuring that the address and control signals remain stable throughout the burst, the system can handle unaligned transfers efficiently and correctly. Proper verification is essential to ensure that the system behaves as expected under all conditions.