diff --git a/eval_tree.cc b/eval_tree.cc index 41526f2ac..0ba396ff4 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -363,11 +363,15 @@ NetEConst* NetEBComp::eval_leeq_() cerr << get_line() << ": : " << *this << endl; } - /* Detect the case where the right side is greater that or + /* Detect the case where the right side is greater than or equal to the largest value the left side can possibly have. */ assert(left_->expr_width() > 0); verinum lv (verinum::V1, left_->expr_width() + 1); + if (left_->has_sign() && rv.has_sign()) { + lv.set(lv.len()-1, verinum::V0); + lv.has_sign(true); + } lv.set(left_->expr_width(), verinum::V0); lv.has_sign( left_->has_sign() ); if (lv <= rv) { diff --git a/verinum.cc b/verinum.cc index 633d7872f..2b2b0d9d6 100644 --- a/verinum.cc +++ b/verinum.cc @@ -493,8 +493,7 @@ verinum::V operator <= (const verinum&left, const verinum&right) return verinum::Vx; if (!right.is_defined()) return verinum::Vx; - long diff = left.as_long() - right.as_long(); - if (diff <= 0) + if (left.as_long() <= right.as_long()) return verinum::V1; else return verinum::V0; @@ -532,8 +531,7 @@ verinum::V operator < (const verinum&left, const verinum&right) return verinum::Vx; if (!right.is_defined()) return verinum::Vx; - long diff = left.as_long() - right.as_long(); - if (diff < 0) + if (left.as_long() < right.as_long()) return verinum::V1; else return verinum::V0;