aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/rtlil.cc
diff options
context:
space:
mode:
authorBenedikt Tutzer <e1225461@student.tuwien.ac.at>2018-07-09 15:48:06 +0200
committerBenedikt Tutzer <e1225461@student.tuwien.ac.at>2018-07-09 15:48:06 +0200
commit8ebaeecd83b22db5c196356844f01ce69d0b4bea (patch)
tree3cb3988ab1e6597ed12f836e93cad8301770ecdf /kernel/rtlil.cc
parent7911379d4a3806af8141e5737e217a2b05368d6c (diff)
downloadyosys-8ebaeecd83b22db5c196356844f01ce69d0b4bea.tar.gz
yosys-8ebaeecd83b22db5c196356844f01ce69d0b4bea.tar.bz2
yosys-8ebaeecd83b22db5c196356844f01ce69d0b4bea.zip
multiple designs can now exist independent from each other. Cells/Wires/Modules can now move to a different parent without referencing issues
Diffstat (limited to 'kernel/rtlil.cc')
-rw-r--r--kernel/rtlil.cc55
1 files changed, 55 insertions, 0 deletions
diff --git a/kernel/rtlil.cc b/kernel/rtlil.cc
index a4fa2cf04..df6e0af62 100644
--- a/kernel/rtlil.cc
+++ b/kernel/rtlil.cc
@@ -358,6 +358,10 @@ RTLIL::Design::Design()
refcount_modules_ = 0;
selection_stack.push_back(RTLIL::Selection());
+
+#ifdef WITH_PYTHON
+ RTLIL::Design::get_all_designs()->insert(std::pair<unsigned int, RTLIL::Design*>(hashidx_, this));
+#endif
}
RTLIL::Design::~Design()
@@ -368,8 +372,19 @@ RTLIL::Design::~Design()
delete n;
for (auto n : verilog_globals)
delete n;
+#ifdef WITH_PYTHON
+ RTLIL::Design::get_all_designs()->erase(hashidx_);
+#endif
}
+#ifdef WITH_PYTHON
+static std::map<unsigned int, RTLIL::Design*> *all_designs = new std::map<unsigned int, RTLIL::Design*>();
+std::map<unsigned int, RTLIL::Design*> *RTLIL::Design::get_all_designs(void)
+{
+ return all_designs;
+}
+#endif
+
RTLIL::ObjRange<RTLIL::Module*> RTLIL::Design::modules()
{
return RTLIL::ObjRange<RTLIL::Module*>(&modules_, &refcount_modules_);
@@ -625,6 +640,11 @@ RTLIL::Module::Module()
design = nullptr;
refcount_wires_ = 0;
refcount_cells_ = 0;
+
+#ifdef WITH_PYTHON
+ std::cout << "inserting module with name " << this->name.c_str() << "\n";
+ RTLIL::Module::get_all_modules()->insert(std::pair<unsigned int, RTLIL::Module*>(hashidx_, this));
+#endif
}
RTLIL::Module::~Module()
@@ -637,7 +657,18 @@ RTLIL::Module::~Module()
delete it->second;
for (auto it = processes.begin(); it != processes.end(); ++it)
delete it->second;
+#ifdef WITH_PYTHON
+ RTLIL::Module::get_all_modules()->erase(hashidx_);
+#endif
+}
+
+#ifdef WITH_PYTHON
+static std::map<unsigned int, RTLIL::Module*> *all_modules = new std::map<unsigned int, RTLIL::Module*>();
+std::map<unsigned int, RTLIL::Module*> *RTLIL::Module::get_all_modules(void)
+{
+ return all_modules;
}
+#endif
RTLIL::IdString RTLIL::Module::derive(RTLIL::Design*, dict<RTLIL::IdString, RTLIL::Const>, bool mayfail)
{
@@ -2187,8 +2218,20 @@ RTLIL::Wire::Wire()
port_input = false;
port_output = false;
upto = false;
+
+#ifdef WITH_PYTHON
+ RTLIL::Wire::get_all_wires()->insert(std::pair<unsigned int, RTLIL::Wire*>(hashidx_, this));
+#endif
}
+#ifdef WITH_PYTHON
+static std::map<unsigned int, RTLIL::Wire*> *all_wires = new std::map<unsigned int, RTLIL::Wire*>();
+std::map<unsigned int, RTLIL::Wire*> *RTLIL::Wire::get_all_wires(void)
+{
+ return all_wires;
+}
+#endif
+
RTLIL::Memory::Memory()
{
static unsigned int hashidx_count = 123456789;
@@ -2208,7 +2251,19 @@ RTLIL::Cell::Cell() : module(nullptr)
// log("#memtrace# %p\n", this);
memhasher();
+
+#ifdef WITH_PYTHON
+ RTLIL::Cell::get_all_cells()->insert(std::pair<unsigned int, RTLIL::Cell*>(hashidx_, this));
+#endif
+}
+
+#ifdef WITH_PYTHON
+static std::map<unsigned int, RTLIL::Cell*> *all_cells = new std::map<unsigned int, RTLIL::Cell*>();
+std::map<unsigned int, RTLIL::Cell*> *RTLIL::Cell::get_all_cells(void)
+{
+ return all_cells;
}
+#endif
bool RTLIL::Cell::hasPort(RTLIL::IdString portname) const
{