aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/yosys.cc
diff options
context:
space:
mode:
authorBenedikt Tutzer <e1225461@student.tuwien.ac.at>2018-08-16 16:00:11 +0200
committerBenedikt Tutzer <e1225461@student.tuwien.ac.at>2018-08-16 16:00:11 +0200
commitd79a2808cf2446fa21d91a6141f6fbe2318c03ec (patch)
treee0c630f1dd8ccab3c5d04ddf8a6fa06376d1f5e7 /kernel/yosys.cc
parentbf7b73acfc2b5e46206e5688b8a6e8d9b0d60d8f (diff)
downloadyosys-d79a2808cf2446fa21d91a6141f6fbe2318c03ec.tar.gz
yosys-d79a2808cf2446fa21d91a6141f6fbe2318c03ec.tar.bz2
yosys-d79a2808cf2446fa21d91a6141f6fbe2318c03ec.zip
Python Passes can now be added with the -m option or with the plugin command. There are still issues when run in shell mode, but they can be used just fine in a python script
Diffstat (limited to 'kernel/yosys.cc')
-rw-r--r--kernel/yosys.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 750a154e6..8e16ba01d 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -469,21 +469,40 @@ int GetSize(RTLIL::Wire *wire)
return wire->width;
}
+bool already_setup = false;
+
void yosys_setup()
{
+ if(already_setup)
+ return;
+ already_setup = true;
// if there are already IdString objects then we have a global initialization order bug
IdString empty_id;
log_assert(empty_id.index_ == 0);
IdString::get_reference(empty_id.index_);
+ #ifdef WITH_PYTHON
+ Py_Initialize();
+ PyRun_SimpleString("import sys");
+ PyRun_SimpleString("sys.path.append(\"./\")");
+ //PyRun_SimpleString("import libyosys");
+ //PyRun_SimpleString("sys.path.append(\"./plugins\")");
+ //PyRun_SimpleString(("sys.path.append(\""+proc_share_dirname()+"plugins\")").c_str());
+ #endif
+
Pass::init_register();
yosys_design = new RTLIL::Design;
yosys_celltypes.setup();
log_push();
}
+bool already_shutdown = false;
+
void yosys_shutdown()
{
+ if(already_shutdown)
+ return;
+ already_shutdown = true;
log_pop();
delete yosys_design;
@@ -511,9 +530,16 @@ void yosys_shutdown()
dlclose(it.second);
loaded_plugins.clear();
+#ifdef WITH_PYTHON
+ loaded_python_plugins.clear();
+#endif
loaded_plugin_aliases.clear();
#endif
+#ifdef WITH_PYTHON
+ Py_Finalize();
+#endif
+
IdString empty_id;
IdString::put_reference(empty_id.index_);
}