声明:
- 🔥文章目的在于学习记录,知识分享。因个人能力有限:++如有错误之处,请帮忙指出;如有疑问,欢迎随时交流++。
- 🔥感谢"++点评赞++",期待大家提出问题进行深度讨论。
内容如涉及侵权,请及时联系我删除。
Caches
Caching in AXI
Cache指的是任何一种存储结构,可以是Buffer/cache等任何存储元素,数据可以缓存在一个系统的多个节点上。如下图是一个拓扑实例,shareable的缓存对于所有一致性代理可见;Non-shareable缓存进队单一代理可见。
Fully coherent代理需要硬件维护一致性,一般使用CHI实现。
I/O一致性代理可以跟Fully coherent代理共享数据,但是当数据缓存在本地时,则必须手动维护一致性(软件)。
Non-coherent代理必须手动维护缓存在本地的数据(且,这些数据跟其它代理共享)一致性。

I/O coherency
I/O一致性代理可以通过一致性总线读写共享区域数据,但是无法实现snoop功能。因为,AXI协议本身不支持该特性。所以,一致性总线需要基于CHI协议,I/O一致性代理通过AXI接口互联。
当I/O作为请求者发起shareable读请求时,一致性总线会尝试去snoop合适的缓存而且检查对应cache line的属性。如果miss,则将该请求送往下游。当数据返回时,不允许I/O缓存该数据。
当I/O作为请求者发起shareable写请求时,一致性互联网络会发起清除和无效的请求,避免该数据被在本地复制(因为已经有新数据进来,已缓存的相关旧数据都要被无效掉)。然后根据具体设计要求,将新数据写到cache或者直接写回到mem里边(write through or write back)。对于部分写请求,对应的脏数据需要被处理掉。即,将原始数据拿过来,将新的部分数据合并后写回。
Caching Shareable Lines
挂在一致性网络下游的AXI master,允许其将Shareable行缓存到Non-shareable行。这么做的优点是:
- 剔除干净的shareable行不需要写回到mem。
- Shareable行的脏数据能直接同步到上游的shareable缓存。
因此,需要额外的Opcode和响应机制。cache必须跟踪对应的被缓存在non-shareable域的shareable lines。

Opcodes to support reading and writing full cache lines
支持下边六种Opcodes
ReadClean
A full cache line read from a Shareable location, where the data is likely to be allocated in an upstream cache. The read data must be Clean.
读清操作
ReadShared
A full cache line read from a Shareable location, where the data is likely to be allocated in an upstream cache. The read data can be Clean or Dirty. If the data is Dirty, the line must be allocated upstream, and the response for all transfers of read data must be OKAYDIRTY instead of OKAY.
读清操作,当对应的cache line脏时需要上游分配,且对应请求的响应要回复okaydirty。
WriteNoSnoopFull
A Non-shareable write of a full cache line where the data is Dirty and not allocated upstream.
An upstream cache can issue a WriteNoSnoopFull transaction when it evicts a Non-shareable Dirty cache line or when streaming write data which is cache line sized. If a downstream cache receives a WriteNoSnoopFull request,it can allocate the line knowing that the line is not allocated upstream.
WriteUniqueFull
A Shareable write of a full cache line where the data is Dirty but was not allocated upstream. This transaction is used by an I/O coherent Manager to write to a cache line that might be stored in a cache within the coherent domain. A system cache can allocate the line as Shareable Dirty.
WriteBackFull
A WriteBackFull transaction can be used when a Shareable Dirty line is evicted from a coherent cache. This transaction enables a system cache to allocate the line as Shareable Dirty.
WriteEvictFull
A WriteEvictFull transaction can be used when a Shareable Clean line is evicted from a coherent cache. This transaction enables a system cache to allocate the line as Shareable Clean.
A Shareable Clean line must not be exposed to any agents outside of the Shareable Domain because the line might become stale within caches in the Shareable Domain. For the same reason, data from a WriteEvictFull must not update memory.
Prefetch transaction
预取请求主要是当master针对有可能在未来使用的数据进行提前获取的操作,减少系统延迟的一种方式。这个操作允许在发起真实读请求之前将数据放在下游的缓存或者片外mem中。预取的主要目的在于通过预测master在未来可能使用的某些数据,并将其提前准备好,以此来减少miss rate,优化系统延迟来提升整体性能。
预取管理员可以通过预取动作命中的反馈来判断是否有必要继续执行相关请求(可以判断成功率)。针对预取请求并没有序的要求,因此无需考虑相关管理。
Rules for the prefetch transaction
协议规定预取使用的是AW通道而不是AR通道(data-less),这个原因是出于AR需要rresp,会产生额外动作。需要注意的是:预取请求的ID必须是唯一的。其它并无特殊要求,协议具体要求如下:
A Prefetch is a data-less transaction, the rules are:
• The Prefetch transaction consists of a request on the AW channel and a single response transfer on the B channel, there is no data transfer.
• A Prefetch request is signaled using the AWSNOOP Opcode of 0b01111.
• A Prefetch request must be cache line sized with the following constraints:
-- The transaction is Regular, see A4.1.8 Regular transactions.
-- AWCACHE[1] is asserted, that is a Normal transaction.
-- AWDOMAIN is Non-shareable or Shareable.
-- AWLOCK is deasserted, not exclusive access.
• The ID value must be unique-in-flight, which means:
-- A Prefetch request can only be issued if there are no outstanding write transactions using the same AWID.
-- The Manager must not issue a request on the write channel with the same AWID as an outstanding Prefetch request.
-- If present on the interface, AWIDUNQ must be asserted for Prefetch transactions.
• The Manager may or may not follow a Prefetch request with a non-Prefetch request to the same address.
• A Subordinate interface at any level can chose to propagate or respond to a Prefetch request.
• It is permitted to respond to a Prefetch request with OKAY, DECERR, SLVERR, or TRANSFAULT. An OKAY response can be sent irrespective of whether the Subordinate acts on the Prefetch request.
Response for prefetched data
针对响应需要注意的是:
- prefetched响应不能用于exclusive。
- 推荐用于全数据或者无数据转换。
- 另外,支持该响应送给并未发出prefetch req的master。
The PREFETCHED response has the following rules and recommendations:
• The PREFETCHED response is signaled using RRESP encoding of 0b100.
• When Prefetch_Transaction is True, RRESP_WIDTH must be 3 to enable the signaling of the PREFETCHED response.
• PREFETCHED indicates that read data is valid and has come from a prefetched source.
• PREFETCHED can be used for a response to the following transaction types:
-- ReadNoSnoop
-- ReadOnce
-- ReadClean
-- ReadShared
-- ReadOnceCleanInvalid
-- ReadOnceMakeInvalid
• A PREFETCHED response cannot be sent for an exclusive read.
• It is recommended that within a cache line, the PREFETCHED response is used for all data transfers or no data transfers. If a transaction spans cache lines, there can be a mixture of PREFETCHED and other responses for each cache line accessed.
• A PREFETCHED response can only be sent if the Prefetch_Transaction property is True for the interface.
• A PREFETCHED response can be sent to a Manager even if the Manager has not sent a Prefetch request to that location. For example, if a Manager happens to read data which was prefetched by another Manager.
Cache Stashing
Cache stash技术就是允许将数据放在离用它的组件最近的地方,来提升系统整体的性能。协议支持的Opcodes如下四种:
WriteUniquePtlStash
Write to a Shareable location with an indication that the data should be allocated into a cache. Any number of bytes within the cache line can be written, including all bytes or zero bytes.
WriteUniqueFullStashWrite a full cache line of data to a Shareable location with an indication that the data should be allocated into a cache. The transaction must be cache line sized and Regular. All write strobes must be asserted.
StashOnceSharedA data-less transaction which indicates that a cache line should be fetched into a particular cache. Other copies of the line are not required to be invalidated.
StashOnceUniqueA data-less transaction which indicates that a cache line should be fetched into a particular cache. It is recommended that all other copies are invalidated.
A StashOnceUnique transaction can cause the invalidation of a cached copy of a cache line and care must be taken to ensure that such transactions do not interfere with exclusive access sequences.
For an interface that supports the Untranslated Transactions feature, an extra stash transaction is supported. The StashTranslation transaction is used to indicate to a System Memory Management Unit (SMMU) that a translation should be obtained for the address that is supplied with the StashTranslation transaction.
Stash请求是以写请求实现,不允许其跨cache line边界,协议规定的限制如下表所示:

Stash request Domain
存储请求域决定了针对chache line的检查以及如何获取和存储。
如果访问的是Shareable位置,那意味着对应的cache line可以被存储在peer/inline cache(peer可以认为是LLC,inline理解为L1/2)。如果发起了目标为downstream的stash请求,尽可能是shareable。要求stash write必须是shareable location。
如果访问的是Non-shareable位置,那意味着对应的cache line可以被存储在inline cache。如果发起了目标为downstream的stash请求,则必须为Non-shareable。
Stash target identifiers
为了便于管理,支持提供两种ID进行识别和针对性维护。
- Node ID,也就具体的物理ID
- Logical Processor ID,这个就是对应的给每个func单元的ID,这个跟NID是有相互关系的。
具体的信号如下图所示:

协议针对信号实现要求如下,在具体实现中需要特别注意:
• For stash transactions, any combination of target enables is permitted.
• For non-stash transactions, AWSTASHLPIDEN and AWSTASHNIDEN must be LOW.
• When AWSTASHNIDEN is LOW, AWSTASHNID is invalid and must be zero.
• When AWSTASHLPIDEN is LOW, AWSTASHLPID is invalid and must be zero.
本文完,感谢大家阅读!
内容如涉及侵权,请及时联系我删除。