Add the ADD instrunction.
This commit is contained in:
parent
6a72b4c10e
commit
4a058632b2
|
|
@ -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.8 2001/03/30 04:55:22 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.9 2001/03/31 01:59:58 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -35,6 +35,7 @@ typedef bool (*vvp_code_fun)(vthread_t thr, vvp_code_t code);
|
|||
* implementation lives in the vthread.cc file so that they have
|
||||
* access to the thread context.
|
||||
*/
|
||||
extern bool of_ADD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_ASSIGN(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPU(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_DELAY(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -95,6 +96,9 @@ extern void codespace_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.9 2001/03/31 01:59:58 steve
|
||||
* Add the ADD instrunction.
|
||||
*
|
||||
* Revision 1.8 2001/03/30 04:55:22 steve
|
||||
* Add fork and join instructions.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.19 2001/03/30 04:55:22 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.20 2001/03/31 01:59:59 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -65,6 +65,7 @@ struct opcode_table_s {
|
|||
};
|
||||
|
||||
const static struct opcode_table_s opcode_table[] = {
|
||||
{ "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%assign", of_ASSIGN, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} },
|
||||
{ "%cmp/u", of_CMPU, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%delay", of_DELAY, 1, {OA_NUMBER, OA_NONE, OA_NONE} },
|
||||
|
|
@ -687,6 +688,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.20 2001/03/31 01:59:59 steve
|
||||
* Add the ADD instrunction.
|
||||
*
|
||||
* Revision 1.19 2001/03/30 04:55:22 steve
|
||||
* Add fork and join instructions.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: opcodes.txt,v 1.7 2001/03/30 04:55:22 steve Exp $
|
||||
* $Id: opcodes.txt,v 1.8 2001/03/31 01:59:59 steve Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -13,6 +13,12 @@ operands. In no case are there more then 3 operands. This chapter
|
|||
describes the specific behavior of each opcode, in hopefully enough
|
||||
detail that its complete effect can be predicted.
|
||||
|
||||
* %add <bit-l>, <bit-r>, <wid>
|
||||
|
||||
This instruction adds the right vector into the left vector, the
|
||||
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.
|
||||
|
||||
* %assign <var-label>, <delay>, <bit>
|
||||
|
||||
|
|
|
|||
|
|
@ -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.14 2001/03/30 04:55:22 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.15 2001/03/31 01:59:59 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -131,6 +131,46 @@ void vthread_schedule_list(vthread_t thr)
|
|||
}
|
||||
}
|
||||
|
||||
bool of_ADD(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_ASSIGN(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned char bit_val = thr_get_bit(thr, cp->bit_idx2);
|
||||
|
|
@ -315,6 +355,9 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.15 2001/03/31 01:59:59 steve
|
||||
* Add the ADD instrunction.
|
||||
*
|
||||
* Revision 1.14 2001/03/30 04:55:22 steve
|
||||
* Add fork and join instructions.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue