For a signed R-value we can use the full width when converting to long

When trying to get the value we can use the full width of a long if the
expression is signed.
This commit is contained in:
Cary R 2014-12-10 14:38:12 -08:00
parent 48b0fed29e
commit 96472e5537
1 changed files with 5 additions and 2 deletions

View File

@ -785,8 +785,11 @@ unsigned PEBLeftWidth::test_width(Design*des, NetScope*scope, width_mode_t&mode)
right_ = tmp;
}
NetEConst*rc = dynamic_cast<NetEConst*> (rp);
if (rc && (r_width < sizeof(long)*8))
r_val = rc->value().as_long();
// Adjust the expression width that can be converter depending
// on if the R-value is signed or not.
unsigned c_width = sizeof(long)*8;
if (! right_->has_sign()) c_width -= 1;
if (rc && (r_width <= c_width)) r_val = rc->value().as_long();
if (debug_elaborate && rc) {
cerr << get_fileline() << ": PEBLeftWidth::test_width: "