Add vector set and load instructions.

This commit is contained in:
steve 2002-11-07 02:32:39 +00:00
parent 46ee38b466
commit d7ae85a13a
4 changed files with 64 additions and 4 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.51 2002/09/18 04:29:55 steve Exp $"
#ident "$Id: codes.h,v 1.52 2002/11/07 02:32:39 steve Exp $"
#endif
@ -74,6 +74,7 @@ extern bool of_JOIN(vthread_t thr, vvp_code_t code);
extern bool of_LOAD(vthread_t thr, vvp_code_t code);
extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code);
extern bool of_LOAD_NX(vthread_t thr, vvp_code_t code);
extern bool of_LOAD_VEC(vthread_t thr, vvp_code_t code);
extern bool of_LOAD_X(vthread_t thr, vvp_code_t code);
extern bool of_MOD(vthread_t thr, vvp_code_t code);
extern bool of_MOV(vthread_t thr, vvp_code_t code);
@ -89,6 +90,7 @@ extern bool of_ORR(vthread_t thr, vvp_code_t code);
extern bool of_RELEASE(vthread_t thr, vvp_code_t code);
extern bool of_SET(vthread_t thr, vvp_code_t code);
extern bool of_SET_MEM(vthread_t thr, vvp_code_t code);
extern bool of_SET_VEC(vthread_t thr, vvp_code_t code);
extern bool of_SET_X(vthread_t thr, vvp_code_t code);
extern bool of_SHIFTL_I0(vthread_t thr, vvp_code_t code);
extern bool of_SHIFTR_I0(vthread_t thr, vvp_code_t code);
@ -157,6 +159,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/*
* $Log: codes.h,v $
* Revision 1.52 2002/11/07 02:32:39 steve
* Add vector set and load instructions.
*
* Revision 1.51 2002/09/18 04:29:55 steve
* Add support for binary NOR operator.
*

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.143 2002/09/18 04:29:55 steve Exp $"
#ident "$Id: compile.cc,v 1.144 2002/11/07 02:32:39 steve Exp $"
#endif
# include "arith.h"
@ -119,6 +119,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} },
{ "%load/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} },
{ "%load/nx",of_LOAD_NX,3, {OA_BIT1, OA_VPI_PTR, OA_BIT2} },
{ "%load/v", of_LOAD_VEC,3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} },
{ "%load/x", of_LOAD_X, 3, {OA_BIT1, OA_FUNC_PTR, OA_BIT2} },
{ "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@ -134,6 +135,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%release",of_RELEASE,1, {OA_FUNC_PTR, OA_NONE, OA_NONE} },
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%set/m", of_SET_MEM,2, {OA_MEM_PTR, OA_BIT1, OA_NONE} },
{ "%set/v", of_SET_VEC,3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%set/x", of_SET_X, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
{ "%shiftl/i0", of_SHIFTL_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
{ "%shiftr/i0", of_SHIFTR_I0, 2, {OA_BIT1,OA_NUMBER, OA_NONE} },
@ -1480,6 +1482,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: compile.cc,v $
* Revision 1.144 2002/11/07 02:32:39 steve
* Add vector set and load instructions.
*
* Revision 1.143 2002/09/18 04:29:55 steve
* Add support for binary NOR operator.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.42 2002/09/18 04:29:55 steve Exp $
* $Id: opcodes.txt,v 1.43 2002/11/07 02:32:39 steve Exp $
*/
@ -297,6 +297,7 @@ ended, then the %join does not block or yield the thread.
* %load <bit>, <functor-label>
* %load/v <bit>, <functor-label>, <wid>
This instruction loads a value from the given functor output into the
specified thread register bit. The functor-label can refer to a .net,
@ -304,6 +305,8 @@ a .var or a .functor, and may be indexed with array syntax to get at a
functor within a vector of functors. This instruction loads only a
single bit.
THe %load/v instruction is a vector version, that loads an entire
vector, starting at the given <bit> and functor.
* %load/m <bit>, <memory-label>
@ -431,6 +434,7 @@ semantics. Like:
* %set <var-label>, <bit>
* %set/v <var-label>, <bit>, <wid>
This sets a bit of a variable, and is used to implement blocking
assignments. The <label> identifies the variable to receive the new
@ -438,6 +442,11 @@ value. Once the set completes, the value is immediately available to
be read out of the variable. The <bit> is the address of the thread
register that contains the bit value to assign.
The %set/v instrunction is the same as the %set, but it adds a width
for a vector. The bits are written out in order, starting at the
addressed variable bit and working up. If the <bit> is one of the
constant bits, then the value is repeated for the width. Otherwise,
the vector is taken from increasing thread bit addresses.
* %set/m <memory-label>, <bit>

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.90 2002/11/05 03:46:44 steve Exp $"
#ident "$Id: vthread.cc,v 1.91 2002/11/07 02:32:39 steve Exp $"
#endif
# include "vthread.h"
@ -1414,6 +1414,21 @@ bool of_LOAD_NX(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_LOAD_VEC(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx[0] >= 4);
assert(cp->bit_idx[1] > 0);
unsigned bit = cp->bit_idx[0];
for (unsigned idx = 0; idx < cp->bit_idx[1]; idx += 1, bit += 1) {
vvp_ipoint_t iptr = ipoint_index(cp->iptr, idx);
thr_put_bit(thr, bit, functor_get(iptr));
}
return true;
}
bool of_LOAD_X(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx[0] >= 4);
@ -2119,6 +2134,29 @@ bool of_SET_MEM(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_SET_VEC(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx[1] > 0);
unsigned bit = cp->bit_idx[0];
if (bit >= 4) {
for (unsigned idx = 0; idx < cp->bit_idx[1]; idx += 1, bit += 1) {
unsigned char bit_val = thr_get_bit(thr, bit);
vvp_ipoint_t iptr = ipoint_index(cp->iptr, idx);
functor_set(iptr, bit_val, strong_values[bit_val], true);
}
} else {
unsigned char bit_val = strong_values[thr_get_bit(thr, bit)];
for (unsigned idx = 0; idx < cp->bit_idx[1]; idx += 1) {
vvp_ipoint_t iptr = ipoint_index(cp->iptr, idx);
functor_set(iptr, bit_val, bit_val, true);
}
}
return true;
}
/*
* Implement the %set/x instruction:
*
@ -2428,6 +2466,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.91 2002/11/07 02:32:39 steve
* Add vector set and load instructions.
*
* Revision 1.90 2002/11/05 03:46:44 steve
* Fix mask calculate when MOV_b is right on the word boundary.
*