Registering VPI applications
Each VPI application must register its system tasks and functions and its callbacks with the simulator. To accomplish this, one or more user-created registration routines must be called at simulation startup. Each registration routine should make one or more calls to vpi_register_systf() to register user-defined system tasks and functions and vpi_register_cb() to register callbacks. The registration routines must be placed in a table named vlog_startup_routines so that the simulator can find them. The table must be terminated with a 0 entry.
Example
PLI_INT32 MyFuncCalltf( PLI_BYTE8 *user_data ) { ... } PLI_INT32 MyFuncCompiletf( PLI_BYTE8 *user_data ) { ... } PLI_INT32 MyFuncSizetf( PLI_BYTE8 *user_data ) { ... } PLI_INT32 MyEndOfCompCB( p_cb_data cb_data_p ) { ... } PLI_INT32 MyStartOfSimCB( p_cb_data cb_data_p ) { ... } void RegisterMySystfs( void ) { s_cb_data callback; s_vpi_systf_data systf_data; systf_data.type = vpiSysFunc; systf_data.sysfunctype = vpiSizedFunc; systf_data.tfname = "$myfunc"; systf_data.calltf = MyFuncCalltf; systf_data.compiletf = MyFuncCompiletf; systf_data.sizetf = MyFuncSizetf; systf_data.user_data = 0; vpi_register_systf( &systf_data ); callback.reason = cbEndOfCompile; callback.cb_rtn = MyEndOfCompCB; callback.user_data = 0; (void) vpi_register_cb( &callback ); callback.reason = cbStartOfSimulation; callback.cb_rtn = MyStartOfSimCB; callback.user_data = 0; (void) vpi_register_cb( &callback ); } void (*vlog_startup_routines[ ] ) () = { RegisterMySystfs, 0 /* last entry must be 0 */ };Loading VPI applications into the simulator is the same as described in Registering PLI applications.
PLI and VPI applications can co-exist in the same application object file. In such cases, the applications are loaded at startup as follows:
- If an init_usertfs() function exists, then it is executed and only those system tasks and functions registered by calls to mti_RegisterUserTF() will be defined.
- If an init_usertfs() function does not exist but a veriusertfs table does exist, then only those system tasks and functions listed in the veriusertfs table will be defined.
- If an init_usertfs() function does not exist and a veriusertfs table does not exist, but a vlog_startup_routines table does exist, then only those system tasks and functions and callbacks registered by functions in the vlog_startup_routines table will be defined.
As a result, when PLI and VPI applications exist in the same application object file, they must be registered in the same manner. VPI registration functions that would normally be listed in a vlog_startup_routines table can be called from an init_usertfs() function instead.
Model Technology Incorporated Voice: (503) 641-1340 Fax: (503)526-5410 www.model.com sales@model.com |