天天看點

AMBA-AXI總線協定

本文參考:

  1. https://www.cnblogs.com/lkiller/p/4773235.html

  2. AMBAAXI and ACE ProtocolSpecification

0.緒論

AXI是進階擴充接口,在AMBA3.0中提出,AMBA4.0将其修改更新為AXI4.0。AMBA4.0 包括AXI4.0、AXI4.0-lite、ACE4.0、AXI4.0-stream

AXI4.0-lite是AXI的簡化版本,ACE4.0 是AXI緩存一緻性擴充接口,AXI4.0-stream是ARM公司和Xilinx公司一起提出,主要用在FPGA進行以資料為主導的大量資料的傳輸應用。

1.簡介

1.1 關于AXI協定

AMBA AXI協定支援支援高性能、高頻率系統設計。

  •  适合高帶寬低延時設計
  •  無需複雜的橋就能實作高頻操作
  •  能滿足大部分器件的接口要求
  • 适合高初始延時的存儲控制器
  •  提供互聯架構的靈活性與獨立性
  •  向下相容已有的AHB和APB接口

關鍵特點:

  •  分離的位址/控制、資料相位
  •  使用位元組線來支援非對齊的資料傳輸
  •  使用基于burst的傳輸,隻需傳輸首位址
  •  分離的讀、寫資料通道,能提供低功耗DMA
  •  支援多種尋址方式
  •  支援亂序傳輸
  •  允許容易的添加寄存器級來進行時序收斂
  •  outstanding transactions    (添加)

1.2 AXI架構

AMBA-AXI總線協定

AXI協定是基于burst的傳輸,并且定義了以下5個獨立的傳輸通道:讀位址通道、讀資料通道、寫位址通道、寫資料通道、寫響應通道。

位址通道攜帶控制消息用于描述被傳輸的資料屬性,資料傳輸使用寫通道來實作“主”到“從”的傳輸,“從”使用寫響應通道來完成一次寫傳輸;讀通道用來實作資料從“從”到“主”的傳輸。

AMBA-AXI總線協定
AMBA-AXI總線協定

AXI是基于VALID/READY的握手機制資料傳輸協定,傳輸源端使用VALID表明位址/控制信号、資料是有效的,目的端使用READY表明自己能夠接受資訊。

1.3 通道定義

Each of the five independent channels consists of a set of information signals and VALID and READY signals that provide a two-way handshake mechanism.

The information source uses the VALID signal to show when valid address, data, or control information is available on the channel. The destination uses the READY signal to show when it can accept the information. Both the read data channel and the write data channel also include a LAST signal to indicate the transfer of the final data item in a transaction.

讀/寫位址通道:讀、寫傳輸每個都有自己的位址通道,對應的位址通道承載着對應傳輸的位址控制資訊。

讀資料通道:讀資料通道承載着讀資料和讀響應信号包括資料總線(8/16/32/64/128/256/512/1024bit) 和訓示讀傳輸完成的讀響應信号。

寫資料通道:寫資料通道的資料資訊被認為是緩沖(buffered)了的,“主”無需等待“從”對上次寫傳輸的确認即可發起一次新的寫傳輸。寫通道包括資料總線(8/16...1024bit)和位元組線(用于訓示8bit 資料信号的有效性)。

寫響應通道:“從”使用寫響應通道對寫傳輸進行響應。所有的寫傳輸需要寫響應通道的完成信号。

圖 1-3 接口與互聯

AMBA-AXI總線協定

The AXI protocol provides a single interface definition, for the interfaces between:

  • A master and the interconnect.
  •  A slave and the interconnect.
  •  A master and a slave

2. 信号

注意信号的來源和目的地。

2.1 全局信号

AMBA-AXI總線協定

2.2 write address channel

自己這水準就關注AWID、AWADDR、AWLEN、AWSIZE、AWBURST、AWVALID、AWREADY這幾個信号

AMBA-AXI總線協定
AMBA-AXI總線協定

2.3 write data channel

AMBA-AXI總線協定

2.4 write response channel

AMBA-AXI總線協定

2.5 read address

AMBA-AXI總線協定
AMBA-AXI總線協定

2.6 read data channel

AMBA-AXI總線協定

(沒在協定中看到低功耗接口)

AMBA-AXI總線協定

3.信号接口要求

3.1時鐘複位

時鐘

每個AXI元件使用一個時鐘信号ACLK,所有輸入信号在ACLK上升沿采樣,所有輸出信号必須在ACLK上升沿後發生。

複位

AXI使用一個低電平有效的複位信号ARESETn,複位信号可以異步斷言,但必須和時鐘上升沿同步去斷言。

複位期間對接口有如下要求:①主機接口必須驅動ARVALID,AWVALID,WVALID為低電平;②從機接口必須驅動RVALID,BVALID為低電平;③所有其他信号可以被驅動到任意值。

在複位後,主機可以在時鐘上升沿驅動ARVALID,AWVALID,WVALID為高電平。

AMBA-AXI總線協定

3.2基本讀寫傳輸

握手過程

