diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 179f531c7..a1849af28 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -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.30 2001/06/16 23:45:05 steve Exp $" +#ident "$Id: eval_expr.c,v 1.31 2001/06/18 01:09:32 steve Exp $" #endif # include "vvp_priv.h" @@ -950,6 +950,18 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) { struct vector_info res; ivl_expr_t sub = ivl_expr_oper1(exp); + const char *rop; + int inv = 0; + + switch (ivl_expr_opcode(exp)) { + case '!': rop = "nor"; break; + case '&': rop = "and"; break; + case '|': rop = "or"; break; + case '^': rop = "xor"; break; + case 'A': rop = "nand"; break; + case 'N': rop = "nor"; break; + case 'X': rop = "xnor"; break; + } switch (ivl_expr_opcode(exp)) { case '~': @@ -958,7 +970,13 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) break; case '!': - case 'N': /* Reduction NOR ~| */ + case 'N': + case 'A': + case 'X': + inv = 1; + case '&': + case '|': + case '^': res = draw_eval_expr(sub); if (res.wid > 1) { /* a ! on a vector is implemented with a reduction @@ -969,11 +987,12 @@ static struct vector_info draw_unary_expr(ivl_expr_t exp, unsigned wid) assert(res.base >= 4); tmp.base = res.base+1; tmp.wid = res.wid - 1; - fprintf(vvp_out, " %%nor/r %u, %u, %u;\n", + fprintf(vvp_out, " %%%s/r %u, %u, %u;\n", + rop, res.base, res.base, res.wid); clr_vector(tmp); res.wid = 1; - } else { + } else if (inv) { fprintf(vvp_out, " %%inv %u, 1;\n", res.base); } break; @@ -1048,6 +1067,10 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.31 2001/06/18 01:09:32 steve + * More behavioral unary reduction operators. + * (Stephan Boettcher) + * * Revision 1.30 2001/06/16 23:45:05 steve * Add support for structural multiply in t-dll. * Add code generators and vvp support for both diff --git a/vvp/codes.h b/vvp/codes.h index 58aa93717..90fa25f8f 100644 --- a/vvp/codes.h +++ b/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.28 2001/06/16 23:45:05 steve Exp $" +#ident "$Id: codes.h,v 1.29 2001/06/18 01:09:32 steve Exp $" #endif @@ -37,6 +37,7 @@ 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_AND(vthread_t thr, vvp_code_t code); +extern bool of_ANDR(vthread_t thr, vvp_code_t code); extern bool of_ASSIGN(vthread_t thr, vvp_code_t code); extern bool of_ASSIGN_MEM(vthread_t thr, vvp_code_t code); extern bool of_BREAKPOINT(vthread_t thr, vvp_code_t code); @@ -64,16 +65,20 @@ extern bool of_LOAD_MEM(vthread_t thr, vvp_code_t code); 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_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); extern bool of_OR(vthread_t thr, vvp_code_t code); +extern bool of_ORR(vthread_t thr, vvp_code_t code); extern bool of_SET(vthread_t thr, vvp_code_t code); extern bool of_SET_MEM(vthread_t thr, vvp_code_t code); extern bool of_SUB(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_XNORR(vthread_t thr, vvp_code_t code); extern bool of_XOR(vthread_t thr, vvp_code_t code); +extern bool of_XORR(vthread_t thr, vvp_code_t code); extern bool of_ZOMBIE(vthread_t thr, vvp_code_t code); @@ -129,6 +134,10 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr); /* * $Log: codes.h,v $ + * Revision 1.29 2001/06/18 01:09:32 steve + * More behavioral unary reduction operators. + * (Stephan Boettcher) + * * Revision 1.28 2001/06/16 23:45:05 steve * Add support for structural multiply in t-dll. * Add code generators and vvp support for both diff --git a/vvp/compile.cc b/vvp/compile.cc index ba6eaebe2..e864726f4 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -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.77 2001/06/16 23:45:05 steve Exp $" +#ident "$Id: compile.cc,v 1.78 2001/06/18 01:09:32 steve Exp $" #endif # include "arith.h" @@ -78,6 +78,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} }, + { "%and/r", of_ANDR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%assign", of_ASSIGN, 3, {OA_FUNC_PTR, OA_BIT1, OA_BIT2} }, { "%assign/m",of_ASSIGN_MEM,3,{OA_MEM_PTR,OA_BIT1, OA_BIT2} }, { "%breakpoint", of_BREAKPOINT, 0, {OA_NONE, OA_NONE, OA_NONE} }, @@ -103,15 +104,19 @@ const static struct opcode_table_s opcode_table[] = { { "%mod", of_MOD, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mov", of_MOV, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%mul", of_MUL, 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} }, { "%or", of_OR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, + { "%or/r", of_ORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%set", of_SET, 2, {OA_FUNC_PTR, OA_BIT1, OA_NONE} }, { "%set/m", of_SET_MEM,2, {OA_MEM_PTR, OA_BIT1, OA_NONE} }, { "%sub", of_SUB, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%wait", of_WAIT, 1, {OA_FUNC_PTR, OA_NONE, OA_NONE} }, { "%xnor", of_XNOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, + { "%xnor/r", of_XNORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%xor", of_XOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, + { "%xor/r", of_XORR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { 0, of_NOOP, 0, {OA_NONE, OA_NONE, OA_NONE} } }; @@ -1401,6 +1406,10 @@ vvp_ipoint_t debug_lookup_functor(const char*name) /* * $Log: compile.cc,v $ + * Revision 1.78 2001/06/18 01:09:32 steve + * More behavioral unary reduction operators. + * (Stephan Boettcher) + * * Revision 1.77 2001/06/16 23:45:05 steve * Add support for structural multiply in t-dll. * Add code generators and vvp support for both diff --git a/vvp/vthread.cc b/vvp/vthread.cc index c82797046..070c47722 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -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.43 2001/06/16 23:45:05 steve Exp $" +#ident "$Id: vthread.cc,v 1.44 2001/06/18 01:09:32 steve Exp $" #endif # include "vthread.h" @@ -869,12 +869,84 @@ bool of_NORR(vthread_t thr, vvp_code_t cp) { assert(cp->bit_idx1 >= 4); + unsigned lb = 1; + unsigned idx2 = cp->bit_idx2; + + for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { + + unsigned rb = thr_get_bit(thr, idx2+idx); + if (rb == 1) { + lb = 0; + break; + } + + if (rb != 0) + lb = 2; + } + + thr_put_bit(thr, cp->bit_idx1, lb); + + return true; +} + +bool of_ANDR(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + + unsigned lb = 1; + unsigned idx2 = cp->bit_idx2; + + for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { + + unsigned rb = thr_get_bit(thr, idx2+idx); + if (rb == 0) { + lb = 0; + break; + } + + if (rb != 1) + lb = 2; + } + + thr_put_bit(thr, cp->bit_idx1, lb); + + return true; +} + +bool of_NANDR(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + unsigned lb = 0; unsigned idx2 = cp->bit_idx2; for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { - unsigned rb = thr_get_bit(thr, idx2); + unsigned rb = thr_get_bit(thr, idx2+idx); + if (rb == 0) { + lb = 1; + break; + } + + if (rb != 1) + lb = 2; + } + + thr_put_bit(thr, cp->bit_idx1, lb); + + return true; +} + +bool of_ORR(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + + unsigned lb = 0; + unsigned idx2 = cp->bit_idx2; + + for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { + + unsigned rb = thr_get_bit(thr, idx2+idx); if (rb == 1) { lb = 1; break; @@ -889,6 +961,52 @@ bool of_NORR(vthread_t thr, vvp_code_t cp) return true; } +bool of_XORR(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + + unsigned lb = 0; + unsigned idx2 = cp->bit_idx2; + + for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { + + unsigned rb = thr_get_bit(thr, idx2+idx); + if (rb == 1) + lb ^= 1; + else if (rb != 0) { + lb = 2; + break; + } + } + + thr_put_bit(thr, cp->bit_idx1, lb); + + return true; +} + +bool of_XNORR(vthread_t thr, vvp_code_t cp) +{ + assert(cp->bit_idx1 >= 4); + + unsigned lb = 1; + unsigned idx2 = cp->bit_idx2; + + for (unsigned idx = 0 ; idx < cp->number ; idx += 1) { + + unsigned rb = thr_get_bit(thr, idx2+idx); + if (rb == 1) + lb ^= 1; + else if (rb != 0) { + lb = 2; + break; + } + } + + thr_put_bit(thr, cp->bit_idx1, lb); + + return true; +} + bool of_OR(vthread_t thr, vvp_code_t cp) { assert(cp->bit_idx1 >= 4); @@ -1087,6 +1205,10 @@ bool of_ZOMBIE(vthread_t thr, vvp_code_t) /* * $Log: vthread.cc,v $ + * Revision 1.44 2001/06/18 01:09:32 steve + * More behavioral unary reduction operators. + * (Stephan Boettcher) + * * Revision 1.43 2001/06/16 23:45:05 steve * Add support for structural multiply in t-dll. * Add code generators and vvp support for both