VPI Access to named events.

This commit is contained in:
steve 2003-04-23 03:09:25 +00:00
parent 3aa3d03397
commit 54ea845f34
4 changed files with 49 additions and 18 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.cc,v 1.159 2003/04/11 05:15:38 steve Exp $"
#ident "$Id: compile.cc,v 1.160 2003/04/23 03:09:25 steve Exp $"
#endif
# include "arith.h"
@ -224,17 +224,28 @@ static vvp_ipoint_t lookup_functor_symbol(const char*label)
static vvp_ipoint_t ipoint_lookup(const char *label, unsigned idx)
{
/* First, look to see if the symbol is a signal, whether net
or reg. If so, get the correct bit out. */
/* First, look to see if the symbol is a vpi object of some
sort. If it is, then get the vvp_ipoint_t pointer out of
the vpiHandle. */
symbol_value_t val = sym_get_value(sym_vpi, label);
if (val.ptr) {
vpiHandle vpi = (vpiHandle) val.ptr;
assert((vpi->vpi_type->type_code == vpiNet)
|| (vpi->vpi_type->type_code == vpiReg)
|| (vpi->vpi_type->type_code == vpiIntegerVar));
switch (vpi->vpi_type->type_code) {
case vpiNet:
case vpiReg:
case vpiIntegerVar: {
__vpiSignal*sig = (__vpiSignal*)vpi;
return vvp_fvector_get(sig->bits, idx);
}
__vpiSignal*sig = (__vpiSignal*)vpi;
return vvp_fvector_get(sig->bits, idx);
case vpiNamedEvent: {
__vpiNamedEvent*tmp = (__vpiNamedEvent*)vpi;
return tmp->funct;
}
default:
assert(0);
}
}
/* Failing that, look for a general functor. */
@ -1530,6 +1541,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/*
* $Log: compile.cc,v $
* Revision 1.160 2003/04/23 03:09:25 steve
* VPI Access to named events.
*
* Revision 1.159 2003/04/11 05:15:38 steve
* Add signed versions of .cmp/gt/ge
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: event.cc,v 1.11 2003/01/06 23:57:26 steve Exp $"
#ident "$Id: event.cc,v 1.12 2003/04/23 03:09:25 steve Exp $"
#endif
# include "event.h"
@ -174,14 +174,19 @@ void compile_event(char*label, char*type,
*/
void compile_named_event(char*label, char*name)
{
named_event_functor_s* obj = new named_event_functor_s;
named_event_functor_s* fp = new named_event_functor_s;
vvp_ipoint_t fdx = functor_allocate(1);
functor_define(fdx, obj);
define_functor_symbol(label, fdx);
functor_define(fdx, fp);
obj->handle = vpip_make_named_event(name);
vpip_attach_to_current_scope(obj->handle);
vpiHandle obj = vpip_make_named_event(name, fdx);
/* The event needs a back pointer so that triggers to the
event functor (%set) can access the callbacks. */
fp->handle = obj;
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
free(label);
free(name);
@ -189,6 +194,9 @@ void compile_named_event(char*label, char*name)
/*
* $Log: event.cc,v $
* Revision 1.12 2003/04/23 03:09:25 steve
* VPI Access to named events.
*
* Revision 1.11 2003/01/06 23:57:26 steve
* Schedule wait lists of threads as a single event,
* to save on events. Also, improve efficiency of

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_event.cc,v 1.7 2003/03/06 04:32:00 steve Exp $"
#ident "$Id: vpi_event.cc,v 1.8 2003/04/23 03:09:25 steve Exp $"
#endif
# include "vpi_priv.h"
@ -86,7 +86,7 @@ static const struct __vpirt vpip_named_event_rt = {
0
};
vpiHandle vpip_make_named_event(const char*name)
vpiHandle vpip_make_named_event(const char*name, vvp_ipoint_t funct)
{
struct __vpiNamedEvent*obj = (struct __vpiNamedEvent*)
malloc(sizeof(struct __vpiNamedEvent));
@ -94,6 +94,7 @@ vpiHandle vpip_make_named_event(const char*name)
obj->base.vpi_type = &vpip_named_event_rt;
obj->name = vpip_name_string(name);
obj->scope = vpip_peek_current_scope();
obj->funct = funct;
obj->callbacks = 0;
return &obj->base;
@ -115,6 +116,9 @@ void vpip_run_named_event_callbacks(vpiHandle ref)
/*
* $Log: vpi_event.cc,v $
* Revision 1.8 2003/04/23 03:09:25 steve
* VPI Access to named events.
*
* Revision 1.7 2003/03/06 04:32:00 steve
* Use hashed name strings for identifiers.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_priv.h,v 1.52 2003/03/10 23:37:07 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.53 2003/04/23 03:09:25 steve Exp $"
#endif
# include "vpi_user.h"
@ -198,11 +198,13 @@ struct __vpiNamedEvent {
const char*name;
/* Parent scope of this object. */
struct __vpiScope*scope;
/* The functor, used for %set operations. */
vvp_ipoint_t funct;
/* List of callbacks interested in this event. */
struct __vpiCallback*callbacks;
};
extern vpiHandle vpip_make_named_event(const char*name);
extern vpiHandle vpip_make_named_event(const char*name, vvp_ipoint_t f);
extern void vpip_run_named_event_callbacks(vpiHandle ref);
extern void vpip_real_value_change(struct __vpiCallback*cbh,
vpiHandle ref);
@ -413,6 +415,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/*
* $Log: vpi_priv.h,v $
* Revision 1.53 2003/04/23 03:09:25 steve
* VPI Access to named events.
*
* Revision 1.52 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*