Support named events as mode 2 functors.

This commit is contained in:
steve 2001-03-29 03:46:36 +00:00
parent 522d0ec864
commit 609d5fe727
7 changed files with 85 additions and 12 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.9 2001/03/26 04:00:39 steve Exp $
* $Id: README.txt,v 1.10 2001/03/29 03:46:36 steve Exp $
*/
VVP SIMULATION ENGINE
@ -197,8 +197,8 @@ through .event objects, that are declare like so:
<label> .event "name";
This event statement declares an object that a %waitfor instruction
can take as an operand. When a thread executes a %waitfor, it puts
This event statement declares an object that a %wait instruction
can take as an operand. When a thread executes a %wait, it puts
itself in the notification list of the event and suspends. The
<symbols_list> is a set of inputs that can trigger the event.
@ -207,6 +207,15 @@ may be posedge, negedge or edge. If the type is instead a "name"
string, then this is a named event which receives events by the %set
instruction instead of from the output of a functor.
If the event has inputs (a requirement unless it is a named event)
then it has up to 4 symbols that address functors. The event then
detects the appropriate edge on any of the inputs and signals when the
event is true. Normally (in Verilog) a posedge or negedge event only
watches a single bit, so the generated code would only include a
single symbol for the addressed bit. However, if there are several
events of the same edge in an event OR expression, the compiler may
combine up to 4 into a single event.
THREAD STATEMENTS:

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.17 2001/03/28 17:24:32 steve Exp $"
#ident "$Id: compile.cc,v 1.18 2001/03/29 03:46:36 steve Exp $"
#endif
# include "compile.h"
@ -316,6 +316,28 @@ void compile_event(char*label, char*type,
free(label);
}
void compile_named_event(char*label, char*name)
{
vvp_ipoint_t fdx = functor_allocate(1);
functor_t obj = functor_index(fdx);
{ symbol_value_t val;
val.num = fdx;
sym_set_value(sym_functors, label, val);
}
obj->ival = 0xaa;
obj->oval = 2;
obj->mode = 2;
obj->event = (struct vvp_event_s*) malloc(sizeof (struct vvp_event_s));
obj->event->threads = 0;
obj->event->ival = obj->ival;
free(label);
free(name);
}
/*
* The parser uses this function to compile an link an executable
* opcode. I do this by looking up the opcode in the opcode_table. The
@ -663,6 +685,9 @@ void compile_dump(FILE*fd)
/*
* $Log: compile.cc,v $
* Revision 1.18 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.17 2001/03/28 17:24:32 steve
* include string.h for strcmp et al.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.h,v 1.11 2001/03/26 04:00:39 steve Exp $"
#ident "$Id: compile.h,v 1.12 2001/03/29 03:46:36 steve Exp $"
#endif
# include <stdio.h>
@ -74,6 +74,8 @@ extern vpiHandle compile_vpi_lookup(const char*label);
extern void compile_event(char*label, char*type,
unsigned argc, struct symb_s*argv);
extern void compile_named_event(char*label, char*name);
/*
* A code statement is a label, an opcode and up to 3 operands. There
* are a few lexical types that the parser recognizes of the operands,
@ -132,6 +134,9 @@ extern void compile_dump(FILE*fd);
/*
* $Log: compile.h,v $
* Revision 1.12 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.11 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.cc,v 1.7 2001/03/26 04:00:39 steve Exp $"
#ident "$Id: functor.cc,v 1.8 2001/03/29 03:46:36 steve Exp $"
#endif
# include "functor.h"
@ -189,6 +189,21 @@ static void functor_set_mode1(functor_t fp)
ep->ival = fp->ival;
}
/*
* A mode-2 functor is a named event. In this case, any set at all is
* enough to trigger the blocked threads.
*/
static void functor_set_mode2(functor_t fp)
{
vvp_event_t ep = fp->event;
if (ep->threads) {
vthread_t tmp = ep->threads;
ep->threads = 0;
vthread_schedule_list(tmp);
}
}
/*
* Set the addressed bit of the functor, and recalculate the
* output. If the output changes any, then generate the necessary
@ -213,6 +228,9 @@ void functor_set(vvp_ipoint_t ptr, unsigned bit)
case 1:
functor_set_mode1(fp);
break;
case 2:
functor_set_mode2(fp);
break;
}
}
@ -282,6 +300,9 @@ const unsigned char ft_var[16] = {
/*
* $Log: functor.cc,v $
* Revision 1.8 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.7 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: functor.h,v 1.6 2001/03/26 04:00:39 steve Exp $"
#ident "$Id: functor.h,v 1.7 2001/03/29 03:46:36 steve Exp $"
#endif
# include "pointers.h"
@ -70,7 +70,7 @@ struct functor_s {
/* These are the input values. */
unsigned char ival;
unsigned char oval;
/* functor mode: 0 == table ; 1 == event */
/* functor mode: 0 == table ; 1 == event ; 2 == named event */
unsigned char mode;
};
@ -144,6 +144,9 @@ extern const unsigned char ft_var[];
/*
* $Log: functor.h,v $
* Revision 1.7 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.6 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.13 2001/03/26 04:00:39 steve Exp $"
#ident "$Id: parse.y,v 1.14 2001/03/29 03:46:36 steve Exp $"
#endif
# include "parse_misc.h"
@ -107,13 +107,17 @@ statement
{ compile_functor($1, $3, $5, 0, 0); }
/* Event statements take a label, a type (the first T_SYMBOL) and a
list of inputs. */
list of inputs. If the type is instead a string, then we have a
named event instead. */
| T_LABEL K_EVENT T_SYMBOL ',' symbols ';'
{ struct symbv_s obj = $5;
compile_event($1, $3, obj.cnt, obj.vect);
}
| T_LABEL K_EVENT T_STRING ';'
{ compile_named_event($1, $3); }
/* Instructions may have a label, and have zero or more
operands. The meaning of and restrictions on the operands depends
on the specific instruction. */
@ -303,6 +307,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.14 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.13 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*

View File

@ -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.12 2001/03/26 04:00:39 steve Exp $"
#ident "$Id: vthread.cc,v 1.13 2001/03/29 03:46:36 steve Exp $"
#endif
# include "vthread.h"
@ -268,7 +268,7 @@ bool of_VPI_CALL(vthread_t thr, vvp_code_t cp)
bool of_WAIT(vthread_t thr, vvp_code_t cp)
{
functor_t fp = functor_index(cp->iptr);
assert(fp->mode == 1);
assert((fp->mode == 1) || (fp->mode == 2));
vvp_event_t ep = fp->event;
thr->next = ep->threads;
ep->threads = thr;
@ -278,6 +278,9 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.13 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.12 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*