From 78dda42493397916b1e10c7fb308f198e0a45c5a Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 15 Dec 2004 17:17:42 +0000 Subject: [PATCH] Add the force/v instruction. --- vvp/codes.h | 7 +++++-- vvp/compile.cc | 9 ++++++-- vvp/force.cc | 56 ++++--------------------------------------------- vvp/opcodes.txt | 27 ++++++++++++------------ vvp/vthread.cc | 33 ++++++++++++++++++++++++++++- 5 files changed, 62 insertions(+), 70 deletions(-) diff --git a/vvp/codes.h b/vvp/codes.h index b6012d618..f0f0d5d89 100644 --- a/vvp/codes.h +++ b/vvp/codes.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: codes.h,v 1.67 2004/12/11 02:31:29 steve Exp $" +#ident "$Id: codes.h,v 1.68 2004/12/15 17:17:42 steve Exp $" #endif @@ -65,7 +65,7 @@ extern bool of_DIV(vthread_t thr, vvp_code_t code); extern bool of_DIV_S(vthread_t thr, vvp_code_t code); extern bool of_DIV_WR(vthread_t thr, vvp_code_t code); extern bool of_END(vthread_t thr, vvp_code_t code); -extern bool of_FORCE(vthread_t thr, vvp_code_t code); +extern bool of_FORCE_V(vthread_t thr, vvp_code_t code); extern bool of_FORK(vthread_t thr, vvp_code_t code); extern bool of_INV(vthread_t thr, vvp_code_t code); extern bool of_IX_ADD(vthread_t thr, vvp_code_t code); @@ -168,6 +168,9 @@ extern vvp_code_t codespace_null(void); /* * $Log: codes.h,v $ + * Revision 1.68 2004/12/15 17:17:42 steve + * Add the force/v instruction. + * * Revision 1.67 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 diff --git a/vvp/compile.cc b/vvp/compile.cc index e0b255d84..167f95479 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.176 2004/12/11 02:31:29 steve Exp $" +#ident "$Id: compile.cc,v 1.177 2004/12/15 17:17:42 steve Exp $" #endif # include "arith.h" @@ -112,7 +112,7 @@ const static struct opcode_table_s opcode_table[] = { { "%div/s", of_DIV_S, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%div/wr", of_DIV_WR, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%end", of_END, 0, {OA_NONE, OA_NONE, OA_NONE} }, - { "%force", of_FORCE, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} }, + { "%force/v",of_FORCE_V,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} }, { "%inv", of_INV, 2, {OA_BIT1, OA_BIT2, OA_NONE} }, { "%ix/add", of_IX_ADD, 2, {OA_BIT1, OA_NUMBER, OA_NONE} }, { "%ix/get", of_IX_GET, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, @@ -1259,6 +1259,7 @@ void compile_code(char*label, char*mnem, comp_operands_t opa) sizeof(struct opcode_table_s), &opcode_compare); if (op == 0) { yyerror("Invalid opcode"); + compile_errors += 1; return; } @@ -1271,6 +1272,7 @@ void compile_code(char*label, char*mnem, comp_operands_t opa) if (op->argc != (opa? opa->argc : 0)) { yyerror("operand count"); + compile_errors += 1; return; } @@ -1560,6 +1562,9 @@ void compile_param_string(char*label, char*name, char*str, char*value) /* * $Log: compile.cc,v $ + * Revision 1.177 2004/12/15 17:17:42 steve + * Add the force/v instruction. + * * Revision 1.176 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 diff --git a/vvp/force.cc b/vvp/force.cc index 9de6ad9bf..fd23cb06e 100644 --- a/vvp/force.cc +++ b/vvp/force.cc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: force.cc,v 1.9 2004/12/11 02:31:29 steve Exp $" +#ident "$Id: force.cc,v 1.10 2004/12/15 17:17:42 steve Exp $" #endif # include "codes.h" @@ -96,57 +96,6 @@ static bool release_force(vvp_ipoint_t itgt, functor_t tgt) return false; } -/* - * The %force instruction causes the referenced force functor[s] to - * interpose themselves in front of the precompiled target - * functors. The operand of the %force is the label of the force - * functor, and the width of the functor array. - */ -bool of_FORCE(vthread_t thr, vvp_code_t cp) -{ -#if 0 - unsigned wid = cp->bit_idx[0]; - - for (unsigned i=0; iiptr, i); - functor_t fofu = functor_index(ifofu); - force_functor_s *ff = dynamic_cast(fofu); - - assert(ff); - - if (ff->active) - return true; - - ff->active = 1; - - // tgt is the functor who's output I plan to force. The - // compiler stored the target pointer is the out pointer - // of the force functor. (The out pointer is not - // otherwise used.) - vvp_ipoint_t itgt = fofu->out; - functor_t tgt = functor_index(itgt); - - // This turns OFF the target functor's output - // driver. If it is already off, then detach the - // previous force before continuing. - if (tgt->disable(itgt)) - release_force(itgt, tgt); - - // Link the functor as the first functor driven by the - // target. This allows the functor to track the unforced - // drive value, and also aids in releasing the force. - fofu->port[3] = tgt->out; - tgt->out = ipoint_make(ifofu, 3); - - // Set the value to cause the overridden functor to take - // on its forced value. - fofu->set(ifofu, false, fofu->get_oval(), fofu->get_ostr()); - } -#else - fprintf(stderr, "XXXX forgot how to implement %%force\n"); -#endif - return true; -} /* * The %release instruction causes any force functors driving the @@ -222,6 +171,9 @@ bool var_functor_s::deassign(vvp_ipoint_t itgt) /* * $Log: force.cc,v $ + * Revision 1.10 2004/12/15 17:17:42 steve + * Add the force/v instruction. + * * Revision 1.9 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 diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index b79c94e7a..f36ba74fa 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com) * - * $Id: opcodes.txt,v 1.56 2004/12/11 02:31:29 steve Exp $ + * $Id: opcodes.txt,v 1.57 2004/12/15 17:17:42 steve Exp $ */ @@ -135,12 +135,8 @@ out, then this function is a no-op. Perform a continuous assign of a constant value to the target variable. This is similar to %set, but it uses the cassign port (port-1) of the signal functor instead of the normal assign, so the -signal responds differently. - -* %deassign - -Deactivate and disconnect a procedural continuous assignment to a -variable. The identifies the affected variable. +signal responds differently. See "VARIABLE STATEMENTS" in the +README.txt file. * %cmp/u , , @@ -203,6 +199,11 @@ The %cvt/vr opcode converts a real word to a thread vector starting at and with the width . Non-integer precision is lost in the conversion. +* %deassign + +Deactivate and disconnect a procedural continuous assignment to a +variable. The identifies the affected variable. + * %delay This opcode pauses the thread, and causes it to be rescheduled for a @@ -240,13 +241,13 @@ This opcode divides the left operand by the right operand. If the right operand is 0, then the result is NaN. -* %force , - -Activate a force represented by the force functors , which -were created with a .force directive. If any force was active on the -signal, that force is released first. A vector of force functors may -be specified with greater than 1. +* %force/v