2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
|
|
|
|
*
|
|
|
|
|
* 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
|
2004-12-11 03:31:25 +01:00
|
|
|
#ident "$Id: event.cc,v 1.15 2004/12/11 02:31:29 steve Exp $"
|
2001-11-06 04:07:21 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "event.h"
|
|
|
|
|
# include "compile.h"
|
|
|
|
|
# include "vthread.h"
|
|
|
|
|
# include "schedule.h"
|
2002-05-19 07:18:16 +02:00
|
|
|
# include "vpi_priv.h"
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
# include <string.h>
|
|
|
|
|
# include <assert.h>
|
2001-11-16 05:22:27 +01:00
|
|
|
# include <stdlib.h>
|
2001-11-06 04:07:21 +01:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
|
# include <malloc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
inline vvp_fun_edge::edge_t VVP_EDGE(vvp_bit4_t from, vvp_bit4_t to)
|
2002-05-19 07:18:16 +02:00
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
return 1 << ((from << 2) | to);
|
2001-11-06 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
const vvp_fun_edge::edge_t vvp_edge_posedge
|
|
|
|
|
= VVP_EDGE(BIT4_0,BIT4_1)
|
|
|
|
|
| VVP_EDGE(BIT4_0,BIT4_X)
|
|
|
|
|
| VVP_EDGE(BIT4_0,BIT4_Z)
|
|
|
|
|
| VVP_EDGE(BIT4_X,BIT4_1)
|
|
|
|
|
| VVP_EDGE(BIT4_Z,BIT4_1)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
const vvp_fun_edge::edge_t vvp_edge_negedge
|
|
|
|
|
= VVP_EDGE(BIT4_1,BIT4_0)
|
|
|
|
|
| VVP_EDGE(BIT4_1,BIT4_X)
|
|
|
|
|
| VVP_EDGE(BIT4_1,BIT4_Z)
|
|
|
|
|
| VVP_EDGE(BIT4_X,BIT4_0)
|
|
|
|
|
| VVP_EDGE(BIT4_Z,BIT4_0)
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
const vvp_fun_edge::edge_t vvp_edge_anyedge = 0x7bde;
|
|
|
|
|
const vvp_fun_edge::edge_t vvp_edge_none = 0;
|
|
|
|
|
|
|
|
|
|
vvp_fun_edge::vvp_fun_edge(edge_t e)
|
|
|
|
|
: edge_(e)
|
2002-07-17 20:30:01 +02:00
|
|
|
{
|
|
|
|
|
threads = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_fun_edge::~vvp_fun_edge()
|
2002-05-19 07:18:16 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
void vvp_fun_edge::recv_vec4(vvp_net_ptr_t port, vvp_vector4_t bit)
|
2002-05-19 07:18:16 +02:00
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
// XXXX for now, only support first port.
|
|
|
|
|
assert(port.port() == 0);
|
|
|
|
|
|
|
|
|
|
/* See what kind of edge this represents. */
|
|
|
|
|
edge_t mask = VVP_EDGE(bits_.value(0), bit.value(0));
|
2002-05-19 07:18:16 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Save the current input for the next time around. */
|
|
|
|
|
bits_ = bit;
|
|
|
|
|
|
|
|
|
|
if (threads && (edge_ & mask)) {
|
2002-05-19 07:18:16 +02:00
|
|
|
vthread_t tmp = threads;
|
|
|
|
|
threads = 0;
|
|
|
|
|
vthread_schedule_list(tmp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
** Create an event functor
|
|
|
|
|
** edge: compile_event(label, type, argc, argv)
|
|
|
|
|
** or: compile_event(label, NULL, argc, argv)
|
2002-05-18 04:34:11 +02:00
|
|
|
**
|
|
|
|
|
** Named events are handled elsewhere.
|
2001-11-06 04:07:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void compile_event(char*label, char*type,
|
|
|
|
|
unsigned argc, struct symb_s*argv)
|
|
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_fun_edge::edge_t edge = vvp_edge_none;
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
if (type) {
|
2001-11-06 04:07:21 +01:00
|
|
|
if (strcmp(type,"posedge") == 0)
|
|
|
|
|
edge = vvp_edge_posedge;
|
|
|
|
|
else if (strcmp(type,"negedge") == 0)
|
|
|
|
|
edge = vvp_edge_negedge;
|
|
|
|
|
else if (strcmp(type,"edge") == 0)
|
|
|
|
|
edge = vvp_edge_anyedge;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
assert(argc <= 4);
|
|
|
|
|
free(type);
|
2001-11-06 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_fun_edge*fun = new vvp_fun_edge(edge);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_net_t* ptr = new vvp_net_t;
|
|
|
|
|
ptr->fun = fun;
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
define_functor_symbol(label, ptr);
|
2001-11-06 04:07:21 +01:00
|
|
|
free(label);
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
inputs_connect(ptr, argc, argv);
|
2001-11-06 04:07:21 +01:00
|
|
|
}
|
|
|
|
|
|
2002-05-18 04:34:11 +02:00
|
|
|
/*
|
|
|
|
|
* This handles the compile of named events. This functor has no
|
|
|
|
|
* inputs, it is only accessed by behavioral trigger statements, which
|
|
|
|
|
* in vvp are %set instructions.
|
|
|
|
|
*/
|
|
|
|
|
void compile_named_event(char*label, char*name)
|
|
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
fprintf(stderr, "XXXX compile_named_event not implemented\n");
|
2002-05-18 04:34:11 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_net_t*fdx = 0;
|
2003-04-23 05:09:25 +02:00
|
|
|
|
|
|
|
|
vpiHandle obj = vpip_make_named_event(name, fdx);
|
2002-05-18 04:34:11 +02:00
|
|
|
|
2003-04-23 05:09:25 +02:00
|
|
|
compile_vpi_symbol(label, obj);
|
|
|
|
|
vpip_attach_to_current_scope(obj);
|
2002-05-18 04:34:11 +02:00
|
|
|
|
|
|
|
|
free(label);
|
2002-07-05 19:14:15 +02:00
|
|
|
free(name);
|
2002-05-18 04:34:11 +02:00
|
|
|
}
|
|
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
* $Log: event.cc,v $
|
2004-12-11 03:31:25 +01:00
|
|
|
* Revision 1.15 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
|
|
|
*
|
|
|
|
|
*/
|