Support constant evaluation of binary ^ operator.

This commit is contained in:
steve 2003-10-26 04:54:56 +00:00
parent edaa7df6d2
commit 1c99c629b1
3 changed files with 43 additions and 3 deletions

View File

@ -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.
*

View File

@ -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.
*

View File

@ -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 <string>
@ -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.