Fix calculation of XOR when z is present

When calculating 0^z with constant arguments, make sure the result is
x. This problem only happens when the arguments are constants and the
expression is calculated at compile time.
This commit is contained in:
Stephen Williams 2008-05-09 09:16:11 -07:00
parent bbed408d68
commit db10de1a6a
2 changed files with 5 additions and 2 deletions

View File

@ -1238,9 +1238,9 @@ verinum::V operator & (verinum::V l, verinum::V r)
verinum::V operator ^ (verinum::V l, verinum::V r)
{
if (l == verinum::V0)
return r;
return bit4_z2x(r);
if (r == verinum::V0)
return l;
return bit4_z2x(l);
if ((l == verinum::V1) && (r == verinum::V1))
return verinum::V0;

View File

@ -130,6 +130,9 @@ extern verinum trim_vnum(const verinum&);
extern ostream& operator<< (ostream&, const verinum&);
extern ostream& operator<< (ostream&, verinum::V);
inline verinum::V bit4_z2x(verinum::V bit)
{ return bit<2? bit : verinum::Vx; /* Relies on V0 and V1 being <2 */}
extern verinum::V operator ~ (verinum::V l);
extern verinum::V operator | (verinum::V l, verinum::V r);
extern verinum::V operator & (verinum::V l, verinum::V r);