24.03.2013 Views

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

ModelSim SE User's Manual - Electrical and Computer Engineering

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Registering VPI applications<br />

Example<br />

Registering VPI applications UM-563<br />

Each VPI application must register its system tasks <strong>and</strong> functions <strong>and</strong> its callbacks with the<br />

simulator. To accomplish this, one or more user-created registration routines must be called<br />

at simulation startup. Each registration routine should make one or more calls to<br />

vpi_register_systf() to register user-defined system tasks <strong>and</strong> functions <strong>and</strong><br />

vpi_register_cb() to register callbacks. The registration routines must be placed in a table<br />

named vlog_startup_routines so that the simulator can find them. The table must be<br />

terminated with a 0 entry.<br />

PLI_INT32 MyFuncCalltf( PLI_BYTE8 *user_data )<br />

{ ... }<br />

PLI_INT32 MyFuncCompiletf( PLI_BYTE8 *user_data )<br />

{ ... }<br />

PLI_INT32 MyFuncSizetf( PLI_BYTE8 *user_data )<br />

{ ... }<br />

PLI_INT32 MyEndOfCompCB( p_cb_data cb_data_p )<br />

{ ... }<br />

PLI_INT32 MyStartOfSimCB( p_cb_data cb_data_p )<br />

{ ... }<br />

void RegisterMySystfs( void )<br />

{<br />

}<br />

vpiH<strong>and</strong>le tmpH;<br />

s_cb_data callback;<br />

s_vpi_systf_data systf_data;<br />

systf_data.type = vpiSysFunc;<br />

systf_data.sysfunctype = vpiSizedFunc;<br />

systf_data.tfname = "$myfunc";<br />

systf_data.calltf = MyFuncCalltf;<br />

systf_data.compiletf = MyFuncCompiletf;<br />

systf_data.sizetf = MyFuncSizetf;<br />

systf_data.user_data = 0;<br />

tmpH = vpi_register_systf( &systf_data );<br />

vpi_free_object(tmpH);<br />

callback.reason = cbEndOfCompile;<br />

callback.cb_rtn = MyEndOfCompCB;<br />

callback.user_data = 0;<br />

tmpH = vpi_register_cb( &callback );<br />

vpi_free_object(tmpH);<br />

callback.reason = cbStartOfSimulation;<br />

callback.cb_rtn = MyStartOfSimCB;<br />

callback.user_data = 0;<br />

tmpH = vpi_register_cb( &callback );<br />

vpi_free_object(tmpH);<br />

void (*vlog_startup_routines[ ] ) () = {<br />

RegisterMySystfs,<br />

0 /* last entry must be 0 */<br />

};<br />

<strong>ModelSim</strong> <strong>SE</strong> User’s <strong>Manual</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!