Add vpi support for named events.

Add vpi_mode_flag to track the mode of the
 vpi engine. This is for error checking.
This commit is contained in:
steve 2002-05-18 02:34:11 +00:00
parent a156d8b8ce
commit b1c0f7306d
12 changed files with 241 additions and 39 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: vpi_user.h,v 1.8 2002/05/17 16:13:08 steve Exp $"
#ident "$Id: vpi_user.h,v 1.9 2002/05/18 02:34:11 steve Exp $"
#endif
@ -150,6 +150,7 @@ typedef struct t_vpi_value {
#define vpiMemoryWord 30
#define vpiModule 32
#define vpiNamedBegin 33
#define vpiNamedEvent 34
#define vpiNamedFork 35
#define vpiNet 36
#define vpiReg 48
@ -312,6 +313,12 @@ EXTERN_C_END
/*
* $Log: vpi_user.h,v $
* Revision 1.9 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.8 2002/05/17 16:13:08 steve
* Add vpiIndex update.
*

View File

@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.37 2002/05/11 04:39:35 steve Exp $"
#ident "$Id: Makefile.in,v 1.38 2002/05/18 02:34:11 steve Exp $"
#
#
SHELL = /bin/sh
@ -61,7 +61,7 @@ distclean: clean
check: all
./vvp -M../vpi $(srcdir)/examples/hello.vvp | grep 'Hello, World.'
V = vpi_modules.o vpi_callback.o vpi_const.o vpi_iter.o vpi_mcd.o \
V = vpi_modules.o vpi_callback.o vpi_const.o vpi_event.o vpi_iter.o vpi_mcd.o \
vpi_priv.o vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o vpi_memory.o \
vpi_vthr_vector.o vpip_bin.o vpip_hex.o vpip_oct.o vpip_to_dec.o vvp_vpi.o

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.h,v 1.41 2002/03/18 00:19:34 steve Exp $"
#ident "$Id: compile.h,v 1.42 2002/05/18 02:34:11 steve Exp $"
#endif
# include <stdio.h>
@ -183,6 +183,7 @@ extern void compile_ufunc(char*label, char*code, unsigned wid,
*/
extern void compile_event(char*label, char*type,
unsigned argc, struct symb_s*argv);
extern void compile_named_event(char*label, char*type);
/*
* A code statement is a label, an opcode and up to 3 operands. There
@ -248,6 +249,12 @@ extern void compile_net(char*label, char*name,
/*
* $Log: compile.h,v $
* Revision 1.42 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.41 2002/03/18 00:19:34 steve
* Add the .ufunc statement.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: event.cc,v 1.5 2002/03/17 03:24:34 steve Exp $"
#ident "$Id: event.cc,v 1.6 2002/05/18 02:34:11 steve Exp $"
#endif
# include "event.h"
@ -91,7 +91,8 @@ void event_functor_s::set(vvp_ipoint_t ptr, bool, unsigned val, unsigned)
** Create an event functor
** edge: compile_event(label, type, argc, argv)
** or: compile_event(label, NULL, argc, argv)
** name: compile_event(label, name, NULL, NULL)
**
** Named events are handled elsewhere.
*/
void compile_event(char*label, char*type,
@ -109,10 +110,6 @@ void compile_event(char*label, char*type,
assert(argc <= 4 || edge == vvp_edge_none);
}
if (!argc && type) {
// "type" is the name of the named event
}
free(type);
@ -144,8 +141,33 @@ void compile_event(char*label, char*type,
free(argv);
}
/*
* This handles the compile of named events. This functor has no
* inputs, it is only accessed by behavioral trigger statements, which
* in vvp are %set instructions.
*/
void compile_named_event(char*label, char*name)
{
functor_t obj = new event_functor_s(vvp_edge_none);
vvp_ipoint_t fdx = functor_allocate(1);
functor_define(fdx, obj);
define_functor_symbol(label, fdx);
vpiHandle vpi = vpip_make_named_event(name);
vpip_attach_to_current_scope(vpi);
free(label);
}
/*
* $Log: event.cc,v $
* Revision 1.6 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.5 2002/03/17 03:24:34 steve
* Clean up edge detection code.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.45 2002/03/31 04:06:49 steve Exp $"
#ident "$Id: parse.y,v 1.46 2002/05/18 02:34:11 steve Exp $"
#endif
# include "parse_misc.h"
@ -244,7 +244,7 @@ statement
{ compile_event($1, $3, $5.cnt, $5.vect); }
| T_LABEL K_EVENT T_STRING ';'
{ compile_event($1, $3, 0, 0); }
{ compile_named_event($1, $3); }
| T_LABEL K_EVENT_OR symbols ';'
{ compile_event($1, 0, $3.cnt, $3.vect); }
@ -550,6 +550,12 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.46 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.45 2002/03/31 04:06:49 steve
* Update for newer bison.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_callback.cc,v 1.15 2002/05/09 03:34:31 steve Exp $"
#ident "$Id: vpi_callback.cc,v 1.16 2002/05/18 02:34:11 steve Exp $"
#endif
/*
@ -237,7 +237,11 @@ static void make_sync_run(vvp_gen_event_t obj, unsigned char)
struct __vpiCallback*cur = cb->handle;
cur->cb_data.time->type = vpiSimTime;
vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime());
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_RWSYNC;
(cur->cb_data.cb_rtn)(&cur->cb_data);
vpi_mode_flag = VPI_MODE_NONE;
vpi_free_object(&cur->base);
}
@ -297,6 +301,9 @@ void vpiPresim() {
* Walk the list of register callbacks, executing them and
* freeing them when done.
*/
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_RWSYNC;
while (EndOfCompile) {
cur = EndOfCompile;
EndOfCompile = cur->next;
@ -310,6 +317,8 @@ void vpiPresim() {
(cur->cb_data.cb_rtn)(&cur->cb_data);
vpi_free_object(&cur->base);
}
vpi_mode_flag = VPI_MODE_NONE;
}
void vpiPostsim() {
@ -318,12 +327,17 @@ void vpiPostsim() {
/*
* Walk the list of register callbacks
*/
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_ROSYNC;
while (EndOfSimulation) {
cur = EndOfSimulation;
EndOfSimulation = cur->next;
(cur->cb_data.cb_rtn)(&cur->cb_data);
vpi_free_object(&cur->base);
}
vpi_mode_flag = VPI_MODE_NONE;
}
static struct __vpiCallback* make_prepost(p_cb_data data)
@ -420,10 +434,15 @@ void callback_functor_s::set(vvp_ipoint_t, bool, unsigned val, unsigned)
fprintf(stderr, "vpi_callback: value format %d not supported\n", cur->cb_data.value->format);
}
}
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_RWSYNC;
cur->cb_data.time->type = vpiSimTime;
vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime());
(cur->cb_data.cb_rtn)(&cur->cb_data);
vpi_mode_flag = VPI_MODE_NONE;
}
}
@ -431,6 +450,12 @@ void callback_functor_s::set(vvp_ipoint_t, bool, unsigned val, unsigned)
/*
* $Log: vpi_callback.cc,v $
* Revision 1.16 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.15 2002/05/09 03:34:31 steve
* Handle null time and calltf pointers.
*

77
vvp/vpi_event.cc Normal file
View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2002 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_event.cc,v 1.1 2002/05/18 02:34:11 steve Exp $"
#endif
# include "vpi_priv.h"
# include "functor.h"
# include <stdio.h>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <stdlib.h>
# include <string.h>
# include <assert.h>
struct __vpiNamedEvent {
struct __vpiHandle base;
/* base name of the event object */
char*name;
/* Parent scope of this object. */
struct __vpiScope*scope;
};
static const struct __vpirt vpip_named_event_rt = {
vpiNamedEvent,
0,
0,
0,
0,
0,
0,
0,
0
};
vpiHandle vpip_make_named_event(char*name)
{
struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)
malloc(sizeof(struct __vpiNamedEvent));
obj->base.vpi_type = &vpip_named_event_rt;
obj->name = name;
obj->scope = vpip_peek_current_scope();
return &obj->base;
}
/*
* $Log: vpi_event.cc,v $
* Revision 1.1 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
*/

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_modules.cc,v 1.10 2002/03/05 05:31:52 steve Exp $"
#ident "$Id: vpi_modules.cc,v 1.11 2002/05/18 02:34:11 steve Exp $"
#endif
# include "config.h"
@ -130,14 +130,21 @@ void vpip_load_module(const char*name)
return;
}
vpi_mode_flag = VPI_MODE_REGISTER;
vlog_startup_routines_t*routines = (vlog_startup_routines_t*)table;
for (unsigned tmp = 0 ; routines[tmp] ; tmp += 1)
(routines[tmp])();
vpi_mode_flag = VPI_MODE_NONE;
}
/*
* $Log: vpi_modules.cc,v $
* Revision 1.11 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.10 2002/03/05 05:31:52 steve
* Better linker error messages.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_priv.cc,v 1.14 2002/05/03 15:44:11 steve Exp $"
#ident "$Id: vpi_priv.cc,v 1.15 2002/05/18 02:34:11 steve Exp $"
#endif
# include "vpi_priv.h"
@ -30,6 +30,8 @@
#endif
# include <stdlib.h>
vpi_mode_t vpi_mode_flag = VPI_MODE_NONE;
/*
* When a task is called, this value is set so that vpi_handle can
* fathom the vpi_handle(vpiSysTfCall,0) function.
@ -157,6 +159,13 @@ static vpiHandle vpi_iterate_global(int type)
vpiHandle vpi_iterate(int type, vpiHandle ref)
{
assert(vpi_mode_flag != VPI_MODE_NONE);
if (vpi_mode_flag == VPI_MODE_REGISTER) {
fprintf(stderr, "vpi error: vpi_iterate called during "
"vpi_register_systf. You can't do that!\n");
return 0;
}
if (ref == 0)
return vpi_iterate_global(type);
@ -190,6 +199,12 @@ extern "C" void vpi_sim_vcontrol(int operation, va_list ap)
/*
* $Log: vpi_priv.cc,v $
* Revision 1.15 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.14 2002/05/03 15:44:11 steve
* Add vpiModule iterator to vpiScope objects.
*
@ -219,24 +234,5 @@ extern "C" void vpi_sim_vcontrol(int operation, va_list ap)
*
* Revision 1.6 2001/06/21 22:54:12 steve
* Support cbValueChange callbacks.
*
* Revision 1.5 2001/06/12 03:53:11 steve
* Change the VPI call process so that loaded .vpi modules
* use a function table instead of implicit binding.
*
* Revision 1.4 2001/06/10 16:47:49 steve
* support scan of scope from VPI.
*
* Revision 1.3 2001/04/03 03:46:14 steve
* VPI access time as a decimal string, and
* stub vpi access to the scopes.
*
* Revision 1.2 2001/03/19 01:55:38 steve
* Add support for the vpiReset sim control.
*
* Revision 1.1 2001/03/16 01:44:34 steve
* Add structures for VPI support, and all the %vpi_call
* instruction. Get linking of VPI modules to work.
*
*/

