Skip to content
Permalink
Browse files

Fix for GitHub issue 8 : Signedness of constant binary bitwise operat…

…ions.

When doing constant evaluation of binary bitwise operations, the result
value must be signed if the expression type is signed.
  • Loading branch information
martinwhitaker committed Feb 15, 2014
1 parent 8135f36 commit ac3aee01720773002f995b9185d2e2024e736177
Showing with 4 additions and 0 deletions.
  1. +4 −0 eval_tree.cc
@@ -248,6 +248,7 @@ NetEConst* NetEBBits::eval_arguments_(const NetExpr*l, const NetExpr*r) const
known to be 0. */
if ((op() == '&') && (lc->value() == verinum(0))) {
verinum res (verinum::V0, expr_width());
res.has_sign(has_sign());
NetEConst*tmp = new NetEConst(res);
ivl_assert(*this, tmp);
eval_debug(this, tmp, false);
@@ -256,6 +257,7 @@ NetEConst* NetEBBits::eval_arguments_(const NetExpr*l, const NetExpr*r) const

if ((op() == '&') && (rc->value() == verinum(0))) {
verinum res (verinum::V0, expr_width());
res.has_sign(has_sign());
NetEConst*tmp = new NetEConst(res);
ivl_assert(*this, tmp);
eval_debug(this, tmp, false);
@@ -306,6 +308,7 @@ NetEConst* NetEBBits::eval_arguments_(const NetExpr*l, const NetExpr*r) const
return 0;
}

res.has_sign(has_sign());
NetEConst*tmp = new NetEConst(res);
ivl_assert(*this, tmp);
eval_debug(this, tmp, false);
@@ -982,6 +985,7 @@ NetExpr* NetEBMinMax::eval_arguments_(const NetExpr*l, const NetExpr*r) const
} else {
res_val = verinum(verinum::Vx, wid);
}
res_val.has_sign(has_sign());
NetEConst*res = new NetEConst(res_val);
ivl_assert(*this, res);
eval_debug(this, res, false);

0 comments on commit ac3aee0

Please sign in to comment.