execute_control gfx_con
API Reference Manual  /  5 Model-to-Simulator Interfaces  / 

freerun

Description
The freerun interface is provided by the freerun-extension extension class. The extension class augments CPU models with support for freerunning mode. The freerun interface is used by CPU models to interface with the extension class.

The enabled member returns true if freerunning mode is enabled and false otherwise. The notifier Sim_Notifier_Freerunning_Mode_Change is triggered for the object whenever freerunning mode is enabled or disabled.

The advance_clock is used by the CPU model to calculate how much its virtual time should be advanced in freerunning mode. The ps_limit argument is the maximal number of pico-seconds virtual time can be advanced. The next CPU event typically occurs at this time. The steps argument should be set to the number of elapsed instructions since the last call to advance_clock. The idle parameter should be set to true if the CPU is idle. The function returns the number of pico-seconds the virtual time of the CPU should be advanced. The returned value is proportional to the time spent simulating the model, but is also subject to configurable freerunning restrictions which ensures that the instruction rate is kept in an acceptable range.

The start_clock function should be called when the CPU model starts instruction simulation. It is used to measure the amount of time used to simulate the model.

The stop_clock function should be called when the CPU model stops instruction simulation.

The current_itime function returns a prediction of the amount of time needed to simulate an instruction, in pico-seconds. The estimate is based on historic data and will always be in an interval which does not conflict with configured freerunning restrictions. The value can be used to estimate how many instructions can be executed until the next time event.

Note: The freerun interface is experimental and may change without notice.
SIM_INTERFACE(freerun) {
        bool (*enabled)(conf_object_t *NOTNULL obj);

        int64 (*advance_clock)(conf_object_t *NOTNULL obj,
                               int64 ps_limit, int64 steps, bool idle);
        void (*start_clock)(conf_object_t *NOTNULL obj);
        void (*stop_clock)(conf_object_t *NOTNULL obj);

        uint64 (*current_itime)(conf_object_t *NOTNULL obj);
};
#define FREERUN_INTERFACE "freerun"

Execution Context
Cell Context for all methods.

execute_control gfx_con