User guide
CIF Peripheral Model - SimpleTimer
CoMET Version 5.9 – Tutorial 101
CODE ENDS
Declaring Instance Data Callback Handles and Callback Data Structures
Callback handles are used to register callback functions with the simulation engine. We will
use callbacks for match events (i.e. timer matches a match registers value) and unmatch
events (i.e. next callback after a match event, occurring on next clock tick).
Add the following declarations at the end of the instance data structure:
CODE BEGINS
/*
** Callback
*/
const tAmpiTaskCallbackHandle *MatchEvent[NUM_MATCH_REGISTERS];
const tAmpiTaskCallbackHandle *UnmatchEvent[NUM_MATCH_REGISTERS];
tTimerCallbackData CallbackData[NUM_MATCH_REGISTERS];
CODE ENDS
Declaring Instance Data State Variables
State variables are used for instance specific data that is needed for the model code, but does
not represent something found in the real hardware. In this case we need to keep some
internal state about the TimerClock tick count at which the GTR register was set. This
supports the callback data structure.
The instance data structure by default contains a state data section that appears as follows:
/*
** States.
*/
tBoolean InReset;
Add the following state variable to the instance data structure in the state data section:
CODE BEGINS
tWord64 LastCounterUpdateTime;
CODE ENDS
Building the Project
At any time you can build the SimpleTimer project. The build process identifies any syntax
errors or other problems with code.
To build the project:
Click on the build button. Alternatively choose Workspace/Build or press Shift-F8.