Fix power operator width in self-determined context.
In a self determined context the width of the power operator
is defined to be the left argument width.
(cherry picked from commit e98000426e)
This commit is contained in:
parent
693fb93962
commit
506c09f5f8
14
net_expr.cc
14
net_expr.cc
|
|
@ -257,15 +257,13 @@ ivl_variable_type_t NetEBMinMax::expr_type() const
|
||||||
NetEBMult::NetEBMult(char op__, NetExpr*l, NetExpr*r)
|
NetEBMult::NetEBMult(char op__, NetExpr*l, NetExpr*r)
|
||||||
: NetEBinary(op__, l, r)
|
: NetEBinary(op__, l, r)
|
||||||
{
|
{
|
||||||
if (expr_type() == IVL_VT_REAL)
|
if (expr_type() == IVL_VT_REAL) {
|
||||||
expr_width(1);
|
expr_width(1);
|
||||||
else
|
|
||||||
expr_width(l->expr_width() + r->expr_width());
|
|
||||||
|
|
||||||
if (expr_type() == IVL_VT_REAL)
|
|
||||||
cast_signed(true);
|
cast_signed(true);
|
||||||
else
|
} else {
|
||||||
|
expr_width(l->expr_width() + r->expr_width());
|
||||||
cast_signed(l->has_sign() && r->has_sign());
|
cast_signed(l->has_sign() && r->has_sign());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetEBMult::~NetEBMult()
|
NetEBMult::~NetEBMult()
|
||||||
|
|
@ -294,8 +292,8 @@ NetEBPow::NetEBPow(char op__, NetExpr*l, NetExpr*r)
|
||||||
: NetEBinary(op__, l, r)
|
: NetEBinary(op__, l, r)
|
||||||
{
|
{
|
||||||
assert(op__ == 'p');
|
assert(op__ == 'p');
|
||||||
/* This is incorrect! a * (2^b - 1) is close. */
|
/* You could need up to a * (2^b - 1) bits. */
|
||||||
expr_width(l->expr_width()+r->expr_width());
|
expr_width(l->expr_width());
|
||||||
cast_signed(l->has_sign() || r->has_sign());
|
cast_signed(l->has_sign() || r->has_sign());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue