From e98000426e814f68e1c62076600d9de952d94d77 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 24 Jul 2009 16:54:58 -0700 Subject: [PATCH] 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. --- net_expr.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/net_expr.cc b/net_expr.cc index 786895237..3b5890caa 100644 --- a/net_expr.cc +++ b/net_expr.cc @@ -257,15 +257,13 @@ ivl_variable_type_t NetEBMinMax::expr_type() const NetEBMult::NetEBMult(char op__, NetExpr*l, NetExpr*r) : NetEBinary(op__, l, r) { - if (expr_type() == IVL_VT_REAL) + if (expr_type() == IVL_VT_REAL) { expr_width(1); - else - expr_width(l->expr_width() + r->expr_width()); - - if (expr_type() == IVL_VT_REAL) cast_signed(true); - else + } else { + expr_width(l->expr_width() + r->expr_width()); cast_signed(l->has_sign() && r->has_sign()); + } } NetEBMult::~NetEBMult() @@ -294,8 +292,8 @@ NetEBPow::NetEBPow(char op__, NetExpr*l, NetExpr*r) : NetEBinary(op__, l, r) { assert(op__ == 'p'); - /* This is incorrect! a * (2^b - 1) is close. */ - expr_width(l->expr_width()+r->expr_width()); + /* You could need up to a * (2^b - 1) bits. */ + expr_width(l->expr_width()); cast_signed(l->has_sign() || r->has_sign()); }