diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 8c0f35dfd..9a5747ac0 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_callback.cc,v 1.26 2003/02/09 23:33:26 steve Exp $" +#ident "$Id: vpi_callback.cc,v 1.27 2003/02/10 05:20:10 steve Exp $" #endif /* @@ -218,6 +218,10 @@ static struct __vpiCallback* make_value_change(p_cb_data data) sig->callback->cb_handle = obj; break; + case vpiRealVar: + vpip_real_value_change(obj, data->obj); + break; + case vpiNamedEvent: struct __vpiNamedEvent*nev; nev = reinterpret_cast<__vpiNamedEvent*>(data->obj); @@ -530,6 +534,9 @@ void callback_functor_s::set(vvp_ipoint_t, bool, unsigned val, unsigned) /* * $Log: vpi_callback.cc,v $ + * Revision 1.27 2003/02/10 05:20:10 steve + * Add value change callbacks to real variables. + * * Revision 1.26 2003/02/09 23:33:26 steve * Spelling fixes. * diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index a7cc56e5a..0216abd57 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -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.47 2003/02/09 23:33:26 steve Exp $" +#ident "$Id: vpi_priv.h,v 1.48 2003/02/10 05:20:10 steve Exp $" #endif # include "vpi_user.h" @@ -202,6 +202,8 @@ struct __vpiNamedEvent { extern vpiHandle vpip_make_named_event(const char*name); extern void vpip_run_named_event_callbacks(vpiHandle ref); +extern void vpip_real_value_change(struct __vpiCallback*cbh, + vpiHandle ref); /* * Memory is an array of bits that is accessible in N-bit chunks, with @@ -395,6 +397,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type); /* * $Log: vpi_priv.h,v $ + * Revision 1.48 2003/02/10 05:20:10 steve + * Add value change callbacks to real variables. + * * Revision 1.47 2003/02/09 23:33:26 steve * Spelling fixes. * diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 342d141af..22d6467bb 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -17,10 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_real.cc,v 1.4 2003/02/04 04:03:40 steve Exp $" +#ident "$Id: vpi_real.cc,v 1.5 2003/02/10 05:20:10 steve Exp $" #endif # include "vpi_priv.h" +# include "schedule.h" # include # include #ifdef HAVE_MALLOC_H @@ -33,8 +34,28 @@ struct __vpiRealVar { struct __vpiHandle base; const char*name; double value; + + struct __vpiCallback*cb; }; +static char* real_var_get_str(int code, vpiHandle ref) +{ + assert(ref->vpi_type->type_code == vpiRealVar); + + struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref; + + switch (code) { + + case vpiName: + return const_cast(rfp->name); + + default: + return 0; + } + + return 0; +} + static void real_var_get_value(vpiHandle ref, s_vpi_value*vp) { assert(ref->vpi_type->type_code == vpiRealVar); @@ -101,6 +122,16 @@ static vpiHandle real_var_put_value(vpiHandle ref, p_vpi_value vp, assert(vp->format == vpiRealVal); rfp->value = vp->value.real; + + for (struct __vpiCallback*cur = rfp->cb ; cur ; cur = cur->next) { + cur->cb_data.time->type = vpiSimTime; + vpip_time_to_timestruct(cur->cb_data.time, schedule_simtime()); + + assert(cur->cb_data.cb_rtn != 0); + + (cur->cb_data.cb_rtn)(&cur->cb_data); + } + return 0; } @@ -108,7 +139,7 @@ static const struct __vpirt vpip_real_var_rt = { vpiRealVar, 0, - 0, + &real_var_get_str, &real_var_get_value, &real_var_put_value, @@ -119,6 +150,14 @@ static const struct __vpirt vpip_real_var_rt = { 0 }; +void vpip_real_value_change(struct __vpiCallback*cbh, + vpiHandle ref) +{ + struct __vpiRealVar*rfp = (struct __vpiRealVar*)ref; + cbh->next = rfp->cb; + rfp->cb = cbh; +} + vpiHandle vpip_make_real_var(const char*name) { struct __vpiRealVar*obj = (struct __vpiRealVar*) @@ -127,12 +166,16 @@ vpiHandle vpip_make_real_var(const char*name) obj->base.vpi_type = &vpip_real_var_rt; obj->name = vpip_string(name); obj->value = 0.0; + obj->cb = 0; return &obj->base; } /* * $Log: vpi_real.cc,v $ + * Revision 1.5 2003/02/10 05:20:10 steve + * Add value change callbacks to real variables. + * * Revision 1.4 2003/02/04 04:03:40 steve * Add hex and binary formatting of real values. *