J
Jon Nall
Guest
Hi all.
After staring at the IEEE spec (2005-D3) for a while, I'm quite confused
as to the semantics of the time field for the Simulation-time-related
callbacks in section 22.37.2.
Specifically, I'm confused as to whether the time value specified when
registering these callbacks is an absolute time or a delay relative to the
current tick.
For instance, if I register a cbAtStartOfSimTime callback with the time
field being a vpiSimTime of 30, does that mean I'll be called back at time
30, or does it mean I'll be called back 30 ticks from the current time?
VCS seems to treat the time field for cbAtStartOfSimTime as absolute,
while treating the time field for other callbacks in that section as
relative. However, cver treats the time field for all callbacks in this
section as relative. I'd be interested to hear other data points.
Is there any consensus on what the proper behavior should be?
The VPI application below will display the semantics of a simulator.
Thanks for any help,
nall.
============================================================
#include <vpi_user.h>
#include <stdio.h>
#include <assert.h>
PLI_INT32 cb_handler2(struct t_cb_data* cb_data)
{
vpi_printf("== INFO == cb_handler2 called at time %d\n", cb_data->time->low);
if(cb_data->time->low == 31)
{
vpi_printf("Time value for cbAtStartOfSimTime is relative for this simulator\n");
}
else if(cb_data->time->low == 17)
{
vpi_printf("Time value for cbAtStartOfSimTime is absolute for this simulator\n");
}
else
{
vpi_printf("Unexpected callback time: %d\n", cb_data->time->low);
}
}
PLI_INT32 cb_handler1(struct t_cb_data* cb_data)
{
s_vpi_time time;
s_cb_data data;
vpiHandle handle;
time.type = vpiSimTime;
time.high = 0;
time.low = 17;
data.reason = cbAtStartOfSimTime;
data.cb_rtn = cb_handler2;
data.time = &time;
data.user_data = NULL;
vpi_printf("== INFO == Registering callback cbAtStartOfSimTime @ %d with a time value of 17\n", cb_data->time->low);
handle = vpi_register_cb(&data);
assert(handle != NULL);
}
void vpitest_entry(void)
{
s_vpi_time time;
s_cb_data data;
vpiHandle handle;
time.type = vpiSimTime;
time.high = 0;
time.low = 14;
data.reason = cbAtStartOfSimTime;
data.cb_rtn = cb_handler1;
data.time = &time;
data.user_data = NULL;
vpi_printf("== INFO == Registering callback cbAtStartOfSimTime @ %d with a time value of 14\n", 0);
handle = vpi_register_cb(&data);
assert(handle != NULL);
}
After staring at the IEEE spec (2005-D3) for a while, I'm quite confused
as to the semantics of the time field for the Simulation-time-related
callbacks in section 22.37.2.
Specifically, I'm confused as to whether the time value specified when
registering these callbacks is an absolute time or a delay relative to the
current tick.
For instance, if I register a cbAtStartOfSimTime callback with the time
field being a vpiSimTime of 30, does that mean I'll be called back at time
30, or does it mean I'll be called back 30 ticks from the current time?
VCS seems to treat the time field for cbAtStartOfSimTime as absolute,
while treating the time field for other callbacks in that section as
relative. However, cver treats the time field for all callbacks in this
section as relative. I'd be interested to hear other data points.
Is there any consensus on what the proper behavior should be?
The VPI application below will display the semantics of a simulator.
Thanks for any help,
nall.
============================================================
#include <vpi_user.h>
#include <stdio.h>
#include <assert.h>
PLI_INT32 cb_handler2(struct t_cb_data* cb_data)
{
vpi_printf("== INFO == cb_handler2 called at time %d\n", cb_data->time->low);
if(cb_data->time->low == 31)
{
vpi_printf("Time value for cbAtStartOfSimTime is relative for this simulator\n");
}
else if(cb_data->time->low == 17)
{
vpi_printf("Time value for cbAtStartOfSimTime is absolute for this simulator\n");
}
else
{
vpi_printf("Unexpected callback time: %d\n", cb_data->time->low);
}
}
PLI_INT32 cb_handler1(struct t_cb_data* cb_data)
{
s_vpi_time time;
s_cb_data data;
vpiHandle handle;
time.type = vpiSimTime;
time.high = 0;
time.low = 17;
data.reason = cbAtStartOfSimTime;
data.cb_rtn = cb_handler2;
data.time = &time;
data.user_data = NULL;
vpi_printf("== INFO == Registering callback cbAtStartOfSimTime @ %d with a time value of 17\n", cb_data->time->low);
handle = vpi_register_cb(&data);
assert(handle != NULL);
}
void vpitest_entry(void)
{
s_vpi_time time;
s_cb_data data;
vpiHandle handle;
time.type = vpiSimTime;
time.high = 0;
time.low = 14;
data.reason = cbAtStartOfSimTime;
data.cb_rtn = cb_handler1;
data.time = &time;
data.user_data = NULL;
vpi_printf("== INFO == Registering callback cbAtStartOfSimTime @ %d with a time value of 14\n", 0);
handle = vpi_register_cb(&data);
assert(handle != NULL);
}