diff --git a/eval_tree.cc b/eval_tree.cc index 056f1863c..85793cddd 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: eval_tree.cc,v 1.57 2003/09/04 01:52:50 steve Exp $" +#ident "$Id: eval_tree.cc,v 1.58 2003/10/26 04:54:56 steve Exp $" #endif # include "config.h" @@ -150,6 +150,24 @@ NetEConst* NetEBBits::eval_tree() break; } + case '^': { + unsigned cnt = lwid; + if (cnt > wid) cnt = wid; + if (cnt > rwid) cnt = rwid; + for (unsigned idx = 0 ; idx < cnt ; idx += 1) + res.set(idx, lval.get(idx) ^ rval.get(idx)); + + if (lwid < rwid) + for (unsigned idx = lwid ; idx < rwid ; idx += 1) + res.set(idx, rval.get(idx)); + + if (rwid < lwid) + for (unsigned idx = rwid ; idx < lwid ; idx += 1) + res.set(idx, lval.get(idx)); + + break; + } + default: return 0; } @@ -1495,6 +1513,9 @@ NetEConst* NetEUReduce::eval_tree() /* * $Log: eval_tree.cc,v $ + * Revision 1.58 2003/10/26 04:54:56 steve + * Support constant evaluation of binary ^ operator. + * * Revision 1.57 2003/09/04 01:52:50 steve * Evaluate real parameter expressions that contain real parameters. * diff --git a/verinum.cc b/verinum.cc index ead87e4c7..8f0e86a29 100644 --- a/verinum.cc +++ b/verinum.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: verinum.cc,v 1.40 2003/05/25 03:01:19 steve Exp $" +#ident "$Id: verinum.cc,v 1.41 2003/10/26 04:54:56 steve Exp $" #endif # include "config.h" @@ -843,8 +843,23 @@ verinum::V operator & (verinum::V l, verinum::V r) return verinum::V1; } +verinum::V operator ^ (verinum::V l, verinum::V r) +{ + if (l == verinum::V0) + return r; + if (r == verinum::V0) + return l; + if ((l == verinum::V1) && (r == verinum::V1)) + return verinum::V0; + + return verinum::Vx; +} + /* * $Log: verinum.cc,v $ + * Revision 1.41 2003/10/26 04:54:56 steve + * Support constant evaluation of binary ^ operator. + * * Revision 1.40 2003/05/25 03:01:19 steve * Get length of trimed unsigned value right. * diff --git a/verinum.h b/verinum.h index a6c58100d..50099ab9a 100644 --- a/verinum.h +++ b/verinum.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: verinum.h,v 1.24 2003/04/14 03:40:21 steve Exp $" +#ident "$Id: verinum.h,v 1.25 2003/10/26 04:54:56 steve Exp $" #endif # include @@ -112,6 +112,7 @@ extern ostream& operator<< (ostream&, verinum::V); extern verinum::V operator | (verinum::V l, verinum::V r); extern verinum::V operator & (verinum::V l, verinum::V r); +extern verinum::V operator ^ (verinum::V l, verinum::V r); extern verinum::V operator == (const verinum&left, const verinum&right); extern verinum::V operator <= (const verinum&left, const verinum&right); @@ -143,6 +144,9 @@ extern verinum v_not(const verinum&left); /* * $Log: verinum.h,v $ + * Revision 1.25 2003/10/26 04:54:56 steve + * Support constant evaluation of binary ^ operator. + * * Revision 1.24 2003/04/14 03:40:21 steve * Make some effort to preserve bits while * operating on constant values.