Check for stopped flag in certain strategic points.

This commit is contained in:
steve 2003-02-22 02:52:06 +00:00
parent 2de0597038
commit 19c6bd2139
3 changed files with 48 additions and 13 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: schedule.cc,v 1.23 2003/02/21 03:40:35 steve Exp $"
#ident "$Id: schedule.cc,v 1.24 2003/02/22 02:52:06 steve Exp $"
#endif
# include "schedule.h"
@ -135,7 +135,7 @@ static struct event_s* synch_list = 0;
* simulation.
*/
static bool schedule_runnable = true;
static bool schedule_stopped = false;
static bool schedule_stopped_flag = false;
void schedule_finish(int)
{
@ -144,7 +144,7 @@ void schedule_finish(int)
void schedule_stop(int)
{
schedule_stopped = true;
schedule_stopped_flag = true;
}
bool schedule_finished(void)
@ -152,13 +152,18 @@ bool schedule_finished(void)
return !schedule_runnable;
}
bool schedule_stopped(void)
{
return schedule_stopped_flag;
}
/*
* These are the signal handling infrastructure. The SIGINT signal
* leads to an implicit $stop.
*/
static void signals_handler(int)
{
schedule_stopped = true;
schedule_stopped_flag = true;
}
static void signals_capture(void)
@ -365,8 +370,8 @@ void schedule_simulate(void)
while (schedule_runnable && sched_list) {
if (schedule_stopped) {
schedule_stopped = false;
if (schedule_stopped_flag) {
schedule_stopped_flag = false;
stop_handler(0);
continue;
}
@ -474,6 +479,9 @@ void schedule_simulate(void)
/*
* $Log: schedule.cc,v $
* Revision 1.24 2003/02/22 02:52:06 steve
* Check for stopped flag in certain strategic points.
*
* Revision 1.23 2003/02/21 03:40:35 steve
* Add vpiStop and interactive mode.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: schedule.h,v 1.14 2003/02/21 03:40:35 steve Exp $"
#ident "$Id: schedule.h,v 1.15 2003/02/22 02:52:06 steve Exp $"
#endif
# include "vthread.h"
@ -90,6 +90,7 @@ extern vvp_time64_t schedule_simtime(void);
extern void schedule_finish(int rc);
extern void schedule_stop(int rc);
extern bool schedule_finished(void);
extern bool schedule_stopped(void);
/*
* The scheduler calls this function to process stop events. When this
@ -108,6 +109,9 @@ extern unsigned long count_event_pool;
/*
* $Log: schedule.h,v $
* Revision 1.15 2003/02/22 02:52:06 steve
* Check for stopped flag in certain strategic points.
*
* Revision 1.14 2003/02/21 03:40:35 steve
* Add vpiStop and interactive mode.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.101 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: vthread.cc,v 1.102 2003/02/22 02:52:06 steve Exp $"
#endif
# include "vthread.h"
@ -1420,28 +1420,48 @@ bool of_IX_GET(vthread_t thr, vvp_code_t cp)
bool of_JMP(vthread_t thr, vvp_code_t cp)
{
thr->pc = cp->cptr;
return true;
/* Normally, this returns true so that the processor just
keeps going to the next instruction. However, if there was
a $stop or vpiStop, returning false here can break the
simulation out of a hung loop. */
return ! schedule_stopped();
}
bool of_JMP0(vthread_t thr, vvp_code_t cp)
{
if (thr_get_bit(thr, cp->bit_idx[0]) == 0)
thr->pc = cp->cptr;
return true;
/* Normally, this returns true so that the processor just
keeps going to the next instruction. However, if there was
a $stop or vpiStop, returning false here can break the
simulation out of a hung loop. */
return ! schedule_stopped();
}
bool of_JMP0XZ(vthread_t thr, vvp_code_t cp)
{
if (thr_get_bit(thr, cp->bit_idx[0]) != 1)
thr->pc = cp->cptr;
return true;
/* Normally, this returns true so that the processor just
keeps going to the next instruction. However, if there was
a $stop or vpiStop, returning false here can break the
simulation out of a hung loop. */
return ! schedule_stopped();
}
bool of_JMP1(vthread_t thr, vvp_code_t cp)
{
if (thr_get_bit(thr, cp->bit_idx[0]) == 1)
thr->pc = cp->cptr;
return true;
/* Normally, this returns true so that the processor just
keeps going to the next instruction. However, if there was
a $stop or vpiStop, returning false here can break the
simulation out of a hung loop. */
return ! schedule_stopped();
}
/*
@ -2481,7 +2501,7 @@ bool of_VPI_CALL(vthread_t thr, vvp_code_t cp)
{
// printf("thread %p: %%vpi_call\n", thr);
vpip_execute_vpi_call(thr, cp->handle);
return schedule_finished()? false : true;
return (schedule_finished() || schedule_stopped())? false : true;
}
/*
@ -2616,6 +2636,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.102 2003/02/22 02:52:06 steve
* Check for stopped flag in certain strategic points.
*
* Revision 1.101 2003/02/09 23:33:26 steve
* Spelling fixes.
*