Real valued nets are signed, and pform unary expression have width.

Real valued nets should ne treated as signed no matter what.
Also, PEUnary nary expressions need a useful test_width method.
This commit is contained in:
Stephen Williams 2008-08-15 22:03:19 -07:00
parent 1ae2c0c9e0
commit 30e6cfce41
3 changed files with 27 additions and 1 deletions

View File

@ -492,6 +492,10 @@ class PEUnary : public PExpr {
virtual void dump(ostream&out) const; virtual void dump(ostream&out) const;
virtual unsigned test_width(Design*des, NetScope*scope,
unsigned min, unsigned lval,
bool&unsized_flag) const;
virtual bool elaborate_sig(Design*des, NetScope*scope) const; virtual bool elaborate_sig(Design*des, NetScope*scope) const;
virtual NetNet* elaborate_net(Design*des, NetScope*scope, virtual NetNet* elaborate_net(Design*des, NetScope*scope,

View File

@ -1954,6 +1954,25 @@ NetETernary*PETernary::elaborate_expr(Design*des, NetScope*scope,
return res; return res;
} }
unsigned PEUnary::test_width(Design*des, NetScope*scope,
unsigned min, unsigned lval,
bool&unsized_flag) const
{
switch (op_) {
case '!':
case '&':
case '|': // Reduction OR
case '^': // Reduction XOR
case 'A': // Reduction NAND (~&)
case 'N': // Reduction NOR (~|)
case 'X': // Reduction NXOR (~^)
return 1;
default:
return expr_->test_width(des, scope, min, lval, unsized_flag);
}
}
NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
int expr_wid, bool) const int expr_wid, bool) const
{ {

View File

@ -604,7 +604,10 @@ void NetNet::data_type(ivl_variable_type_t t)
bool NetNet::get_signed() const bool NetNet::get_signed() const
{ {
return signed_; if (data_type_ == IVL_VT_REAL)
return true;
else
return signed_;
} }
void NetNet::set_signed(bool flag) void NetNet::set_signed(bool flag)