Add simulator event callbacks.

This commit is contained in:
steve 2002-05-04 03:03:17 +00:00
parent fb457128bf
commit f23aec7f14
2 changed files with 81 additions and 3 deletions

View File

@ -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.16 2002/04/20 04:33:23 steve Exp $"
#ident "$Id: schedule.cc,v 1.17 2002/05/04 03:03:17 steve Exp $"
#endif
# include "schedule.h"
@ -280,10 +280,16 @@ static vvp_time64_t schedule_time;
vvp_time64_t schedule_simtime(void)
{ return schedule_time; }
extern void vpiPresim();
extern void vpiPostsim();
void schedule_simulate(void)
{
schedule_time = 0;
// Execute pre-simulation callbacks
vpiPresim();
while (schedule_runnable && sched_list) {
/* Pull the first item off the list. Fixup the last
@ -358,12 +364,17 @@ void schedule_simulate(void)
break;
}
}
// Execute post-simulation callbacks
vpiPostsim();
}
/*
* $Log: schedule.cc,v $
* Revision 1.17 2002/05/04 03:03:17 steve
* Add simulator event callbacks.
*
* Revision 1.16 2002/04/20 04:33:23 steve
* Support specified times in cbReadOnlySync, and
* add support for cbReadWriteSync.

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.12 2002/04/20 04:33:23 steve Exp $"
#ident "$Id: vpi_callback.cc,v 1.13 2002/05/04 03:03:17 steve Exp $"
#endif
/*
@ -270,6 +270,64 @@ static struct __vpiCallback* make_sync(p_cb_data data, bool readonly_flag)
return obj;
}
/*
* The following functions are the used for pre and post simulation
* callbacks.
*/
static struct __vpiCallback*EndOfCompile = NULL;
static struct __vpiCallback*StartOfSimulation = NULL;
static struct __vpiCallback*EndOfSimulation = NULL;
void vpiPresim() {
struct __vpiCallback* cur;
/*
* Walk the list of register callbacks
*/
for (cur = EndOfCompile; cur != NULL; cur = cur->next) {
(cur->cb_data.cb_rtn)(&cur->cb_data);
}
for (cur = StartOfSimulation; cur != NULL; cur = cur->next) {
(cur->cb_data.cb_rtn)(&cur->cb_data);
}
}
void vpiPostsim() {
struct __vpiCallback* cur;
/*
* Walk the list of register callbacks
*/
for (cur = EndOfSimulation; cur != NULL; cur = cur->next) {
(cur->cb_data.cb_rtn)(&cur->cb_data);
}
}
static struct __vpiCallback* make_prepost(p_cb_data data)
{
struct __vpiCallback*obj = new_vpi_callback();
obj->cb_data = *data;
/* Insert at head of list */
switch (data->reason) {
case cbEndOfCompile:
obj->next = EndOfCompile;
EndOfCompile = obj;
break;
case cbStartOfSimulation:
obj->next = StartOfSimulation;
StartOfSimulation = obj;
break;
case cbEndOfSimulation:
obj->next = EndOfSimulation;
EndOfSimulation = obj;
break;
}
return obj;
}
vpiHandle vpi_register_cb(p_cb_data data)
{
struct __vpiCallback*obj = 0;
@ -288,6 +346,12 @@ vpiHandle vpi_register_cb(p_cb_data data)
obj = make_sync(data, false);
break;
case cbEndOfCompile:
case cbStartOfSimulation:
case cbEndOfSimulation:
obj = make_prepost(data);
break;
default:
fprintf(stderr, "vpi error: vpi_register_cb invalid or "
"unsupported callback reason: %d\n",
@ -345,6 +409,9 @@ void callback_functor_s::set(vvp_ipoint_t, bool, unsigned val, unsigned)
/*
* $Log: vpi_callback.cc,v $
* Revision 1.13 2002/05/04 03:03:17 steve
* Add simulator event callbacks.
*
* Revision 1.12 2002/04/20 04:33:23 steve
* Support specified times in cbReadOnlySync, and
* add support for cbReadWriteSync.