2001-03-11 01:29:38 +01:00
|
|
|
#ifndef __schedule_H
|
|
|
|
|
#define __schedule_H
|
|
|
|
|
/*
|
2003-09-09 02:56:45 +02:00
|
|
|
* Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com)
|
2001-03-11 01:29:38 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2005-01-29 18:53:25 +01:00
|
|
|
#ident "$Id: schedule.h,v 1.18 2005/01/29 17:53:25 steve Exp $"
|
2001-03-11 01:29:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "vthread.h"
|
|
|
|
|
# include "pointers.h"
|
2004-12-11 03:31:25 +01:00
|
|
|
# include "vvp_net.h"
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2001-03-11 23:42:11 +01:00
|
|
|
/*
|
|
|
|
|
* This causes a thread to be scheduled for execution. The schedule
|
|
|
|
|
* puts the event into the event queue after any existing events for a
|
|
|
|
|
* given time step. The delay is a relative time.
|
2002-05-13 01:44:41 +02:00
|
|
|
*
|
|
|
|
|
* If the delay is zero, the push_flag can be used to force the event
|
|
|
|
|
* to the front of the queue. %fork uses this to get the thread
|
|
|
|
|
* execution ahead of non-blocking assignments.
|
2001-03-11 23:42:11 +01:00
|
|
|
*/
|
2003-09-09 02:56:45 +02:00
|
|
|
extern void schedule_vthread(vthread_t thr, vvp_time64_t delay,
|
2002-05-13 01:44:41 +02:00
|
|
|
bool push_flag =false);
|
2001-03-11 01:29:38 +01:00
|
|
|
|
2001-03-11 23:42:11 +01:00
|
|
|
/*
|
|
|
|
|
* Create an assignment event. The val passed here will be assigned to
|
2005-01-29 18:53:25 +01:00
|
|
|
* the specified input when the delay times out. This is scheduled
|
|
|
|
|
* like a non-blocking assignment. This is in fact mostly used to
|
|
|
|
|
* implement the non-blocking assignment.
|
2001-03-11 23:42:11 +01:00
|
|
|
*/
|
2004-12-11 03:31:25 +01:00
|
|
|
extern void schedule_assign_vector(vvp_net_ptr_t ptr,
|
|
|
|
|
vvp_vector4_t val,
|
|
|
|
|
vvp_time64_t delay);
|
2001-03-11 23:42:11 +01:00
|
|
|
|
2005-01-29 18:53:25 +01:00
|
|
|
/*
|
|
|
|
|
* This is very similar to schedule_assign_vector, but generates an
|
|
|
|
|
* even in the active queue. It is used at link time to set an initial
|
|
|
|
|
* value (a compile time constant) to the input of a functor. This
|
|
|
|
|
* creates an event in the active queue.
|
|
|
|
|
*/
|
|
|
|
|
extern void schedule_set_vector(vvp_net_ptr_t ptr, vvp_vector4_t val);
|
|
|
|
|
|
2001-05-02 03:38:13 +02:00
|
|
|
|
2001-05-01 03:09:39 +02:00
|
|
|
/*
|
2001-05-02 03:38:13 +02:00
|
|
|
* Create a generic event. This supports scheduled events that are not
|
|
|
|
|
* any of the specific types above. The vvp_get_event_t points to a
|
|
|
|
|
* function to be executed when the scheduler gets to the event. It is
|
|
|
|
|
* up to the user to allocate/free the vvp_get_event_s object. The
|
|
|
|
|
* object is never referenced by the scheduler after the run method is
|
|
|
|
|
* called.
|
2001-05-01 03:09:39 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
typedef struct vvp_gen_event_s *vvp_gen_event_t;
|
|
|
|
|
|
|
|
|
|
extern void schedule_generic(vvp_gen_event_t obj, unsigned char val,
|
2003-09-09 02:56:45 +02:00
|
|
|
vvp_time64_t delay, bool sync_flag);
|
2001-05-01 03:09:39 +02:00
|
|
|
|
|
|
|
|
struct vvp_gen_event_s
|
|
|
|
|
{
|
2001-07-11 04:27:21 +02:00
|
|
|
void (*run)(vvp_gen_event_t obj, unsigned char val);
|
2001-05-01 03:09:39 +02:00
|
|
|
};
|
|
|
|
|
|
2001-03-11 23:42:11 +01:00
|
|
|
/*
|
2001-03-19 02:55:38 +01:00
|
|
|
* This runs the simulator. It runs until all the functors run out or
|
|
|
|
|
* the simulation is otherwise finished.
|
2001-03-11 23:42:11 +01:00
|
|
|
*/
|
2001-03-11 01:29:38 +01:00
|
|
|
extern void schedule_simulate(void);
|
|
|
|
|
|
2001-03-31 21:00:43 +02:00
|
|
|
/*
|
2003-02-10 00:33:26 +01:00
|
|
|
* Get the current absolute simulation time. This is not used
|
2001-03-31 21:00:43 +02:00
|
|
|
* internally by the scheduler (which uses time differences instead)
|
|
|
|
|
* but is used for printouts and stuff.
|
|
|
|
|
*/
|
2002-04-20 06:33:23 +02:00
|
|
|
extern vvp_time64_t schedule_simtime(void);
|
2001-03-31 21:00:43 +02:00
|
|
|
|
2001-03-19 02:55:38 +01:00
|
|
|
/*
|
2003-02-10 00:33:26 +01:00
|
|
|
* This function is the equivalent of the $finish system task. It
|
2001-03-19 02:55:38 +01:00
|
|
|
* 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);
|
2003-02-21 04:40:35 +01:00
|
|
|
extern void schedule_stop(int rc);
|
2001-03-19 02:55:38 +01:00
|
|
|
extern bool schedule_finished(void);
|
2003-02-22 03:52:06 +01:00
|
|
|
extern bool schedule_stopped(void);
|
2001-03-19 02:55:38 +01:00
|
|
|
|
2003-02-21 04:40:35 +01:00
|
|
|
/*
|
|
|
|
|
* The scheduler calls this function to process stop events. When this
|
|
|
|
|
* function returns, the simulation resumes.
|
|
|
|
|
*/
|
|
|
|
|
extern void stop_handler(int rc);
|
|
|
|
|
|
2003-01-07 00:57:26 +01:00
|
|
|
/*
|
|
|
|
|
* These are event counters for the sake of performance measurements.
|
|
|
|
|
*/
|
|
|
|
|
extern unsigned long count_assign_events;
|
|
|
|
|
extern unsigned long count_gen_events;
|
|
|
|
|
extern unsigned long count_prop_events;
|
|
|
|
|
extern unsigned long count_thread_events;
|
|
|
|
|
extern unsigned long count_event_pool;
|
2001-03-19 02:55:38 +01:00
|
|
|
|
2001-03-11 01:29:38 +01:00
|
|
|
/*
|
|
|
|
|
* $Log: schedule.h,v $
|
2005-01-29 18:53:25 +01:00
|
|
|
* Revision 1.18 2005/01/29 17:53:25 steve
|
|
|
|
|
* Use scheduler to initialize constant functor inputs.
|
|
|
|
|
*
|
2004-12-11 03:31:25 +01:00
|
|
|
* Revision 1.17 2004/12/11 02:31:30 steve
|
|
|
|
|
* Rework of internals to carry vectors through nexus instead
|
|
|
|
|
* of single bits. Make the ivl, tgt-vvp and vvp initial changes
|
|
|
|
|
* down this path.
|
|
|
|
|
*
|
2003-09-09 02:56:45 +02:00
|
|
|
* Revision 1.16 2003/09/09 00:56:45 steve
|
|
|
|
|
* Reimpelement scheduler to divide nonblocking assign queue out.
|
|
|
|
|
*
|
2003-02-22 03:52:06 +01:00
|
|
|
* Revision 1.15 2003/02/22 02:52:06 steve
|
|
|
|
|
* Check for stopped flag in certain strategic points.
|
2001-03-11 01:29:38 +01:00
|
|
|
*/
|
|
|
|
|
#endif
|