diff --git a/vvp/README.txt b/vvp/README.txt index 0f87c475a..a00d55561 100644 --- a/vvp/README.txt +++ b/vvp/README.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: README.txt,v 1.44 2003/04/11 05:15:38 steve Exp $ + * $Id: README.txt,v 1.45 2003/09/04 20:26:30 steve Exp $ */ VVP SIMULATION ENGINE @@ -537,13 +537,22 @@ Thread statements create the initial threads for a simulation. These represent the initial and always blocks, and possibly other causes to create threads at startup. - .thread + .thread [, ] This statement creates a thread with a starting address at the -instruction given by . +instruction given by . When the simulation starts, a thread is +created for the .thread statement, and it starts at the +addressed instruction. +The modifies the creation/execution behavior of the +thread. Supported flags are: -THREADS IN GENERAL: + $push -- Cause the thread to be pushed in the scheduler. This + only effects startup (time 0) by arranging for pushed + threads to be started before non-pushed threads. This + is useful for resolving time-0 races. + +* Threads in general Thread statements create the initial threads of a design. These include the ``initial'' and ``always'' statements of the original @@ -575,7 +584,7 @@ parent, and %end in the child. Without this proper matching, the hierarchical relationships can get confused. The behavior of erroneous code is undefined. -THREADS AND SCOPES: +* Threads and scopes The Verilog ``disable'' statement deserves some special mention because of how it interacts with threads. In particular, threads diff --git a/vvp/compile.cc b/vvp/compile.cc index ff71b8998..aea1f94a7 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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.169 2003/07/30 01:13:28 steve Exp $" +#ident "$Id: compile.cc,v 1.170 2003/09/04 20:26:31 steve Exp $" #endif # include "arith.h" @@ -1456,8 +1456,10 @@ void compile_vpi_func_call(char*label, char*name, * with the start address referenced by the program symbol passed to * me. */ -void compile_thread(char*start_sym) +void compile_thread(char*start_sym, char*flag) { + bool push_flag = false; + symbol_value_t tmp = sym_get_value(sym_codespace, start_sym); vvp_code_t pc = reinterpret_cast(tmp.ptr); if (pc == 0) { @@ -1465,9 +1467,15 @@ void compile_thread(char*start_sym) return; } + if (flag && (strcmp(flag,"$push") == 0)) + push_flag = true; + vthread_t thr = vthread_new(pc, vpip_peek_current_scope()); - schedule_vthread(thr, 0); + schedule_vthread(thr, 0, push_flag); + free(start_sym); + if (flag != 0) + free(flag); } /* @@ -1539,6 +1547,9 @@ void compile_param_string(char*label, char*name, char*str, char*value) /* * $Log: compile.cc,v $ + * Revision 1.170 2003/09/04 20:26:31 steve + * Add $push flag for threads. + * * Revision 1.169 2003/07/30 01:13:28 steve * Add support for triand and trior. * diff --git a/vvp/compile.h b/vvp/compile.h index 04d12ee09..f4caeee59 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: compile.h,v 1.52 2003/05/29 02:21:45 steve Exp $" +#ident "$Id: compile.h,v 1.53 2003/09/04 20:26:31 steve Exp $" #endif # include @@ -250,7 +250,7 @@ extern void compile_scope_recall(char*sym); * The parser uses this function to declare a thread. The start_sym is * the start instruction, and must already be defined. */ -extern void compile_thread(char*start_sym); +extern void compile_thread(char*start_sym, char*flag); /* * This function is called to create a var vector with the given name. @@ -264,6 +264,9 @@ extern void compile_net(char*label, char*name, /* * $Log: compile.h,v $ + * Revision 1.53 2003/09/04 20:26:31 steve + * Add $push flag for threads. + * * Revision 1.52 2003/05/29 02:21:45 steve * Implement acc_fetch_defname and its infrastructure in vvp. * diff --git a/vvp/parse.y b/vvp/parse.y index a9bea104b..dbd776bff 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: parse.y,v 1.55 2003/08/22 23:14:27 steve Exp $" +#ident "$Id: parse.y,v 1.56 2003/09/04 20:26:31 steve Exp $" #endif # include "parse_misc.h" @@ -345,10 +345,14 @@ statement { compile_timescale(-$3); } /* Thread statements declare a thread with its starting address. The - starting address must already be defined. */ + starting address must already be defined. The .thread statement + may also take an optional flag word. */ | K_THREAD T_SYMBOL ';' - { compile_thread($2); } + { compile_thread($2, 0); } + + | K_THREAD T_SYMBOL ',' T_SYMBOL ';' + { compile_thread($2, $4); } /* Var statements declare a bit of a variable. This also implicitly creates a functor with the same name that acts as the output of @@ -613,6 +617,9 @@ int compile_design(const char*path) /* * $Log: parse.y,v $ + * Revision 1.56 2003/09/04 20:26:31 steve + * Add $push flag for threads. + * * Revision 1.55 2003/08/22 23:14:27 steve * Preserve variable ranges all the way to the vpi. *