Mastering AMBA CHI: Part 2—The Coherency Protocol
Maintaining cache coherence across a vast silicon expanse requires a precise state machine and a highly optimized orchestrator. In the previous installment, we established the physical and logical foundations of AMBA CHI. Now, we examine the coherency protocol that dictates how Request Nodes (RN-Fs) and Home Nodes (HN-Fs) manage shared memory.
AMBA CHI utilizes a directory-based coherence mechanism, which fundamentally diverges from the broadcast-snooping approach of ACE. This transition is essential for ensuring that bandwidth scales linearly with node count rather than degrading exponentially due to snoop traffic.
The CHI Cache State Model
The coherency protocol in CHI is built upon a modified MOESI model. It defines the exact state of a cache line (typically 64 bytes) within any given RN-F. The CHI specification formalizes these states around three orthogonal characteristics:
- Validity: Is the data present and usable?
- Uniqueness: Is this RN-F the sole owner of the cache line in the system, or might copies exist in other RN-Fs?
- Cleanliness: Has the data been modified relative to the downstream memory (or the Home Node)?
Based on these characteristics, the primary states include:
| State | Unique? | Clean? | Implications |
|---|---|---|---|
| Invalid (I) | - | - | Data is not present. |
| Unique Clean (UC) | Yes | Yes | RN-F has the only cached copy; it matches main memory. Can transition to UD locally. |
| Unique Dirty (UD) | Yes | No | RN-F has the only cached copy; it differs from main memory. Must write back on eviction. |
| Shared Clean (SC) | No | Yes | RN-F has a shared copy. Other RN-Fs may hold it. It matches memory. |
| Shared Dirty (SD) | No | No | RN-F has a shared copy but is responsible for writing it back to memory upon eviction. Other RN-Fs may have SC copies. |
CHI introduces subtle variations and transient states depending on the specific implementation (e.g., partial cache line states), but this core MOESI matrix dictates the fundamental rules of engagement for all read and write transactions.
The Directory-Based Approach
The defining feature of CHI coherency is the role of the Fully Coherent Home Node (HN-F). Instead of RN-Fs shouting across a crossbar to see who has a cache line, every request is sent directly to the HN-F assigned to that physical address range.
The HN-F maintains a Directory or Snoop Filter (SF). This structure tracks the state and location of cached data across all RN-Fs.
Precise vs. Coarse-Grained Directories
- Precise Snoop Filter: Tracks exact cache lines and the specific RN-Fs holding them. When a request arrives, the HN-F only sends snoops to the RN-Fs actively holding the line. This minimizes network traffic but requires significant SRAM at the Home Node.
- Coarse-Grained Directory: Tracks regions of memory or utilizes probabilistic structures (like Bloom filters). It requires less storage but may generate superfluous snoops (false positives) to RN-Fs that do not actually hold the line.
Snoop Generation and Orchestration
When an RN-F requires data or wishes to modify a shared line, it dispatches a Request (REQ) to the HN-F. The HN-F consults its Snoop Filter to determine the next action.
- Miss in SF: The HN-F knows no other RN-F holds the data. It skips snooping and directly requests the data from the Slave Node (SN-F).
- Hit in SF: The HN-F identifies one or more RN-Fs holding the line. It dispatches Snoop (SNP) flits to those specific RN-Fs.
- If the request is a
ReadShared, the snoop asks the peer RN-F to return a copy of the data (and potentially downgrade its state to SC). - If the request is a
ReadUnique(intent to write) or aMakeUnique(upgrade request), the snoop instructs the peer RN-F to invalidate its copy and return the dirty data if applicable.
- If the request is a
PoC and PoS: establishing Memory Ordering
To maintain consistency in a distributed system, CHI defines two critical synchronization points.
Point of Coherence (PoC)
The PoC is the point in the system where all observers (coherent and non-coherent) are guaranteed to see the same copy of a memory location. In a typical CHI SoC, the PoC for a given address is the Home Node (HN-F). When a transaction reaches the HN-F and the HN-F resolves any required snoops, the transaction has reached coherency.
Point of Serialization (PoS)
The PoS dictates the global ordering of transactions to the exact same address. Because CHI is a packetized network, requests from different RN-Fs to the same address might arrive out of order. The HN-F acts as the PoS.
When a transaction arrives at the HN-F, it enters a tracker. If a subsequent request for the same address arrives, the HN-F forces the second request to wait until the first is completely resolved. This strict serialization prevents race conditions, ensuring that if CPU 0 writes to address , and CPU 1 subsequently reads address , CPU 1 will strictly observe CPU 0’s modification.
In Part 3, we will trace the exact lifecycle of these transactions, examining the multi-phase protocol flows that move data from the SN-F to the RN-F.