Add support for unary +/- in real parameter evaluation.
This patch adds support for unary + and - of real value constants to the eval_tree() functionality.
This commit is contained in:
parent
538d3d1f4d
commit
3716e972ec
27
eval_tree.cc
27
eval_tree.cc
|
|
@ -1483,6 +1483,8 @@ void NetEUnary::eval_expr_()
|
|||
assert(expr_);
|
||||
if (dynamic_cast<NetEConst*>(expr_))
|
||||
return;
|
||||
if (dynamic_cast<NetECReal*>(expr_))
|
||||
return;
|
||||
|
||||
NetExpr*oper = expr_->eval_tree();
|
||||
if (oper == 0)
|
||||
|
|
@ -1492,9 +1494,30 @@ void NetEUnary::eval_expr_()
|
|||
expr_ = oper;
|
||||
}
|
||||
|
||||
NetEConst* NetEUnary::eval_tree(int prune_to_width)
|
||||
NetExpr* NetEUnary::eval_tree_real_()
|
||||
{
|
||||
NetECReal*val= dynamic_cast<NetECReal*> (expr_), *res;
|
||||
if (val == 0) return 0;
|
||||
|
||||
switch (op_) {
|
||||
case '+':
|
||||
res = new NetECReal(val->value());
|
||||
res->set_line(*this);
|
||||
return res;
|
||||
case '-':
|
||||
res = new NetECReal(-(val->value()));
|
||||
res->set_line(*this);
|
||||
return res;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
NetExpr* NetEUnary::eval_tree(int prune_to_width)
|
||||
{
|
||||
eval_expr_();
|
||||
if (expr_type() == IVL_VT_REAL) return eval_tree_real_();
|
||||
|
||||
NetEConst*rval = dynamic_cast<NetEConst*>(expr_);
|
||||
if (rval == 0)
|
||||
return 0;
|
||||
|
|
@ -1549,7 +1572,7 @@ NetEConst* NetEUnary::eval_tree(int prune_to_width)
|
|||
}
|
||||
|
||||
|
||||
NetEConst* NetEUBits::eval_tree(int prune_to_width)
|
||||
NetExpr* NetEUBits::eval_tree(int prune_to_width)
|
||||
{
|
||||
return NetEUnary::eval_tree(prune_to_width);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3138,7 +3138,7 @@ class NetEUnary : public NetExpr {
|
|||
virtual bool set_width(unsigned w, bool last_chance);
|
||||
|
||||
virtual NetEUnary* dup_expr() const;
|
||||
virtual NetEConst* eval_tree(int prune_to_width = -1);
|
||||
virtual NetExpr* eval_tree(int prune_to_width = -1);
|
||||
|
||||
virtual ivl_variable_type_t expr_type() const;
|
||||
virtual NexusSet* nex_input(bool rem_out = true);
|
||||
|
|
@ -3150,6 +3150,9 @@ class NetEUnary : public NetExpr {
|
|||
NetExpr* expr_;
|
||||
|
||||
void eval_expr_();
|
||||
|
||||
private:
|
||||
virtual NetExpr* eval_tree_real_();
|
||||
};
|
||||
|
||||
class NetEUBits : public NetEUnary {
|
||||
|
|
@ -3160,7 +3163,7 @@ class NetEUBits : public NetEUnary {
|
|||
|
||||
virtual NetNet* synthesize(Design*);
|
||||
|
||||
virtual NetEConst* eval_tree(int prune_to_width = -1);
|
||||
virtual NetExpr* eval_tree(int prune_to_width = -1);
|
||||
virtual ivl_variable_type_t expr_type() const;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue