From 9756cb6382c633d5b025b3a92a2537f586c28b8e Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 1 Feb 2002 05:09:14 +0000 Subject: [PATCH] Propagate sign in unary minus. --- eval_tree.cc | 6 +++++- netlist.cc | 13 ++++++++++++- verinum.cc | 9 ++++++--- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/eval_tree.cc b/eval_tree.cc index 5591e31a5..9909fb6f3 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: eval_tree.cc,v 1.32 2002/01/22 01:40:04 steve Exp $" +#ident "$Id: eval_tree.cc,v 1.33 2002/02/01 05:09:14 steve Exp $" #endif # include "config.h" @@ -963,6 +963,7 @@ NetEConst* NetEUnary::eval_tree() if (val.is_defined()) { verinum tmp (verinum::V0, val.len()); + tmp.has_sign(val.has_sign()); val = tmp - val; } else { @@ -1063,6 +1064,9 @@ NetEConst* NetEUReduce::eval_tree() /* * $Log: eval_tree.cc,v $ + * Revision 1.33 2002/02/01 05:09:14 steve + * Propagate sign in unary minus. + * * Revision 1.32 2002/01/22 01:40:04 steve * Precalculate constant results of memory index expressions. * diff --git a/netlist.cc b/netlist.cc index a26237987..9469a59d8 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.cc,v 1.180 2002/01/22 01:40:04 steve Exp $" +#ident "$Id: netlist.cc,v 1.181 2002/02/01 05:09:14 steve Exp $" #endif # include "config.h" @@ -2339,6 +2339,14 @@ NetEUnary::NetEUnary(char op, NetExpr*ex) expr_width(1); break; } + switch (op_) { + case '-': + case '+': + cast_signed(ex->has_sign()); + break; + default: + ; + } } NetEUnary::~NetEUnary() @@ -2415,6 +2423,9 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.181 2002/02/01 05:09:14 steve + * Propagate sign in unary minus. + * * Revision 1.180 2002/01/22 01:40:04 steve * Precalculate constant results of memory index expressions. * diff --git a/verinum.cc b/verinum.cc index 0cd9842d2..2acaaf257 100644 --- a/verinum.cc +++ b/verinum.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: verinum.cc,v 1.30 2001/12/31 00:02:33 steve Exp $" +#ident "$Id: verinum.cc,v 1.31 2002/02/01 05:09:14 steve Exp $" #endif # include "config.h" @@ -359,7 +359,7 @@ ostream& operator<< (ostream&o, const verinum&v) if (v.has_sign()) o << "'sb"; else - o << "'sb"; + o << "'b"; if (v.len() == 0) { o << "0"; @@ -595,7 +595,7 @@ verinum operator - (const verinum&left, const verinum&r) for (unsigned idx = min ; idx < max ; idx += 1) val.set(idx, add_with_carry(verinum::V0, right[idx], carry)); - + val.has_sign(left.has_sign() && r.has_sign()); return val; } @@ -793,6 +793,9 @@ verinum::V operator & (verinum::V l, verinum::V r) /* * $Log: verinum.cc,v $ + * Revision 1.31 2002/02/01 05:09:14 steve + * Propagate sign in unary minus. + * * Revision 1.30 2001/12/31 00:02:33 steve * Include s indicator in dump of signed numbers. *