5個傳輸通道均使用VALID/READY信号對傳輸過程的位址、資料、控制信号進行握手。使用雙向握手機制,傳輸僅僅發生在VALID、READY同時有效的時候。下圖是幾種握手機制:(看圖,圖中很清楚)

AMBA-AXI總線協定
AMBA-AXI總線協定
AMBA-AXI總線協定

通道信号要求

通道握手信号:每個通道有自己的xVALID/xREADY握手信号對。

 寫位址通道:

  當主機驅動有效的位址和控制信号時,主機可以斷言AWVALID,一旦斷言,需要保持AWVALID的斷言狀态,直到時鐘上升沿采樣到從機的AWREADY。AWREADY預設值可高可低,推薦為高(如果為低,一次傳輸至少需要兩個周期,一個用來斷言AWVALID,一個用來斷言AWREADY);當AWREADY為高時,從機必須能夠接受提供給它的有效位址。

 寫資料通道:

  在寫突發傳輸過程中,主機隻能在它提供有效的寫資料時斷言WVALID,一旦斷言,需要保持斷言狀态,直到時鐘上升沿采樣到從機的WREADY。WREADY預設值可以為高,這要求從機總能夠在單個周期内接受寫資料。主機在驅動最後一次寫突發傳輸是需要斷言WLAST信号。

 寫響應通道:

  從機隻能它在驅動有效的寫響應時斷言BVALID,一旦斷言需要保持,直到時鐘上升沿采樣到主機的BREADY信号。當主機總能在一個周期内接受寫響應信号時,可以将BREADY的預設值設為高。

 讀位址通道:

  當主機驅動有效的位址和控制信号時,主機可以斷言ARVALID,一旦斷言,需要保持ARVALID的斷言狀态,直到時鐘上升沿采樣到從機的ARREADY。ARREADY預設值可高可低,推薦為高(如果為低,一次傳輸至少需要兩個周期,一個用來斷言ARVALID,一個用來斷言ARREADY);當ARREADY為高時,從機必須能夠接受提供給它的有效位址。

 讀資料通道:

  隻有當從機驅動有效的讀資料時從機才可以斷言RVALID,一旦斷言需要保持直到時鐘上升沿采樣到主機的BREADY。BREADY預設值可以為高,此時需要主機任何時候一旦開始讀傳輸就能立馬接受讀資料。當最後一次突發讀傳輸時,從機需要斷言RLAST。

3.3 通道間關系

AXI協定要求通道間滿足如下關系:

  •  寫響應必須跟随最後一次burst的的寫傳輸
  •  讀資料必須跟随資料對應的位址
  •  通道握手信号需要确認一些依耐關系

通道握手信号的依耐關系

為防止死鎖,通道握手信号需要遵循一定的依耐關系。①VALID信号不能依耐READY信号。②AXI接口可以等到檢測到VALID才斷言對應的READY,也可以檢測到VALID之前就斷言READY。下面有幾個圖表明依耐關系,單箭頭指向的信号能在箭頭起點信号之前或之後斷言;雙箭頭指向的信号必須在箭頭起點信号斷言之後斷言。

Read transaction dependencies

AMBA-AXI總線協定

AXI3 write transaction dependencies

因為寫的資料是被緩存的,M不需要等到S接受完資料就可以發送下一個資料,是以AW***信号和W***信号沒有強制的先後關系

AMBA-AXI總線協定

AXI4 and AXI5 write transaction dependencies

AXI4 and AXI5 define an additional slave write response dependency. The slave must wait for AWVALID, AWREADY, WVALID, and WREADY to be asserted before asserting BVALID.

The slave must also wait for WLAST to be asserted before asserting BVALID. This wait is because the writeresponse, BRESP, must be signaled only after the last data transfer of a write transaction

AMBA-AXI總線協定

3.3 傳輸結構

3.3.1 位址結構

  AXI協定是基于burst的,主機隻給出突發傳輸的第一個位元組的位址,從機必須計算突發傳輸後續的位址。突發傳輸不能跨4KB邊界 (防止突發跨越兩個從機的邊界,也限制了從機所需支援的位址自增數)。

Burst  Length

AMBA-AXI總線協定

  ARLEN[7:0]決定讀傳輸的突發長度,AWLEN[7:0]決定寫傳輸的突發長度。AXI3隻支援1~16次的突發傳輸(Burst_length=AxLEN[3:0]+1),AXI4擴充突發長度支援INCR突發類型為1~256次傳輸,對于其他的傳輸類型依然保持1~16次突發傳輸(Burst_Length=AxLEN[7:0]+1)。

burst傳輸具有如下規則:

  •  wraping burst ,burst長度必須是2,4,8,16
  •  burst不能跨4KB邊界
  •  不支援提前終止burst傳輸

  所有的元件都不能提前終止一次突發傳輸。然而,主機可以通過解斷言所有的寫的strobes來使非所有的寫位元組來減少寫傳輸的數量。讀burst中,主機可以忽略後續的讀資料來減少讀個數。也就是說,不管怎樣,都必須完成所有的burst傳輸。

注:對于FIFO,忽略後續讀資料可能導緻資料丢失,必須保證突發傳輸長度和要求的資料傳輸大小比對。

Burst Size

The maximum number of bytes to transfer in each data transfer, or beat, in a burst, is specified by:

• ARSIZE[2:0], for read transfers.

• AWSIZE[2:0], for write transfers.

AMBA-AXI總線協定

Burst type

AMBA-AXI總線協定

FIXED:突發傳輸過程中位址固定,用于FIFO通路

INCR:增量突發,傳輸過程中,位址遞增。增加量取決AxSIZE的值。

WRAP:回環突發,和增量突發類似,但會在特定高位址的邊界處回到低位址處。回環突發的長度隻能是2,4,8,16次傳輸,傳輸首位址和每次傳輸的大小對齊。最低的位址整個傳輸的資料大小對齊。回環邊界等于(AxSIZE*AxLEN)。

AMBA-AXI總線協定
AMBA-AXI總線協定

These equations determine addresses of transfers within a burst:

  • Start_Address = AxADDR
  • Number_Bytes = 2 ^ AxSIZE
  •  Burst_Length = AxLEN + 1
  •  Aligned_Address = (INT(Start_Address / Number_Bytes)) × Number_Bytes

3.3.2 資料讀寫結構

Write strobe(寫選通)

WSTRB[n:0]對應于對應的寫位元組,WSTRB[n]對應WDATA[8n+7:8n]。WVALID為低時,WSTRB可以為任意值,WVALID為高時,WSTRB為高的位元組線必須訓示有效的資料。

窄傳輸

當主機産生比它資料總線要窄的傳輸時,由位址和控制信号決定哪個位元組被傳輸:

INCR和WRAP,不同的位元組線決定每次burst傳輸的資料,FIXED,每次傳輸使用相同的位元組線。

下圖給出了5次突發傳輸,起始位址為0,每次傳輸為8bit,資料總線為32bit,突發類型為INCR。

AMBA-AXI總線協定
AMBA-AXI總線協定

非對齊傳輸

  AXI supports unaligned transfers. For any burst that is made up of data transfers wider than 1 byte, the first bytes

accessed might be unaligned with the natural address boundary. For example, a 32-bit data packet that starts at a

byte address of 0x1002 is not aligned to the natural 32-bit address boundary.

主機可以

①使用低位位址線來表示非對齊的起始位址;

②提供對齊的起始位址,使用位元組線來表示非對齊的起始位址。

AMBA-AXI總線協定
AMBA-AXI總線協定
AMBA-AXI總線協定
AMBA-AXI總線協定
AMBA-AXI總線協定
AMBA-AXI總線協定

 讀寫響應結構

讀傳輸的響應資訊是附加在讀資料通道上的,寫傳輸的響應在寫響應通道。

RRESP[1:0],讀傳輸

BRESP[1:0],寫傳輸

AMBA-AXI總線協定

OKAY('b00):正常通路成功

EXOKAY('b01):Exclusive 通路成功

SLVERR('b10):從機錯誤。表明通路已經成功到了從機,但從機希望傳回一個錯誤的情況給主機。

DECERR('b11):譯碼錯誤。一般由互聯元件給出,表明沒有對應的從機位址。

OKAY, normal access success

An OKAY response indicates any one of the following:

• The success of a normal access.

• The failure of an exclusive access.

• An exclusive access to a slave that does not support exclusive access.

OKAY is the response for most transactions.

AMBA-AXI總線協定

4. AXI transaction

AXI中有AXI ID作為transaction identifier,相同ID 的transaction需要in order,不同ID 的transaction可以out order。

By using AXI IDs, a master can issue transactions without waiting for earlier transactions to complete. This can improve system performance, because it enables parallel processing of transactions。這個就是Outstanding transactions,master不需要要等待slave READY。

AMBA-AXI總線協定

4.1 Transactions  ordering

master通過AWID或者ARID來表明它的ordering requirement,具體如下:

  •  來自不同master的Transactions 可以任意order;
  •  來自相同master但ID不同的Transactions ,可以任意order;
  •  連續讀操作有相同的ARID,需要按照master發出位址的順序傳回資料;
  •  連續寫操作有相同的AWID,需要按照master發出位址的順序完成傳輸;
  •  讀寫操作之間沒有order requirement;

Read ordering

  At a master interface, read data from transactions with the same ARID value must arrive in the order that the master issued the addresses. Data from read transactions with different ARID values can arrive in any order.

  The slave must ensure that the RID value of any returned data matches the ARID value of the address to which it is responding.

Read and write interaction

A master can only consider the earlier transaction is complete when:

  • For a read transaction, it receives the last of the read data.

  • For a write transaction, it receives the write response.

Note

Typically, when writing to a peripheral, a master must wait between read and write transactions that must be ordered

Interconect using ID identifier

  For read data, the interconnect uses the additional bits of the RID identifier to determine which master port the read data is destined for. The interconnect removes these bits of the RID identifier before passing the RID value to the correct master port

繼續閱讀