Add support for binary nand operator.

This commit is contained in:
steve
2002-09-12 15:49:43 +00:00
parent 1573477caf
commit dac99b9374
10 changed files with 120 additions and 14 deletions
+5 -1
View File
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: codes.h,v 1.49 2002/08/28 18:38:07 steve Exp $"
#ident "$Id: codes.h,v 1.50 2002/09/12 15:49:43 steve Exp $"
#endif
@@ -79,6 +79,7 @@ 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_MUL(vthread_t thr, vvp_code_t code);
extern bool of_MULI(vthread_t thr, vvp_code_t code);
extern bool of_NAND(vthread_t thr, vvp_code_t code);
extern bool of_NANDR(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);
@@ -155,6 +156,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr);
/*
* $Log: codes.h,v $
* Revision 1.50 2002/09/12 15:49:43 steve
* Add support for binary nand operator.
*
* Revision 1.49 2002/08/28 18:38:07 steve
* Add the %subi instruction, and use it where possible.
*
+5 -1
View File
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.cc,v 1.140 2002/08/28 18:38:07 steve Exp $"
#ident "$Id: compile.cc,v 1.141 2002/09/12 15:49:43 steve Exp $"
#endif
# include "arith.h"
@@ -124,6 +124,7 @@ const static struct opcode_table_s opcode_table[] = {
{ "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%mul", of_MUL, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%muli", of_MULI, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%nand", of_NAND, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%nand/r", of_NANDR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
{ "%noop", of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} },
{ "%nor/r", of_NORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
@@ -1449,6 +1450,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
/*
* $Log: compile.cc,v $
* Revision 1.141 2002/09/12 15:49:43 steve
* Add support for binary nand operator.
*
* Revision 1.140 2002/08/28 18:38:07 steve
* Add the %subi instruction, and use it where possible.
*
+13 -1
View File
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams ([email protected])
*
* $Id: opcodes.txt,v 1.40 2002/08/28 18:38:07 steve Exp $
* $Id: opcodes.txt,v 1.41 2002/09/12 15:49:43 steve Exp $
*/
@@ -359,6 +359,18 @@ This instruction is the same as %mul, but the second operand is an
immediate value that is padded to the width of the result.
* %nand <dst>, <src>, <wid>
Perform the bitwise NAND of the two vectors, and store the result in
the left vector. Each bit is calculated independent of other bits. NAND
means the following:
0 and ? --> 1
? and 0 --> 1
1 and 1 --> 0
otherwise x
* %nor/r <dst>, <src>, <wid>
The %nor/r instruction is a reduction nor. That is, the <src> is a
+36 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001 Stephen Williams ([email protected])
* Copyright (c) 2001-2002 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vthread.cc,v 1.84 2002/08/28 18:38:07 steve Exp $"
#ident "$Id: vthread.cc,v 1.85 2002/09/12 15:49:43 steve Exp $"
#endif
# include "vthread.h"
@@ -1815,6 +1815,37 @@ bool of_MULI(vthread_t thr, vvp_code_t cp)
return true;
}
bool of_NAND(vthread_t thr, vvp_code_t cp)
{
assert(cp->bit_idx[0] >= 4);
unsigned idx1 = cp->bit_idx[0];
unsigned idx2 = cp->bit_idx[1];
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, 1);
} else if ((lb == 1) && (rb == 1)) {
thr_put_bit(thr, idx1, 0);
} else {
thr_put_bit(thr, idx1, 2);
}
idx1 += 1;
if (idx2 >= 4)
idx2 += 1;
}
return true;
}
bool of_NOOP(vthread_t thr, vvp_code_t cp)
{
return true;
@@ -2319,6 +2350,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp)
/*
* $Log: vthread.cc,v $
* Revision 1.85 2002/09/12 15:49:43 steve
* Add support for binary nand operator.
*
* Revision 1.84 2002/08/28 18:38:07 steve
* Add the %subi instruction, and use it where possible.
*