Implement %cmp/x and %cmp/z instructions.
This commit is contained in:
parent
d25690cc8e
commit
29a50a52ca
|
|
@ -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.10 2001/03/31 17:36:02 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.11 2001/04/01 04:34:28 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -38,6 +38,8 @@ typedef bool (*vvp_code_fun)(vthread_t thr, vvp_code_t code);
|
|||
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_CMPX(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_CMPZ(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_DELAY(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_END(vthread_t thr, vvp_code_t code);
|
||||
extern bool of_FORK(vthread_t thr, vvp_code_t code);
|
||||
|
|
@ -97,6 +99,9 @@ extern void codespace_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.11 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z instructions.
|
||||
*
|
||||
* Revision 1.10 2001/03/31 17:36:02 steve
|
||||
* Add the jmp/1 instruction.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.22 2001/03/31 19:00:43 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.23 2001/04/01 04:34:28 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -68,6 +68,8 @@ 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} },
|
||||
{ "%cmp/x", of_CMPX, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%cmp/z", of_CMPZ, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ "%delay", of_DELAY, 1, {OA_NUMBER, OA_NONE, OA_NONE} },
|
||||
{ "%end", of_END, 0, {OA_NONE, OA_NONE, OA_NONE} },
|
||||
{ "%fork", of_FORK, 1, {OA_CODE_PTR, OA_NONE, OA_NONE} },
|
||||
|
|
@ -692,6 +694,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.23 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z instructions.
|
||||
*
|
||||
* Revision 1.22 2001/03/31 19:00:43 steve
|
||||
* Add VPI support for the simulation time.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.16 2001/03/31 17:36:02 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.17 2001/04/01 04:34:28 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -213,6 +213,56 @@ bool of_CMPU(vthread_t thr, vvp_code_t cp)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool of_CMPX(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned eq = 1;
|
||||
|
||||
unsigned idx1 = cp->bit_idx1;
|
||||
unsigned idx2 = cp->bit_idx2;
|
||||
|
||||
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
|
||||
unsigned lv = thr_get_bit(thr, idx1);
|
||||
unsigned rv = thr_get_bit(thr, idx2);
|
||||
|
||||
if ((lv < 2) && (rv < 2) && (lv != rv)) {
|
||||
eq = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (idx1 >= 4) idx1 += 1;
|
||||
if (idx2 >= 4) idx2 += 1;
|
||||
}
|
||||
|
||||
thr_put_bit(thr, 4, eq);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_CMPZ(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
unsigned eq = 1;
|
||||
|
||||
unsigned idx1 = cp->bit_idx1;
|
||||
unsigned idx2 = cp->bit_idx2;
|
||||
|
||||
for (unsigned idx = 0 ; idx < cp->number ; idx += 1) {
|
||||
unsigned lv = thr_get_bit(thr, idx1);
|
||||
unsigned rv = thr_get_bit(thr, idx2);
|
||||
|
||||
if ((lv < 3) && (rv < 3) && (lv != rv)) {
|
||||
eq = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (idx1 >= 4) idx1 += 1;
|
||||
if (idx2 >= 4) idx2 += 1;
|
||||
}
|
||||
|
||||
thr_put_bit(thr, 4, eq);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool of_DELAY(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
//printf("thread %p: %%delay %lu\n", thr, cp->number);
|
||||
|
|
@ -362,6 +412,9 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.17 2001/04/01 04:34:28 steve
|
||||
* Implement %cmp/x and %cmp/z instructions.
|
||||
*
|
||||
* Revision 1.16 2001/03/31 17:36:02 steve
|
||||
* Add the jmp/1 instruction.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue