Skip to content

Instantly share code, notes, and snippets.

@keesj
Created February 26, 2024 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keesj/fe9004f205b92f2a2419cc0eb5ad2a7e to your computer and use it in GitHub Desktop.
Save keesj/fe9004f205b92f2a2419cc0eb5ad2a7e to your computer and use it in GitHub Desktop.
verilog / iverilog return value from vpi
# include <vpi_user.h>
static int rnginit_compiletf(char*user_data __attribute__((unused)))
{
return 0;
}
static int rnginit_calltf(char*user_data __attribute__((unused)))
{
vpiHandle callh;
s_vpi_value val;
callh = vpi_handle(vpiSysTfCall, 0);
vpi_printf("Hello, World!\n");
val.format = vpiIntVal;
val.value.integer = 0xffffffff;
vpi_put_value(callh, &val, 0, vpiNoDelay);
return 0;
}
void rnginit_register(void)
{
s_vpi_systf_data tf_data;
tf_data.type = vpiSysFunc;
tf_data.sysfunctype = vpiSysFuncInt;
tf_data.tfname = "$rnginit";
tf_data.calltf = rnginit_calltf;
tf_data.compiletf = rnginit_compiletf;
tf_data.sizetf = 0;
tf_data.user_data = 0;
vpi_register_systf(&tf_data);
}
void (*vlog_startup_routines[])(void) = {
rnginit_register,
0
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment