Add the bitwise %and instruction.
This commit is contained in:
parent
6dbf7333c8
commit
5769bbe15e
10
vvp/codes.h
10
vvp/codes.h
|
|
@ -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.11 2001/04/01 04:34:28 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.12 2001/04/01 06:12:13 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -36,6 +36,7 @@ typedef bool (*vvp_code_fun)(vthread_t thr, vvp_code_t code);
|
|||
* access to the thread context.
|
||||
*/
|
||||
extern bool of_ADD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_AND(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_CMPX(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -51,10 +52,10 @@ 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_LOAD(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_MOV(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_WAIT(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_NOOP(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_SET(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);
|
||||
|
||||
/*
|
||||
* This is the format of a machine code instruction.
|
||||
|
|
@ -99,6 +100,9 @@ extern void codespace_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.12 2001/04/01 06:12:13 steve
|
||||
* Add the bitwise %and instruction.
|
||||
*
|
||||
* Revision 1.11 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z 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.23 2001/04/01 04:34:28 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.24 2001/04/01 06:12:13 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -66,6 +66,7 @@ struct opcode_table_s {
|
|||
|
||||
const static struct opcode_table_s opcode_table[] = {
|
||||
{ "%add", of_ADD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%and", of_AND, 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} },
|
||||
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
|
|
@ -81,6 +82,7 @@ const static struct opcode_table_s opcode_table[] = {
|
|||
{ "%join", of_JOIN, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||
{ "%load", of_LOAD, 2, {OA_BIT1, OA_FUNC_PTR, OA_NONE} },
|
||||
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||
{ "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} },
|
||||
{ "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} },
|
||||
{ 0, of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} }
|
||||
|
|
@ -694,6 +696,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.24 2001/04/01 06:12:13 steve
|
||||
* Add the bitwise %and instruction.
|
||||
*
|
||||
* Revision 1.23 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z instructions.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: opcodes.txt,v 1.8 2001/03/31 01:59:59 steve Exp $
|
||||
* $Id: opcodes.txt,v 1.9 2001/04/01 06:12:14 steve Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -20,6 +20,17 @@ 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.
|
||||
|
||||
* %and <bit-l>, <bit-r>, <wid>
|
||||
|
||||
Perform the bitwise AND of the two vectors, and store the result in
|
||||
the left vector. Each bit is calculated independent of other bits. AND
|
||||
means the following:
|
||||
|
||||
0 and ? --> 0
|
||||
? and 0 --> 0
|
||||
1 and 1 --> 1
|
||||
otherwise x
|
||||
|
||||
* %assign <var-label>, <delay>, <bit>
|
||||
|
||||
This does a non-blocking assignment to a variable. The <label>
|
||||
|
|
|
|||
|
|
@ -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.17 2001/04/01 04:34:28 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.18 2001/04/01 06:12:14 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -131,6 +131,36 @@ void vthread_schedule_list(vthread_t thr)
|
|||
}
|
||||
}
|
||||
|
||||
bool of_AND(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx1 >= 4);
|
||||
|
||||
unsigned idx1 = cp->bit_idx1;
|
||||
unsigned idx2 = cp->bit_idx2;
|
||||
|
||||
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 == 0) || (rb == 0)) {
|
||||
thr_put_bit(thr, idx1, 0);
|
||||
|
||||
} else if ((lb == 1) && (rb == 1)) {
|
||||
thr_put_bit(thr, idx1, 1);
|
||||
|
||||
} else {
|
||||
thr_put_bit(thr, idx1, 2);
|
||||
}
|
||||
|
||||
idx1 += 1;
|
||||
if (idx2 >= 4)
|
||||
idx2 += 1;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_ADD(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
assert(cp->bit_idx1 >= 4);
|
||||
|
|
@ -412,6 +442,9 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.18 2001/04/01 06:12:14 steve
|
||||
* Add the bitwise %and instruction.
|
||||
*
|
||||
* Revision 1.17 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z instructions.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue