3/27/2007

Most useful VPI code blocks

1. Register a system call
void hello_register()
{
 s_vpi_systf_data tf_data;

 tf_data.type = vpiSysTask;
 tf_data.tfname = "$hello";
 tf_data.calltf = hello;
 tf_data.compiletf = NULL;
 tf_data.sizetf = NULL;
 vpi_register_systf(&tf_data);
}

2. Obtain system task arguments

 vpiHandle systf_handle, arg_iterator, arg_handle, net_handle;
 s_vpi_value current_value;

 /* obtain a handle to the system task instance */
 systf_handle = vpi_handle(vpiSysTfCall, NULL);

 /* obtain handle to system task argument */
 arg_iterator = vpi_iterate(vpiArgument, systf_handle);
 net_handle = vpi_scan(arg_iterator);
 vpi_free_object(arg_iterator); /* free iterator memory */

No comments: