diff --git a/net_expr.cc b/net_expr.cc index 2efb91f8f..d71ecb231 100644 --- a/net_expr.cc +++ b/net_expr.cc @@ -81,6 +81,7 @@ NetEBAdd::NetEBAdd(char op, NetExpr*l, NetExpr*r, bool lossless_flag) } unsigned pad_width = lossless_flag? 1 : 0; + cast_signed(l->has_sign() && r->has_sign()); /* Now that we have the operand sizes the way we like, or as good as we are going to get them, set the size of myself. */ @@ -91,8 +92,6 @@ NetEBAdd::NetEBAdd(char op, NetExpr*l, NetExpr*r, bool lossless_flag) } else { expr_width(l->expr_width() + pad_width); } - - cast_signed(l->has_sign() && r->has_sign()); } NetEBAdd::~NetEBAdd() diff --git a/verinum.cc b/verinum.cc index 44e114731..11d561c1a 100644 --- a/verinum.cc +++ b/verinum.cc @@ -448,7 +448,7 @@ verinum pad_to_width(const verinum&that, unsigned width) verinum::V pad = that[that.len()-1]; if (pad==verinum::V1 && !that.has_sign()) pad = verinum::V0; - if (that.has_len()) { + if (that.has_len() && !that.has_sign()) { if (pad==verinum::Vx) pad = verinum::V0; if (pad==verinum::Vz)