View File

@ -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.34 2002/05/17 04:12:19 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.35 2002/05/18 02:34:11 steve Exp $"
#endif
# include "vpi_user.h"
@ -33,6 +33,25 @@
*/
/*
* The vpi_mode_flag contains the major mode for VPI use. This is used
* to generate error messages whe vpi functions are called
* incorrectly.
*/
enum vpi_mode_t {
VPI_MODE_NONE =0,
/* The compiler is calling a register function. */
VPI_MODE_REGISTER,
/* The compiler is calling a compiletf function. */
VPI_MODE_COMPILETF,
/* The compiler is calling a calltf function. */
VPI_MODE_CALLTF,
/* We are in the midst of a RWSync callback. */
VPI_MODE_RWSYNC,
/* We are in a ROSync callback. */
VPI_MODE_ROSYNC
};
extern vpi_mode_t vpi_mode_flag;
/*
* This structure is the very base of a vpiHandle. Every handle
@ -131,6 +150,13 @@ extern vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
extern vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
vvp_fvector_t vec);
/*
* These methods support the vpi creation of events. The name string
* passed in will be saved, so the caller must allocate it (or not
* free it) after it is handed to this function.
*/
extern vpiHandle vpip_make_named_event(char*name);
/*
* Memory is an array of bits that is accessible in N-bit chunks, with
* N being the width of a word. The memory word handle just points
@ -300,6 +326,12 @@ extern void vpip_oct_str_to_bits(unsigned char*bits, unsigned nbits,
/*
* $Log: vpi_priv.h,v $
* Revision 1.35 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.34 2002/05/17 04:12:19 steve
* Rewire vpiMemory and vpiMemoryWord handles to
* support proper iteration of words, and the

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_scope.cc,v 1.14 2002/05/10 16:00:57 steve Exp $"
#ident "$Id: vpi_scope.cc,v 1.15 2002/05/18 02:34:11 steve Exp $"
#endif
# include "compile.h"
@ -35,6 +35,8 @@ static unsigned vpip_root_table_cnt = 0;
vpiHandle vpip_make_root_iterator(void)
{
assert(vpip_root_table_ptr);
assert(vpip_root_table_cnt);
return vpip_make_iterator(vpip_root_table_cnt,
vpip_root_table_ptr, false);
}
@ -136,6 +138,7 @@ static vpiHandle module_iter(int code, vpiHandle obj)
in this scope. */
case vpiMemory:
case vpiModule:
case vpiNamedEvent:
case vpiNet:
case vpiReg:
return module_iter_subset(code, ref);
@ -381,6 +384,12 @@ void vpip_attach_to_current_scope(vpiHandle obj)
/*
* $Log: vpi_scope.cc,v $
* Revision 1.15 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.14 2002/05/10 16:00:57 steve
* Support scope iterate over vpiNet,vpiReg/vpiMemory.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vpi_tasks.cc,v 1.13 2002/05/09 03:34:31 steve Exp $"
#ident "$Id: vpi_tasks.cc,v 1.14 2002/05/18 02:34:11 steve Exp $"
#endif
/*
@ -279,9 +279,13 @@ vpiHandle vpip_build_vpi_call(const char*name, unsigned vbit, unsigned vwid,
/* If there is a compiletf function, call it here. */
if (obj->defn->info.compiletf) {
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_COMPILETF;
vpip_cur_task = obj;
obj->defn->info.compiletf (obj->defn->info.user_data);
vpip_cur_task = 0;
vpi_mode_flag = VPI_MODE_NONE;
}
return &obj->base;
@ -305,8 +309,12 @@ void vpip_execute_vpi_call(vthread_t thr, vpiHandle ref)
vpip_cur_task = (struct __vpiSysTaskCall*)ref;
if (vpip_cur_task->defn->info.calltf)
if (vpip_cur_task->defn->info.calltf) {
assert(vpi_mode_flag == VPI_MODE_NONE);
vpi_mode_flag = VPI_MODE_CALLTF;
vpip_cur_task->defn->info.calltf(vpip_cur_task->defn->info.user_data);
vpi_mode_flag = VPI_MODE_NONE;
}
}
/*
@ -335,6 +343,12 @@ void vpi_register_systf(const struct t_vpi_systf_data*ss)
/*
* $Log: vpi_tasks.cc,v $
* Revision 1.14 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.13 2002/05/09 03:34:31 steve
* Handle null time and calltf pointers.
*