Fix for GitHub issue #117 - delays in VPI simulation time callbacks.
Change cbReadWriteSynch and cbReadOnlySynch to interpret the passed time value as a relative delay, not an absolute time. This matches the behaviour of other simulators.
This commit is contained in:
parent
e56e52bc42
commit
0fdf29e099
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999-2015 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 1999-2016 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -35,6 +35,8 @@
|
|||
static char *dump_path = NULL;
|
||||
static struct fstContext *dump_file = NULL;
|
||||
|
||||
static struct t_vpi_time zero_delay = { vpiSimTime, 0, 0, 0.0 };
|
||||
|
||||
struct vcd_info {
|
||||
vpiHandle item;
|
||||
vpiHandle cb;
|
||||
|
|
@ -182,6 +184,7 @@ static PLI_INT32 variable_cb_1(p_cb_data cause)
|
|||
|
||||
if (!vcd_dmp_list) {
|
||||
cb = *cause;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = variable_cb_2;
|
||||
vpi_register_cb(&cb);
|
||||
|
|
@ -248,7 +251,6 @@ static PLI_INT32 finish_cb(p_cb_data cause)
|
|||
__inline__ static int install_dumpvars_callback(void)
|
||||
{
|
||||
struct t_cb_data cb;
|
||||
static struct t_vpi_time now;
|
||||
|
||||
if (dumpvars_status == 1) return 0;
|
||||
|
||||
|
|
@ -259,8 +261,7 @@ __inline__ static int install_dumpvars_callback(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
now.type = vpiSimTime;
|
||||
cb.time = &now;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = dumpvars_cb;
|
||||
cb.user_data = 0x0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002-2015 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2002-2016 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -38,6 +38,8 @@
|
|||
static char *dump_path = NULL;
|
||||
static struct lt_trace *dump_file = NULL;
|
||||
|
||||
static struct t_vpi_time zero_delay = { vpiSimTime, 0, 0, 0.0 };
|
||||
|
||||
struct vcd_info {
|
||||
vpiHandle item;
|
||||
vpiHandle cb;
|
||||
|
|
@ -261,6 +263,7 @@ static PLI_INT32 variable_cb_1(p_cb_data cause)
|
|||
|
||||
if (!vcd_dmp_list) {
|
||||
cb = *cause;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = variable_cb_2;
|
||||
vpi_register_cb(&cb);
|
||||
|
|
@ -320,7 +323,6 @@ static PLI_INT32 finish_cb(p_cb_data cause)
|
|||
__inline__ static int install_dumpvars_callback(void)
|
||||
{
|
||||
struct t_cb_data cb;
|
||||
static struct t_vpi_time now;
|
||||
|
||||
if (dumpvars_status == 1) return 0;
|
||||
|
||||
|
|
@ -331,8 +333,7 @@ __inline__ static int install_dumpvars_callback(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
now.type = vpiSimTime;
|
||||
cb.time = &now;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = dumpvars_cb;
|
||||
cb.user_data = 0x0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2015 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2003-2016 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -40,6 +40,8 @@ static struct lxt2_wr_trace *dump_file = NULL;
|
|||
|
||||
static void* lxt2_thread(void*arg);
|
||||
|
||||
static struct t_vpi_time zero_delay = { vpiSimTime, 0, 0, 0.0 };
|
||||
|
||||
/*
|
||||
* Manage a table of all the dump-enabled vcd item. The cells of this
|
||||
* table are allocated incrementally, but are released all at once, so
|
||||
|
|
@ -105,7 +107,6 @@ void delete_all_vcd_info(void)
|
|||
*/
|
||||
# define VCD_INFO_ENDP ((struct vcd_info*)1)
|
||||
static struct vcd_info *vcd_dmp_list = VCD_INFO_ENDP;
|
||||
static struct t_vpi_time vcd_dmp_time;
|
||||
|
||||
static PLI_UINT64 vcd_cur_time = 0;
|
||||
static int dump_is_off = 0;
|
||||
|
|
@ -302,9 +303,8 @@ static PLI_INT32 variable_cb_1(p_cb_data cause)
|
|||
}
|
||||
|
||||
if (vcd_dmp_list == VCD_INFO_ENDP) {
|
||||
vcd_dmp_time.type = vpiSuppressTime;
|
||||
cb = *cause;
|
||||
cb.time = &vcd_dmp_time;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = variable_cb_2;
|
||||
vpi_register_cb(&cb);
|
||||
|
|
@ -358,7 +358,6 @@ static PLI_INT32 finish_cb(p_cb_data cause)
|
|||
__inline__ static int install_dumpvars_callback(void)
|
||||
{
|
||||
struct t_cb_data cb;
|
||||
static struct t_vpi_time now;
|
||||
|
||||
if (dumpvars_status == 1) return 0;
|
||||
|
||||
|
|
@ -369,8 +368,7 @@ __inline__ static int install_dumpvars_callback(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
now.type = vpiSimTime;
|
||||
cb.time = &now;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = dumpvars_cb;
|
||||
cb.user_data = 0x0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999-2015 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 1999-2016 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
static char *dump_path = NULL;
|
||||
static FILE *dump_file = NULL;
|
||||
|
||||
static struct t_vpi_time zero_delay = { vpiSimTime, 0, 0, 0.0 };
|
||||
|
||||
struct vcd_info {
|
||||
vpiHandle item;
|
||||
vpiHandle cb;
|
||||
|
|
@ -216,6 +218,7 @@ static PLI_INT32 variable_cb_1(p_cb_data cause)
|
|||
|
||||
if (!vcd_dmp_list) {
|
||||
cb = *cause;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = variable_cb_2;
|
||||
vpi_register_cb(&cb);
|
||||
|
|
@ -283,7 +286,6 @@ static PLI_INT32 finish_cb(p_cb_data cause)
|
|||
__inline__ static int install_dumpvars_callback(void)
|
||||
{
|
||||
struct t_cb_data cb;
|
||||
static struct t_vpi_time now;
|
||||
|
||||
if (dumpvars_status == 1) return 0;
|
||||
|
||||
|
|
@ -294,8 +296,7 @@ __inline__ static int install_dumpvars_callback(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
now.type = vpiSimTime;
|
||||
cb.time = &now;
|
||||
cb.time = &zero_delay;
|
||||
cb.reason = cbReadOnlySynch;
|
||||
cb.cb_rtn = dumpvars_cb;
|
||||
cb.user_data = 0x0;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2016 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -332,21 +332,14 @@ static sync_callback* make_sync(p_cb_data data, bool readonly_flag)
|
|||
cb->handle = obj;
|
||||
obj->cb_sync = cb;
|
||||
|
||||
vvp_time64_t tv = 0;
|
||||
switch (obj->cb_time.type) {
|
||||
case vpiSuppressTime:
|
||||
schedule_generic(cb, 0, true, readonly_flag);
|
||||
break;
|
||||
|
||||
case vpiSimTime:
|
||||
{ vvp_time64_t tv = vpip_timestruct_to_time(&obj->cb_time);
|
||||
vvp_time64_t tn = schedule_simtime();
|
||||
if (tv < tn) {
|
||||
schedule_generic(cb, 0, true, readonly_flag);
|
||||
} else {
|
||||
schedule_generic(cb, tv - tn, true, readonly_flag);
|
||||
}
|
||||
break;
|
||||
}
|
||||
tv = vpip_timestruct_to_time(&obj->cb_time);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unsupported time type %d.\n",
|
||||
|
|
@ -354,6 +347,7 @@ static sync_callback* make_sync(p_cb_data data, bool readonly_flag)
|
|||
assert(0);
|
||||
break;
|
||||
}
|
||||
schedule_generic(cb, tv, true, readonly_flag);
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
|
@ -365,7 +359,7 @@ static struct __vpiCallback* make_afterdelay(p_cb_data data, bool simtime_flag)
|
|||
cb->handle = obj;
|
||||
obj->cb_sync = cb;
|
||||
|
||||
vvp_time64_t tv;
|
||||
vvp_time64_t tv = 0;
|
||||
switch (obj->cb_time.type) {
|
||||
case vpiSimTime:
|
||||
tv = vpip_timestruct_to_time(&obj->cb_time);
|
||||
|
|
@ -375,7 +369,6 @@ static struct __vpiCallback* make_afterdelay(p_cb_data data, bool simtime_flag)
|
|||
fprintf(stderr, "Unsupported time type %d.\n",
|
||||
(int)obj->cb_time.type);
|
||||
assert(0);
|
||||
tv = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue