Add support for behavioral xnor.
This commit is contained in:
parent
09cd582cc5
commit
05e30ed43b
|
|
@ -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.14 2001/04/06 02:28:03 steve Exp $"
|
||||
#ident "$Id: eval_expr.c,v 1.15 2001/04/15 04:07:56 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vvp_priv.h"
|
||||
|
|
@ -259,6 +259,26 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp,
|
|||
lv = draw_eval_expr_wid(le, wid);
|
||||
rv = draw_eval_expr_wid(re, wid);
|
||||
|
||||
/* The result goes into the left operand, and that is returned
|
||||
as the result. The instructions do not allow the lv value
|
||||
to be a constant bit, so we either switch the operands, or
|
||||
copy the vector into a new area. */
|
||||
if (lv.base < 4) {
|
||||
if (rv.base > 4) {
|
||||
struct vector_info tmp = lv;
|
||||
lv = rv;
|
||||
rv = tmp;
|
||||
|
||||
} else {
|
||||
struct vector_info tmp;
|
||||
tmp.base = allocate_vector(lv.wid);
|
||||
tmp.wid = lv.wid;
|
||||
fprintf(vvp_out, " %%mov %u, %u, %u;\n",
|
||||
tmp.base, lv.base, tmp.wid);
|
||||
lv = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
switch (ivl_expr_opcode(exp)) {
|
||||
|
||||
case '&':
|
||||
|
|
@ -271,6 +291,11 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp,
|
|||
lv.base, rv.base, wid);
|
||||
break;
|
||||
|
||||
case 'X': /* exclusive nor (~^) */
|
||||
fprintf(vvp_out, " %%xnor %u, %u, %u;\n",
|
||||
lv.base, rv.base, wid);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
|
|
@ -330,6 +355,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid)
|
|||
|
||||
case '&':
|
||||
case '|':
|
||||
case 'X':
|
||||
rv = draw_binary_expr_logic(exp, wid);
|
||||
break;
|
||||
|
||||
|
|
@ -637,6 +663,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp)
|
|||
|
||||
/*
|
||||
* $Log: eval_expr.c,v $
|
||||
* Revision 1.15 2001/04/15 04:07:56 steve
|
||||
* Add support for behavioral xnor.
|
||||
*
|
||||
* Revision 1.14 2001/04/06 02:28:03 steve
|
||||
* Generate vvp code for functions with ports.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.17 2001/04/13 03:55:18 steve Exp $"
|
||||
#ident "$Id: codes.h,v 1.18 2001/04/15 04:07:56 steve Exp $"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -59,6 +59,7 @@ 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_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);
|
||||
|
||||
extern bool of_ZOMBIE(vthread_t thr, vvp_code_t code);
|
||||
|
||||
|
|
@ -108,6 +109,9 @@ extern void codespace_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: codes.h,v $
|
||||
* Revision 1.18 2001/04/15 04:07:56 steve
|
||||
* Add support for behavioral xnor.
|
||||
*
|
||||
* Revision 1.17 2001/04/13 03:55:18 steve
|
||||
* More complete reap of all threads.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.32 2001/04/14 05:10:56 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.33 2001/04/15 04:07:56 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -88,6 +88,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} },
|
||||
{ "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} },
|
||||
{ "%xnor", of_XNOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} },
|
||||
{ 0, of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} }
|
||||
};
|
||||
|
||||
|
|
@ -758,6 +759,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.33 2001/04/15 04:07:56 steve
|
||||
* Add support for behavioral xnor.
|
||||
*
|
||||
* Revision 1.32 2001/04/14 05:10:56 steve
|
||||
* support the .event/or statement.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: opcodes.txt,v 1.11 2001/04/01 22:25:33 steve Exp $
|
||||
* $Id: opcodes.txt,v 1.12 2001/04/15 04:07:56 steve Exp $
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -192,6 +192,17 @@ threads that await the functor. When the defined sort of event occurs
|
|||
on the functor, a thread schedule event is created for all the threads
|
||||
in its list and the list is cleared.
|
||||
|
||||
* %xnor <dst>, <src>, <wid>
|
||||
|
||||
This does a bitwise exclusive nor (~^) of the <src> and <dst> vector,
|
||||
and leaves the result in the <dst> vector. xnor is this:
|
||||
|
||||
0 xnor 0 --> 1
|
||||
0 xnor 1 --> 0
|
||||
1 xnor 0 --> 0
|
||||
1 xnor 1 --> 1
|
||||
otherwise x
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.24 2001/04/14 05:10:05 steve Exp $"
|
||||
#ident "$Id: vthread.cc,v 1.25 2001/04/15 04:07:56 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vthread.h"
|
||||
|
|
@ -690,6 +690,43 @@ bool of_WAIT(vthread_t thr, vvp_code_t cp)
|
|||
}
|
||||
|
||||
|
||||
bool of_XNOR(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 == 1) && (rb == 1)) {
|
||||
thr_put_bit(thr, idx1, 1);
|
||||
|
||||
} else if ((lb == 0) && (rb == 0)) {
|
||||
thr_put_bit(thr, idx1, 1);
|
||||
|
||||
} else if ((lb == 1) && (rb == 0)) {
|
||||
thr_put_bit(thr, idx1, 0);
|
||||
|
||||
} else if ((lb == 0) && (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_ZOMBIE(vthread_t, vvp_code_t)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -697,6 +734,9 @@ bool of_ZOMBIE(vthread_t, vvp_code_t)
|
|||
|
||||
/*
|
||||
* $Log: vthread.cc,v $
|
||||
* Revision 1.25 2001/04/15 04:07:56 steve
|
||||
* Add support for behavioral xnor.
|
||||
*
|
||||
* Revision 1.24 2001/04/14 05:10:05 steve
|
||||
* Initialize the waiting_for_event member.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue