aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rtlil.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-07-25 15:05:18 +0200
committerClifford Wolf <clifford@clifford.at>2014-07-25 17:56:19 +0200
commit2bec47a4045d23d46e7d300cbf80b2dce1a549a9 (patch)
tree991a75afe9b009486a57834fefee075ec695a28c /kernel/rtlil.cc
parent5826670009e1018734de49aaf1554cb8a43d09d7 (diff)
downloadyosys-2bec47a4045d23d46e7d300cbf80b2dce1a549a9.tar.gz
yosys-2bec47a4045d23d46e7d300cbf80b2dce1a549a9.tar.bz2
yosys-2bec47a4045d23d46e7d300cbf80b2dce1a549a9.zip
Use only module->addCell() and module->remove() to create and delete cells
Diffstat (limited to 'kernel/rtlil.cc')
-rw-r--r--kernel/rtlil.cc37
1 files changed, 35 insertions, 2 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index 83524d796..17e4a2733 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -782,8 +782,14 @@ void RTLIL::Module::cloneInto(RTLIL::Module *new_mod) const
for (auto &it : memories)
new_mod->memories[it.first] = new RTLIL::Memory(*it.second);
- for (auto &it : cells)
- new_mod->cells[it.first] = new RTLIL::Cell(*it.second);
+ for (auto &it : cells) {
+ new_mod->cells[it.first] = new RTLIL::Cell;
+ new_mod->cells[it.first]->name = it.second->name;
+ new_mod->cells[it.first]->type = it.second->type;
+ new_mod->cells[it.first]->connections = it.second->connections;
+ new_mod->cells[it.first]->parameters = it.second->parameters;
+ new_mod->cells[it.first]->attributes = it.second->attributes;
+ }
for (auto &it : processes)
new_mod->processes[it.first] = it.second->clone();
@@ -834,6 +840,33 @@ void RTLIL::Module::remove(RTLIL::Cell *cell)
delete cell;
}
+void RTLIL::Module::rename(RTLIL::Wire *wire, RTLIL::IdString new_name)
+{
+ assert(wires[wire->name] == wire);
+ wires.erase(wire->name);
+ wire->name = new_name;
+ add(wire);
+}
+
+void RTLIL::Module::rename(RTLIL::Cell *cell, RTLIL::IdString new_name)
+{
+ assert(cells[cell->name] == cell);
+ cells.erase(cell->name);
+ cell->name = new_name;
+ add(cell);
+}
+
+void RTLIL::Module::rename(RTLIL::IdString old_name, RTLIL::IdString new_name)
+{
+ assert(count_id(old_name) != 0);
+ if (wires.count(old_name))
+ rename(wires.at(old_name), new_name);
+ else if (cells.count(old_name))
+ rename(cells.at(old_name), new_name);
+ else
+ log_abort();
+}
+
static bool fixup_ports_compare(const RTLIL::Wire *a, const RTLIL::Wire *b)
{
if (a->port_id && !b->port_id)