V0.9: Add support for taking ! of a constant real value.

This commit is contained in:
Cary R 2010-11-06 12:32:58 -07:00 committed by Stephen Williams
parent c88caa764d
commit 3612e53f7c
2 changed files with 19 additions and 0 deletions

View File

@ -1661,9 +1661,25 @@ NetExpr* NetEUBits::eval_tree(int prune_to_width)
return NetEUnary::eval_tree(prune_to_width); return NetEUnary::eval_tree(prune_to_width);
} }
NetEConst* NetEUReduce::eval_tree_real_()
{
ivl_assert(*this, op_ == '!');
NetECReal*val= dynamic_cast<NetECReal*> (expr_);
if (val == 0) return 0;
verinum::V res = val->value().as_double() == 0.0 ? verinum::V1 :
verinum::V0;
return new NetEConst(verinum(res, 1));
}
NetEConst* NetEUReduce::eval_tree(int prune_to_width) NetEConst* NetEUReduce::eval_tree(int prune_to_width)
{ {
eval_expr(expr_); eval_expr(expr_);
if (expr_type() == IVL_VT_REAL) return eval_tree_real_();
NetEConst*rval = dynamic_cast<NetEConst*>(expr_); NetEConst*rval = dynamic_cast<NetEConst*>(expr_);
if (rval == 0) return 0; if (rval == 0) return 0;

View File

@ -3804,6 +3804,9 @@ class NetEUReduce : public NetEUnary {
virtual NetEUReduce* dup_expr() const; virtual NetEUReduce* dup_expr() const;
virtual NetEConst* eval_tree(int prune_to_width = -1); virtual NetEConst* eval_tree(int prune_to_width = -1);
virtual ivl_variable_type_t expr_type() const; virtual ivl_variable_type_t expr_type() const;
private:
virtual NetEConst* eval_tree_real_();
}; };
/* /*