From 3d3116d48b742b6e98efdd6d50f588c217023cfa Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 18 Sep 2002 04:29:55 +0000 Subject: [PATCH] Add support for binary NOR operator. --- elab_net.cc | 20 +++++++++++++++++++- tgt-vvp/eval_expr.c | 11 ++++++++++- vvp/codes.h | 6 +++++- vvp/compile.cc | 6 +++++- vvp/opcodes.txt | 14 +++++++++++++- vvp/vthread.cc | 35 ++++++++++++++++++++++++++++++++++- 6 files changed, 86 insertions(+), 6 deletions(-) diff --git a/elab_net.cc b/elab_net.cc index 7e0d1a495..e8767d2a2 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_net.cc,v 1.100 2002/09/12 15:49:43 steve Exp $" +#ident "$Id: elab_net.cc,v 1.101 2002/09/18 04:29:55 steve Exp $" #endif # include "config.h" @@ -68,6 +68,7 @@ NetNet* PEBinary::elaborate_net(Design*des, NetScope*scope, case '&': case '^': case 'A': // Bitwise NAND (~&) + case 'O': // Bitwise NOR (~|) case 'X': // Exclusing NOR return elaborate_net_bit_(des, scope, width, rise, fall, decay); case 'E': // === (case equals) @@ -369,6 +370,20 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope, } break; + case 'O': // Bitwise NOR + for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) { + NetLogic*gate = new NetLogic(scope, scope->local_hsymbol(), + 3, NetLogic::NOR); + connect(gate->pin(1), lsig->pin(idx)); + connect(gate->pin(2), rsig->pin(idx)); + connect(gate->pin(0), osig->pin(idx)); + gate->rise_time(rise); + gate->fall_time(fall); + gate->decay_time(decay); + des->add_node(gate); + } + break; + default: assert(0); } @@ -2192,6 +2207,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope, /* * $Log: elab_net.cc,v $ + * Revision 1.101 2002/09/18 04:29:55 steve + * Add support for binary NOR operator. + * * Revision 1.100 2002/09/12 15:49:43 steve * Add support for binary nand operator. * diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index f24b638b5..d646e3e33 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: eval_expr.c,v 1.77 2002/09/13 04:09:51 steve Exp $" +#ident "$Id: eval_expr.c,v 1.78 2002/09/18 04:29:55 steve Exp $" #endif # include "vvp_priv.h" @@ -630,6 +630,11 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, lv.base, rv.base, wid); break; + case 'O': /* NOR (~|) */ + fprintf(vvp_out, " %%nor %u, %u, %u;\n", + lv.base, rv.base, wid); + break; + case 'X': /* exclusive nor (~^) */ fprintf(vvp_out, " %%xnor %u, %u, %u;\n", lv.base, rv.base, wid); @@ -921,6 +926,7 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, case '|': case '^': case 'A': /* NAND (~&) */ + case 'O': /* NOR (~|) */ case 'X': /* XNOR (~^) */ rv = draw_binary_expr_logic(exp, wid); break; @@ -1834,6 +1840,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp, int xz_ok_flag) /* * $Log: eval_expr.c,v $ + * Revision 1.78 2002/09/18 04:29:55 steve + * Add support for binary NOR operator. + * * Revision 1.77 2002/09/13 04:09:51 steve * single bit optimization for != in expressions, * and expand ++ and != results if needed. diff --git a/vvp/codes.h b/vvp/codes.h index 7f32e13d6..2eaae966b 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: codes.h,v 1.50 2002/09/12 15:49:43 steve Exp $" +#ident "$Id: codes.h,v 1.51 2002/09/18 04:29:55 steve Exp $" #endif @@ -82,6 +82,7 @@ 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_NOR(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); @@ -156,6 +157,9 @@ extern vvp_code_t codespace_index(vvp_cpoint_t ptr); /* * $Log: codes.h,v $ + * Revision 1.51 2002/09/18 04:29:55 steve + * Add support for binary NOR operator. + * * Revision 1.50 2002/09/12 15:49:43 steve * Add support for binary nand operator. * diff --git a/vvp/compile.cc b/vvp/compile.cc index 7ce7f6fb3..705ae24ff 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: compile.cc,v 1.142 2002/09/18 02:55:18 steve Exp $" +#ident "$Id: compile.cc,v 1.143 2002/09/18 04:29:55 steve Exp $" #endif # include "arith.h" @@ -127,6 +127,7 @@ const static struct opcode_table_s opcode_table[] = { { "%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", of_NOR, 3, {OA_BIT1, OA_BIT2, OA_NUMBER} }, { "%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} }, @@ -1479,6 +1480,9 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag, /* * $Log: compile.cc,v $ + * Revision 1.143 2002/09/18 04:29:55 steve + * Add support for binary NOR operator. + * * Revision 1.142 2002/09/18 02:55:18 steve * Allow forward references of memories. * diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index fe06ed79b..842505f2d 100644 --- a/vvp/opcodes.txt +++ b/vvp/opcodes.txt @@ -1,7 +1,7 @@ /* * Copyright (c) 2001 Stephen Williams (steve@icarus.com) * - * $Id: opcodes.txt,v 1.41 2002/09/12 15:49:43 steve Exp $ + * $Id: opcodes.txt,v 1.42 2002/09/18 04:29:55 steve Exp $ */ @@ -371,6 +371,18 @@ means the following: otherwise x +* %nor , , + +Perform the bitwise nor of the vectors. Each bit in the is +combined with the corresponding bit in the source, according to the +truth table: + + 1 nor ? --> 0 + ? nor 1 --> 0 + 0 nor 0 --> 1 + otherwise x + + * %nor/r , , The %nor/r instruction is a reduction nor. That is, the is a diff --git a/vvp/vthread.cc b/vvp/vthread.cc index fcd6f126e..24b37f923 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vthread.cc,v 1.85 2002/09/12 15:49:43 steve Exp $" +#ident "$Id: vthread.cc,v 1.86 2002/09/18 04:29:55 steve Exp $" #endif # include "vthread.h" @@ -2023,6 +2023,36 @@ bool of_OR(vthread_t thr, vvp_code_t cp) return true; } +bool of_NOR(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 == 1) || (rb == 1)) { + thr_put_bit(thr, idx1, 0); + + } else if ((lb == 0) && (rb == 0)) { + thr_put_bit(thr, idx1, 1); + + } else { + thr_put_bit(thr, idx1, 2); + } + + idx1 += 1; + if (idx2 >= 4) + idx2 += 1; + } + + return true; +} + static const unsigned char strong_values[4] = {St0, St1, StX, HiZ}; bool of_SET(vthread_t thr, vvp_code_t cp) @@ -2350,6 +2380,9 @@ bool of_CALL_UFUNC(vthread_t thr, vvp_code_t cp) /* * $Log: vthread.cc,v $ + * Revision 1.86 2002/09/18 04:29:55 steve + * Add support for binary NOR operator. + * * Revision 1.85 2002/09/12 15:49:43 steve * Add support for binary nand operator. *