Fix for GitHub issue 14 : Bug in processing 1'b1 >= |1'bx.

During expression evaluation, the compiler attempts to optimise away
relational operations when one side is constant and all possible values
of the other side would result in the relation being true. This is not
a valid optimisation if the other side is a 4-state variable, as an
'x' or 'z' will result in the relation being unknown.
This commit is contained in:
Martin Whitaker 2014-02-18 21:22:19 +00:00
parent 830083d99b
commit 5a06602af2
1 changed files with 4 additions and 0 deletions

View File

@ -358,6 +358,10 @@ NetEConst* NetEBComp::eval_less_(const NetExpr*le, const NetExpr*re) const
NetEConst* NetEBComp::must_be_leeq_(const NetExpr*le, const verinum&rv, bool eq_flag) const
{
// The following optimization is not valid if le can contain 'x'
// or 'z' values.
if (le->expr_type() == IVL_VT_LOGIC) return 0;
assert(le->expr_width() > 0);
verinum lv (verinum::V1, le->expr_width());
if (le->has_sign() && rv.has_sign()) {