Skip to content
STIMSMITH

Cache Coherence Verification

Concept WIKI v2 · 6/6/2026

Cache coherence verification is the discipline of validating that a processor design correctly maintains consistency across its cache hierarchy and memory subsystem, ensuring all memory accesses observe a coherent view of shared data. It is exercised both as a first-class class of verification events in hardware-accelerated co-simulation frameworks (e.g., DiffTest-H covering 32 event types on XiangShan) and as the dedicated target of unit-level cache verification frameworks (e.g., TL-Test, which checks TileLink protocol behavior and coherence directly on the cache design).

Cache Coherence Verification

Overview

Cache coherence verification is the discipline of checking that a processor implementation correctly enforces its cache coherence protocol, so that loads, stores, refills, and invalidations across the cache hierarchy produce an architecturally consistent view of memory. It is pursued at two complementary levels in the XiangShan ecosystem: (1) as a verification event class within a full-processor hardware-accelerated co-simulation (DiffTest-H), and (2) as a dedicated target of a unit-level cache verification framework (TL-Test) that exercises the cache subsystem in isolation.

Cache Coherence as a Verification Event in Co-Simulation

In the DiffTest-H framework, verification events are organized into six representative categories spanning the architectural surface of an out-of-order RISC-V processor:

Category Count Representative Examples
Control Flow 5 Exceptions and interrupts, instruction commits, traps, ...
Register Updates 9 CSRs, general-purpose registers, floating-point registers, ...
Memory Access 3 Load/store operations, atomic memory operations, ...
Memory Hierarchy 6 Cache refill operations, L1/L2 TLB operations, ... (including cache coherence events)
RISC-V Extensions 9 Vector/Hypervisor CSRs, vector registers, ...

Cache coherence events fall under the Memory Hierarchy category, one of the six representative event types. Across the full DiffTest-H framework, 32 distinct verification event types are covered, including instructions, cache coherence, TLB, vectorization, and virtualization.

Role in Co-Simulation Verification

During co-simulation:

  1. The DUT emits verification events — including cache coherence events such as refill transactions and protocol messages — to the REF.
  2. Deterministic events (DEs) such as ordinary instruction commits are stepped and compared by the REF independently.
  3. Non-deterministic events (NDEs) such as external interrupts and MMIO accesses are synchronized from the DUT to the REF at precise instructions and then compared.
  4. On any mismatch between the DUT's emitted state (including cache coherence state) and the REF's expected state, the co-simulation is aborted.

The hardware–software communication that carries cache coherence events, like all verification events, is a point-to-point interaction that can be modeled by the LogGP model and dominates the co-simulation time when not optimized — over 98% of co-simulation time is consumed by communication overhead in unoptimized setups.

Three Semantic Properties Used in Optimization

Verification events, including cache coherence events, carry three key semantic properties that frameworks exploit to optimize communication while preserving debuggability:

  1. Structural Semantics — the length and data structure of each event. Cache coherence events have variable-length payloads, so tight packing (allocating space according to length) eliminates bubble padding that fixed-width schemes incur.
  2. Order Semantics — the specific checking order of events. Decoupling communication from checking order via order tags allows cache coherence events to be fused and reordered at the software side, even when interleaved with NDEs such as external interrupts.
  3. Behavioral Semantics — the architectural behavior checked, which localizes errors to specific microarchitectural components (e.g., a particular coherence state, directory, or snoop port).

Significance in Bug Detection

In DiffTest-H's evaluation on XiangShan — a 6-wide out-of-order RISC-V processor — the framework achieves simulation speeds of 478 KHz on the Cadence Palladium emulator and 7.8 MHz on the Xilinx VU19P FPGA, representing 80× and 78× speedups over the baseline DiffTest, 273× and 1945× faster than 16-thread Verilator, and 7.8× faster than the prior state-of-the-art on the FPGA. DiffTest-H reduces communication overhead by 99.84% on the emulator.

Over 151 complex bugs in XiangShan were uncovered that required up to 2 months to identify with Verilator-based simulation but were detected within 11 hours by DiffTest-H on Palladium. All of these bugs have been confirmed and fixed by XiangShan developers, totaling more than 780 lines of code change across 19 pull requests. Cache coherence bugs are a notable class within these, given that the memory-hierarchy event category (which subsumes coherence events) is one of the six representative categories the framework explicitly models.

Unit-Level Cache Verification with TL-Test

While DiffTest-H verifies cache coherence in the context of full-processor co-simulation, the XiangShan project also provides a dedicated unit-level framework for exercising cache coherence directly on the cache design.

TL-Test is a Unit Level Verification Framework for the cache system. As an infrastructure for cache verification, it:

  • Supports the TileLink protocol and cache coherence check.
  • Can generate testcases or run constrained-random tests quickly to exercise the cache.
  • Supports converting real cache access traces into a testbench via its tl-trace mode, so that a trace dumped from the whole XS-Core can be replayed against the cache system alone as a trace-driven model.
  • Uses tl-trace mode for fast reproduction of functional bugs and analysis of performance problems.

A typical TL-Test workflow (as documented in the XiangShan ASPLOS '25 tutorial):

  1. Run the pre-compiled TL-Test, which generates a constrained-random testcase and flags mismatches. For example, an injected bug in the GrantBuffer of the CoupledL2 (wrongly shifting the Grant Data on the L2→L1 path, d.data := data << 8 instead of d.data := data) is detected at address 0x4000.
  2. Analyze the failure by querying the TL-Log / chiselDB for all transactions on the effective address. The TL-Log pinpoints the wrong transaction and the precise cycle number, enabling quick root-cause analysis.

This complements DiffTest-H: TL-Test isolates cache coherence failures at the unit level with reproducible trace-driven or constrained-random stimuli, while DiffTest-H catches coherence violations that only manifest in full-processor execution.

Related Frameworks

  • DiffTest-H — A semantic-aware, hardware-accelerated co-simulation framework that uses cache coherence verification (and 31 other event types) to validate the XiangShan RISC-V processor. It introduces three optimizations: Batch (packing), Squash (fusion with decoupled checking order), and Replay (preserving instruction-level debuggability).
  • TL-Test — A unit-level TileLink/cache coherence verification framework that performs constrained-random and trace-driven (tl-trace) testing of the cache subsystem in isolation, and produces TL-Log traces for debugging.

LINKED ENTITIES

1 links

CITATIONS

9 sources
9 citations
[1] DiffTest-H covers 32 types of verification events, including instructions, cache coherence, TLB, vectorization, and virtualization. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[2] Verification events are organized into six representative categories (Control Flow, Register Updates, Memory Access, Memory Hierarchy, RISC-V Extensions, …) with the Memory Hierarchy category containing six representative event types such as cache refill operations and L1/L2 TLB operations. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[3] The three semantic properties (Structural Semantics, Order Semantics, Behavioral Semantics) of verification events can be exploited to optimize communication while preserving debuggability. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[4] Hardware–software communication is a point-to-point interaction that can be modeled by the LogGP model, and over 98% of co-simulation time is consumed by communication overhead in unoptimized setups. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[5] DiffTest-H achieves 478 KHz on Palladium and 7.8 MHz on FPGA, 80× and 78× over baseline DiffTest, 273× and 1945× over 16-thread Verilator, and reduces communication overhead by 99.84% on the emulator. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[6] DiffTest-H uncovered over 151 complex bugs in XiangShan that required up to 2 months to identify with Verilator but were detected within 11 hours on Palladium; all bugs were fixed across 19 pull requests with more than 780 lines of code change. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)
[7] TL-Test is a Unit Level Verification Framework for the cache system that supports the TileLink protocol and cache coherence check, can generate testcases or constrained-random tests quickly, and supports converting real cache access traces into a testbench via tl-trace mode for fast reproduction of functional bugs and analysis of performance problems. XiangShan ASPLOS '25 Tutorial — Function Verification (TL-Test section)
[8] An injected cache coherence bug that incorrectly shifts the Grant Data on the L2→L1 path (d.data := data << 8 instead of d.data := data) is detected by TL-Test at address 0x4000, and is analyzed via TL-Log / chiselDB queries over the effective address to identify the wrong transaction and cycle number. XiangShan ASPLOS '25 Tutorial — Function Verification (TL-Test section)
[9] In the DiffTest-H co-simulation workflow, deterministic events (DEs) such as ordinary instruction commits are stepped and compared by the REF independently, while non-deterministic events (NDEs) such as external interrupts and MMIO accesses are synchronized from the DUT to the REF at precise instructions; any mismatch aborts co-simulation. DiffTest-H: Toward Semantic-Aware Communication in Hardware-Accelerated Processor Verification (MICRO '25)

VERSION HISTORY

v2 · 6/6/2026 · minimax/minimax-m3 (current)
v1 · 6/6/2026 · minimax/minimax-m3