3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-19 20:33:39 +00:00

kernel/rtlil: Add SigBit operator[](int offset) to SigChunk

This is already supported by `SigSpec` and since both `SigChunk` and
`SigSpec` implement `extract` which is the multi-bit variant of this,
there is no good reason for `SigChunk` to not support
`SigBit operator[](int offset)`.
This commit is contained in:
Jannis Harder 2024-04-15 14:08:58 +02:00 committed by Emily Schmidt
parent c73c8a39cf
commit f24e2536c6
2 changed files with 15 additions and 0 deletions

View file

@ -3754,6 +3754,20 @@ RTLIL::SigChunk RTLIL::SigChunk::extract(int offset, int length) const
return ret;
}
RTLIL::SigBit RTLIL::SigChunk::operator[](int offset) const
{
log_assert(offset >= 0);
log_assert(offset <= width);
RTLIL::SigBit ret;
if (wire) {
ret.wire = wire;
ret.offset = this->offset + offset;
} else {
ret.data = data[offset];
}
return ret;
}
bool RTLIL::SigChunk::operator <(const RTLIL::SigChunk &other) const
{
if (wire && other.wire)