Skip to content
systemcoding.dev
Hardware

How AXI4 Channels, Handshakes and Bursts Work

Learn how AXI4 splits transfers into five channels, how VALID and READY handshakes move each beat, and how burst length, size and type set the addresses.

7 min read
Summarize in AI
Flat illustration of logic gates wired into a small circuit, with the KiCad, Haskell and SparkFun logos.

AXI4 is the bus you meet the moment you use an FPGA's hard processor, a DMA engine or most modern IP. It looks intimidating because it has dozens of signals, but the design is regular: five independent channels, one handshake rule that applies to all of them, and a small set of fields that describe a burst. Once those three ideas are clear, an AXI waveform reads like a sentence. This post explains them from the AMBA AXI and ACE Protocol Specification (Arm IHI 0022), in the AXI4 form, and shows a Verilog function that computes burst addresses with output for FIXED, INCR and WRAP bursts. It assumes you know what a bus master and a slave are, and have written a Verilog module.

Five channels, two directions

A simple bus uses one set of wires for an address, data and a response, and waits for each transfer to complete before the next. AXI separates the pieces so they can overlap. Each of the five channels has its own set of signals and its own handshake.

ChannelDirectionCarriesKey signals
AW, write addressmaster to slavewhere a write goes and how long it isAWADDR, AWLEN, AWSIZE, AWBURST, AWID
W, write datamaster to slavethe data beats of a writeWDATA, WSTRB, WLAST
B, write responseslave to masterwhether the write succeededBRESP, BID
AR, read addressmaster to slavewhere a read comes from and how long it isARADDR, ARLEN, ARSIZE, ARBURST, ARID
R, read dataslave to masterthe data beats of a read, with statusRDATA, RRESP, RLAST

Every channel also has a VALID signal driven by the sender and a READY signal driven by the receiver. A write is three channels working together: the master sends an address on AW, sends the data on W, and the slave replies on B. A read is two: an address on AR and the data on R. Because reads and writes use separate channels, a master can issue a read while a write is in progress, and a slave can serve them independently.

The handshake

A transfer on any channel happens on a clock edge where VALID and READY are both high. That is the whole rule. Both signals are sampled at the rising edge of the single clock, and the payload moves when both are 1.

Three consequences follow, and they are the rules you must design to. Once a sender raises VALID it must keep it high and keep the payload stable until the handshake completes. The sender must not wait for READY before raising VALID. The receiver may wait for VALID before raising READY, or may raise READY first and keep it high. The next post in this cluster covers why those rules prevent deadlock; here, the point is that the handshake gives you flow control for free. A slow receiver holds READY low and the sender waits with its data stable.

Three timings are legal: READY already high when VALID rises (a transfer in one cycle), READY rising later (the sender waits) and VALID rising later (READY waits). A testbench or checker must accept all three.

One write, step by step

A write of one 32-bit word to address 0x1000 goes like this.

  1. The master puts the address on AWADDR with AWVALID high, and the data on WDATA with WVALID, WSTRB set to all four byte lanes (4'b1111) and WLAST high, since this is a single-beat burst.

  2. The slave accepts the address when AWREADY is high at an edge, and accepts the data when WREADY is high at an edge. The two may happen in the same cycle or in either order.

  3. After the slave has taken the last data beat, it raises BVALID with BRESP set to OKAY. The master accepts it with BREADY.

The write is complete only when the response arrives. A master that moves on at the end of the data phase cannot know whether the write was accepted.

One read, step by step

A read is two channels. The master sends the address with ARVALID and the burst fields. The slave later returns the data on R with RVALID, one beat per cycle, RRESP on each beat and RLAST on the last. Each beat carries its own response code, so a read burst can fail partway.

Response codes

BRESP and RRESP are two bits:

CodeNameMeaning
00OKAYnormal success
01EXOKAYexclusive access succeeded
10SLVERRthe slave was reached but the transfer failed, for example a write to a read-only register
11DECERRno slave at that address; usually returned by the interconnect

Firmware that reads a wrong address often gets DECERR, which the processor turns into a bus fault.

Describing a burst

A burst is several data beats under one address. Three fields describe it.

AxLEN is the number of beats minus one, so a value of 3 means four beats. AXI4 allows up to 256 beats on an incrementing burst, a value of 255, while AXI3 allowed 16. AxSIZE is the number of bytes in each beat, encoded as a power of two: 0 for one byte, 1 for two, 2 for four, 3 for eight, up to 7 for 128 bytes. A beat can be no wider than the data bus. AxBURST chooses the address pattern:

ValueTypeAddress patternTypical use
00FIXEDthe same address every beatreading or writing a FIFO register
01INCReach beat advances by the beat sizememory, DMA
10WRAPlike INCR but wraps at a boundarycache line fills

For WRAP, the length must be 2, 4, 8 or 16 beats, and the start address must be aligned to the beat size. The wrap boundary is the total burst size, beats times bytes per beat. A fourth rule applies to every burst: it must not cross a 4 KB boundary, so a burst that would run from 0xFF8 into 0x1000 must be split. This keeps a burst inside one slave when slaves are placed on 4 KB pages.

Computing burst addresses

The address of beat n follows from the fields, and writing the function is the quickest way to learn it.

axi_burst_demo.vverilog
module axi_burst_demo;
    function [31:0] next_addr(
        input [31:0] cur,
        input [31:0] start,
        input [7:0]  len,
        input [2:0]  size,
        input [1:0]  burst
    );
        reg [31:0] nbytes;
        reg [31:0] wrap_bytes;
        reg [31:0] lower;
        reg [31:0] nxt;
        begin
            nbytes     = 32'd1 << size;
            wrap_bytes = (len + 32'd1) * nbytes;
            lower      = (start / wrap_bytes) * wrap_bytes;
            nxt        = cur + nbytes;
            case (burst)
                2'd0:    next_addr = cur;
                2'd1:    next_addr = nxt;
                default: next_addr = (nxt == lower + wrap_bytes) ? lower : nxt;
            endcase
        end
    endfunction

    function crosses_4k(input [31:0] start, input [7:0] len, input [2:0] size);
        reg [31:0] last;
        begin
            last = start + ((len + 32'd1) << size) - 32'd1;
            crosses_4k = (start[31:12] != last[31:12]);
        end
    endfunction

    reg [31:0] a;
    integer    i;

    initial begin
        a = 32'h1000;
        $write("INCR :");
        for (i = 0; i < 4; i = i + 1) begin
            $write(" %08h", a);
            a = next_addr(a, 32'h1000, 8'd3, 3'd2, 2'd1);
        end
        $display;

        a = 32'h1008;
        $write("WRAP :");
        for (i = 0; i < 4; i = i + 1) begin
            $write(" %08h", a);
            a = next_addr(a, 32'h1008, 8'd3, 3'd2, 2'd2);
        end
        $display;

        a = 32'h2000;
        $write("FIXED:");
        for (i = 0; i < 4; i = i + 1) begin
            $write(" %08h", a);
            a = next_addr(a, 32'h2000, 8'd3, 3'd2, 2'd0);
        end
        $display;

        $display("start 0x00000ff8 len=3 size=2 crosses 4KB: %0d", crosses_4k(32'h0FF8, 8'd3, 3'd2));
        $display("start 0x00000ff0 len=3 size=2 crosses 4KB: %0d", crosses_4k(32'h0FF0, 8'd3, 3'd2));
        $finish;
    end
endmodule
Shell
iverilog -g2012 -o axi_sim axi_burst_demo.v
vvp axi_sim
Text
INCR : 00001000 00001004 00001008 0000100c
WRAP : 00001008 0000100c 00001000 00001004
FIXED: 00002000 00002000 00002000 00002000
start 0x00000ff8 len=3 size=2 crosses 4KB: 1
start 0x00000ff0 len=3 size=2 crosses 4KB: 0

Read the WRAP line carefully. The burst has four beats of four bytes, so the wrap size is 16 bytes and the window it wraps inside is 0x1000 to 0x100F. Starting at 0x1008, the beats go 0x1008, 0x100C, then wrap to 0x1000 and 0x1004. A cache that wants the word at 0x1008 first gets it first and fills the rest of its 16-byte line afterwards, which is why WRAP exists.

The last two lines apply the 4 KB rule. Four beats of four bytes make a 16-byte burst. Starting at 0xFF8, the last byte is at 0x1007, which is in the next page, so the function returns 1 and the master must split the transfer into two bursts, one that ends at 0xFFF and one that starts at 0x1000. Starting at 0xFF0, the last byte is at 0xFFF, the burst ends exactly at the page boundary and the function returns 0. A DMA engine runs this check on every burst it generates, and a later post in this cluster builds the splitter that acts on it.

Outstanding transactions and IDs

Each address carries an ID. A master may issue several reads before the first returns, and the slave may return data for different IDs out of order, but responses with the same ID return in the order issued. This lets a master keep the pipeline full while waiting for slow memory. AXI4-Lite drops bursts, IDs and exclusive access, so every transfer is a single beat, which is why it is the usual choice for register blocks.

Share

Keep reading

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.