mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-03 13:07:58 +00:00
Replace use of SigSpec::operator[] const in sigtools with iterators
This commit is contained in:
parent
8875efcebd
commit
ff86130cf9
2 changed files with 21 additions and 8 deletions
|
|
@ -1236,6 +1236,16 @@ struct RTLIL::SigSpecConstIterator
|
|||
inline bool operator==(const RTLIL::SigSpecConstIterator &other) const { return bit_index == other.bit_index; }
|
||||
inline RTLIL::SigSpecConstIterator &operator++();
|
||||
inline RTLIL::SigSpecConstIterator &operator--();
|
||||
inline RTLIL::SigSpecConstIterator operator++(int) {
|
||||
RTLIL::SigSpecConstIterator result(*this);
|
||||
++(*this);
|
||||
return result;
|
||||
}
|
||||
inline RTLIL::SigSpecConstIterator operator--(int) {
|
||||
RTLIL::SigSpecConstIterator result(*this);
|
||||
--(*this);
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
// Must be called when sig_p is packed and `bit_index` is in range. Finds the chunk containing `bit_index`
|
||||
|
|
|
|||
|
|
@ -72,8 +72,9 @@ struct SigPool
|
|||
void expand(const RTLIL::SigSpec &from, const RTLIL::SigSpec &to)
|
||||
{
|
||||
log_assert(GetSize(from) == GetSize(to));
|
||||
for (int i = 0; i < GetSize(from); i++) {
|
||||
bitDef_t bit_from(from[i]), bit_to(to[i]);
|
||||
RTLIL::SigSpecConstIterator to_it = to.begin();
|
||||
for (auto &bit : from) {
|
||||
bitDef_t bit_from(bit), bit_to(*to_it++);
|
||||
if (bit_from.first != NULL && bit_to.first != NULL && bits.count(bit_from) > 0)
|
||||
bits.insert(bit_to);
|
||||
}
|
||||
|
|
@ -321,10 +322,11 @@ struct SigMap final : public SigMapView
|
|||
{
|
||||
log_assert(GetSize(from) == GetSize(to));
|
||||
|
||||
for (int i = 0; i < GetSize(from); i++)
|
||||
RTLIL::SigSpecConstIterator to_it = to.begin();
|
||||
for (auto &bit : from)
|
||||
{
|
||||
int bfi = database.lookup(from[i]);
|
||||
int bti = database.lookup(to[i]);
|
||||
int bfi = database.lookup(bit);
|
||||
int bti = database.lookup(*to_it++);
|
||||
|
||||
const RTLIL::SigBit &bf = database[bfi];
|
||||
const RTLIL::SigBit &bt = database[bti];
|
||||
|
|
@ -415,10 +417,11 @@ struct SigValMap final : public SigMapView
|
|||
{
|
||||
log_assert(GetSize(from) == GetSize(to));
|
||||
|
||||
for (int i = 0; i < GetSize(from); i++)
|
||||
RTLIL::SigSpecConstIterator to_it = to.begin();
|
||||
for (auto &bit : from)
|
||||
{
|
||||
int bfi = database.lookup(from[i]);
|
||||
int bti = database.lookup(to[i]);
|
||||
int bfi = database.lookup(bit);
|
||||
int bti = database.lookup(*to_it++);
|
||||
if (bfi == bti) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue