diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-27 14:47:48 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-27 14:47:48 +0200 |
commit | 4be645860bf83de75cdd00fbe615f3fe05221d54 (patch) | |
tree | fe7d18597997c3acef3adb8612a900588630d2a8 /kernel | |
parent | cbc3a46a9717f0f6e90b20b29c9003c3720a5aa0 (diff) | |
download | yosys-4be645860bf83de75cdd00fbe615f3fe05221d54.tar.gz yosys-4be645860bf83de75cdd00fbe615f3fe05221d54.tar.bz2 yosys-4be645860bf83de75cdd00fbe615f3fe05221d54.zip |
Added RTLIL::SigSpec::remove_const() handling of packed SigSpecs
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/rtlil.cc | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index db85f9e3d..9f9bd7e03 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1978,19 +1978,36 @@ void RTLIL::SigSpec::replace(int offset, const RTLIL::SigSpec &with) 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_)); + + width_ = 0; + for (auto &chunk : chunks_) + if (chunk.wire != NULL) { + new_chunks.push_back(chunk); + width_ += chunk.width; + } + + chunks_.swap(new_chunks); + } + else + { + cover("kernel.rtlil.sigspec.remove_const.unpacked"); - std::vector<RTLIL::SigBit> new_bits; - new_bits.reserve(width_); + std::vector<RTLIL::SigBit> new_bits; + new_bits.reserve(width_); - for (auto &bit : bits_) - if (bit.wire != NULL) - new_bits.push_back(bit); + for (auto &bit : bits_) + if (bit.wire != NULL) + new_bits.push_back(bit); - bits_.swap(new_bits); - width_ = bits_.size(); + bits_.swap(new_bits); + width_ = bits_.size(); + } check(); } |