aboutsummaryrefslogtreecommitdiffstats
path: root/src/grt/grt-cvpi.c
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2015-10-30 07:11:28 +0100
committerTristan Gingold <tgingold@free.fr>2015-10-30 07:11:28 +0100
commitce10f7dbd57cb5d2273567aa536bfce79620849c (patch)
tree62fdd99a17aa09a04166e014444aeb8b732dce81 /src/grt/grt-cvpi.c
parentab70415983fec433dd35aea6cc8b107699a5aff0 (diff)
downloadghdl-ce10f7dbd57cb5d2273567aa536bfce79620849c.tar.gz
ghdl-ce10f7dbd57cb5d2273567aa536bfce79620849c.tar.bz2
ghdl-ce10f7dbd57cb5d2273567aa536bfce79620849c.zip
Rework callbacks, support cocotb.
Diffstat (limited to 'src/grt/grt-cvpi.c')
-rw-r--r--src/grt/grt-cvpi.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/src/grt/grt-cvpi.c b/src/grt/grt-cvpi.c
index 51edd678f..3e427c551 100644
--- a/src/grt/grt-cvpi.c
+++ b/src/grt/grt-cvpi.c
@@ -28,15 +28,7 @@
//-----------------------------------------------------------------------------
// VPI callback functions
typedef void *vpiHandle, *p_vpi_time, *p_vpi_value;
-typedef struct t_cb_data {
- int reason;
- int (*cb_rtn)(struct t_cb_data*cb);
- vpiHandle obj;
- p_vpi_time time;
- p_vpi_value value;
- int index;
- char*user_data;
-} s_cb_data, *p_cb_data;
+typedef struct t_cb_data s_cb_data, *p_cb_data;
//-----------------------------------------------------------------------------
// vpi thunking a la Icarus Verilog
@@ -103,7 +95,7 @@ typedef struct {
int vpi_register_sim(p_vpi_thunk tp);
-static vpi_thunk thunkTable =
+static vpi_thunk thunkTable =
{ VPI_THUNK_MAGIC,
vpi_register_systf,
vpi_vprintf,
@@ -128,8 +120,8 @@ static vpi_thunk thunkTable =
vpi_put_value,
vpi_free_object,
vpi_get_vlog_info,
- 0, //vpi_chk_error,
- 0 //vpi_handle_by_name
+ vpi_chk_error,
+ vpi_handle_by_name
};
//-----------------------------------------------------------------------------
@@ -202,7 +194,7 @@ loadVpiModule (const char* modulename)
"vpi_register_sim" // w/o leading underscore: Linux
};
- int i;
+ int i;
void* vpimod;
fprintf (stderr, "loading VPI module '%s'\n", modulename);
@@ -223,15 +215,15 @@ loadVpiModule (const char* modulename)
{
void* vpithunk;
void* vpitable;
-
+
vpitable = module_symbol (vpimod, vpitablenames[i]);
vpithunk = module_symbol (vpimod, vpithunknames[i]);
-
+
if (vpithunk)
{
typedef int (*funT)(p_vpi_thunk tp);
funT regsim;
-
+
regsim = (funT)vpithunk;
regsim (&thunkTable);
}
@@ -240,20 +232,20 @@ loadVpiModule (const char* modulename)
// this is not an error, as the register-mechanism
// is not standardized
}
-
+
if (vpitable)
{
unsigned int tmp;
//extern void (*vlog_startup_routines[])();
typedef void (*vlog_startup_routines_t)(void);
vlog_startup_routines_t *vpifuns;
-
+
vpifuns = (vlog_startup_routines_t*)vpitable;
for (tmp = 0; vpifuns[tmp]; tmp++)
{
vpifuns[tmp]();
}
-
+
fprintf (stderr, "VPI module loaded!\n");
return 0; // successfully registered VPI module
}
@@ -274,4 +266,3 @@ vpi_printf (const char *fmt, ...)
//-----------------------------------------------------------------------------
// end of file
-