master和slave驱动信号

在一些小型 SoC 芯片如MCU,一般使用AHB或者APB总线;而对于大型芯片,一般会选择AXI
两个重要性能指标:
- Latency降低(总线源头到数据端较短)
- Bandwidth更大
1. AHB Limitation
- The Performance Index: BandWidth & Latency
- The maximum BW = Freq. * DataWidth

1.1 Half-duplex mode
AHB works at half-duplex mode:
- Master and Slave can both transmit and receive data, but not at the same time
- e.g, 单车道方向可变
- Bandwidth will be affected if needing write and read access at the same time

1.2 MUST be Aligned
Aligned data transfers
- All transfers in a burst must be aligned to the address boundary equal to the size of the transfer. For example, word/4 byte transfers must align to word address boundaries (HADDR[1:0] = 0b00), and halfword transfers to halfword address boundaries (HADDR[0] = 0).
- log2(4) = 2,所以二进制的最低 2 位必须是 0
Unaligned transfers need to be converted into multiple aligned transfers
- Incurring
clock penalty
1.3 Contiguous addresses
Need to provide contiguous addresses for each transfer data
上图是AHB的一次INCR8读突发(8拍,每拍4字节,没有等待周期):master每个时钟周期都要送出当拍的地址,HADDR从0x60递增到0x7c;HTRANS第一拍是NSEQ,其余是SEQ;读数据HRDATA比对应的地址晚一拍返回。AXI只在突发开头给一次起始地址,后面的地址由slave按AxLEN、AxSIZE、AxBURST自己算。
1.4 AXI improvement
- Full-duplex mode —— AXI works at full-duplex mode
- Master and Slave can both transmit and receive data, even at the same time.
- Separated read/write channels:Bandwidth will not be affected if needing write and read access at the same time.
- Support for unaligned data transfers
- No strict timing relationship between the address and data phases
- (AHB must send the address before sending the data)
- Burst transactions based on start address issue only
- AHB should provide the corresponding address of each Burst_length
Are these enough? Let’s have a look at AXI protocol firstly
ooo…
2. AXI Channel
2.1 Channel
- Channel is a set of signals for different information transfer
五个独立通道:
- 读地址通道(AR)、读数据通道(R)
- 写地址通道(AW)、写数据通道(W)、写响应通道(B)
这五个通道合起来是一个AXI接口(interface),连接一个master和一个slave。一个模块有几个AXI接口,就有几套这样的五个通道(例:一个模块既要从内存读数据,又要被CPU配置寄存器,就有一个master接口和一个slave接口,各自五个通道)。

2.2 Channel Handshake

VALID可以先被激活:
- Master 在发送
VALID信号时,不需要等待 Slave 的READY信号 - Slave 在准备好接收数据时,可能会等到
VALID信号被 Master 激活
2.3 Timing diagram
-
Slave Buffer is ready later

- Master的Valid一直保持高电平,等待Slave的Ready
- Master的Valid下一次为高时,可以发送下一笔数据
- Slave Buffer在Valid拉高后才可接收信息
-
Waiting:Slave Buffer is ready

-
Valid & Ready is high at the same time

- Slave Ready组合逻辑电路产生
握手依赖包括不同通道之间的依赖关系、以及同一通道中不同信号之间的依赖关系。
首先记住一点:VALID 和 READY 信号之间确实存在依赖关系
-
发送方的
VALID信号不应依赖于接收方的READY信号。 -
接收方的
READY信号可以在检测到VALID信号后再被激活这样可以有效地控制数据流,防止接收方被过多的数据淹没。
下面给出握手依赖关系,单箭头指向表示不依赖(Not ordered),双箭头指向的信号必须依赖前者(Ordered)。
(1)Read transaction handshake dependencies

- 先有读地址handshake,再有读数据
- 拉高RLAST:slave端发送突发传输中的最后一拍读传输时
(2)Write transaction handshake dependencies

