3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-22 09:21:29 +00:00

Update kernel to avoid bits()

This commit is contained in:
Robert O'Callahan 2025-08-28 01:55:47 +00:00
parent 7f247fb125
commit 6dc9a8bacf
14 changed files with 151 additions and 122 deletions

View file

@ -214,18 +214,19 @@ bool mp_int_to_const(mp_int *a, Const &b, bool is_signed)
buf.resize(mp_unsigned_bin_size(a));
mp_to_unsigned_bin(a, buf.data());
b.bits().reserve(mp_count_bits(a) + is_signed);
Const::Builder b_bits(mp_count_bits(a) + is_signed);
for (int i = 0; i < mp_count_bits(a);) {
for (int j = 0; j < 8 && i < mp_count_bits(a); j++, i++) {
bool bv = ((buf.back() & (1 << j)) != 0) ^ negative;
b.bits().push_back(bv ? RTLIL::S1 : RTLIL::S0);
b_bits.push_back(bv ? RTLIL::S1 : RTLIL::S0);
}
buf.pop_back();
}
if (is_signed) {
b.bits().push_back(negative ? RTLIL::S1 : RTLIL::S0);
b_bits.push_back(negative ? RTLIL::S1 : RTLIL::S0);
}
b = b_bits.build();
return true;
}