Development Tools User’s Guide
257
Simulator APIs
9
This section describes the information comprising the XACT API. If you plan to access this API
via a foreign model dll, include the header file
xact_vmod.h
.
9.1
Foreign Model API
The following 6 routines must be supplied in a foreign model dll. Note that they do not have to be
exported because the transactor obtains their addresses by calling
GetVmodForeignModelFunctions()
:
9.1.1
FOR_MOD_INITIALIZE
This routine will be called to initialize the foreign model after the transactor "
init
" command has
successfully executed. It supplies a model instance number, a model name that corresponds to it,
and an initialization string that will be passed to the foreign model at initialization time. The model
name was previously specified by the user when the foreign model was registered with the
simulator. The model instance number is a unique non-negative number that acts as a handle to this
particular foreign model instance. The model instance number will be passed in to all foreign
model functions below. As a result, multiple instances of a single foreign model dll can be
registered with the simulator because each call to a foreign model function specifies a particular
foreign model instance number. The
init_str
argument may be NULL.
Function Prototype
int for_mod_initialize( int model_instance_num,
const char *model_name, const char *init_str
)
Returns
TRUE if successful and FALSE otherwise.
9.1.2
FOR_MOD_PRE_SIM
This routine will be called prior to each transactor simulation event. It can be used to deposit state
values into the transactor model prior to simulating the next event. Returning 0 results in an error
Function Prototype
int for_mod_pre_sim( int model_instance_num )
9.1.3
FOR_MOD_POST_SIM
This routine will be called subsequent to each transactor simulation event. It can be used to query
transactor simulation state, in order to copy it into the foreign model simulator.
Function Prototype
int for_mod_post_sim ( int model_instance_num )
9.1.4
FOR_MOD_EXIT
This routine will be called just prior to exiting the simulator. The routine allows the foreign model
to clean up, close files, etc before shutting down the program