Extend the VPI value change callback tests.
Cover the vpiSuppressTime and null time pointer cases.
This commit is contained in:
parent
1d793ddba8
commit
5c1ca6eb93
|
|
@ -1,7 +1,9 @@
|
|||
#ifdef TEST_SCALED_TIME
|
||||
#if defined(TEST_SCALED_TIME)
|
||||
#define TIME_TYPE vpiScaledRealTime
|
||||
#else
|
||||
#elif defined(TEST_SIM_TIME)
|
||||
#define TIME_TYPE vpiSimTime
|
||||
#else
|
||||
#define TIME_TYPE vpiSuppressTime
|
||||
#endif
|
||||
|
||||
# include <sv_vpi_user.h>
|
||||
|
|
@ -12,29 +14,40 @@ static PLI_INT32 report_change(p_cb_data cb)
|
|||
{
|
||||
vpiHandle handle = (vpiHandle)(cb->user_data);
|
||||
|
||||
s_vpi_time time;
|
||||
|
||||
#ifndef TEST_NULL_TIME
|
||||
assert(cb->time && (cb->time->type == TIME_TYPE));
|
||||
#endif
|
||||
assert(cb->value);
|
||||
|
||||
#if defined(TEST_SCALED_TIME) || defined(TEST_SIM_TIME)
|
||||
time = *(cb->time);
|
||||
#else
|
||||
time.type = vpiSimTime;
|
||||
vpi_get_time(NULL, &time);
|
||||
#endif
|
||||
|
||||
switch (cb->value->format) {
|
||||
case vpiIntVal:
|
||||
#ifdef TEST_SCALED_TIME
|
||||
vpi_printf("At time %f %s = %d\n", cb->time->real, vpi_get_str(vpiName, handle), cb->value->value.integer);
|
||||
#if defined(TEST_SCALED_TIME)
|
||||
vpi_printf("At time %f %s = %d\n", time.real, vpi_get_str(vpiName, handle), cb->value->value.integer);
|
||||
#else
|
||||
vpi_printf("At time %d %s = %d\n", cb->time->low, vpi_get_str(vpiName, handle), cb->value->value.integer);
|
||||
vpi_printf("At time %d %s = %d\n", time.low, vpi_get_str(vpiName, handle), cb->value->value.integer);
|
||||
#endif
|
||||
break;
|
||||
case vpiRealVal:
|
||||
#ifdef TEST_SCALED_TIME
|
||||
vpi_printf("At time %f %s = %f\n", cb->time->real, vpi_get_str(vpiName, handle), cb->value->value.real);
|
||||
vpi_printf("At time %f %s = %f\n", time.real, vpi_get_str(vpiName, handle), cb->value->value.real);
|
||||
#else
|
||||
vpi_printf("At time %d %s = %f\n", cb->time->low, vpi_get_str(vpiName, handle), cb->value->value.real);
|
||||
vpi_printf("At time %d %s = %f\n", time.low, vpi_get_str(vpiName, handle), cb->value->value.real);
|
||||
#endif
|
||||
break;
|
||||
case vpiSuppressVal:
|
||||
#ifdef TEST_SCALED_TIME
|
||||
vpi_printf("At time %f %s changed\n", cb->time->real, vpi_get_str(vpiName, handle));
|
||||
vpi_printf("At time %f %s changed\n", time.real, vpi_get_str(vpiName, handle));
|
||||
#else
|
||||
vpi_printf("At time %d %s changed\n", cb->time->low, vpi_get_str(vpiName, handle));
|
||||
vpi_printf("At time %d %s changed\n", time.low, vpi_get_str(vpiName, handle));
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
#define TEST_SUPPRESS_TIME
|
||||
#include "value_change.c"
|
||||
|
|
@ -0,0 +1 @@
|
|||
`include "vpi/value_change.v"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
#define TEST_NULL_TIME
|
||||
#include "value_change.c"
|
||||
|
|
@ -0,0 +1 @@
|
|||
`include "vpi/value_change.v"
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Compiling vpi/value_change3.c...
|
||||
Making value_change3.vpi from value_change3.o...
|
||||
At time 1000 v4 = 1
|
||||
At time 1000 w4 = 1
|
||||
At time 2000 i4 = 2
|
||||
At time 3000 v2 = 3
|
||||
At time 4000 b2 = 4
|
||||
At time 5000 s2 = 5
|
||||
At time 6000 i2 = 6
|
||||
At time 7000 l2 = 7
|
||||
At time 8000 r = 8.000000
|
||||
At time 9000 e changed
|
||||
At time 10000 p4[1:0] = 10
|
||||
At time 11000 a4 = 11
|
||||
At time 12000 a4 = 12
|
||||
At time 14000 a2[1] = 14
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
Compiling vpi/value_change4.c...
|
||||
Making value_change4.vpi from value_change4.o...
|
||||
At time 1000 v4 = 1
|
||||
At time 1000 w4 = 1
|
||||
At time 2000 i4 = 2
|
||||
At time 3000 v2 = 3
|
||||
At time 4000 b2 = 4
|
||||
At time 5000 s2 = 5
|
||||
At time 6000 i2 = 6
|
||||
At time 7000 l2 = 7
|
||||
At time 8000 r = 8.000000
|
||||
At time 9000 e changed
|
||||
At time 10000 p4[1:0] = 10
|
||||
At time 11000 a4 = 11
|
||||
At time 12000 a4 = 12
|
||||
At time 14000 a2[1] = 14
|
||||
|
|
@ -137,6 +137,8 @@ start_of_simtime1 normal start_of_simtime1.c start_of_simtime1.log
|
|||
timescale normal timescale.c timescale.log
|
||||
value_change1 normal,-g2009 value_change1.c value_change1.gold
|
||||
value_change2 normal,-g2009 value_change2.c value_change2.gold
|
||||
value_change3 normal,-g2009 value_change3.c value_change3.gold
|
||||
value_change4 normal,-g2009 value_change4.c value_change4.gold
|
||||
|
||||
# Add new tests in alphabetic/numeric order. If the test needs
|
||||
# a compile option or a different log file to run with an older
|
||||
|
|
|
|||
Loading…
Reference in New Issue