Handle event/or with specific, efficient nodes.

This commit is contained in:
steve 2005-05-25 05:44:51 +00:00
parent 015d280c6a
commit aa2e178667
3 changed files with 77 additions and 12 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: compile.cc,v 1.202 2005/05/24 01:43:27 steve Exp $"
#ident "$Id: compile.cc,v 1.203 2005/05/25 05:44:51 steve Exp $"
#endif
# include "arith.h"
@ -36,6 +36,7 @@
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <iostream.h>
# include <stdlib.h>
# include <string.h>
# include <assert.h>
@ -765,6 +766,9 @@ void input_connect(vvp_net_t*fdx, unsigned port, char*label)
void inputs_connect(vvp_net_t*fdx, unsigned argc, struct symb_s*argv)
{
if (argc > 4) {
cerr << "XXXX argv[0] = " << argv[0].text << endl;
}
assert(argc <= 4);
for (unsigned idx = 0; idx < argc; idx += 1) {
@ -1543,6 +1547,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/*
* $Log: compile.cc,v $
* Revision 1.203 2005/05/25 05:44:51 steve
* Handle event/or with specific, efficient nodes.
*
* Revision 1.202 2005/05/24 01:43:27 steve
* Add a sign-extension node.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: event.cc,v 1.17 2004/12/29 23:45:13 steve Exp $"
#ident "$Id: event.cc,v 1.18 2005/05/25 05:44:51 steve Exp $"
#endif
# include "event.h"
@ -130,6 +130,21 @@ void vvp_fun_anyedge::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
}
}
vvp_fun_event_or::vvp_fun_event_or()
{
}
vvp_fun_event_or::~vvp_fun_event_or()
{
}
void vvp_fun_event_or::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
{
run_waiting_threads_();
vvp_net_t*net = port.ptr();
vvp_send_vec4(net->out, bit);
}
vvp_named_event::vvp_named_event(struct __vpiHandle*h)
{
handle_ = h;
@ -154,12 +169,19 @@ void vvp_named_event::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
** Named events are handled elsewhere.
*/
static void compile_event_or(char*label, unsigned argc, struct symb_s*argv);
void compile_event(char*label, char*type,
unsigned argc, struct symb_s*argv)
{
vvp_net_fun_t*fun = 0;
if (type && (strcmp(type,"edge") == 0) ) {
if (type == 0) {
compile_event_or(label, argc, argv);
return;
}
if (strcmp(type,"edge") == 0) {
free(type);
fun = new vvp_fun_anyedge;
@ -168,15 +190,13 @@ void compile_event(char*label, char*type,
vvp_fun_edge::edge_t edge = vvp_edge_none;
if (type) {
if (strcmp(type,"posedge") == 0)
edge = vvp_edge_posedge;
else if (strcmp(type,"negedge") == 0)
edge = vvp_edge_negedge;
if (strcmp(type,"posedge") == 0)
edge = vvp_edge_posedge;
else if (strcmp(type,"negedge") == 0)
edge = vvp_edge_negedge;
assert(argc <= 4);
free(type);
}
assert(argc <= 4);
free(type);
fun = new vvp_fun_edge(edge);
}
@ -190,6 +210,23 @@ void compile_event(char*label, char*type,
inputs_connect(ptr, argc, argv);
}
static void compile_event_or(char*label, unsigned argc, struct symb_s*argv)
{
vvp_net_fun_t*fun = new vvp_fun_event_or;
vvp_net_t* ptr = new vvp_net_t;
ptr->fun = fun;
define_functor_symbol(label, ptr);
free(label);
/* This is a very special case. Point all the source inputs to
the same input. It doesn't matter that the streams get
tangled because data values are irrelevant. */
for (unsigned idx = 0 ; idx < argc ; idx += 1) {
input_connect(ptr, 0, argv[idx].text);
}
}
/*
* This handles the compile of named events. This functor has no
* inputs, it is only accessed by behavioral trigger statements, which
@ -212,6 +249,9 @@ void compile_named_event(char*label, char*name)
/*
* $Log: event.cc,v $
* Revision 1.18 2005/05/25 05:44:51 steve
* Handle event/or with specific, efficient nodes.
*
* Revision 1.17 2004/12/29 23:45:13 steve
* Add the part concatenation node (.concat).
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: event.h,v 1.8 2004/12/29 23:45:13 steve Exp $"
#ident "$Id: event.h,v 1.9 2005/05/25 05:44:51 steve Exp $"
#endif
# include "vvp_net.h"
@ -83,6 +83,21 @@ class vvp_fun_anyedge : public vvp_net_fun_t, public waitable_hooks_s {
vvp_vector4_t bits_[4];
};
/*
* 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();
void recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit);
private:
};
/*
* 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
@ -103,6 +118,9 @@ class vvp_named_event : public vvp_net_fun_t, public waitable_hooks_s {
/*
* $Log: event.h,v $
* Revision 1.9 2005/05/25 05:44:51 steve
* Handle event/or with specific, efficient nodes.
*
* Revision 1.8 2004/12/29 23:45:13 steve
* Add the part concatenation node (.concat).
*