Add the general $time system function.

This commit is contained in:
steve 2000-11-01 03:19:36 +00:00
parent 3591e06c4e
commit 4d27b947bc
4 changed files with 84 additions and 5 deletions

View File

@ -18,7 +18,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.17 2000/10/06 23:11:39 steve Exp $"
#ident "$Id: Makefile.in,v 1.18 2000/11/01 03:19:36 steve Exp $"
#
#
SHELL = /bin/sh
@ -54,7 +54,7 @@ all: system.vpi
mv $*.d dep
O = sys_table.o sys_display.o sys_finish.o sys_random.o \
sys_readmem.o sys_readmem_lex.o sys_vcd.o
sys_readmem.o sys_readmem_lex.o sys_time.o sys_vcd.o
ifeq (@CYGWIN@,yes)
SYSTEM_VPI_LDFLAGS=-Wl,--enable-auto-image-base -L../vvm -lvvm -lvpip

View File

@ -17,13 +17,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: sys_table.c,v 1.6 2000/09/30 03:20:47 steve Exp $"
#ident "$Id: sys_table.c,v 1.7 2000/11/01 03:19:36 steve Exp $"
#endif
extern void sys_finish_register();
extern void sys_display_register();
extern void sys_random_register();
extern void sys_readmem_register();
extern void sys_time_register();
extern void sys_vcd_register();
void (*vlog_startup_routines[])() = {
@ -31,6 +32,7 @@ void (*vlog_startup_routines[])() = {
sys_display_register,
sys_random_register,
sys_readmem_register,
sys_time_register,
sys_vcd_register,
0
};
@ -42,6 +44,9 @@ DECLARE_CYGWIN_DLL(DllMain);
/*
* $Log: sys_table.c,v $
* Revision 1.7 2000/11/01 03:19:36 steve
* Add the general $time system function.
*
* Revision 1.6 2000/09/30 03:20:47 steve
* Cygwin port changes from Venkat
*

69
vpi/sys_time.c Normal file
View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2000 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
* 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
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: sys_time.c,v 1.1 2000/11/01 03:19:36 steve Exp $"
#endif
# include "vpi_user.h"
# include <assert.h>
static int sys_time_sizetf(char*x)
{
return 64;
}
static int sys_time_calltf(char*name)
{
s_vpi_value val;
s_vpi_time now;
vpiHandle call_handle;
call_handle = vpi_handle(vpiSysTfCall, 0);
assert(call_handle);
vpi_get_time(0, &now);
val.format = vpiIntVal;
val.value.integer = now.low;
assert(now.high == 0);
vpi_put_value(call_handle, &val, 0, vpiNoDelay);
return 0;
}
void sys_time_register()
{
s_vpi_systf_data tf_data;
tf_data.type = vpiSysFunc;
tf_data.tfname = "$time";
tf_data.calltf = sys_time_calltf;
tf_data.compiletf = 0;
tf_data.sizetf = sys_time_sizetf;
vpi_register_systf(&tf_data);
}
/*
* $Log: sys_time.c,v $
* Revision 1.1 2000/11/01 03:19:36 steve
* Add the general $time system function.
*
*/

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_systask.c,v 1.8 2000/10/28 00:51:42 steve Exp $"
#ident "$Id: vpi_systask.c,v 1.9 2000/11/01 03:19:36 steve Exp $"
#endif
# include "vpi_priv.h"
@ -90,8 +90,10 @@ static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value val,
/* XXXX For now, only support very specific formats. */
assert(val->format == vpiIntVal);
assert(rfp->nres <= (8*sizeof val->value.integer));
/* This fills the result bits with the signed value of the
integer. This automagically extends the sign bit by nature
of how the >> works in C. */
tmp = val->value.integer;
for (idx = 0 ; idx < rfp->nres ; idx += 1) {
rfp->res[idx] = (tmp&1) ? St1 : St0;
@ -123,6 +125,9 @@ DECLARE_CYGWIN_DLL(DllMain);
/*
* $Log: vpi_systask.c,v $
* Revision 1.9 2000/11/01 03:19:36 steve
* Add the general $time system function.
*
* Revision 1.8 2000/10/28 00:51:42 steve
* Add scope to threads in vvm, pass that scope
* to vpi sysTaskFunc objects, and add vpi calls