V0.8: only return a real time value for $realtime.

This patch mirrors what was done in development to only return a
real value when realtime is called.
This commit is contained in:
Cary R 2008-11-21 16:50:46 -08:00 committed by Stephen Williams
parent 451783056d
commit 8deb2c0b60
1 changed files with 21 additions and 9 deletions

View File

@ -133,7 +133,7 @@ static vpiHandle timevar_handle(int code, vpiHandle ref)
} }
static void timevar_get_value(vpiHandle ref, s_vpi_value*vp) static void timevar_get_value(vpiHandle ref, s_vpi_value*vp, bool is_int_func)
{ {
/* Keep a persistent structure for passing time values back to /* Keep a persistent structure for passing time values back to
the caller. */ the caller. */
@ -174,12 +174,14 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp)
break; break;
case vpiRealVal: case vpiRealVal:
/* Oops, in this case I want a double power of 10 to do /* If this is an integer based call (anything but $realtime)
the scaling, instead of the integer scaling done * just return the value as a double. */
everywhere else. */ if (is_int_func) vp->value.real = (double) simtime;
units = rfp->scope? rfp->scope->time_units : vpi_time_precision; else {
vp->value.real = pow(10, vpi_time_precision - units); units = rfp->scope? rfp->scope->time_units : vpi_time_precision;
vp->value.real *= schedule_simtime(); vp->value.real = pow(10, vpi_time_precision - units);
vp->value.real *= schedule_simtime();
}
break; break;
case vpiBinStrVal: case vpiBinStrVal:
@ -216,11 +218,21 @@ static void timevar_get_value(vpiHandle ref, s_vpi_value*vp)
} }
} }
static void timevar_get_ivalue(vpiHandle ref, s_vpi_value*vp)
{
timevar_get_value(ref, vp, true);
}
static void timevar_get_rvalue(vpiHandle ref, s_vpi_value*vp)
{
timevar_get_value(ref, vp, false);
}
static const struct __vpirt vpip_system_time_rt = { static const struct __vpirt vpip_system_time_rt = {
vpiSysFuncCall, vpiSysFuncCall,
timevar_time_get, timevar_time_get,
timevar_time_get_str, timevar_time_get_str,
timevar_get_value, timevar_get_ivalue,
0, 0,
timevar_handle, timevar_handle,
0 0
@ -230,7 +242,7 @@ static const struct __vpirt vpip_system_realtime_rt = {
vpiSysFuncCall, vpiSysFuncCall,
timevar_realtime_get, timevar_realtime_get,
timevar_realtime_get_str, timevar_realtime_get_str,
timevar_get_value, timevar_get_rvalue,
0, 0,
timevar_handle, timevar_handle,
0 0