Atomic Operations Testing
Overview
Atomic Operations Testing is a class of functional verification that exercises the atomic memory operations (AMOs) of a processor — such as compare-and-swap, atomic add, atomic load/store — across one or more cores. The defining verification goal, as described in Breker's RISC-V Core & SoC Verification presentation, is to check that the result is the aggregate of synchronized atomic operations performed by the cores under test. This ensures that atomic semantics — indivisibility, ordering, and visibility — are preserved when multiple agents operate on shared memory.
Why It Matters
Atomic operations are foundational for synchronization primitives (locks, semaphores, lock-free data structures) and for inter-processor coordination in multi-core systems. Bugs in their implementation can lead to lost updates, torn reads/writes, deadlocks, and coherency violations. Coverage analysis of RISC-V cores has shown that atomics, loads, and stores are not reachable in a register-only test, meaning atomic behavior can only be exercised with tests that touch shared memory across cores.
Test Composition
In a typical multi-core atomic-operations test, multiple cores simultaneously issue atomic operations to shared memory locations. The testbench then reads back the aggregated memory state and compares it to a software-computed expectation derived from the sequence of atomic operations issued. Discrepancies indicate lost updates, reordering, or incorrect atomic semantics.
Atomic Operations Testing is typically deployed as part of a broader coherency test suite that also exercises:
- Dekker Memory Ordering — verifying mutual-exclusion and ordering of loads/stores between two cores without hardware barriers.
- False-Share Memory Stress Tests — driving contention on cache lines shared between cores using free-running write/check loops (e.g., patterns written via
trek_writeand validated viatrek_reads). - MOESI State Transitions — verifying that cache lines traverse the expected Modified/Owned/Exclusive/Shared/Invalid states across multi-core workloads.
Bug Classes Detected
Atomic Operations Testing has been shown to surface real design defects, including:
- Common cache line access deadlocks under multi-core contention.
- Custom-instruction bugs discovered by stress tests.
- RISC-V specification misunderstandings between core vendor and integrator.
- Coherent Mesh Network (CMN) programming issues and misconfigured ARM CMN pins.
- Result mismatches with ultrawide address strides.
Implementation
Atomic Operations Testing for RISC-V multi-core designs is implemented by the Cache Coherency TrekApp 2.0, part of the Breker SystemVIP library. The TrekApp automates synthesis of coherency and atomic-operation test scenarios across cores, including coverage of MOESI state transitions and aggregate-result checking.
Verification Stack Context
Atomic Operations Testing sits at the multi-core coherency layer of the RISC-V verification stack, above single-core Core-Integrity tests (instruction generation, load/store, exception, MMU) and below full SoC-Integrity use cases (end-to-end, firmware, performance/power profiling). Its automated approach is presented as an alternative to directed coherency coverage, which typically leaves large portions of the coherency state space unexercised.