Add simulator event callbacks.
This commit is contained in:
parent
fb457128bf
commit
f23aec7f14
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#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
|
#endif
|
||||||
|
|
||||||
# include "schedule.h"
|
# include "schedule.h"
|
||||||
|
|
@ -280,10 +280,16 @@ static vvp_time64_t schedule_time;
|
||||||
vvp_time64_t schedule_simtime(void)
|
vvp_time64_t schedule_simtime(void)
|
||||||
{ return schedule_time; }
|
{ return schedule_time; }
|
||||||
|
|
||||||
|
extern void vpiPresim();
|
||||||
|
extern void vpiPostsim();
|
||||||
|
|
||||||
void schedule_simulate(void)
|
void schedule_simulate(void)
|
||||||
{
|
{
|
||||||
schedule_time = 0;
|
schedule_time = 0;
|
||||||
|
|
||||||
|
// Execute pre-simulation callbacks
|
||||||
|
vpiPresim();
|
||||||
|
|
||||||
while (schedule_runnable && sched_list) {
|
while (schedule_runnable && sched_list) {
|
||||||
|
|
||||||
/* Pull the first item off the list. Fixup the last
|
/* Pull the first item off the list. Fixup the last
|
||||||
|
|
@ -358,12 +364,17 @@ void schedule_simulate(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Execute post-simulation callbacks
|
||||||
|
vpiPostsim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: schedule.cc,v $
|
* $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
|
* Revision 1.16 2002/04/20 04:33:23 steve
|
||||||
* Support specified times in cbReadOnlySync, and
|
* Support specified times in cbReadOnlySync, and
|
||||||
* add support for cbReadWriteSync.
|
* add support for cbReadWriteSync.
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#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
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -270,6 +270,64 @@ static struct __vpiCallback* make_sync(p_cb_data data, bool readonly_flag)
|
||||||
return obj;
|
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)
|
vpiHandle vpi_register_cb(p_cb_data data)
|
||||||
{
|
{
|
||||||
struct __vpiCallback*obj = 0;
|
struct __vpiCallback*obj = 0;
|
||||||
|
|
@ -288,6 +346,12 @@ vpiHandle vpi_register_cb(p_cb_data data)
|
||||||
obj = make_sync(data, false);
|
obj = make_sync(data, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case cbEndOfCompile:
|
||||||
|
case cbStartOfSimulation:
|
||||||
|
case cbEndOfSimulation:
|
||||||
|
obj = make_prepost(data);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "vpi error: vpi_register_cb invalid or "
|
fprintf(stderr, "vpi error: vpi_register_cb invalid or "
|
||||||
"unsupported callback reason: %d\n",
|
"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 $
|
* $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
|
* Revision 1.12 2002/04/20 04:33:23 steve
|
||||||
* Support specified times in cbReadOnlySync, and
|
* Support specified times in cbReadOnlySync, and
|
||||||
* add support for cbReadWriteSync.
|
* add support for cbReadWriteSync.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue