Add the force/v instruction.

This commit is contained in:
steve 2004-12-15 17:17:42 +00:00
parent 36f36bd2ac
commit 78dda42493
5 changed files with 62 additions and 70 deletions

View File

@ -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

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.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

View File

@ -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; i<wid; i++) {
vvp_ipoint_t ifofu = ipoint_index(cp->iptr, i);
functor_t fofu = functor_index(ifofu);
force_functor_s *ff = dynamic_cast<force_functor_s *>(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

View File

@ -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 <var-label>
Deactivate and disconnect a procedural continuous assignment to a
variable. The <var-label> identifies the affected variable.
signal responds differently. See "VARIABLE STATEMENTS" in the
README.txt file.
* %cmp/u <bit-l>, <bit-r>, <wid>
@ -203,6 +199,11 @@ The %cvt/vr opcode converts a real word <bit-r> to a thread vector
starting at <bit-l> and with the width <wid>. Non-integer precision is
lost in the conversion.
* %deassign <var-label>
Deactivate and disconnect a procedural continuous assignment to a
variable. The <var-label> identifies the affected variable.
* %delay <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 <fofu-label>, <width>
Activate a force represented by the force functors <fofu-label>, 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 <width> greater than 1.
* %force/v <label>, <bit>, <wid>
Force a constant value to the target variable. This is similar to %set
and %cassign/v, but it uses the force port (port-2) of the signal
functor instead of the normal assign port (port-0), so the signal
responds differently. See "VARIABLE STATEMENTS" and "NET STATEMENTS"
in the README.txt file.
* %fork <code-label>, <scope-label>

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.123 2004/12/11 02:31:30 steve Exp $"
#ident "$Id: vthread.cc,v 1.124 2004/12/15 17:17:42 steve Exp $"
#endif
# include "config.h"
@ -1424,6 +1424,34 @@ bool of_END(vthread_t thr, vvp_code_t)
return false;
}
/*
* The %force/v instruction invokes a force assign of a constant value
* to a signal. The instruction arguments are:
*
* %force/v <net>, <base>, <wid> ;
*
* where the <net> is the net label assembled into a vvp_net pointer,
* and the <base> and <wid> are stashed in the bit_idx array.
*
* The instruction writes a vvp_vector4_t value to port-2 of the
* target signal.
*/
bool of_FORCE_V(vthread_t thr, vvp_code_t cp)
{
vvp_net_t*net = cp->net;
unsigned base = cp->bit_idx[0];
unsigned wid = cp->bit_idx[1];
/* Collect the thread bits into a vector4 item. */
vvp_vector4_t value = vthread_bits_to_vector(thr, base, wid);
/* set the value into port 1 of the destination. */
vvp_net_ptr_t ptr (net, 2);
vvp_send_vec4(ptr, value);
return true;
}
/*
* The %fork instruction causes a new child to be created and pushed
* in front of any existing child. This causes the new child to be the
@ -2979,6 +3007,9 @@ bool of_JOIN_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.124 2004/12/15 17:17:42 steve
* Add the force/v instruction.
*
* Revision 1.123 2004/12/11 02:31:30 steve
* Rework of internals to carry vectors through nexus instead
* of single bits. Make the ivl, tgt-vvp and vvp initial changes