AXI(Advanced eXtensible Interface)是一種總線協議,該協議是ARM公司提出的AMBA(Advanced Microcontroller Bus Architecture)3.0協議中最重要的部分,是一種面向高性能、高帶寬、低延遲的片內總線。它的地址/控制和數據相位是分離的,支持不對齊的數據傳輸,同時在突發傳輸中,只需要首地址,同時分離的讀寫數據通道、並支持Outstanding傳輸訪問和亂序訪問,並更加容易進行時序收斂。
AXI的特點
單向通道體系結構。信息流只以單方向傳輸,簡化時鍾域間的橋接,減少門數量。當信號經過復雜的片上系統時,減少延時。
支持多項數據交換。通過並行執行猝發操作,極大地提高了數據吞吐能力,可在更短的時間內完成任務,在滿足高性能要求的同時,又減少了功耗。
獨立的地址和數據通道。地址和數據通道分開,能對每一個通道進行單獨優化,可以根據需要控制時序通道,將時鍾頻率提到最高,並將延時降到最低。
增強的靈活性。AXI技術擁有對稱的主從接口,無論在點對點或在多層系統中,都能十分方便地使用AXI技術。
AXI總線還定義了在進出低功耗節電模式前后的握手協議,規定如何通知進入低功耗模式,何時關斷時鍾,何時開啟時鍾,如何退出低功耗模式。這使得所有IP在進行功耗控制的設計時,有據可依,容易集成在統一的系統中。
總之,AXI 能夠使SoC 以更小的面積、更低的功耗,獲得更加優異的性能。AXI獲得如此優異性能的一個主要原因,就是它的單向通道體系結構。單向通道體系結構使得片上的信息流只以單方向傳輸,減少了延時。
AXI的工作模式
A. 握手機制
AXI所采用的是一種READY,VALID握手通信機制,即主從模塊進行數據通信前,新根據操作對各所用到的數據、地址通道進行握手。主要操作包括傳輸發送者A等到傳輸接受者B的READY信號后,A將數據與VALID信號同時發送給B。根據READY和VALID拉高的先后順序,可分為如下3種情況:
Valid before Ready handshake
Ready before Valid handshake
Valid with Ready handshake
每個channel內的valid和ready之間沒有嚴格的先后順序,但是channel間的valid和ready信號有依賴關系。對於讀操作,spec要求讀data必須出現在讀addr之后,因此讀操作的兩個channel之間存在如下的依賴關系,即必須等到ARVALID和ARREADY同時為High后,RVALID才能拉高。
Read transaction handshake dependencies
對於寫操作,addr和data兩個channel之間不存在依賴關系,但是只能等最后一次transfer結束后,才能拉高BVALID。從下圖中看不出AWVLAID, AWREAY與BVALID之間的關系,但是,隱含條件是slave只有接收到addr和data后,才能做出響應,因此AWAVLID, AWREADY為High,且最后一次transfer結束后才能拉高BVALID.
Write transaction handshake dependencies
B. axi總線的五個通道:
- 讀地址通道,包含ARVALID, ARADDR, ARREADY信號;
- 寫地址通道,包含AWVALID,AWADDR, AWREADY信號;
- 讀數據通道,包含RVALID, RDATA, RREADY, RRESP信號;
- 寫數據通道,包含WVALID, WDATA,WSTRB, WREADY信號;
- 寫應答通道,包含BVALID, BRESP, BREADY信號;
另外,還有兩個global signal,ACLK,ARESETN信號;
其中ACLK為axi總線時鍾,僅上升沿有效,ARESETN是axi總線復位信號,低電平有效,異步復位同步釋放;所有master和slave共用ACLK和ARESETn。
READY與VALID是對應的通道握手信號;WSTRB信號為1的bit對應WDATA有效數據字節,WSTRB寬度是32bit/8=4bit;BRESP與RRESP分別為寫回應信號,讀回應信號,寬度都為2bit,‘h0代表成功,其他為錯誤。
a. 讀操作:
順序
- 主與從進行讀地址通道握手並傳輸地址內容,
- 讀數據通道握手並傳輸所讀內容以及讀取操作的回應。
對於讀操作,slave必須先知道master想要讀取的地址,因此,slave必須先接收到command后再回數據。normal的操作如圖所示:
Channel architecture of READ TRANSACTION
READ Burst
b. 寫操作:
順序
- 主與從進行寫地址通道握手並傳輸地址內容,
- 寫數據通道握手並傳輸所讀內容,
- 寫回應通道握手,並傳輸寫回應數據。
對於寫操作,command和數據都是master發給slave的,因此command和data沒有順序,可以先發command,再發data,也可以先發data,在發送data過程中發送command。normal的操作如圖所示:
Channel architecture of writeTRANSACTION
Write Burst
什么是支持 outstanding
Outstanding 支持的多少是需要設定的。舉個例子,如果 outstanding設為5,對於寫來說,可以連續發送5個寫操作而不用等待bresponse的響應,否則必須等待有一個responese回來才能發送下一個寫操作,對於讀來說,是通過rlast信號來看是否有respone,也類似於寫操作;也就是說,如果沒有respone的操作超過了outstanding的值,則會通過拉低響應的ready信號,從而不能發送有效操作;
三、 各個通道的時序關系:
1、讀地址通道:
output [0: 0] master_axi_arid; // axi read command ID
output [35: 0] master_axi_araddr; // axi read command address
output [3:0] master_axi_arlen; // axi encoded read command length
output [2:0] master_axi_arsize; // axi encoded read command size
output [1:0] master_axi_arburst; // axi read command burst type.
output [1:0] master_axi_arlock; // axi atomic access indicator
output [3:0] master_axi_arcache; // axi cache control os for the read.
output [2:0] master_axi_arprot; // axi read command protection type.
output master_axi_arvalid; // axi read command valid indicator.
input master_axi_arready; // indicates that axi is ready to accept the read command.
2、讀數據通道:
Input [0:0] master_axi_rid; // axi read data ID.
Input [255:0] master_axi_rdata ; // axi read data.
Input [1:0] master_axi_rresp ; // aix read data response a response is sent with each burst indicating the status of the burst.
input master_axi_rlast; // Indicates that this is the final world of the data for the command.
input master_axi_rvalid; // axi read data valid indicator.
output master_axi_rready; // indicates that the axi master is ready to accept read data.
4.寫地址通道:
output [ 0: 0] master_axi_awid; // axi write command ID
output [35: 0] master_axi_awaddr; // axi write command address
output [ 3:0] master_axi_awlen; // axi encoded write command length
output [ 2:0] master_axi_awsize; // axi encoded write command size
output [ 1:0] master_axi_awburst; // axi write command burst type.
output [ 1:0] master_axi_awlock; // axi atomic access indicator
output [ 3:0] master_axi_awcache; // axi cache control os for the read.
output [ 2:0] master_axi_awprot; // axi read command protection type.
output master_axi_awprot; // axi read command valid indicator.
input master_axi_awready; // indicates that aix is ready to accept the read command.
5.寫數據通道:
output [ 0:0] master_axi_wid; // axi write data ID.
output [255:0] master_axi_wdata ; // axi write data.
output [ 31:0] master_axi_wstrb ; // axi write data strobe.
output master_axi_wlast; // Indicates that this is the final world of the data for the command.
output master_axi_wvalid; // axi write data valid indicator.
input master_axi_0_wready; // indicates that the axi master is ready to accept write data.
6.寫響應通道:
input [0:0] master_axi_bid; // AXI write respone ID.
input [1:0] master_axi_bresp; // AXI write respone A responese is sent for the entire burst.
input master_axi_bvalid; // AXI write response valid indicator.
input master_axi_bready; // Indicates that the AXI master is ready to accepta write respone.
7.寫地址、寫數據、寫響應的時序關系
四.傳輸順序說明
AXI 協議可以完成按照固定順序的傳輸操作,其通過接口給每一個傳輸操作一個ID標記,協議要求具有相同的ID標記的傳輸要按照指定順序完成,但是不同的ID的傳輸可以不按照制定的順序進行傳輸; 完成亂序傳輸的能力意味着可以完成向快速內存的傳輸,不用等待之前向慢速內存的傳輸,這樣可以提高系統的性能,減少不必要的等待時間;