Support behavioral subtraction.

This commit is contained in:
steve 2001-05-02 01:57:25 +00:00
parent ba910c0fac
commit 06437b7fba
5 changed files with 79 additions and 6 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: eval_expr.c,v 1.22 2001/05/01 02:07:34 steve Exp $"
#ident "$Id: eval_expr.c,v 1.23 2001/05/02 01:57:25 steve Exp $"
#endif
# include "vvp_priv.h"
@ -524,7 +524,10 @@ static struct vector_info draw_binary_expr_plus(ivl_expr_t exp, unsigned wid)
lv = draw_eval_expr_wid(le, wid);
rv = draw_eval_expr_wid(re, wid);
fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid);
if (ivl_expr_opcode(exp) == '-')
fprintf(vvp_out, " %%sub %u, %u, %u;\n", lv.base, rv.base, wid);
else
fprintf(vvp_out, " %%add %u, %u, %u;\n", lv.base, rv.base, wid);
clr_vector(rv);
@ -556,6 +559,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
break;
case '+':
case '-':
rv = draw_binary_expr_plus(exp, wid);
break;
@ -883,6 +887,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
/*
* $Log: eval_expr.c,v $
* Revision 1.23 2001/05/02 01:57:25 steve
* Support behavioral subtraction.
*
* Revision 1.22 2001/05/01 02:07:34 steve
* Comparisons cant leave their results in the opcode
* result area or their values will be clobbered by other

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: codes.h,v 1.21 2001/05/01 01:09:39 steve Exp $"
#ident "$Id: codes.h,v 1.22 2001/05/02 01:57:25 steve Exp $"
#endif
@ -65,6 +65,7 @@ extern bool of_NORR(vthread_t thr, vvp_code_t code);
extern bool of_OR(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_SUB(vthread_t thr, vvp_code_t code);
extern bool of_VPI_CALL(vthread_t thr, vvp_code_t code);
extern bool of_WAIT(vthread_t thr, vvp_code_t code);
extern bool of_XNOR(vthread_t thr, vvp_code_t code);
@ -125,6 +126,9 @@ extern void codespace_dump(FILE*fd);
/*
* $Log: codes.h,v $
* Revision 1.22 2001/05/02 01:57:25 steve
* Support behavioral subtraction.
*
* Revision 1.21 2001/05/01 01:09:39 steve
* Add support for memory objects. (Stephan Boettcher)
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: compile.cc,v 1.50 2001/05/01 05:00:02 steve Exp $"
#ident "$Id: compile.cc,v 1.51 2001/05/02 01:57:25 steve Exp $"
#endif
# include "compile.h"
@ -97,6 +97,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
{ "%set/m", of_SET_MEM,2, {OA_MEM_I1, OA_BIT1, OA_NONE} },
{ "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} },
{ "%xnor", of_XNOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%xor", of_XOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@ -1064,6 +1065,9 @@ void compile_dump(FILE*fd)
/*
* $Log: compile.cc,v $
* Revision 1.51 2001/05/02 01:57:25 steve
* Support behavioral subtraction.
*
* Revision 1.50 2001/05/01 05:00:02 steve
* Implement %ix/load.
*

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: opcodes.txt,v 1.15 2001/05/01 05:00:02 steve Exp $
* $Id: opcodes.txt,v 1.16 2001/05/02 01:57:26 steve Exp $
*/
@ -20,6 +20,8 @@ vectors having the width <wid>. If any of the bits of either vector
are x or z, the result is x. Otherwise, the result is the arithmetic
sum.
See also the %sub instruction.
* %and <bit-l>, <bit-r>, <wid>
Perform the bitwise AND of the two vectors, and store the result in
@ -208,6 +210,19 @@ 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.
* %sub <bit-l>, <bit-r>, <wid>
This instruction arithmetically subtracts the right vector out of the
left vector. It accomplishes this by adding to the left vector 1 plus
the 1s complement of the right vector. The carry value is dropped, and
the result, placed in <bit-l>, is the subtraction of <bit-r> from the
input <bit-l>. Both vectors have the same width. If any bits in either
operand are x, then the entire result is x.
See also the %add instruction.
* %vpi_call <name> [, ...]
This instruction makes a call to a system task or function that was

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: vthread.cc,v 1.32 2001/05/02 01:37:38 steve Exp $"
#ident "$Id: vthread.cc,v 1.33 2001/05/02 01:57:26 steve Exp $"
#endif
# include "vthread.h"
@ -816,6 +816,46 @@ bool of_SET_MEM(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_SUB(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_VPI_CALL(vthread_t thr, vvp_code_t cp)
{
// printf("thread %p: %%vpi_call\n", thr);
@ -926,6 +966,9 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t)
/*
* $Log: vthread.cc,v $
* Revision 1.33 2001/05/02 01:57:26 steve
* Support behavioral subtraction.
*
* Revision 1.32 2001/05/02 01:37:38 steve
* initialize is_schedule.
*