mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Added RTLIL::SigSpec::remove_const() handling of packed SigSpecs
This commit is contained in:
parent
cbc3a46a97
commit
4be645860b
|
@ -1978,19 +1978,36 @@ void RTLIL::SigSpec::replace(int offset, const RTLIL::SigSpec &with)
|
||||||
|
|
||||||
void RTLIL::SigSpec::remove_const()
|
void RTLIL::SigSpec::remove_const()
|
||||||
{
|
{
|
||||||
cover("kernel.rtlil.sigspec.remove_const");
|
if (packed())
|
||||||
|
{
|
||||||
|
cover("kernel.rtlil.sigspec.remove_const.packed");
|
||||||
|
|
||||||
unpack();
|
std::vector<RTLIL::SigChunk> new_chunks;
|
||||||
|
new_chunks.reserve(SIZE(chunks_));
|
||||||
|
|
||||||
std::vector<RTLIL::SigBit> new_bits;
|
width_ = 0;
|
||||||
new_bits.reserve(width_);
|
for (auto &chunk : chunks_)
|
||||||
|
if (chunk.wire != NULL) {
|
||||||
|
new_chunks.push_back(chunk);
|
||||||
|
width_ += chunk.width;
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &bit : bits_)
|
chunks_.swap(new_chunks);
|
||||||
if (bit.wire != NULL)
|
}
|
||||||
new_bits.push_back(bit);
|
else
|
||||||
|
{
|
||||||
|
cover("kernel.rtlil.sigspec.remove_const.unpacked");
|
||||||
|
|
||||||
bits_.swap(new_bits);
|
std::vector<RTLIL::SigBit> new_bits;
|
||||||
width_ = bits_.size();
|
new_bits.reserve(width_);
|
||||||
|
|
||||||
|
for (auto &bit : bits_)
|
||||||
|
if (bit.wire != NULL)
|
||||||
|
new_bits.push_back(bit);
|
||||||
|
|
||||||
|
bits_.swap(new_bits);
|
||||||
|
width_ = bits_.size();
|
||||||
|
}
|
||||||
|
|
||||||
check();
|
check();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue