AMBA AXI Protocol === ## AXI Architecture AXI 是 burst-based 的 protocol 其中有五個 channels - Write Address Channel - Write Data Channel - Write Response Channel - Read Address Channel - Read Data Channel ## Read and Write Transactions ### Handshake Process 每個 channel 都有自己的 handshake 機制,handshake 都是用 VALID/READY 來完成一次的傳輸。 要傳輸資訊的一端不必等目的地是否有拉起 READY 就可以發送 VALID,但一旦發送 VALID 就必須等到目的地回 READY 才能結束 VALID。 VALID/READY handshake 機制可以有兩種做法: - 等有來源發送 VALID 後目的地若可以接收才回 READY。如下圖所示,T1 發送 VALID,T2 收到 VALID 後才回 READY,T3 完成此次的傳輸  - 只要目的地可以接收資訊就一直拉著 READY。如下圖所示,T1 目的地可以接收資訊,T2 來源發送 VALID,T3 完成此次的傳輸  一般推薦用第二種方法,這樣可以在來源發送 VALID 的下一 cycle 就完成傳輸。 ### 各 Channel Handshake Process 的訊號名稱  ### Channel 間的關係 - Write response 必須要在最後一筆 write data 傳輸後才能回 - Read data 必須要有 read address 傳輸後才能回 - channel handshake 必須遵守下面的關係,其中單箭頭代表後者跟前著的關係沒有誰先誰後,雙箭頭代表前者一定要先發生後者才能發生  上圖代表 read address channel 可以是 VALID 先拉起或 READY 先拉起,但 read address channel handshake 的訊號都必須要在 read data channel VALID 拉起前先拉起 (這其實也就是要傳輸 read data 前一定要先完成 read address 的傳輸),而 read data channel 的 VALID 跟 READY 誰先拉起都可以。這邊並沒有要求 read data channel 的 READY 跟 read address channel 的 handshake 訊號的關係。  上圖代表 write address channel 跟 write data channel 的 VALID 跟 READY 誰先拉起都可以,但這些訊號都必須在 write response channel 的 VALID 拉起前先拉起過 (這表示要有 write response 必須先完成 write address 跟 write data 的傳輸才行),write response channel 的 VALID 跟 READY 誰先拉起都可以。 write data channel 另外需要注意的是 VALID 要看的是最後一筆 data 的 VALID。 另外,AXI3 的時候並沒有要求 write response channel 的 VALID 必須要在 write address channel handshake 完成之後,因為當時並沒有預期會有可能有 write response channel 拉起 VALID 但還沒有完成 write address 傳輸的情況。 ## Transaction Structure 一次的 Transaction 包含三個部分: address、data read/write、response ### Address Structure AXI 是 burst-based 的 protocol,傳送 address 時也會傳送 burst 相關的控制資訊,而接收端就需要去根據這些控制資訊來處理 address。 :::info Write address channel 跟 read address channel 除了傳 address 也包含 burst 的控制資訊。 ::: #### Burst 的控制資訊 - ARLEN[7:0] / AWLEN[7:0]: read address 跟 write address 的 burst 長度。 我們下面舉 read 的例子,write 也可依此類推 ARLEN = 0 代表這次發送的 read address 只會回傳一筆 data ARLEN = 2 代表這次發送的 read address 會回傳三筆 data - ARSIZE[2:0] / AWSIZE[2:0]: 每一筆 read / write 傳輸的 data size  - ARBURST[1:0] / AWBURST[1:0]: burst type,有三種 FIXED、INCR、WRAP - FIXED - burst 的每一筆傳輸都是相同的 address - 雖然 burst 的每一筆傳輸都是相同的 address,但 write 時可以指定不同的 write byte (WSTRB) - FIXED type 適合用重複在存取相同 address 的時候,例如存取 FIFO - INCR - burst 的每一筆傳輸的 address 都是前一筆 address 的累加,累加的值取決於 burst size - WRAP - WRAP 跟 INCR 類似,差別在當 address 超過上限會繞回較低的 address - 當 address 的到達 wrapper boundary + burst size x burst length 就會繞回 wrapper boundary,wrapper boundary = int(start address / (burst size x burst length)) x burst size x burst length,int() 會無條件捨去小數位 - WRAP burst 的 start address 必須要 align burst size - WRAP burst 只能是 2, 4, 8, 16  Burst 的規則: - Burst address 不能夠跨 4KB address boundary - Burst 長度限制從 1 - 256 - AXI3 只有 1 - 128 - AXI4 只有 INCR type 才能是 1 - 256,其餘仍是 1 - 128 - WRAP type 的 burst 長度只能夠是 2, 4, 8, 16 - 一旦給了 burst 長度就一定要發完,不能提前結束 ### Data Read and Write Structure #### Write Strobes write data channel 的 data bus 可以分成一條條的 byte lane,每條由 WSTRB (write strobes) 控制,若 data bus 為 n bytes 那 WSTRB 就需要 n bits,每個 bit 對應 data bus 第 n 個 byte 是否是 valid data。 WSTRB 在 WVALID 沒有拉起前是任何值都無所謂。 #### Narrow Transfers write data channel 可以接受較大的 data bus 但指傳輸較小的 data size,要達到如此我們需知道 address 跟一些控制訊號,像是 burst size 之類來控制 WSTRB 來決定哪些 byte lane 需要使用。 以下圖為例,下圖為 data bus 為 32-bit,burst size 為 0 (也就是每次傳輸 8-bit data),burst length 為 4 (也就是會傳輸 5 筆 data),burst type 為 0 (也就是 INCR type) 的 data 傳輸範例  #### Byte Invariance AXI 使用的是 byte-invariant endianness,如此可以比較容易的處理 mixed-endian。byte-invariant endianness 不管 data 是 big-endian 或 little-endian 都是按照對應 address 的 byte 去存取。 #### Unaligned Transfers AXI 支援沒有對齊的傳輸,舉例來說,有個 data packet 為 4-byte 但它的 start address 為 0x0002 並沒有對其 4-byte。 要做到 unaligned transfers 可以搭配 WSTRB 把不要存取的 byte 擋掉就行了。 以下圖為例,下圖為一個 data bus 為 64-bit 從 0x07 address 開始的 data size 為 32-bit 的傳輸。灰色部分為用 WRSTB 遮掉的部分,白色為每次 transfer valid 的 data。  ### Read and Write Response Structure AXI 在 read 跟 write 的 transactions 都有 response 訊號。Read transaction 的 response 訊號是在 read data channel (RRESP[1:0]),write transaction 的 response 訊號是在 write response channel (BRESP[1:0])。 有四種 response:  - OKAY: normal access 成功時使用 - EXOKAY: exclusive access 成功時使用 - SLVERR: master 到 slaver 的傳輸成功,但 slaver 想要對 master 回覆錯誤時使用 - DECERR: master 要傳輸的 slaver 不存在時使用 對於 write transaction,一次 response 訊號回應所有 burst 的傳輸。而對於 read transaction,一次 response 訊號回應 burst 裡單一筆傳輸。 前面有提到 burst 傳輸無論如何都要把傳輸傳完,response 也是如此,即使其中有 error response 也要把剩餘的傳輸完成。
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.