Add behavioral modulus.
This commit is contained in:
parent
150fc6f3ee
commit
39ffe91230
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: eval_expr.c,v 1.28 2001/05/20 01:18:38 steve Exp $"
|
#ident "$Id: eval_expr.c,v 1.29 2001/05/24 04:20:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_priv.h"
|
# include "vvp_priv.h"
|
||||||
|
|
@ -510,7 +510,7 @@ static struct vector_info draw_binary_expr_rs(ivl_expr_t exp, unsigned wid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct vector_info draw_binary_expr_plus(ivl_expr_t exp, unsigned wid)
|
static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid)
|
||||||
{
|
{
|
||||||
ivl_expr_t le = ivl_expr_oper1(exp);
|
ivl_expr_t le = ivl_expr_oper1(exp);
|
||||||
ivl_expr_t re = ivl_expr_oper2(exp);
|
ivl_expr_t re = ivl_expr_oper2(exp);
|
||||||
|
|
@ -524,10 +524,22 @@ static struct vector_info draw_binary_expr_plus(ivl_expr_t exp, unsigned wid)
|
||||||
lv = draw_eval_expr_wid(le, wid);
|
lv = draw_eval_expr_wid(le, wid);
|
||||||
rv = draw_eval_expr_wid(re, wid);
|
rv = draw_eval_expr_wid(re, wid);
|
||||||
|
|
||||||
if (ivl_expr_opcode(exp) == '-')
|
switch (ivl_expr_opcode(exp)) {
|
||||||
fprintf(vvp_out, " %%sub %u, %u, %u;\n", lv.base, rv.base, wid);
|
case '+':
|
||||||
else
|
|
||||||
fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid);
|
fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
fprintf(vvp_out, " %%sub %u, %u, %u;\n", lv.base, rv.base, wid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '%':
|
||||||
|
fprintf(vvp_out, " %%mod %u, %u, %u;\n", lv.base, rv.base, wid);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
clr_vector(rv);
|
clr_vector(rv);
|
||||||
|
|
||||||
|
|
@ -560,7 +572,8 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
|
||||||
|
|
||||||
case '+':
|
case '+':
|
||||||
case '-':
|
case '-':
|
||||||
rv = draw_binary_expr_plus(exp, wid);
|
case '%':
|
||||||
|
rv = draw_binary_expr_arith(exp, wid);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l': /* << */
|
case 'l': /* << */
|
||||||
|
|
@ -1030,6 +1043,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: eval_expr.c,v $
|
* $Log: eval_expr.c,v $
|
||||||
|
* Revision 1.29 2001/05/24 04:20:10 steve
|
||||||
|
* Add behavioral modulus.
|
||||||
|
*
|
||||||
* Revision 1.28 2001/05/20 01:18:38 steve
|
* Revision 1.28 2001/05/20 01:18:38 steve
|
||||||
* Implement reduction nor.
|
* Implement reduction nor.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: codes.h,v 1.26 2001/05/09 04:23:18 steve Exp $"
|
#ident "$Id: codes.h,v 1.27 2001/05/24 04:20:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -61,6 +61,7 @@ extern bool of_JMP1(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_JOIN(vthread_t thr, vvp_code_t code);
|
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(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code);
|
extern bool of_LOAD_MEM(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);
|
extern bool of_MOV(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_NOOP(vthread_t thr, vvp_code_t code);
|
extern bool of_NOOP(vthread_t thr, vvp_code_t code);
|
||||||
extern bool of_NORR(vthread_t thr, vvp_code_t code);
|
extern bool of_NORR(vthread_t thr, vvp_code_t code);
|
||||||
|
|
@ -127,6 +128,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: codes.h,v $
|
* $Log: codes.h,v $
|
||||||
|
* Revision 1.27 2001/05/24 04:20:10 steve
|
||||||
|
* Add behavioral modulus.
|
||||||
|
*
|
||||||
* Revision 1.26 2001/05/09 04:23:18 steve
|
* Revision 1.26 2001/05/09 04:23:18 steve
|
||||||
* Now that the interactive debugger exists,
|
* Now that the interactive debugger exists,
|
||||||
* there is no use for the output dump.
|
* there is no use for the output dump.
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: compile.cc,v 1.67 2001/05/22 04:08:16 steve Exp $"
|
#ident "$Id: compile.cc,v 1.68 2001/05/24 04:20:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "compile.h"
|
# include "compile.h"
|
||||||
|
|
@ -98,6 +98,7 @@ const static struct opcode_table_s opcode_table[] = {
|
||||||
{ "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
{ "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||||
{ "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} },
|
{ "%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/m", of_LOAD_MEM,2, {OA_BIT1, OA_MEM_PTR, OA_NONE} },
|
||||||
|
{ "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||||
{ "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
{ "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||||
|
|
@ -1206,6 +1207,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: compile.cc,v $
|
* $Log: compile.cc,v $
|
||||||
|
* Revision 1.68 2001/05/24 04:20:10 steve
|
||||||
|
* Add behavioral modulus.
|
||||||
|
*
|
||||||
* Revision 1.67 2001/05/22 04:08:16 steve
|
* Revision 1.67 2001/05/22 04:08:16 steve
|
||||||
* Get the initial inputs to functors set at xxxx.
|
* Get the initial inputs to functors set at xxxx.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* $Id: opcodes.txt,v 1.21 2001/05/20 00:46:12 steve Exp $
|
* $Id: opcodes.txt,v 1.22 2001/05/24 04:20:10 steve Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -13,6 +13,14 @@ operands. In no case are there more then 3 operands. This chapter
|
||||||
describes the specific behavior of each opcode, in hopefully enough
|
describes the specific behavior of each opcode, in hopefully enough
|
||||||
detail that its complete effect can be predicted.
|
detail that its complete effect can be predicted.
|
||||||
|
|
||||||
|
General principles of Arithmetic:
|
||||||
|
|
||||||
|
The binary arithmetic instruction in general take three parameters,
|
||||||
|
the left operand, the right operand, and the base. The left operand is
|
||||||
|
replaced with the result, which is the same width as the left and
|
||||||
|
right operands.
|
||||||
|
|
||||||
|
|
||||||
* %add <bit-l>, <bit-r>, <wid>
|
* %add <bit-l>, <bit-r>, <wid>
|
||||||
|
|
||||||
This instruction adds the right vector into the left vector, the
|
This instruction adds the right vector into the left vector, the
|
||||||
|
|
@ -219,6 +227,14 @@ Bit address zero is the LSB of the first memory word. This
|
||||||
instruction loads only a single bit.
|
instruction loads only a single bit.
|
||||||
|
|
||||||
|
|
||||||
|
* %mod <bit-l>, <bit-r>, <wid>
|
||||||
|
|
||||||
|
|
||||||
|
This instruction calculates the modulus %r of the left operand, and
|
||||||
|
replaces the left operand with the result. The <wid> gives the width
|
||||||
|
of the left and the right vectors, and the left vector is completely
|
||||||
|
replaced with the result.
|
||||||
|
|
||||||
* %mov <dst>, <src>, <wid>
|
* %mov <dst>, <src>, <wid>
|
||||||
|
|
||||||
This instruction copies a vector from one place in register space to
|
This instruction copies a vector from one place in register space to
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: vthread.cc,v 1.40 2001/05/20 00:56:48 steve Exp $"
|
#ident "$Id: vthread.cc,v 1.41 2001/05/24 04:20:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vthread.h"
|
# include "vthread.h"
|
||||||
|
|
@ -760,6 +760,46 @@ bool of_LOAD_MEM(vthread_t thr, vvp_code_t cp)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool of_MOD(vthread_t thr, vvp_code_t cp)
|
||||||
|
{
|
||||||
|
assert(cp->bit_idx1 >= 4);
|
||||||
|
assert(cp->number <= 8*sizeof(unsigned long));
|
||||||
|
|
||||||
|
unsigned idx1 = cp->bit_idx1;
|
||||||
|
unsigned idx2 = cp->bit_idx2;
|
||||||
|
unsigned long lv = 0, rv = 0;
|
||||||
|
|
||||||
|
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
|
||||||
|
unsigned lb = thr_get_bit(thr, idx1);
|
||||||
|
unsigned rb = thr_get_bit(thr, idx2);
|
||||||
|
|
||||||
|
if ((lb | rb) & 2)
|
||||||
|
goto x_out;
|
||||||
|
|
||||||
|
lv |= lb << idx;
|
||||||
|
rv |= rb << idx;
|
||||||
|
|
||||||
|
idx1 += 1;
|
||||||
|
if (idx2 >= 4)
|
||||||
|
idx2 += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
lv %= rv;
|
||||||
|
|
||||||
|
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
|
||||||
|
thr_put_bit(thr, cp->bit_idx1+idx, (lv&1) ? 1 : 0);
|
||||||
|
lv >>= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
x_out:
|
||||||
|
for (unsigned idx = 0 ; idx < cp->number ; idx += 1)
|
||||||
|
thr_put_bit(thr, cp->bit_idx1+idx, 2);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool of_MOV(vthread_t thr, vvp_code_t cp)
|
bool of_MOV(vthread_t thr, vvp_code_t cp)
|
||||||
{
|
{
|
||||||
assert(cp->bit_idx1 >= 4);
|
assert(cp->bit_idx1 >= 4);
|
||||||
|
|
@ -1005,6 +1045,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vthread.cc,v $
|
* $Log: vthread.cc,v $
|
||||||
|
* Revision 1.41 2001/05/24 04:20:10 steve
|
||||||
|
* Add behavioral modulus.
|
||||||
|
*
|
||||||
* Revision 1.40 2001/05/20 00:56:48 steve
|
* Revision 1.40 2001/05/20 00:56:48 steve
|
||||||
* Make vthread_put_but expand the space if needed.
|
* Make vthread_put_but expand the space if needed.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue