The Approximation abstraction describes an approximate state of the simulated CPU, and what is the expected behavior of instructions and memory operations when the execution activates this state.
The code snippet below describes an example approximation STATE_A.
approximation STATE_A {
initial = on;
pre_behavior = TraceState("A");
instruction mult {
parameters = set_C;
alt_behavior = ApproxMult(RB[rd], RB[rs], RB[rt]);
};
group VECTOR {
parameters = set_D;
regbank_write = RandomFlip();
probability = VectorProbability();
};
}
This description is interpreted as, in the order that the declarations are written:
- At simulation startup, this approximation is active.
- For every instrution fetched while this approximation is active, the user-defined method TraceState() is called before execution, with a string parameter “A” (see Implementation modifiers).
- The instruction mult has some specific configuration:
3.1. The set of operating parameters set_C has to be used (see Operating Parameters).
3.2. The execution main behavior has to be replaced with the user-defined method ApproxMult() with parameters RB[rd], RB[rs] and RB[rt], where each parameter is derived from data structures specified by the CPU model (see Implementation modifiers). - The group of instructions VECTOR has some specific configuration (see The Group Abstraction):
4.1. The set of operating parameters set_D has to be used (see Operating Parameters).
4.2. Every time a register from a register bank is written, the user-defined method RandomFlip() may be called (see Data modifiers).
4.2.1. RandomFlip() has to be called only if the user-defined method VectorProbability() returns TRUE (see The Probability Model).