3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-11-05 13:56:04 +00:00

Make SigSpec::chunks() return an object that can be iterated over without packing the SigSpec

This commit is contained in:
Robert O'Callahan 2025-10-27 15:46:36 +00:00
parent c4f3e61339
commit 37e4c2e8f8
4 changed files with 104 additions and 9 deletions

View file

@ -4648,6 +4648,31 @@ RTLIL::SigSpec::SigSpec(bool bit)
check();
}
void RTLIL::SigSpec::Chunks::const_iterator::next_chunk_bits()
{
int bits_size = GetSize(spec.bits_);
if (bit_index >= bits_size)
return;
int i = bit_index;
const SigBit &bit = spec.bits_[i++];
chunk.wire = bit.wire;
chunk.data.clear();
if (bit.is_wire()) {
chunk.offset = bit.offset;
while (i < bits_size && spec.bits_[i].wire == bit.wire &&
spec.bits_[i].offset == bit.offset + i - bit_index)
++i;
} else {
chunk.offset = 0;
chunk.data.push_back(bit.data);
while (i < bits_size && !spec.bits_[i].is_wire()) {
chunk.data.push_back(spec.bits_[i].data);
++i;
}
}
chunk.width = i - bit_index;
}
void RTLIL::SigSpec::pack() const
{
RTLIL::SigSpec *that = (RTLIL::SigSpec*)this;