Restructure and simplify the nextsimtime VPI tests.
Add support for properly testing the vpiScaledRealTime time type for when it's implemented.
This commit is contained in:
parent
cae337231c
commit
5d40f6ecb2
|
|
@ -20,19 +20,38 @@
|
||||||
# include "vpi_user.h"
|
# include "vpi_user.h"
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
|
|
||||||
|
#if defined(TEST_SIM_TIME)
|
||||||
|
#define TIME_TYPE vpiSimTime
|
||||||
|
#elif defined(TEST_SCALED_TIME)
|
||||||
|
#define TIME_TYPE vpiScaledRealTime
|
||||||
|
#else
|
||||||
|
#define TIME_TYPE vpiSuppressTime
|
||||||
|
#endif
|
||||||
|
|
||||||
static s_vpi_time cb_timerec = {vpiSimTime, 0, 0, 0};
|
#ifndef TEST_NULL_TIME
|
||||||
|
static s_vpi_time cb_timerec = {TIME_TYPE, 0, 0, 0};
|
||||||
|
#endif
|
||||||
|
|
||||||
static PLI_INT32 register_nextsimtime(struct t_cb_data* cb);
|
static PLI_INT32 register_nextsimtime(struct t_cb_data* cb);
|
||||||
|
|
||||||
|
|
||||||
static PLI_INT32 nextsimtime_cb(struct t_cb_data* cb) {
|
static PLI_INT32 nextsimtime_cb(struct t_cb_data* cb) {
|
||||||
uint64_t nextsimtime = ((uint64_t)cb->time->high << 32) | cb->time->low;
|
|
||||||
s_vpi_time timerec;
|
s_vpi_time timerec;
|
||||||
|
#ifdef TEST_SCALED_TIME
|
||||||
|
timerec.type = vpiScaledRealTime;
|
||||||
|
#else
|
||||||
timerec.type = vpiSimTime;
|
timerec.type = vpiSimTime;
|
||||||
|
#endif
|
||||||
vpi_get_time(NULL, &timerec);
|
vpi_get_time(NULL, &timerec);
|
||||||
|
#ifdef TEST_SCALED_TIME
|
||||||
|
vpi_printf("nextsimtime: %f vpi_get_time: %f\n",
|
||||||
|
cb->time->real, timerec.real);
|
||||||
|
#else
|
||||||
|
uint64_t nextsimtime = ((uint64_t)cb->time->high << 32) | cb->time->low;
|
||||||
uint64_t time = ((uint64_t)timerec.high << 32) | timerec.low;
|
uint64_t time = ((uint64_t)timerec.high << 32) | timerec.low;
|
||||||
vpi_printf("nextsimtime: %" PLI_UINT64_FMT " vpi_get_time: %" PLI_UINT64_FMT "\n",
|
vpi_printf("nextsimtime: %" PLI_UINT64_FMT " vpi_get_time: %" PLI_UINT64_FMT "\n",
|
||||||
nextsimtime, time);
|
nextsimtime, time);
|
||||||
|
#endif
|
||||||
register_nextsimtime(NULL);
|
register_nextsimtime(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -40,7 +59,16 @@ static PLI_INT32 nextsimtime_cb(struct t_cb_data* cb) {
|
||||||
static PLI_INT32 register_nextsimtime(struct t_cb_data* cb) {
|
static PLI_INT32 register_nextsimtime(struct t_cb_data* cb) {
|
||||||
(void)cb; /* unused */
|
(void)cb; /* unused */
|
||||||
s_cb_data cb_data;
|
s_cb_data cb_data;
|
||||||
|
#ifdef TEST_NULL_TIME
|
||||||
|
cb_data.time = 0;
|
||||||
|
#else
|
||||||
cb_data.time = &cb_timerec;
|
cb_data.time = &cb_timerec;
|
||||||
|
#endif
|
||||||
|
#ifdef TEST_SCALED_TIME
|
||||||
|
cb_data.obj = vpi_handle_by_name("main", NULL);
|
||||||
|
#else
|
||||||
|
cb_data.obj = 0;
|
||||||
|
#endif
|
||||||
cb_data.reason = cbNextSimTime;
|
cb_data.reason = cbNextSimTime;
|
||||||
cb_data.cb_rtn = nextsimtime_cb;
|
cb_data.cb_rtn = nextsimtime_cb;
|
||||||
vpiHandle hndl = NULL;
|
vpiHandle hndl = NULL;
|
||||||
|
|
@ -17,6 +17,8 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
`timescale 1s/1ms
|
||||||
|
|
||||||
module main;
|
module main;
|
||||||
|
|
||||||
initial begin
|
initial begin
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2022 Jevin Sweval (jevinsweval@gmail.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
|
|
||||||
* General Public License as published by the Free Software
|
|
||||||
* Foundation; either version 2 of the License, or (at your option)
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
# include "vpi_user.h"
|
|
||||||
# include <assert.h>
|
|
||||||
|
|
||||||
#if defined(TEST_SCALED) || defined(TEST_SUPPRESS)
|
|
||||||
#if defined(TEST_SCALED)
|
|
||||||
#define TIME_TYPE vpiScaledRealTime
|
|
||||||
#elif defined(TEST_SUPPRESS)
|
|
||||||
#define TIME_TYPE vpiSuppressTime
|
|
||||||
#endif
|
|
||||||
static s_vpi_time cb_timerec = {TIME_TYPE, 0, 0, 0};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static PLI_INT32 dummy_cb(struct t_cb_data* cb) {
|
|
||||||
(void)cb; /* unused */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PLI_INT32 register_nextsimtime(struct t_cb_data* cb) {
|
|
||||||
(void)cb; /* unused */
|
|
||||||
s_cb_data cb_data;
|
|
||||||
#if defined(TEST_SCALED) || defined(TEST_SUPPRESS)
|
|
||||||
cb_data.time = &cb_timerec;
|
|
||||||
#elif defined(TEST_NULL)
|
|
||||||
cb_data.time = NULL;
|
|
||||||
#endif
|
|
||||||
cb_data.reason = cbNextSimTime;
|
|
||||||
cb_data.cb_rtn = dummy_cb;
|
|
||||||
vpiHandle hndl = NULL;
|
|
||||||
assert((hndl = vpi_register_cb(&cb_data)) && vpi_free_object(hndl));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void register_functions(void)
|
|
||||||
{
|
|
||||||
s_cb_data cb_data;
|
|
||||||
cb_data.reason = cbEndOfCompile;
|
|
||||||
cb_data.cb_rtn = register_nextsimtime;
|
|
||||||
vpi_register_cb(&cb_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void (*vlog_startup_routines[])(void) = {
|
|
||||||
register_functions,
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#define TEST_NULL
|
#define TEST_NULL_TIME
|
||||||
#include "nextsimtime_errors.c"
|
#include "nextsimtime_common.c"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
`include "vpi/nextsimtime_fill_time.v"
|
`include "vpi/nextsimtime_common.v"
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#define TEST_SCALED
|
#define TEST_SCALED_TIME
|
||||||
#include "nextsimtime_errors.c"
|
#include "nextsimtime_common.c"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
`include "vpi/nextsimtime_fill_time.v"
|
`include "vpi/nextsimtime_common.v"
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
#define TEST_SIM_TIME
|
||||||
|
#include "nextsimtime_common.c"
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
`include "vpi/nextsimtime_common.v"
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
#define TEST_SUPPRESS
|
#define TEST_SUPPRESS_TIME
|
||||||
#include "nextsimtime_errors.c"
|
#include "nextsimtime_common.c"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
`include "vpi/nextsimtime_fill_time.v"
|
`include "vpi/nextsimtime_common.v"
|
||||||
|
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
Compiling vpi/nextsimtime_fill_time.c...
|
|
||||||
Making nextsimtime_fill_time.vpi from nextsimtime_fill_time.o...
|
|
||||||
time 0: 0
|
|
||||||
nextsimtime: 1 vpi_get_time: 1
|
|
||||||
time 1: 1
|
|
||||||
nextsimtime: 4 vpi_get_time: 4
|
|
||||||
time 4: 4
|
|
||||||
nextsimtime: 5 vpi_get_time: 5
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
Compiling vpi/nextsimtime_sim_time.c...
|
||||||
|
Making nextsimtime_sim_time.vpi from nextsimtime_sim_time.o...
|
||||||
|
time 0: 0
|
||||||
|
nextsimtime: 1000 vpi_get_time: 1000
|
||||||
|
time 1: 1
|
||||||
|
nextsimtime: 4000 vpi_get_time: 4000
|
||||||
|
time 4: 4
|
||||||
|
nextsimtime: 5000 vpi_get_time: 5000
|
||||||
|
|
@ -99,10 +99,10 @@ hello_tf normal hello_tf.c hello_tf.log
|
||||||
hello_vpi normal hello_vpi.c hello.log
|
hello_vpi normal hello_vpi.c hello.log
|
||||||
hello_vpi2 normal hello_vpi2.c hello2.log vpi/hello_vpi1.c
|
hello_vpi2 normal hello_vpi2.c hello2.log vpi/hello_vpi1.c
|
||||||
listparams normal listparams.c listparams.log
|
listparams normal listparams.c listparams.log
|
||||||
nextsimtime_fill_time normal nextsimtime_fill_time.c nextsimtime_fill_time.gold
|
nextsimtime_null_time normal nextsimtime_null_time.c nextsimtime_null_time.gold
|
||||||
nextsimtime_null_time normal nextsimtime_null_time.c nextsimtime_null_time.gold
|
nextsimtime_scaled_time normal nextsimtime_scaled_time.c nextsimtime_scaled_time.gold
|
||||||
nextsimtime_scaled_time normal nextsimtime_scaled_time.c nextsimtime_scaled_time.gold
|
nextsimtime_sim_time normal nextsimtime_sim_time.c nextsimtime_sim_time.gold
|
||||||
nextsimtime_suppress_time normal nextsimtime_suppress_time.c nextsimtime_suppress_time.gold
|
nextsimtime_suppress_time normal nextsimtime_suppress_time.c nextsimtime_suppress_time.gold
|
||||||
memmon normal,-g1995 memmon.c memmon.log
|
memmon normal,-g1995 memmon.c memmon.log
|
||||||
memwide normal memwide.cc memwide.log
|
memwide normal memwide.cc memwide.log
|
||||||
mipname normal mipname.c mipname.log
|
mipname normal mipname.c mipname.log
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue