2001-11-06 04:07:21 +01:00
|
|
|
#ifndef __event_H
|
|
|
|
|
#define __event_H
|
|
|
|
|
/*
|
2004-12-18 19:52:44 +01:00
|
|
|
* Copyright (c) 2004 Stephen Williams (steve@icarus.com)
|
2001-11-06 04:07:21 +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
|
2006-12-09 20:06:53 +01:00
|
|
|
#ident "$Id: event.h,v 1.13 2006/12/09 19:06:53 steve Exp $"
|
2001-11-06 04:07:21 +01:00
|
|
|
#endif
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
# include "vvp_net.h"
|
|
|
|
|
# include "pointers.h"
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Event / edge detection functors
|
|
|
|
|
*/
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/*
|
|
|
|
|
* A "waitable" functor is one that the %wait instruction can wait
|
|
|
|
|
* on. This includes the infrastructure needed to hold threads.
|
|
|
|
|
*/
|
|
|
|
|
struct waitable_hooks_s {
|
2004-12-18 19:52:44 +01:00
|
|
|
|
2005-06-18 01:47:02 +02:00
|
|
|
public:
|
|
|
|
|
waitable_hooks_s() : threads(0) { }
|
2004-12-11 03:31:25 +01:00
|
|
|
vthread_t threads;
|
2004-12-18 19:52:44 +01:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
void run_waiting_threads_();
|
2001-11-06 04:07:21 +01:00
|
|
|
};
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/*
|
|
|
|
|
* The vvp_fun_edge functor detects events that are edges of various
|
|
|
|
|
* types. This should be hooked to a vvp_net_t that is connected to
|
|
|
|
|
* the output of a signal that we wish to watch for edges.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_edge : public vvp_net_fun_t, public waitable_hooks_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
typedef unsigned short edge_t;
|
2006-11-22 07:10:05 +01:00
|
|
|
explicit vvp_fun_edge(edge_t e, bool debug_flag);
|
2004-12-11 03:31:25 +01:00
|
|
|
|
|
|
|
|
virtual ~vvp_fun_edge();
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
private:
|
2004-12-30 00:45:13 +01:00
|
|
|
vvp_bit4_t bits_[4];
|
2004-12-11 03:31:25 +01:00
|
|
|
edge_t edge_;
|
2006-11-22 07:10:05 +01:00
|
|
|
bool debug_;
|
2004-12-11 03:31:25 +01:00
|
|
|
};
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
extern const vvp_fun_edge::edge_t vvp_edge_posedge;
|
|
|
|
|
extern const vvp_fun_edge::edge_t vvp_edge_negedge;
|
|
|
|
|
extern const vvp_fun_edge::edge_t vvp_edge_none;
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-30 00:45:13 +01:00
|
|
|
/*
|
|
|
|
|
* The vvp_fun_anyedge functor checks to see if any value in an input
|
|
|
|
|
* vector changes. Unlike the vvp_fun_edge, which watches for the LSB
|
|
|
|
|
* of its inputs to change in a particular direction, the anyedge
|
|
|
|
|
* functor looks at the entire input vector for any change.
|
2006-12-09 20:06:53 +01:00
|
|
|
*
|
|
|
|
|
* The anyedge is also different in that it can receive real
|
|
|
|
|
* values. in this case, any detectable change in the real value leads
|
|
|
|
|
* to an even trigger.
|
2004-12-30 00:45:13 +01:00
|
|
|
*/
|
|
|
|
|
class vvp_fun_anyedge : public vvp_net_fun_t, public waitable_hooks_s {
|
|
|
|
|
|
|
|
|
|
public:
|
2006-11-22 07:10:05 +01:00
|
|
|
explicit vvp_fun_anyedge(bool debug_flag);
|
2004-12-30 00:45:13 +01:00
|
|
|
virtual ~vvp_fun_anyedge();
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2006-12-09 20:06:53 +01:00
|
|
|
void recv_real(vvp_net_ptr_t port, double bit);
|
2004-12-30 00:45:13 +01:00
|
|
|
|
|
|
|
|
private:
|
2006-11-22 07:10:05 +01:00
|
|
|
bool debug_;
|
2004-12-30 00:45:13 +01:00
|
|
|
vvp_vector4_t bits_[4];
|
2006-12-09 20:06:53 +01:00
|
|
|
// In case I'm a real-valued event.
|
|
|
|
|
double bitsr_[4];
|
2004-12-30 00:45:13 +01:00
|
|
|
};
|
|
|
|
|
|
2005-05-25 07:44:51 +02:00
|
|
|
/*
|
|
|
|
|
* This functor triggers anytime any input is set, no matter what the
|
|
|
|
|
* value. This is similar to a named event, but it has no handle.
|
|
|
|
|
*/
|
|
|
|
|
class vvp_fun_event_or : public vvp_net_fun_t, public waitable_hooks_s {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit vvp_fun_event_or();
|
|
|
|
|
~vvp_fun_event_or();
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2005-05-25 07:44:51 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
};
|
|
|
|
|
|
2002-05-19 07:18:16 +02:00
|
|
|
/*
|
2004-12-18 19:52:44 +01:00
|
|
|
* A named event is simpler then a vvp_fun_edge in that it triggers on
|
|
|
|
|
* any input at all to port-0. The idea here is that behavioral code
|
|
|
|
|
* can use a %set/v instruction to trigger the event.
|
2002-05-19 07:18:16 +02:00
|
|
|
*/
|
2004-12-18 19:52:44 +01:00
|
|
|
class vvp_named_event : public vvp_net_fun_t, public waitable_hooks_s {
|
2002-05-19 07:18:16 +02:00
|
|
|
|
|
|
|
|
public:
|
2004-12-18 19:52:44 +01:00
|
|
|
explicit vvp_named_event(struct __vpiHandle*eh);
|
|
|
|
|
~vvp_named_event();
|
|
|
|
|
|
2005-06-22 02:04:48 +02:00
|
|
|
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
2002-05-19 07:18:16 +02:00
|
|
|
|
2004-12-18 19:52:44 +01:00
|
|
|
private:
|
|
|
|
|
struct __vpiHandle*handle_;
|
2002-05-19 07:18:16 +02:00
|
|
|
};
|
|
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: event.h,v $
|
2006-12-09 20:06:53 +01:00
|
|
|
* Revision 1.13 2006/12/09 19:06:53 steve
|
|
|
|
|
* Handle vpiRealVal reads of signals, and real anyedge events.
|
|
|
|
|
*
|
2006-11-22 07:10:05 +01:00
|
|
|
* Revision 1.12 2006/11/22 06:10:05 steve
|
|
|
|
|
* Fix spurious event from net8 that is forced.
|
|
|
|
|
*
|
2005-06-22 02:04:48 +02:00
|
|
|
* Revision 1.11 2005/06/22 00:04:49 steve
|
|
|
|
|
* Reduce vvp_vector4 copies by using const references.
|
|
|
|
|
*
|
2005-06-18 01:47:02 +02:00
|
|
|
* Revision 1.10 2005/06/17 23:47:02 steve
|
|
|
|
|
* threads member for waitable_hook_s needs initailizing.
|
|
|
|
|
*
|
2005-05-25 07:44:51 +02:00
|
|
|
* Revision 1.9 2005/05/25 05:44:51 steve
|
|
|
|
|
* Handle event/or with specific, efficient nodes.
|
|
|
|
|
*
|
2004-12-30 00:45:13 +01:00
|
|
|
* Revision 1.8 2004/12/29 23:45:13 steve
|
|
|
|
|
* Add the part concatenation node (.concat).
|
|
|
|
|
*
|
|
|
|
|
* Add a vvp_event_anyedge class to handle the special
|
|
|
|
|
* case of .event statements of edge type. This also
|
|
|
|
|
* frees the posedge/negedge types to handle all 4 inputs.
|
|
|
|
|
*
|
|
|
|
|
* Implement table functor recv_vec4 method to receive
|
|
|
|
|
* and process vectors.
|
|
|
|
|
*
|
2004-12-18 19:52:44 +01:00
|
|
|
* Revision 1.7 2004/12/18 18:52:44 steve
|
|
|
|
|
* Rework named events and event/or.
|
|
|
|
|
*
|
2004-12-11 03:31:25 +01:00
|
|
|
* Revision 1.6 2004/12/11 02:31:29 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.
|
2001-11-06 04:07:21 +01:00
|
|
|
*/
|
|
|
|
|
#endif // __event_H
|