Fix for issue #280 - the condition operator may return a valid enum type.
If the condition expression is 2-state, the result won't be blended, so
the result will be a valid enum value if both true and false expressions
return the same enum type.
(cherry picked from commit 82c8a49573)
This commit is contained in:
parent
f1990caf6f
commit
fbe423305e
14
netlist.cc
14
netlist.cc
|
|
@ -2443,6 +2443,20 @@ NetETernary::~NetETernary()
|
|||
delete false_val_;
|
||||
}
|
||||
|
||||
const netenum_t* NetETernary::enumeration() const
|
||||
{
|
||||
// If the condition can evaluate to an ambiguous value,
|
||||
// the result may be blended, and so is not guaranteed
|
||||
// to be a valid enumeration value.
|
||||
if (cond_->expr_type() != IVL_VT_BOOL)
|
||||
return 0;
|
||||
|
||||
if (true_val_->enumeration() != false_val_->enumeration())
|
||||
return 0;
|
||||
|
||||
return true_val_->enumeration();
|
||||
}
|
||||
|
||||
const NetExpr* NetETernary::cond_expr() const
|
||||
{
|
||||
return cond_;
|
||||
|
|
|
|||
|
|
@ -4580,6 +4580,8 @@ class NetETernary : public NetExpr {
|
|||
NetETernary(NetExpr*c, NetExpr*t, NetExpr*f, unsigned wid, bool signed_flag);
|
||||
~NetETernary();
|
||||
|
||||
const netenum_t* enumeration() const;
|
||||
|
||||
const NetExpr*cond_expr() const;
|
||||
const NetExpr*true_expr() const;
|
||||
const NetExpr*false_expr() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue