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=OKAY
withBVALID
untilBREADY
. -
For reads, handshake
AR
, then presentRDATA
andRRESP=OKAY
withRVALID
untilRREADY
. -
Honor
WSTRB
for 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:
AWREADY
is only asserted whenWVALID
is 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:
STATUS
andDATA_OUT
are 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_out
in 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_ACLK
tied to the processor/interconnect clock andS_AXI_ARESETN
to 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
OKAY
with data. -
Simulate byte-writes with varied
WSTRB
(e.g., write only the high byte). -
Back-pressure: hold off
BREADY
orRREADY
in the testbench to ensure the slave keepsBVALID
/RVALID
asserted as required.
Pitfalls to avoid
-
Forgetting
WSTRB
(software writes will mysteriously not stick). -
Allowing reads/writes when
ARESETN
is asserted (reset proper). -
Driving
AWREADY/WREADY
constantly 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.
评论
发表评论