3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-23 17:15:33 +00:00

Changed a lot of code to the new RTLIL::Wire constructors

This commit is contained in:
Clifford Wolf 2014-07-26 20:12:50 +02:00
parent d49dec1f86
commit 946ddff9ce
19 changed files with 156 additions and 224 deletions

View file

@ -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);

View file

@ -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);