summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRick Altherr <kc8apf@kc8apf.net>2016-01-30 19:43:29 -0800
committerRick Altherr <kc8apf@kc8apf.net>2016-01-31 09:20:16 -0800
commit89dc40f162a7f06d15ad489066dd0cc64937fbd7 (patch)
tree013a344605252dfb82e0929a7e04d624d8826185
parent34969d41405a1ad418b82caa394f880ea0f6243f (diff)
rtlil: improve performance of SigSpec::replace(SigSpec, SigSpec, SigSpec*)
-rw-r--r--kernel/rtlil.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 91b73715..ca448057 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -2584,18 +2584,26 @@ void RTLIL::SigSpec::replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec
void RTLIL::SigSpec::replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with, RTLIL::SigSpec *other) const
{
+ log_assert(other != NULL);
+ log_assert(width_ == other->width_);
log_assert(pattern.width_ == with.width_);
pattern.unpack();
with.unpack();
+ unpack();
+ other->unpack();
- dict<RTLIL::SigBit, RTLIL::SigBit> rules;
-
- for (int i = 0; i < GetSize(pattern.bits_); i++)
- if (pattern.bits_[i].wire != NULL)
- rules[pattern.bits_[i]] = with.bits_[i];
+ for (int i = 0; i < GetSize(pattern.bits_); i++) {
+ if (pattern.bits_[i].wire != NULL) {
+ for (int j = 0; j < GetSize(bits_); j++) {
+ if (bits_[j] == pattern.bits_[i]) {
+ other->bits_[j] = with.bits_[i];
+ }
+ }
+ }
+ }
- replace(rules, other);
+ other->check();
}
void RTLIL::SigSpec::replace(const dict<RTLIL::SigBit, RTLIL::SigBit> &rules)