mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-05 13:56:04 +00:00
Instead of using packing and hashing to compute SigSpec ordering and equality, just use the width and chunkwise comparisons
This avoids having to pack and compute hashes, and generally results in a simpler ordering.
This commit is contained in:
parent
973e8a3928
commit
be530bef73
1 changed files with 11 additions and 39 deletions
|
|
@ -5337,23 +5337,12 @@ bool RTLIL::SigSpec::operator <(const RTLIL::SigSpec &other) const
|
||||||
if (width_ != other.width_)
|
if (width_ != other.width_)
|
||||||
return width_ < other.width_;
|
return width_ < other.width_;
|
||||||
|
|
||||||
pack();
|
auto other_it = other.chunks().begin();
|
||||||
other.pack();
|
for (const SigChunk &c : chunks()) {
|
||||||
|
if (c != *other_it)
|
||||||
if (chunks_.size() != other.chunks_.size())
|
return c < *other_it;
|
||||||
return chunks_.size() < other.chunks_.size();
|
++other_it;
|
||||||
|
}
|
||||||
updhash();
|
|
||||||
other.updhash();
|
|
||||||
|
|
||||||
if (hash_ != other.hash_)
|
|
||||||
return hash_ < other.hash_;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < chunks_.size(); i++)
|
|
||||||
if (chunks_[i] != other.chunks_[i]) {
|
|
||||||
cover("kernel.rtlil.sigspec.comp_lt.hash_collision");
|
|
||||||
return chunks_[i] < other.chunks_[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
cover("kernel.rtlil.sigspec.comp_lt.equal");
|
cover("kernel.rtlil.sigspec.comp_lt.equal");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -5369,29 +5358,12 @@ bool RTLIL::SigSpec::operator ==(const RTLIL::SigSpec &other) const
|
||||||
if (width_ != other.width_)
|
if (width_ != other.width_)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Without this, SigSpec() == SigSpec(State::S0, 0) will fail
|
auto other_it = other.chunks().begin();
|
||||||
// since the RHS will contain one SigChunk of width 0 causing
|
for (const SigChunk &c : chunks()) {
|
||||||
// the size check below to fail
|
if (c != *other_it)
|
||||||
if (width_ == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
pack();
|
|
||||||
other.pack();
|
|
||||||
|
|
||||||
if (chunks_.size() != other.chunks_.size())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
updhash();
|
|
||||||
other.updhash();
|
|
||||||
|
|
||||||
if (hash_ != other.hash_)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < chunks_.size(); i++)
|
|
||||||
if (chunks_[i] != other.chunks_[i]) {
|
|
||||||
cover("kernel.rtlil.sigspec.comp_eq.hash_collision");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
++other_it;
|
||||||
|
}
|
||||||
|
|
||||||
cover("kernel.rtlil.sigspec.comp_eq.equal");
|
cover("kernel.rtlil.sigspec.comp_eq.equal");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue