diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-07-26 20:12:50 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-07-26 20:12:50 +0200 |
commit | 946ddff9cef3ea0b4dad8664319fb13074133775 (patch) | |
tree | e35f5ebe3cd76a8e10fe945872e32c2ed3a7d815 /kernel | |
parent | d49dec1f861ce11a87c48cc21c8edc1755802a5f (diff) | |
download | yosys-946ddff9cef3ea0b4dad8664319fb13074133775.tar.gz yosys-946ddff9cef3ea0b4dad8664319fb13074133775.tar.bz2 yosys-946ddff9cef3ea0b4dad8664319fb13074133775.zip |
Changed a lot of code to the new RTLIL::Wire constructors
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/rtlil.cc | 40 | ||||
-rw-r--r-- | kernel/rtlil.h | 3 |
2 files changed, 43 insertions, 0 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc index 059357d21..930e8a719 100644 --- a/kernel/rtlil.cc +++ b/kernel/rtlil.cc @@ -827,6 +827,46 @@ void RTLIL::Module::add(RTLIL::Cell *cell) cells[cell->name] = cell; } +namespace { + struct DeleteWireWorker + { + RTLIL::Module *module; + const std::set<RTLIL::Wire*> *wires_p; + + void operator()(RTLIL::SigSpec &sig) { + std::vector<RTLIL::SigChunk> chunks = sig; + for (auto &c : chunks) + if (c.wire != NULL && wires_p->count(c.wire)) { + c.wire = module->addWire(NEW_ID, c.width); + c.offset = 0; + } + sig = chunks; + } + }; +} + +#if 0 +void RTLIL::Module::remove(RTLIL::Wire *wire) +{ + std::set<RTLIL::Wire*> wires; + wires.insert(wire); + remove(wires); +} +#endif + +void RTLIL::Module::remove(const std::set<RTLIL::Wire*> &wires) +{ + DeleteWireWorker delete_wire_worker; + delete_wire_worker.module = this; + delete_wire_worker.wires_p = &wires; + rewrite_sigspecs(delete_wire_worker); + + for (auto &it : wires) { + this->wires.erase(it->name); + delete it; + } +} + void RTLIL::Module::remove(RTLIL::Cell *cell) { assert(cells.count(cell->name) != 0); diff --git a/kernel/rtlil.h b/kernel/rtlil.h index 73d3727ce..f43e7b670 100644 --- a/kernel/rtlil.h +++ b/kernel/rtlil.h @@ -299,6 +299,9 @@ struct RTLIL::Module void add(RTLIL::Wire *wire); void add(RTLIL::Cell *cell); + + // Removing wires is expensive. If you have to remove wires, remove them all at once. + void remove(const std::set<RTLIL::Wire*> &wires); void remove(RTLIL::Cell *cell); void rename(RTLIL::Wire *wire, RTLIL::IdString new_name); |