Add VPI support for the simulation time.
This commit is contained in:
parent
b3a3b888d8
commit
a4c722b195
|
|
@ -16,7 +16,7 @@
|
|||
# 59 Temple Place - Suite 330
|
||||
# Boston, MA 02111-1307, USA
|
||||
#
|
||||
#ident "$Id: Makefile.in,v 1.11 2001/03/25 05:59:47 steve Exp $"
|
||||
#ident "$Id: Makefile.in,v 1.12 2001/03/31 19:00:43 steve Exp $"
|
||||
#
|
||||
#
|
||||
SHELL = /bin/sh
|
||||
|
|
@ -39,8 +39,8 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
|||
INSTALL_DATA = @INSTALL_DATA@
|
||||
STRIP = @STRIP@
|
||||
|
||||
CPPFLAGS = @CPPFLAGS@ @DEFS@ -DMODULE_DIR=\"$(libdir)/ivl\"
|
||||
CXXFLAGS = @CXXFLAGS@ -I. -I$(srcdir)/..
|
||||
CPPFLAGS = -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ -DMODULE_DIR=\"$(libdir)/ivl\"
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
dllib=@DLLIB@
|
||||
|
|
@ -58,7 +58,7 @@ check: all
|
|||
./vvp -M../vpi $(srcdir)/examples/hello.vvp | grep 'Hello, World.'
|
||||
|
||||
V = vpi_modules.o vpi_const.o vpi_iter.o vpi_mcd.o vpi_priv.o \
|
||||
vpi_scope.o vpi_signal.o vpi_tasks.o
|
||||
vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o
|
||||
|
||||
O = main.o parse.o parse_misc.o lexor.o compile.o functor.o symbols.o \
|
||||
codes.o vthread.o schedule.o tables.o $V
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.cc,v 1.21 2001/03/31 17:36:02 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.22 2001/03/31 19:00:43 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -160,6 +160,13 @@ struct cresolv_list_s {
|
|||
|
||||
static struct cresolv_list_s*cresolv_list = 0;
|
||||
|
||||
void compile_vpi_symbol(const char*label, vpiHandle obj)
|
||||
{
|
||||
symbol_value_t val;
|
||||
val.ptr = obj;
|
||||
sym_set_value(sym_vpi, label, val);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the compiler by allocation empty symbol tables and
|
||||
* initializing the various address spaces.
|
||||
|
|
@ -167,8 +174,11 @@ static struct cresolv_list_s*cresolv_list = 0;
|
|||
void compile_init(void)
|
||||
{
|
||||
sym_vpi = new_symbol_table();
|
||||
compile_vpi_symbol("$time", vpip_sim_time());
|
||||
|
||||
sym_functors = new_symbol_table();
|
||||
functor_init();
|
||||
|
||||
sym_codespace = new_symbol_table();
|
||||
codespace_init();
|
||||
|
||||
|
|
@ -515,13 +525,6 @@ void compile_thread(char*start_sym)
|
|||
free(start_sym);
|
||||
}
|
||||
|
||||
void compile_vpi_symbol(const char*label, vpiHandle obj)
|
||||
{
|
||||
symbol_value_t val;
|
||||
val.ptr = obj;
|
||||
sym_set_value(sym_vpi, label, val);
|
||||
}
|
||||
|
||||
vpiHandle compile_vpi_lookup(const char*label)
|
||||
{
|
||||
symbol_value_t val;
|
||||
|
|
@ -689,6 +692,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.22 2001/03/31 19:00:43 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
* Revision 1.21 2001/03/31 17:36:02 steve
|
||||
* Add the jmp/1 instruction.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
:vpi_module "system";
|
||||
|
||||
; Copyright (c) 2001 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
|
||||
|
||||
|
||||
; This example is similar to the code that the following Verilog program
|
||||
; would make:
|
||||
;
|
||||
; module main;
|
||||
; initial #45 $display("Hello, Clock: ", $time);
|
||||
; endmodule
|
||||
;
|
||||
; This tests that the special $time symbol references the vpiHandle for
|
||||
; the system time.
|
||||
|
||||
main .scope "main";
|
||||
|
||||
code
|
||||
%delay 45;
|
||||
%vpi_call "$display", "Hello, Clock: ", $time;
|
||||
%end;
|
||||
.thread code;
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: schedule.cc,v 1.3 2001/03/19 01:55:38 steve Exp $"
|
||||
#ident "$Id: schedule.cc,v 1.4 2001/03/31 19:00:43 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "schedule.h"
|
||||
|
|
@ -150,6 +150,8 @@ void schedule_assign(vvp_ipoint_t fun, unsigned char val, unsigned delay)
|
|||
}
|
||||
|
||||
static unsigned long schedule_time;
|
||||
unsigned long schedule_simtime(void)
|
||||
{ return schedule_time; }
|
||||
|
||||
void schedule_simulate(void)
|
||||
{
|
||||
|
|
@ -192,6 +194,9 @@ void schedule_simulate(void)
|
|||
|
||||
/*
|
||||
* $Log: schedule.cc,v $
|
||||
* Revision 1.4 2001/03/31 19:00:43 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
* Revision 1.3 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: schedule.h,v 1.3 2001/03/19 01:55:38 steve Exp $"
|
||||
#ident "$Id: schedule.h,v 1.4 2001/03/31 19:00:43 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -52,6 +52,13 @@ extern void schedule_assign(vvp_ipoint_t fun, unsigned char val,
|
|||
*/
|
||||
extern void schedule_simulate(void);
|
||||
|
||||
/*
|
||||
* Get the current absolue simulation time. This is not used
|
||||
* internally by the scheduler (which uses time differences instead)
|
||||
* but is used for printouts and stuff.
|
||||
*/
|
||||
extern unsigned long schedule_simtime(void);
|
||||
|
||||
/*
|
||||
* This function is the equivilent of the $finish system task. It
|
||||
* tells the simulator that simulation is done, the current thread
|
||||
|
|
@ -67,6 +74,9 @@ extern bool schedule_finished(void);
|
|||
|
||||
/*
|
||||
* $Log: schedule.h,v $
|
||||
* Revision 1.4 2001/03/31 19:00:43 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
* Revision 1.3 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.h,v 1.7 2001/03/25 00:35:35 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.8 2001/03/31 19:00:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -180,8 +180,13 @@ extern void vpip_execute_vpi_call(vpiHandle obj);
|
|||
* and to finish compilation in preparation for execution.
|
||||
*/
|
||||
|
||||
vpiHandle vpip_sim_time(void);
|
||||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.8 2001/03/31 19:00:44 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
* Revision 1.7 2001/03/25 00:35:35 steve
|
||||
* Add the .net statement.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* Copyright (c) 2001 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)
|
||||
#ident "$Id: vpi_time.cc,v 1.1 2001/03/31 19:00:44 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include "schedule.h"
|
||||
# include <assert.h>
|
||||
|
||||
static struct __vpiSystemTime {
|
||||
struct __vpiHandle base;
|
||||
struct t_vpi_time value;
|
||||
} time_handle;
|
||||
|
||||
static void timevar_get_value(vpiHandle ref, s_vpi_value*vp)
|
||||
{
|
||||
assert(ref == &time_handle.base);
|
||||
|
||||
switch (vp->format) {
|
||||
case vpiObjTypeVal:
|
||||
case vpiTimeVal:
|
||||
vp->value.time = &time_handle.value;
|
||||
vp->value.time->type = vpiSimTime;
|
||||
vp->value.time->high = 0;
|
||||
vp->value.time->low = schedule_simtime();
|
||||
vp->format = vpiTimeVal;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static const struct __vpirt vpip_system_time_rt = {
|
||||
vpiTimeVar,
|
||||
0,
|
||||
0,
|
||||
timevar_get_value,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
vpiHandle vpip_sim_time(void)
|
||||
{
|
||||
time_handle.base.vpi_type = &vpip_system_time_rt;
|
||||
return &time_handle.base;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vpi_time.cc,v $
|
||||
* Revision 1.1 2001/03/31 19:00:44 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue