Overview
Cache Memory Modeling is the activity of formally describing the structure and behavioral characteristics of processor caches so that they can be reasoned about and exercised by automated test-generation tools. In the context of microprocessor verification, the model must capture both the static configuration of cache buffers and the dynamic conditions under which cache events (hits, misses, evictions) occur, including dependencies on prior instructions.
Buffer Configuration Attributes
A cache memory is modeled as a buffer that stores lines of data addressed by main-memory addresses. The following attributes are used to specify buffer configuration:
- Set size (associativity) — the number of ways in each set.
- Number of sets — the total number of sets in the cache.
- Line field description — the structure of a cache line.
- Address-to-index translation rule — how an address maps to a set.
- Rule for checking if a line and an address match — the tag-comparison policy.
- Data displacement policy — the replacement algorithm used when a miss occurs.
These attributes are expressed declaratively using Configuration Facilities (CFs) in tools that target ADL-based design descriptions.
Hit and Miss Modeling as Constraint Satisfaction Problems
For functional verification, the two primary situations of interest are cache hits and cache misses. Both situations can be formulated as Constraint Satisfaction Problems (CSPs) over the address being used to access data and the current state of the buffer. Because architectural specifications typically describe classes of valid parameter values rather than concrete values, expressing these situations as CSPs allows the same model to generate varied test data on each invocation.
Instruction Dependencies
A cache event does not occur in isolation. Instructions modify the state of the microprocessor and therefore affect the behavior of subsequent instructions. For example, a precondition for a cache hit event is that the corresponding data has been loaded into the cache, which requires a previous instruction that accesses the same data line. To produce a complex instruction sequence with predictable results, the sequence must be simulated so that the final parameter values of dependent instructions can be determined. Knowledge about possible dependencies between instructions is part of the Test Knowledge (TK) extracted from Configuration Facilities.
Tool Support: MicroTESK
The MicroTESK test program generator uses the nML/Sim-nML Architecture Description Language to describe target microprocessor designs, including their cache structures. MicroTESK extracts Test Knowledge from ADL specifications and uses it as the basis for creating test scenarios. Test situations that involve caches — such as specifying that an instruction access should produce a hit event in a particular cache level — are expressed in the Test Template Description Language (TTDL).
A TTDL example for cache modeling specifies that for a load instruction the line should cause a cache hit event, naming a set of target caches and the probability of the hit event:
hit([L1(), L2()], [25, 50, 75]);
This statement instructs MicroTESK to generate a list of possible combinations and add an instruction for each one to the resulting test program.
CSP Solver Engine
MicroTESK formulates CSPs using the SMT-LIB language and delegates solving to an external solver. The current implementation uses the Z3 SMT solver from Microsoft Research, with bit-vector support that is well suited to describing data buffers used in different parts of microprocessor models (registers, cache, main memory, etc.). The Test Program generator interacts with the solver through a solver-independent CSP solver API, allowing different solvers to be substituted.
SMT-Based Test Program Generation
The SMT-Based Test Program Generation for Cache-Memory Testing approach, introduced by E. Kornykhin at the East-West Design & Test Symposium (EWDTS) in 2009, frames cache-memory test generation as an SMT problem. This work is part of a broader line of research on generating test data for verification of caching mechanisms and address translation in microprocessors.
Related ADL and Tool References
- nML / Sim-nML — the ADL formalism used by MicroTESK to describe target microprocessor designs, using a format similar to that found in microprocessor manuals.
- Mishra, Shrivastava and Dutt (2006) — Architecture Description Language (ADL)-Driven Software Toolkit Generation for Architectural Exploration of Programmable SOCs.
- Kamkin, Kornykhin and Vorobyev (2011) — Reconfigurable Model-Based Test Program Generator for Microprocessors.