return sig;
}
- // just pass thru the signal. the parent will evaluate the is_signed property and inperpret the SigSpec accordingly
+ // just pass thru the signal. the parent will evaluate the is_signed property and interpret the SigSpec accordingly
case AST_TO_SIGNED:
case AST_TO_UNSIGNED: {
RTLIL::SigSpec sig = children[0]->genRTLIL();
genRTLIL_subst_to = backup_subst_to;
if (width >= 0)
- widthExtend(this, sig, width, is_signed);
+ sig.extend_u0(width, is_signed);
return sig;
}
arg.bits.push_back(padding);
}
+static void extend_u0(RTLIL::Const &arg, int width, bool is_signed)
+{
+ RTLIL::State padding = RTLIL::State::S0;
+
+ if (arg.bits.size() > 0 && is_signed)
+ padding = arg.bits.back();
+
+ while (int(arg.bits.size()) < width)
+ arg.bits.push_back(padding);
+}
+
static BigInteger const2big(const RTLIL::Const &val, bool as_signed, int &undef_bit_pos)
{
BigInteger result = 0, this_bit = 1;
result_len = arg1.bits.size();
RTLIL::Const arg1_ext = arg1;
- extend(arg1_ext, result_len, signed1);
+ extend_u0(arg1_ext, result_len, signed1);
RTLIL::Const result(RTLIL::State::Sx, result_len);
for (size_t i = 0; i < size_t(result_len); i++) {
if (result_len < 0)
result_len = std::max(arg1.bits.size(), arg2.bits.size());
- extend(arg1, result_len, signed1);
- extend(arg2, result_len, signed2);
+ extend_u0(arg1, result_len, signed1);
+ extend_u0(arg2, result_len, signed2);
RTLIL::Const result(RTLIL::State::Sx, result_len);
for (size_t i = 0; i < size_t(result_len); i++) {
RTLIL::Const arg2_ext = arg2;
RTLIL::Const result(RTLIL::State::S0, result_len);
- while (arg1_ext.bits.size() < arg2_ext.bits.size())
- arg1_ext.bits.push_back(signed1 && signed2 && arg1_ext.bits.size() > 0 ? arg1_ext.bits.back() : RTLIL::State::S0);
-
- while (arg2_ext.bits.size() < arg1_ext.bits.size())
- arg2_ext.bits.push_back(signed1 && signed2 && arg2_ext.bits.size() > 0 ? arg2_ext.bits.back() : RTLIL::State::S0);
+ int width = std::max(arg1_ext.bits.size(), arg2_ext.bits.size());
+ extend_u0(arg1_ext, width, signed1 && signed2);
+ extend_u0(arg2_ext, width, signed1 && signed2);
RTLIL::State matched_status = RTLIL::State::S1;
for (size_t i = 0; i < arg1_ext.bits.size(); i++) {