-
AW 和 W 无依赖关系——可以先有数据再有地址
- E.g. 收到写数据后可以将其暂存在 slave buffer,(继续等)待收到写地址后再放入对应的内存地址空间
-
BVALID 和 W 存在依赖关系——必须先有W,再有BVALID。
-
拉高WLAST:主机发送Burst中的最后一拍写传输时
2.4 Summary
- AR 和 R 存在依赖关系——先有读地址handshake,再有读数据
- BVALID 和 W 存在依赖关系——必须先有W,再有BVALID。
AXI3 与 AXI4 的区别:
- 在 AXI3 中,地址不一定需要在写响应返回之前被传输(少见)
- 在 AXI4 中,先有写数据 再有写响应
3. AXI Transactions
3.1 Terminology:Transaction / Transfer / Burst
- Transfer A single exchange of information - that is, with one xVALID/xREADY handshake.
- Transaction An entire burst of transfers, comprising an address, one or more data transfers, and a response transfer (writes only).
AXI真正的高性能来自于不同transaction之间可以乱序。
3.1.1 Transaction
AXI允许多笔不同ID的transaction在同一通道上乱序完成
一笔transaction(一次突发传输,burst)由:
- 一次地址阶段(AR或AW,只发一次)
- 多次数据阶段
组成。地址通道里的 ARLEN/AWLEN 字段就决定了这笔transaction包含多少个transfer(beat数 = LEN+1,AXI4里LEN是8位,最多256个beat)。
注意:同一笔transaction里的所有transfer ID都一样
- 写事务:地址阶段有
AWID,之后所有的写数据beat(W通道)不带ID(AXI4取消了AXI3里的WID) - 读事务:地址阶段有
ARID,之后每一个返回的数据beat(R通道)都带有RID字段,且这个transaction里每个beat的RID都相同,等于ARID
3.1.2 Transfer
两个注意点:
- 一笔transaction里的多个transfer是串行(顺序)传输的
- 每一个transfer都需要单独满足一次握手条件(
VALID=1且READY=1才算完成这一拍)
一个transfer就是:在一个时钟周期内,当VALID和READY同时为高(握手成立)时,数据总线上传输的那一份数据 它的大小 = 数据总线的位宽(DATA_WIDTH),而不是固定的一个字节。比如:
- 如果数据总线宽度是32位(4字节),那么一个transfer最多搬运4字节数据
- 如果是64位总线,一个transfer最多搬运8字节
具体每个字节是否有效,由WSTRB(写选通信号)决定——总线宽度是32位,但WSTRB可以指示只有其中1、2或3个字节是真正有效的写入数据
假设:
- 数据总线宽度:32位(4字节)
- 发起一笔读事务:ARADDR = 0x1000,ARLEN = 3(表示burst长度为4),ARID = 0x5
那么这笔transaction会产生:
- 1次地址握手(AR通道)
- 4次数据握手(R通道),即4个transfer,分别读回0x1000、0x1004、0x1008、0x100C这4个地址(若是INCR burst)各自的4字节数据
- 这4个transfer里,RID全部等于0x5
- 第4个(最后一个)transfer的RLAST信号会拉高,表示这是本次transaction的最后一个transfer
所以:一个transfer ≠ 一个字节,它是”总线位宽大小”的一次数据搬运,一笔transaction = 1次地址阶段 + N个这样的transfer(beat),共享同一个ID。
3.1.3 Burst length
AXI4(现在主流用的版本):
ARLEN/AWLEN是 8位,取值范围 0~255- Burst Length = ARLEN + 1
- 即最多支持256个beat(transfer)的一次transaction
- 但注意:AXI4规定,只有
INCR类型的burst才允许长度到256;如果是WRAP或FIXED类型,长度被限制为2/4/8/16(且必须是2的幂)
3.2 Write Transaction
-
Single data item

-
Multiple data items

Note: burst_length = 3 is missing above fig.
3.3 Read Transaction
single data item

-
在R channel中,RReady表示Master是否能接收数据
-
注意对于读来说一定是先发地址再发数据(AXI4)
multiple data items
Read doesn’t have a specific RESP signal

- 读没有Response通道,所以每笔数据除了Rvalid信号外,还需要Slave 用 RRESP告诉Master这笔数据是否成功读到
3.4 Active / Outstanding Transactions

Active read transaction
In this process, the read address (A) has been transmitted to the target device, but the read data has not been fully transmitted.
Active write transaction
In this process, the write address (A) or write data (W) has been sent to the target device, but the write response (B) has not been completed.
结论:看是否为Outstanding状态
- read:看这个请求的data和RRESP是否返回
- Write:看这个请求的 B 信号是否为okay状态
一笔 transaction 完成的判据:
- 写:B Channel handshake(
BVALID(Slave 发出) 和BREADY(Master 发出) 握手)- 很多人误以为写数据的最后一个数据包(
WLAST)发完就算结束了,其实不是。WLAST仅仅表示 Master 把数据发完了(Data Phase 结束)。 - B 通道的 handshake 必须在 WLAST 拉起后才能握手,因为写响应(Write Response)代表的是整笔 Burst 的状态。
- 很多人误以为写数据的最后一个数据包(
- 读:R Channel RLAST handshake —— 当
RLAST(Slave 发出) 为 High,且RVALID和RREADY在时钟上升沿同时为 High。
3.5 Write Channel Signals

-
AWBURST: Transfer data types, e.g, fixed, increment type, etc.
-
AWID: For OOO tags
-
AWLEN: Burst Length
-
AWLOCK: Controls whether a write operation is a locked operation(e.g, two masters access the same address space)(locked transaction只在AXI3里有;AXI4去掉了它,AxLOCK只剩1位,用来表示exclusive access)
-
AWUSER: Extended functionality (e.g, you want to customize Parity and data to pass through Bus together)
-
WSTRB: Indicates which bytes are valid in the write operation (No need to read - modify - and write back the entire data.【read modify write】)
3.6 Read Channel Signals

3.6.1 Data size, Length and Burst Type

-
AxLEN[7:0]:每次传输数据数量;(8 位)表示每次最多可以传输256 笔的数据 -
AxSIZE[2:0]: 数据宽度;并不是直接用“数值”去表示传输的字节数,而是用编码的方式来表示“每次传输的字节数”是 2 的几次幂。3 位可以组合成 8 种取值,所以每次可以传输8种不同大小的数据宽度,- e.g, AxSIZE = 3’b011(3),即定义数据宽度为2^3 = 8bytes / 64bits
Burst Type(AxBURST[1:0])
00FIXED:Writing data to a fixed address. The target device design includes control, status, and data registers, each with its own address. Data is stored in a FIFO before being transmitted.10WRAP:For a cache miss, you read the entire cache line from memory. The critical word is transferred first, not sequentially from the start of the cache line.(same as AHB/APB)11reserved
3.6.2 Protection Level Support

P stands for whether the OS is secure.
NS stands for Secure/Non-Secure memory region
3.6.3 Cache Support

-
Bufferable 表示响应数据是否可以通过中间缓存传递,而不是直接从目标从设备获取。
-
Cacheable 属性用于指示数据是否可以被缓存。传输的源 和 目的地之间的突发传输特性可以变化。
- E.g, Modifiable 可以将burst一次性传输16笔数据 改为传输两笔
-
cache miss
read allocate: cache controller Load the data from memory into the cache and then read it
write allocate: cache controller write the data to the cache first, then write it
3.6.4 Response Signaling

3.6.5 Write data Strobes
Indicates which bytes are valid in the write operation (No need to read - modify - and write back the entire data.)

4. Outstanding
为什么要 Outstanding? 维持数据流像流水线一般持续的”满载”状态,以此获得更高的整体带宽和更短的平均等待时间。
4.1 Outstanding、interleaving 与 OOO
-
outstanding:request可以不需要等待Slave端的Response即可发送下一笔;
-
OOO:Slave端的Response返回可不按照request发送的(ID)顺序返回
-
interleaving:在每一次发送的transaction中,比如burst_length=4,则可以将此笔transaction打断中间插入其他request transaction的数据
-
Case A —— Without Outstanding

Assume each transfer data is 10B.
-
Case B —— With Outstanding

-
Case C —— outstanding number = 3
When A, B, and C transmission are completed, the transactions for A, B, and C should be initiated. In this way, we can guarantee the number of outstanding transactions.

-
Case D —— outstanding number = 4
- In case C, we find a bubble with 3 transactions. What about adding that number? In case below, we can find 4 transactions with outstanding at the same moment.
- When in ordered situation, each latency will gradually increase, so we can’t add an unlimited number of transactions.
- Limit average latency formula:Limit (15+n*5)/n = 5s
- Limit BandWidth formula:Limit (10*n) / (15+n*5) = 2Bps
式中
15= prepare time(准备数据的固定耗时),n= transaction number,5= transfer data time,10= data size
We can here initially experienced the two major benefits of AXI!
4.2 How to decide outstanding number?
Take a SoC design for example:
Suppose:
1.Latency: 200ns
2.Suppose BUS@500MHz => T(Clock cycle) = 2ns
3.Suppose AXI command is burst 8 (ideal: need 8 cycles to transfer) <ideally: Assume VALID asserted,then READY response imm>
- Outstanding Number: Latency / Time required for each transfer
-
200 / (2ns*8) = 12.5(8~16)
- In practical applications, Outstanding Number usually takes integer values.
-
Outstanding Number is how many transactions are required to complete with a given delay.
-
Q: Is it better to have more outstanding numbers? >>>
- Areas!!!
- bad e.g :Master supports 16 outstanding, but slave only supports 8
| PROs | CONs |
|---|---|
| Improve BW. | May increase absolute latency.¹ |
| Reduce average latency. | Cost more area. |
¹ 哪个 transaction 的最后一个 data 最后发,它的绝对 latency 就会增加。
设计 Outstanding 时还要考虑 Master 和 Slave 的匹配度,以及 PPA(面积)问题。
5. Out of Order Transactions
OOO是为了处理在Master与不同速度Slave(memory)空间数据交互时,避免阻塞/Bubble的产生,从而提升传输带宽
总体要求:
- All transactions with a given ID must be ordered
- No restriction on the ordering of transactions with different IDs
What is out of order transactions?
- Data from transactions with different IDs can be transferred without following the order of transactions.
Why are out of order transactions needed?
- Transactions to faster memory regions can complete without waiting for earlier transactions to slower memory regions.
- Improve bus performance because it reduces the effect of transaction latency.
两层 OOO:
- 第一层建立在 Outstanding 基础上:顺序发送 transaction,但 Slave 端返回速度可能慢从而产生 bubble;OOO 对 Slave 返回顺序做调整,乱序填充 bubble,从而提升带宽、降低 latency。
- 第二层是 Transaction level 的 interleave(见 5.7)—— for Read op,AXI3/4 都有 interleave。
写乱序 vs 写交织:
- 写乱序靠 AWID 不同实现;写交织是同一拍多个 ID 的 data/beat 混在一起
- AXI3 支持 out-of-order + interleaving(Master 给 ID、Slave 回 BID)
- AXI4 支持 out-of-order,但不支持 interleaved write data(同一 ID 写数据必须连续);AXI4 读数据 interleaving 也仅限 read data channel
- 为什么 AXI4 去掉了交织:简化 slave 实现、降低数据通路 buffer 复杂度
5.1 Transfer IDs
(The 5 channels have different IDs: AWID,WID,BID,ARID,RID)
General Rules
- All transactions with a SAME ID must be ordered
- All transfers have an ID.
- All transfers in a transaction have the same ID.
- Masters can support multiple IDs
- Slaves generally need a configurable ID width.
- Third-party IP is often used, if the Master issues a 3-bit width ID, the Slave needs to match it when designing it.
5.2 Read ordering

-
Data for different transaction IDs has no ordering restrictions
-
Data with the same ID must follow in the order as issued
- C必须要在A之后issue
- B的ID不同,可实现ooo,(先发送了ID 0的req,但是先返回的却是ID 1的rsp)
-
Data for different transaction IDs may be interleaved
- B transaction的transfer可以被A transaction的transfer穿插

5.3 Write ordering (AXI3)

- Data for different transaction IDs may be interleaved (AXI3 only).
- Write interleave只有AXI3有,AXI4没有此定义
- The first item of Write Data must be issued in the same order as the Address. —— A0不可晚于B0发送(A0 B0 C0)
- Data with the same ID from a master must follow in the order as issued. —— A和C是same ID,则A的last需先于C的第一笔transfer W发送
5.4 Write ordering (AXI4)
- In AXI4, write data interleaving support is removed- so WID isn’t needed - write data 就必须是顺序的了
- Data from a master must follow in the same order as issued
- Transactions with different IDs can complete in any order

OOO:B可以乱序,该例未呈现
以上例子中,虽然arready和valid未同时有效,但是arid仍然变化了,这是因为master无需等待slave回馈ready信号即可发送下一笔id(outstanding)
5.5 Read/Write ordering
AXI协议本身没有读写顺序的要求,所以是通过Master来控制读写的先后顺序的
- Master must ensure correct order of READ / WRITE transfers.
- Read and Write channels have no ordering rules, they can complete in any order.
E.g. – Master requires W-R-W sequence completes in order
- Master must wait until BRESP received for first WRITE transaction…
- …before starting READ transaction
- …and must wait for RLAST transfer
- …before commencing second WRITE transaction
You can only read it after receiving Write Resp

You can only write next transaction after receiving previous transaction RLAST

So, we can get a conclusion that the ordering for Read/Write operations is controlled by MASTER itself
5.6 Outstanding without OOO
outstanding is the basis of OOO. If outstanding does not exist, there is no OOO.
- Suppose slave B is slower than others
- Slow slave will retard the bus

- Case: suppose we have OOO; R channel does not follow the order of transactions

5.7 OOO without interleave
- Example: suppose slave must insert an idle after 2 transfers(without interleave)

with interleave
- Transactions with different IDs can interleave
- Performance will be better

5.8 AXI Features
- Separated read/write channels
- Support for unaligned data transfers
- No strict timing relationship between the address and data phases
- Burst transactions based on start address issue only
- Multiple outstanding addresses
- Out of order transaction completion

6. 窄传输 & Unalignment
6.1 前提:拍 / AxSIZE / AxLEN
前情提要: 拍 = beat = 一个 transfer = 一次 VALID&READY 同时为高的时钟周期。三个词同一个东西,下面只说”拍”
一笔 transaction(一个地址 + 一串数据)在 W 通道长这样:
- 有几个方框 ← AWLEN 定。协议规定 拍数 = AWLEN + 1(0 拍没意义,所以编码省 1,AWLEN=3 → 4 拍)
- 每个方框装几字节 ← AWSIZE 定。AWSIZE 是编码不是字节数:字节数 = 2^AWSIZE
- 整笔数据量 = 拍数 × 每拍字节。图中 AWSIZE=2、AWLEN=3 → 4 拍 × 4B = 16B
AXI 没有任何信号描述整笔 transaction 的数据量,只能算:总字节 = (AxLEN+1) × 2^AxSIZE。
AXI3(AWLEN/ARLEN 为 4-bit): 突发长度(Burst Length)支持 1 到 16 次传输(寄存器配置值为 0-15)。
AXI4(AWLEN/ARLEN 为 8-bit): 突发长度支持 1 到 256 次传输(寄存器配置值为 0-255)。
补充细节:
- 仅限 INCR 模式:AXI4 扩展到 256 次传输仅适用于
INCR(递增)突发类型。对于WRAP(回环)突发,AXI4 的最大长度仍然限制在 16 次(主要用于 Cache 填充)。 - 设计初衷: AXI4 增加到 256 是为了优化长数据流或 DMA 传输。单次发地址可以连续传更多数据,减少了握手开销,大幅提升了总线利用率。
补一个精度问题:这个乘积是地址空间跨度,不等于实际有效字节数。非对齐时首拍会被 strobe 掉一部分 lane,实际写入 < 乘积。
硬件根本不做 2^N 这个”算”。指数就是移位量,直接当控制信号用:
wire [7:0] bytes_per_beat = 8'd1 << AxSIZE; // 移位,非乘法,零面积
wire aligned = (AxADDR & ((1 << AxSIZE) - 1)) == 0;
wire [31:0] next_addr = AxADDR + (1 << AxSIZE); // INCR 递增
wire [2:0] byte_offset = AxADDR[AxSIZE-1:0]; // 直接当位选下标
反过来若总线给的是字节数,硬件得先求 log2 才能做上面这些 —— log2 = priority encoder,比一根移位线贵得多。
所以”要算”只是人肉读波形时的负担,对 RTL 是免费。记住 3’b010=4B 这张表就行,不用每次现算。
6.2 窄传输(narrow transfer)
窄传输是地址通道声明的 transaction 形态,总线是死的,一拍用不满就叫窄传输。判据两边都要换算成字节再比:
narrow ⟺ 2^AxSIZE (字节/拍) < DATA_WIDTH/8 (总线字节数)
32bit总线 = 4 字节,所以 32bit 总线上 AxSIZE=2(4B/拍)是满宽,不是窄传输。
| 总线 DATA_WIDTH | 总线字节数 | 满宽时 AxSIZE | 窄传输的 AxSIZE |
|---|---|---|---|
| 32 bit | 4 B | 2 | 0 / 1 |
| 64 bit | 8 B | 3 | 0 / 1 / 2 |
| 128 bit | 16 B | 4 | 0 ~ 3 |
有效lane会换位置,不是永远贴在低字节。落点由该拍自己的地址决定:lane_start = 本拍地址 % 总线字节数
32bit总线(4条lane),AWADDR=0x00,AWSIZE=1(2B/拍),AWLEN=3,INCR:
| 拍 | 地址 | lane3 | lane2 | lane1 | lane0 | WSTRB |
|---|---|---|---|---|---|---|
| 0 | 0x00 | – | – | D0h | D0l | 4'b0011 |
| 1 | 0x02 | D1h | D1l | – | – | 4'b1100 |
| 2 | 0x04 | – | – | D2h | D2l | 4'b0011 |
| 3 | 0x06 | D3h | D3l | – | – | 4'b1100 |
所以slave侧不能无脑取WDATA[15:0],必须按WSTRB/地址低位选lane。
读通道没有 strobe。没有 RSTRB 这根信号,但读一样能窄传输 —— slave 按 ARSIZE + 该拍地址把数据摆到正确 lane,master 自己知道去哪几条 lane 取。
AxSIZE声明形态(读写通用),WSTRB只是写侧的执行细节,能表达的范围更宽:
AWSIZE=2(满宽)+WSTRB=4'b1010→ 稀疏字节写,不是窄传输(窄传输有效字节必须连续且对齐)AWSIZE=2(满宽)+WSTRB=4'b0011→ 只是屏蔽高2字节,不是窄传输- 读通道无strobe,照样能窄传输
6.3 非对齐传输(unaligned transfer)
An unaligned transfer means that the address of the AxADDR does not need to be aligned with the transfer size 2^AxSIZE.
6.3.1 判据
对齐 = 起点正好踩在某条竖线上;非对齐 = 掉进格子肚子里。 AxSIZE=3’b011 (每格8B) → 看低3位(log2(8)=3):
0x10 = 0001_0000 低3位 000 → 踩线, 对齐
0x14 = 0001_0100 低3位 100 → 偏 4, 非对齐
0x18 = 0001_1000 低3位 000 → 踩线, 对齐
所以 aligned = (AxADDR[AxSIZE-1:0] == 0) —— 低 log2(每拍字节) 位全 0 就对齐
6.3.2 首拍机制
非对齐只影响首拍,第2拍起地址自动回到网格:
拍1 地址 = AxADDR (歪的)
拍N 地址 = align_down(AxADDR) + (N-1)×2^AxSIZE (踩线)
上面”从0x01开始、4 words + 3 bytes”就是这个例子。32bit总线,AxSIZE=2(4B),AxADDR=0x01,AxLEN=4:(4B = 总线4B,满宽,这里故意不掺窄传输,好把非对齐单独看清)
| 拍 | 地址 | lane3 | lane2 | lane1 | lane0 | WSTRB | 有效 |
|---|---|---|---|---|---|---|---|
| 0 | 0x01 | B3 | B2 | B1 | ✗ | 4'b1110 | 3B |
| 1 | 0x04 | B7 | B6 | B5 | B4 | 4'b1111 | 4B |
| 2 | 0x08 | .. | .. | .. | .. | 4'b1111 | 4B |
| 3 | 0x0C | .. | .. | .. | .. | 4'b1111 | 4B |
| 4 | 0x10 | .. | .. | .. | .. | 4'b1111 | 4B |
地址跨度按对齐边界0x00算是 5×4 = 20B,实际有效19B(= 4 words + 3 bytes),差的1B就是 offset = AxADDR % 4 = 1。
从0开始写,只是0会被AXI内部strobe为无效,写入仍然是32bit,只是区分了有效/无效bit
此处AxADDR若对齐的话应该是0x00(4byte最低2位为0)

此处AxADDR若对齐的话应该是0x00(2byte最低1位为0)

We can see that because AxADDR and AxSIZE are unaligned, the first transfer operation only transferred partial data.
剩下那部分去哪了?
哪也没去,压根没传。写侧被WSTRB屏蔽掉;读侧没有strobe,slave不在那条lane上摆有效数据,master直接丢弃。
6.4 窄 + 非对齐叠加
两个效应正交,可同时出现:窄管”一拍占几条lane”,非对齐只砍首拍的头。
32bit总线,AxSIZE=1(2B/拍 → 窄),AxADDR=0x03(3 % 2 = 1 → 非对齐),AxLEN=3:
| 拍 | 地址 | lane3 | lane2 | lane1 | lane0 | WSTRB | 有效 |
|---|---|---|---|---|---|---|---|
| 0 | 0x03 | B0 | ✗ | – | – | 4'b1000 | 1B |
| 1 | 0x04 | – | – | B2 | B1 | 4'b0011 | 2B |
| 2 | 0x06 | B4 | B3 | – | – | 4'b1100 | 2B |
| 3 | 0x08 | – | – | B6 | B5 | 4'b0011 | 2B |
align_down(0x03) = 0x02,跨度 4×2 = 8B,减 offset 1 → 有效7B。跟6.3.2同一套算法,只是格子从4B变2B。
6.5 一句话对比
| 窄传输 | 非对齐传输 | |
|---|---|---|
| 判据 | 2^AxSIZE < 总线字节数 | AxADDR % 2^AxSIZE ≠ 0 |
| 由谁声明 | AxSIZE | AxADDR |
| 影响范围 | 每一拍 | 只有首拍,之后回网格 |
| 动机 | 窄外设挂宽总线不浪费(8bit UART 挂 64bit AXI) | memcpy任意起点、结构体非对齐字段,软件不用先补齐 |
| AHB能否做到 | 否 | 否,AHB强制对齐(见 §1.2) |
7. Endianness
Endianness(字节序)指数据在存储器中按字节分布的顺序。
AXI协议支持在同一内存空间内访问不同字节序的数据结构,方便多种处理器或外设在统一总线上协同工作。
该方案采用Byte Invariance Endianness Scheme(BE-8),即保持字节地址不变,只是同一字中各字节的顺序会随端的大小端设置而变化。
7.1 Byte Invariance(BE-8)含义
- “字节不变”意味着无论大小端如何,某个固定地址对应的都是同一个字节。
- Little Endian下,低地址对应低字节;高地址对应高字节
- Big Endian下,高对低,低对高
这样做能保证硬件地址管理简单明了,软件在解释数据时只需要根据端模式调整对字节的理解顺序即可。
7.2 AXI 端口信号示例(图示解读)
- 图中以32位数据为例,分别示意Little Endian和Big Endian对同一字(Word)的存储方式:
- Little Endian:字节顺序从 7:0 → 31:24,最低地址保存最低有效字节。
- Big Endian:字节顺序从 31:24 → 7:0,最低地址保存最高有效字节。
- 由于采用了BE-8方案,地址总线并不会因为大小端模式而调整映射关系,改变的仅是数据字节在同一字中的排列顺序。

8. Atomic Access
在软件系统中会存在竞争冒险的情况,同一memory地址空间的数据访问和修改需具有独一性
Atomic Access指的是一种保证数据操作在执行过程中不会被其他操作中断的机制。换句话说,当一个操作被设计为原子操作时,它要么全部完成,要么完全不执行,中间状态对其他访问者来说是不可见的。
AxLOCK indicates when Atomic Accesses are being performed.


8.1 Exclusive Access


9. AXI4-Lite

- 没有ID了,不支持OOO
访问不可修改(Non-modifiable)、不可缓存(Non-bufferable)
-
在AXI4协议中,访问类型常由
AWCACHE、ARCACHE、AWPROT、ARPROT等信号指定。这里设置为“Non-modifiable”、“Non-bufferable”意味着:-
不允许总线在传输过程中对事务进行重排序或合并等操作。
-
不允许对数据进行缓存,写操作应当直接落到目标寄存器,读操作也直接从目标寄存器获取数据。
-
-
对于简单Slave设备来说,这些高级特性并不需要,反而可能增加实现复杂度。
11. AXI 协议理解
-
interleave 是 beats 的交叉
-
outstanding 是 transactions 的并发
Outstanding = 同时存在的 transactions 数量(按 ID)
Out-of-order = 不同 ID 的 transactions 可以乱序完成
Interleave = 不同 ID 的 transfer 可以交叉在同一个 channel 上传输
参考
- Arm, AMBA AXI Protocol Specification(IHI 0022)
- Arm, AMBA AHB Protocol Specification(IHI 0033)
Discussion
Loading comments…
Checking sign-in…