diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-05-15 21:00:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-15 21:00:56 +0200 |
commit | c9def5407cd59e8542201217c890bbe4c89fff5c (patch) | |
tree | 8bcd4e44241c57766114f826e5c5fe7790dda85a /kernel/rtlil.cc | |
parent | f67ec1b2350c3bd88edacba7ad799bf60b33da61 (diff) | |
parent | a21a84b3b45d252ff050d3ae7e738d157b0b2be8 (diff) | |
download | yosys-c9def5407cd59e8542201217c890bbe4c89fff5c.tar.gz yosys-c9def5407cd59e8542201217c890bbe4c89fff5c.tar.bz2 yosys-c9def5407cd59e8542201217c890bbe4c89fff5c.zip |
Merge pull request #1012 from YosysHQ/clifford/sigspecrw
Another rounds of opt_clean improvements
Diffstat (limited to 'kernel/rtlil.cc')
-rw-r--r-- | kernel/rtlil.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 79ff4a6a6..790ba52a3 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -1514,7 +1514,10 @@ void RTLIL::Module::add(RTLIL::Cell *cell) cell->module = this; } -namespace { +void RTLIL::Module::remove(const pool<RTLIL::Wire*> &wires) +{ + log_assert(refcount_wires_ == 0); + struct DeleteWireWorker { RTLIL::Module *module; @@ -1529,17 +1532,29 @@ namespace { } sig = chunks; } - }; -} -void RTLIL::Module::remove(const pool<RTLIL::Wire*> &wires) -{ - log_assert(refcount_wires_ == 0); + void operator()(RTLIL::SigSpec &lhs, RTLIL::SigSpec &rhs) { + log_assert(GetSize(lhs) == GetSize(rhs)); + RTLIL::SigSpec new_lhs, new_rhs; + for (int i = 0; i < GetSize(lhs); i++) { + RTLIL::SigBit lhs_bit = lhs[i]; + if (lhs_bit.wire != nullptr && wires_p->count(lhs_bit.wire)) + continue; + RTLIL::SigBit rhs_bit = rhs[i]; + if (rhs_bit.wire != nullptr && wires_p->count(rhs_bit.wire)) + continue; + new_lhs.append(lhs_bit); + new_rhs.append(rhs_bit); + } + lhs = new_lhs; + rhs = new_rhs; + } + }; DeleteWireWorker delete_wire_worker; delete_wire_worker.module = this; delete_wire_worker.wires_p = &wires; - rewrite_sigspecs(delete_wire_worker); + rewrite_sigspecs2(delete_wire_worker); for (auto &it : wires) { log_assert(wires_.count(it->name) != 0); |