How does FPGA implement AXI Lite interface?
AXI4-Lite is the “simple, memory-mapped” subset of AXI: no bursts, one beat per transaction, at most one outstanding per direction, no IDs. Implementing it in an FPGA usually means building a tiny register file that the CPU can read/write.
Below is a compact, production-ready AXI4-Lite slave you can drop into your design (32-bit data, word-aligned addresses). It handles byte strobes, correct handshakes, and OKAY responses.
What you implement
Five channels (slave side, S_AXI_*):
-
Write address:
AWADDR, AWVALID → AWREADY -
Write data:
WDATA, WSTRB, WVALID → WREADY -
Write response:
BRESP, BVALID ← BREADY -
Read address:
ARADDR, ARVALID → ARREADY -
Read data/resp:
RDATA, RRESP, RVALID ← RREADY
Rules (AXI-Lite):
-
Accept a write only when both AW and W fire (address and data are independent but you can require them to handshake in the same cycle).
-
After the write, return
BRESP=OKAYwithBVALIDuntilBREADY. -
For reads, handshake
AR, then presentRDATAandRRESP=OKAYwithRVALIDuntilRREADY. -
Honor
WSTRBfor byte-granular writes.
Minimal register map (example)
| Address | Register | R/W | Notes |
|---|---|---|---|
| 0x00 | CTRL | R/W | Bit0 start, Bit1 clear |
| 0x04 | STATUS | R | Bit0 done, Bit1 busy |
| 0x08 | DATA_IN | R/W | Payload/config |
| 0x0C | DATA_OUT | R | Result/status |
You’ll wire these to your logic in the same clock domain as S_AXI_ACLK (or add CDC if not).
Verilog: AXI4-Lite slave with 4 registers
Notes on the template
-
Handshakes:
AWREADYis only asserted whenWVALIDis high (and vice-versa). That forces address+data to complete in the same cycle and keeps logic simple and AXI-Lite compliant. -
Byte strobes:
WSTRB[i]guards each written byte. -
Addresses: With 32-bit data,
ADDR_LSB=2. The code looks ataw_idx[3:0]/ar_idx[3:0]so you can expand to more registers by growingC_S_AXI_ADDR_WIDTH. -
RO vs RW:
STATUSandDATA_OUTare wired as read-only from the bus; drive them from your logic.
Hooking to your logic (example)
-
Generate a one-shot “start” pulse when SW writes
CTRL[0]=1:-
Detect rising edge of
reg_ctrl[0]or implement “write-1-to-start then auto-clear”.
-
-
Drive
reg_status[1:0]from your FSM (busy,done). -
Put results into
reg_data_outin your logic clock domain. If that differs fromS_AXI_ACLK, add CDC (e.g., a 2-FF sync for status bits, an async FIFO for data).
Common integration steps in Vivado (7-Series)
-
Instantiate this module in your design with
S_AXI_ACLKtied to the processor/interconnect clock andS_AXI_ARESETNto the shared active-low reset. -
Package as IP (optional) and add an AXI4-Lite interface; or drop it into a Block Design and expose
S_AXI_*. -
In Address Editor, assign a base address (e.g.,
0x4000_0000). -
If your user logic runs on a different clock, add proper CDC between these registers and your logic (status flags through 2-FF sync; data via async FIFO or handshake).
Verification tips
-
AXI-Lite write: AW, W → (one cycle later) B returns
OKAY. -
AXI-Lite read: AR → R returns
OKAYwith data. -
Simulate byte-writes with varied
WSTRB(e.g., write only the high byte). -
Back-pressure: hold off
BREADYorRREADYin the testbench to ensure the slave keepsBVALID/RVALIDasserted as required.
Pitfalls to avoid
-
Forgetting
WSTRB(software writes will mysteriously not stick). -
Allowing reads/writes when
ARESETNis asserted (reset proper). -
Driving
AWREADY/WREADYconstantly high (can accept address and data in different cycles and complicate design unless you fully track ordering). -
Crossing to a different logic clock without CDC.

评论
发表评论