From 4d8c0c79d6b6ef529540e744f2e47776093ea21a Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 5 Oct 1999 06:19:46 +0000 Subject: [PATCH] Add support for reduction NOR. --- design_dump.cc | 15 +++++++++++++-- elaborate.cc | 11 ++++++++++- set_width.cc | 13 +++++-------- t-vvm.cc | 28 ++++++++++++++-------------- vvm/vvm_func.h | 12 +++++++++++- 5 files changed, 53 insertions(+), 26 deletions(-) diff --git a/design_dump.cc b/design_dump.cc index 6d9779a7b..7f59480d1 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.45 1999/09/30 02:43:01 steve Exp $" +#ident "$Id: design_dump.cc,v 1.46 1999/10/05 06:19:46 steve Exp $" #endif /* @@ -698,7 +698,15 @@ void NetEUFunc::dump(ostream&o) const void NetEUnary::dump(ostream&o) const { - o << op_ << "("; + switch (op_) { + case 'N': + o << "~|"; + break; + default: + o << op_; + break; + } + o << "("; expr_->dump(o); o << ")"; } @@ -774,6 +782,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.46 1999/10/05 06:19:46 steve + * Add support for reduction NOR. + * * Revision 1.45 1999/09/30 02:43:01 steve * Elaborate ~^ and ~| operators. * diff --git a/elaborate.cc b/elaborate.cc index 43c8e174b..211f4b0d3 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.108 1999/10/05 02:00:06 steve Exp $" +#ident "$Id: elaborate.cc,v 1.109 1999/10/05 06:19:46 steve Exp $" #endif /* @@ -1867,6 +1867,12 @@ NetProc* PCondit::elaborate(Design*des, const string&path) const // generate a comparison operator to get the result down to // one bit. Turn into != 0; + if (expr->expr_width() < 1) { + cerr << get_line() << ": internal error: " + "incomprehensible expression width (0)." << endl; + return 0; + } + if (! expr->set_width(1)) { assert(expr->expr_width() > 1); verinum zero (verinum::V0, expr->expr_width()); @@ -2547,6 +2553,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.109 1999/10/05 06:19:46 steve + * Add support for reduction NOR. + * * Revision 1.108 1999/10/05 02:00:06 steve * sorry message for non-constant l-value bit select. * diff --git a/set_width.cc b/set_width.cc index 393444791..823618caf 100644 --- a/set_width.cc +++ b/set_width.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: set_width.cc,v 1.5 1999/10/05 04:02:10 steve Exp $" +#ident "$Id: set_width.cc,v 1.6 1999/10/05 06:19:46 steve Exp $" #endif /* @@ -245,14 +245,8 @@ bool NetEUnary::set_width(unsigned w) case '-': flag = expr_->set_width(w); break; - case '&': - case '!': - if (w != 1) { - flag = false; - } - break; default: - flag = false; + flag = expr_width() == w; break; } expr_width(w); @@ -262,6 +256,9 @@ bool NetEUnary::set_width(unsigned w) /* * $Log: set_width.cc,v $ + * Revision 1.6 1999/10/05 06:19:46 steve + * Add support for reduction NOR. + * * Revision 1.5 1999/10/05 04:02:10 steve * Relaxed width handling for <= assignment. * diff --git a/t-vvm.cc b/t-vvm.cc index 8fcbf025b..cf0a1cc43 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: t-vvm.cc,v 1.57 1999/10/05 04:02:10 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.58 1999/10/05 06:19:46 steve Exp $" #endif # include @@ -305,32 +305,29 @@ void vvm_proc_rval::expr_unary(const NetEUnary*expr) expr->expr()->expr_scan(this); string tname = make_temp(); - os_ << " vvm_bitset_t<" << expr->expr_width() << "> " + os_ << " vvm_bitset_t<" << expr->expr_width() << "> " << tname << " = "; switch (expr->op()) { case '~': - os_ << "vvm_unop_not(" << result << ");" - << endl; + os_ << "vvm_unop_not(" << result << ");" << endl; break; case '&': - os_ << "vvm_unop_and(" << result << ");" - << endl; + os_ << "vvm_unop_and(" << result << ");" << endl; break; case '^': - os_ << "vvm_unop_xor(" << result << ");" - << endl; + os_ << "vvm_unop_xor(" << result << ");" << endl; break; case '!': - os_ << "vvm_unop_lnot(" << result << ");" - << endl; + os_ << "vvm_unop_lnot(" << result << ");" << endl; break; case '-': - os_ << "vvm_unop_uminus(" << result << ");" - << endl; + os_ << "vvm_unop_uminus(" << result << ");" << endl; + break; + case 'N': + os_ << "vvm_unop_nor(" << result << ");" << endl; break; case 'X': - os_ << "vvm_unop_xnor(" << result << ");" - << endl; + os_ << "vvm_unop_xnor(" << result << ");" << endl; break; default: cerr << "vvm: Unhandled unary op `" << expr->op() << "'" @@ -1681,6 +1678,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.58 1999/10/05 06:19:46 steve + * Add support for reduction NOR. + * * Revision 1.57 1999/10/05 04:02:10 steve * Relaxed width handling for <= assignment. * diff --git a/vvm/vvm_func.h b/vvm/vvm_func.h index ebe669739..bc408d61b 100644 --- a/vvm/vvm_func.h +++ b/vvm/vvm_func.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvm_func.h,v 1.13 1999/10/01 15:26:29 steve Exp $" +#ident "$Id: vvm_func.h,v 1.14 1999/10/05 06:19:47 steve Exp $" #endif # include "vvm.h" @@ -78,6 +78,13 @@ vvm_bitset_t<1> vvm_unop_or(const vvm_bitset_t&r) return res; } +template +vvm_bitset_t<1> vvm_unop_nor(const vvm_bitset_t&r) +{ + vvm_bitset_t<1>res = vvm_unop_or(r); + return vvm_unop_not(res); +} + template vvm_bitset_t<1> vvm_unop_lnot(const vvm_bitset_t&r) { @@ -601,6 +608,9 @@ vvm_bitset_t vvm_ternary(vvm_bit_t c, const vvm_bitset_t&t, /* * $Log: vvm_func.h,v $ + * Revision 1.14 1999/10/05 06:19:47 steve + * Add support for reduction NOR. + * * Revision 1.13 1999/10/01 15:26:29 steve * Add some vvm operators from Eric Aardoom. *