From c63a3acf93c0c365fb9c7caba72648bb2c56451b Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 30 Sep 1999 02:43:01 +0000 Subject: [PATCH] Elaborate ~^ and ~| operators. --- design_dump.cc | 11 ++++++++++- elab_expr.cc | 7 ++++++- elaborate.cc | 25 ++++++++++++++++++------- netlist.h | 9 ++++++++- parse.y | 18 +++++++++++++++--- pform_dump.cc | 17 +++++++++++++---- 6 files changed, 70 insertions(+), 17 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index 8f99a3462..6d9779a7b 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: design_dump.cc,v 1.44 1999/09/29 18:36:03 steve Exp $" +#ident "$Id: design_dump.cc,v 1.45 1999/09/30 02:43:01 steve Exp $" #endif /* @@ -598,9 +598,15 @@ void NetEBinary::dump(ostream&o) const case 'o': o << "||"; break; + case 'O': + o << "~|"; + break; case 'r': o << ">>"; break; + case 'X': + o << "~^"; + break; } o << "("; right_->dump(o); @@ -768,6 +774,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.45 1999/09/30 02:43:01 steve + * Elaborate ~^ and ~| operators. + * * Revision 1.44 1999/09/29 18:36:03 steve * Full case support * diff --git a/elab_expr.cc b/elab_expr.cc index a214d0049..0ea90b1e5 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 */ #if !defined(WINNT) -#ident "$Id: elab_expr.cc,v 1.5 1999/09/30 00:48:49 steve Exp $" +#ident "$Id: elab_expr.cc,v 1.6 1999/09/30 02:43:02 steve Exp $" #endif @@ -77,6 +77,8 @@ NetExpr* PEBinary::elaborate_expr(Design*des, const string&path) const case '^': case '&': case '|': + case 'O': + case 'X': tmp = new NetEBBits(op_, lp, rp); tmp->set_line(*this); break; @@ -316,6 +318,9 @@ NetExpr*PETernary::elaborate_expr(Design*des, const string&path) const /* * $Log: elab_expr.cc,v $ + * Revision 1.6 1999/09/30 02:43:02 steve + * Elaborate ~^ and ~| operators. + * * Revision 1.5 1999/09/30 00:48:49 steve * Cope with errors during ternary operator elaboration. * diff --git a/elaborate.cc b/elaborate.cc index 8f5b94069..f0f8d481e 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: elaborate.cc,v 1.104 1999/09/30 00:48:50 steve Exp $" +#ident "$Id: elaborate.cc,v 1.105 1999/09/30 02:43:02 steve Exp $" #endif /* @@ -2277,12 +2277,20 @@ NetProc* PRepeat::elaborate(Design*des, const string&path) const */ void PTask::elaborate(Design*des, const string&path) const { - NetProc*st = statement_->elaborate(des, path); - if (st == 0) { - cerr << statement_->get_line() << ": Unable to elaborate " - "statement in task " << path << " at " << get_line() - << "." << endl; - return; + NetProc*st; + if (statement_ == 0) { + cerr << get_line() << ": warning: task has no statement." << endl; + st = new NetBlock(NetBlock::SEQU); + + } else { + + st = statement_->elaborate(des, path); + if (st == 0) { + cerr << statement_->get_line() << ": Unable to elaborate " + "statement in task " << path << " at " << get_line() + << "." << endl; + return; + } } /* Translate the wires that are ports to NetNet pointers by @@ -2500,6 +2508,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.105 1999/09/30 02:43:02 steve + * Elaborate ~^ and ~| operators. + * * Revision 1.104 1999/09/30 00:48:50 steve * Cope with errors during ternary operator elaboration. * diff --git a/netlist.h b/netlist.h index 758e99330..d3e2bc11b 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.h,v 1.74 1999/09/29 18:36:03 steve Exp $" +#ident "$Id: netlist.h,v 1.75 1999/09/30 02:43:02 steve Exp $" #endif /* @@ -1146,8 +1146,10 @@ class NetProcTop : public LineInfo { * N -- Case inequality (!==) * a -- Logical AND (&&) * o -- Logical OR (||) + * O -- Bit-wise NOR * l -- Left shift (<<) * r -- Right shift (>>) + * X -- Bitwise exclusive NOR (~^) */ class NetEBinary : public NetExpr { @@ -1202,6 +1204,8 @@ class NetEBAdd : public NetEBinary { * ^ -- Bit-wise exclusive OR * & -- Bit-wise AND * | -- Bit-wise OR + * O -- Bit-wise NOR + * X -- Bit-wise XNOR (~^) */ class NetEBBits : public NetEBinary { @@ -1700,6 +1704,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.75 1999/09/30 02:43:02 steve + * Elaborate ~^ and ~| operators. + * * Revision 1.74 1999/09/29 18:36:03 steve * Full case support * diff --git a/parse.y b/parse.y index 0ac477346..9f5a22fb9 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) -#ident "$Id: parse.y,v 1.72 1999/09/30 01:22:37 steve Exp $" +#ident "$Id: parse.y,v 1.73 1999/09/30 02:43:02 steve Exp $" #endif # include "parse_misc.h" @@ -149,8 +149,8 @@ extern void lex_end_table(); %left K_LOR %left K_LAND %left '|' -%left '^' -%left '&' +%left '^' K_NXOR K_NOR +%left '&' K_NAND %left K_EQ K_NE K_CEQ K_CNE %left K_GE K_LE '<' '>' %left K_LS K_RS @@ -496,6 +496,18 @@ expression tmp->set_lineno(@2.first_line); $$ = tmp; } + | expression K_NOR expression + { PEBinary*tmp = new PEBinary('O', $1, $3); + tmp->set_file(@2.text); + tmp->set_lineno(@2.first_line); + $$ = tmp; + } + | expression K_NXOR expression + { PEBinary*tmp = new PEBinary('X', $1, $3); + tmp->set_file(@2.text); + tmp->set_lineno(@2.first_line); + $$ = tmp; + } | expression '<' expression { PEBinary*tmp = new PEBinary('<', $1, $3); tmp->set_file(@2.text); diff --git a/pform_dump.cc b/pform_dump.cc index ab2344299..e58277da9 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: pform_dump.cc,v 1.43 1999/09/30 00:48:50 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.44 1999/09/30 02:43:02 steve Exp $" #endif /* @@ -505,7 +505,10 @@ void PTask::dump(ostream&out, unsigned ind) const out << (*ports_)[idx]->name() << ";" << endl; } - statement_->dump(out, ind); + if (statement_) + statement_->dump(out, ind); + else + out << setw(ind) << "" << "/* NOOP */" << endl; } @@ -569,8 +572,11 @@ void Module::dump(ostream&out) const typedef map::const_iterator parm_iter_t; for (parm_iter_t cur = parameters.begin() ; cur != parameters.end() ; cur ++) { - out << " parameter " << (*cur).first << " = " << - *(*cur).second << ";" << endl; + out << " parameter " << (*cur).first << " = "; + if ((*cur).second) + out << *(*cur).second << ";" << endl; + else + out << "/* ERROR */;" << endl; } // Iterate through and display all the wires. @@ -666,6 +672,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.44 1999/09/30 02:43:02 steve + * Elaborate ~^ and ~| operators. + * * Revision 1.43 1999/09/30 00:48:50 steve * Cope with errors during ternary operator elaboration. *