diff --git a/elab_expr.cc b/elab_expr.cc index 8002ea80e..480cf8251 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_expr.cc,v 1.63 2002/08/19 02:39:16 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.64 2002/09/12 15:49:43 steve Exp $" #endif # include "config.h" @@ -121,6 +121,7 @@ NetEBinary* PEBinary::elaborate_expr_base_(Design*des, case '&': case '|': case 'O': + case 'A': // NAND (~&) case 'X': tmp = new NetEBBits(op_, lp, rp); tmp->set_line(*this); @@ -874,6 +875,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const /* * $Log: elab_expr.cc,v $ + * Revision 1.64 2002/09/12 15:49:43 steve + * Add support for binary nand operator. + * * Revision 1.63 2002/08/19 02:39:16 steve * Support parameters with defined ranges. * diff --git a/elab_net.cc b/elab_net.cc index 62161efc2..7e0d1a495 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.99 2002/09/08 01:37:13 steve Exp $" +#ident "$Id: elab_net.cc,v 1.100 2002/09/12 15:49:43 steve Exp $" #endif # include "config.h" @@ -67,6 +67,7 @@ NetNet* PEBinary::elaborate_net(Design*des, NetScope*scope, case '|': // Bitwise OR case '&': case '^': + case 'A': // Bitwise NAND (~&) case 'X': // Exclusing NOR return elaborate_net_bit_(des, scope, width, rise, fall, decay); case 'E': // === (case equals) @@ -340,6 +341,20 @@ NetNet* PEBinary::elaborate_net_bit_(Design*des, NetScope*scope, } break; + case 'A': // NAND (~&) + for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) { + NetLogic*gate = new NetLogic(scope, scope->local_hsymbol(), + 3, NetLogic::NAND); + 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; + case '|': // Bitwise OR for (unsigned idx = 0 ; idx < lsig->pin_count() ; idx += 1) { NetLogic*gate = new NetLogic(scope, scope->local_hsymbol(), @@ -2177,6 +2192,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope, /* * $Log: elab_net.cc,v $ + * Revision 1.100 2002/09/12 15:49:43 steve + * Add support for binary nand operator. + * * Revision 1.99 2002/09/08 01:37:13 steve * Fix padding of operand of unary minus. * diff --git a/ivl_target.h b/ivl_target.h index 61a28b84e..4bb1dd062 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: ivl_target.h,v 1.105 2002/08/24 05:03:40 steve Exp $" +#ident "$Id: ivl_target.h,v 1.106 2002/09/12 15:49:43 steve Exp $" #endif #ifdef __cplusplus @@ -418,7 +418,15 @@ extern ivl_nexus_t ivl_event_pos(ivl_event_t net, unsigned idx); * * ivl_expr_width * This method returns the bit width of the expression at this - * node. It can be applied to any expression node. + * node. It can be applied to any expression node, and returns the + * *output* width of the expression node. + * + * ivl_expr_opcode + * IVL_EX_BINARY and IVL_EX_UNARY expression nodes include an + * upcode from this table: + * & -- AND + * A -- NAND (~&) + * X -- XNOR (~^) */ extern ivl_expr_type_t ivl_expr_type(ivl_expr_t net); @@ -1079,6 +1087,9 @@ _END_DECL /* * $Log: ivl_target.h,v $ + * Revision 1.106 2002/09/12 15:49:43 steve + * Add support for binary nand operator. + * * Revision 1.105 2002/08/24 05:03:40 steve * Missing declaration of ivl_memory_scope. * diff --git a/netlist.h b/netlist.h index 48f176b6c..33b84bb0d 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.h,v 1.260 2002/08/19 00:06:12 steve Exp $" +#ident "$Id: netlist.h,v 1.261 2002/09/12 15:49:43 steve Exp $" #endif /* @@ -2157,8 +2157,9 @@ class NetProcTop : public LineInfo, public Attrib { * n -- Logical inequality (!=) * N -- Case inequality (!==) * a -- Logical AND (&&) + * A -- Bitwise NAND (~&) * o -- Logical OR (||) - * O -- Bit-wise NOR + * O -- Bit-wise NOR (~|) * l -- Left shift (<<) * r -- Right shift (>>) * X -- Bitwise exclusive NOR (~^) @@ -3026,6 +3027,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.261 2002/09/12 15:49:43 steve + * Add support for binary nand operator. + * * Revision 1.260 2002/08/19 00:06:12 steve * Allow release to handle removal of target net. * diff --git a/parse.y b/parse.y index 0c5fe505f..591488249 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.159 2002/09/01 03:01:48 steve Exp $" +#ident "$Id: parse.y,v 1.160 2002/09/12 15:49:43 steve Exp $" #endif # include "config.h" @@ -736,6 +736,12 @@ expression tmp->set_lineno(@2.first_line); $$ = tmp; } + | expression K_NAND expression + { PEBinary*tmp = new PEBinary('A', $1, $3); + tmp->set_file(@2.text); + tmp->set_lineno(@2.first_line); + $$ = tmp; + } | expression K_NOR expression { PEBinary*tmp = new PEBinary('O', $1, $3); tmp->set_file(@2.text); diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 24732039e..a3a05ac64 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.74 2002/09/01 01:42:34 steve Exp $" +#ident "$Id: eval_expr.c,v 1.75 2002/09/12 15:49:43 steve Exp $" #endif # include "vvp_priv.h" @@ -595,6 +595,11 @@ static struct vector_info draw_binary_expr_logic(ivl_expr_t exp, lv.base, rv.base, wid); break; + case 'A': /* NAND (~&) */ + fprintf(vvp_out, " %%nand %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); @@ -883,7 +888,8 @@ static struct vector_info draw_binary_expr(ivl_expr_t exp, unsigned wid) case '&': case '|': case '^': - case 'X': + case 'A': /* NAND (~&) */ + case 'X': /* XNOR (~^) */ rv = draw_binary_expr_logic(exp, wid); break; @@ -1795,6 +1801,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp) /* * $Log: eval_expr.c,v $ + * Revision 1.75 2002/09/12 15:49:43 steve + * Add support for binary nand operator. + * * Revision 1.74 2002/09/01 01:42:34 steve * Fix leaking vthread bits in ?: eval. * diff --git a/vvp/codes.h b/vvp/codes.h index 8f0e7a74b..7f32e13d6 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.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. * diff --git a/vvp/compile.cc b/vvp/compile.cc index 1286f0574..e4669f202 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.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. * diff --git a/vvp/opcodes.txt b/vvp/opcodes.txt index 99ebda6ab..fe06ed79b 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.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 , , + +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 , , The %nor/r instruction is a reduction nor. That is, the is a diff --git a/vvp/vthread.cc b/vvp/vthread.cc index c526bc05a..fcd6f126e 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2002 Stephen Williams (steve@icarus.com) * * 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. *