Add support for the vpiReset sim control.
This commit is contained in:
parent
d8ef63efd1
commit
f8c3b84f68
|
|
@ -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.2 2001/03/11 22:42:11 steve Exp $"
|
||||
#ident "$Id: schedule.cc,v 1.3 2001/03/19 01:55:38 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "schedule.h"
|
||||
|
|
@ -43,8 +43,27 @@ const unsigned TYPE_THREAD = 0;
|
|||
const unsigned TYPE_PROP = 1;
|
||||
const unsigned TYPE_ASSIGN = 2;
|
||||
|
||||
/*
|
||||
* This is the head of the list of pending events.
|
||||
*/
|
||||
static struct event_s* list = 0;
|
||||
|
||||
/*
|
||||
* This flag is true until a VPI task or function finishes the
|
||||
* simulation.
|
||||
*/
|
||||
static bool schedule_runnable = true;
|
||||
|
||||
void schedule_finish(int)
|
||||
{
|
||||
schedule_runnable = false;
|
||||
}
|
||||
|
||||
bool schedule_finished(void)
|
||||
{
|
||||
return !schedule_runnable;
|
||||
}
|
||||
|
||||
static void schedule_event_(struct event_s*cur)
|
||||
{
|
||||
cur->last = cur;
|
||||
|
|
@ -136,7 +155,7 @@ void schedule_simulate(void)
|
|||
{
|
||||
schedule_time = 0;
|
||||
|
||||
while (list) {
|
||||
while (schedule_runnable && list) {
|
||||
|
||||
/* Pull the first item off the list. Fixup the last
|
||||
pointer in the next cell, if necessary. */
|
||||
|
|
@ -148,7 +167,7 @@ void schedule_simulate(void)
|
|||
|
||||
} else {
|
||||
schedule_time += cur->delay;
|
||||
printf("TIME: %u\n", schedule_time);
|
||||
//printf("TIME: %u\n", schedule_time);
|
||||
}
|
||||
|
||||
switch (cur->type) {
|
||||
|
|
@ -157,7 +176,7 @@ void schedule_simulate(void)
|
|||
break;
|
||||
|
||||
case TYPE_PROP:
|
||||
printf("Propagate %p\n", cur->fun);
|
||||
//printf("Propagate %p\n", cur->fun);
|
||||
functor_propagate(cur->fun);
|
||||
break;
|
||||
|
||||
|
|
@ -173,6 +192,9 @@ void schedule_simulate(void)
|
|||
|
||||
/*
|
||||
* $Log: schedule.cc,v $
|
||||
* Revision 1.3 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
* Revision 1.2 2001/03/11 22:42:11 steve
|
||||
* Functor values and propagation.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: schedule.h,v 1.2 2001/03/11 22:42:11 steve Exp $"
|
||||
#ident "$Id: schedule.h,v 1.3 2001/03/19 01:55:38 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -47,12 +47,29 @@ extern void schedule_assign(vvp_ipoint_t fun, unsigned char val,
|
|||
unsigned delay);
|
||||
|
||||
/*
|
||||
* This runs the simulator. It runs until all the functors run out.
|
||||
* This runs the simulator. It runs until all the functors run out or
|
||||
* the simulation is otherwise finished.
|
||||
*/
|
||||
extern void schedule_simulate(void);
|
||||
|
||||
/*
|
||||
* This function is the equivilent of the $finish system task. It
|
||||
* tells the simulator that simulation is done, the current thread
|
||||
* should be stopped, all remaining events abandoned and the
|
||||
* schedule_simulate() function will return.
|
||||
*
|
||||
* The schedule_finished() function will return true if the
|
||||
* schedule_finish() function has been called.
|
||||
*/
|
||||
extern void schedule_finish(int rc);
|
||||
extern bool schedule_finished(void);
|
||||
|
||||
|
||||
/*
|
||||
* $Log: schedule.h,v $
|
||||
* Revision 1.3 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
* Revision 1.2 2001/03/11 22:42:11 steve
|
||||
* Functor values and propagation.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.cc,v 1.1 2001/03/16 01:44:34 steve Exp $"
|
||||
#ident "$Id: vpi_priv.cc,v 1.2 2001/03/19 01:55:38 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_priv.h"
|
||||
# include "schedule.h"
|
||||
# include <stdio.h>
|
||||
# include <stdarg.h>
|
||||
# include <assert.h>
|
||||
|
|
@ -148,11 +149,21 @@ int vpi_remove_cb(vpiHandle ref)
|
|||
|
||||
void vpi_sim_control(int operation, ...)
|
||||
{
|
||||
assert(0);
|
||||
switch (operation) {
|
||||
case vpiFinish:
|
||||
schedule_finish(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vpi_priv.cc,v $
|
||||
* Revision 1.2 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
* Revision 1.1 2001/03/16 01:44:34 steve
|
||||
* Add structures for VPI support, and all the %vpi_call
|
||||
* instruction. Get linking of VPI modules to work.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vthread.cc,v 1.4 2001/03/16 01:44:34 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.5 2001/03/19 01:55:38 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -55,6 +55,10 @@ void vthread_run(vthread_t thr)
|
|||
thr->pc += 1;
|
||||
|
||||
assert(cp->opcode);
|
||||
|
||||
/* Run the opcode implementation. If the execution of
|
||||
the opcode returns false, then the thread is meant to
|
||||
be paused, so break out of the loop. */
|
||||
bool rc = (cp->opcode)(thr, cp);
|
||||
if (rc == false)
|
||||
return;
|
||||
|
|
@ -63,7 +67,7 @@ void vthread_run(vthread_t thr)
|
|||
|
||||
bool of_ASSIGN(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
printf("thread %p: %%assign\n", thr);
|
||||
//printf("thread %p: %%assign\n", thr);
|
||||
|
||||
unsigned char bit_val = 3;
|
||||
if ((cp->bit_idx2 & ~0x3) == 0x0) {
|
||||
|
|
@ -79,14 +83,14 @@ bool of_ASSIGN(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
bool of_DELAY(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
printf("thread %p: %%delay %lu\n", thr, cp->number);
|
||||
//printf("thread %p: %%delay %lu\n", thr, cp->number);
|
||||
schedule_vthread(thr, cp->number);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool of_END(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
printf("thread %p: %%end\n", thr);
|
||||
//printf("thread %p: %%end\n", thr);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +101,7 @@ bool of_NOOP(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
bool of_SET(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
printf("thread %p: %%set %u, %u\n", thr, cp->iptr, cp->bit_idx1);
|
||||
//printf("thread %p: %%set %u, %u\n", thr, cp->iptr, cp->bit_idx1);
|
||||
|
||||
unsigned char bit_val = 3;
|
||||
if ((cp->bit_idx1 & ~0x3) == 0x0) {
|
||||
|
|
@ -114,13 +118,16 @@ bool of_SET(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
bool of_VPI_CALL(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
printf("thread %p: %%vpi_call\n", thr);
|
||||
// printf("thread %p: %%vpi_call\n", thr);
|
||||
vpip_execute_vpi_call(cp->handle);
|
||||
return true;
|
||||
return schedule_finished()? false : true;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.5 2001/03/19 01:55:38 steve
|
||||
* Add support for the vpiReset sim control.
|
||||
*
|
||||
* Revision 1.4 2001/03/16 01:44:34 steve
|
||||
* Add structures for VPI support, and all the %vpi_call
|
||||
* instruction. Get linking of VPI modules to work.
|
||||
|
|
|
|||
Loading…
Reference in New Issue