Setup is called automatically when the module is loaded, shutdown when python exits

This commit is contained in:
Benedikt Tutzer 2018-08-01 10:08:23 +02:00 committed by Benedikt Tutzer
parent 57d2197703
commit 79d7e608cf
1 changed files with 19 additions and 16 deletions

View File

@ -15,25 +15,11 @@ namespace YOSYS_PYTHON {
struct Wire;
struct Monitor;
void yosys_setup()
{
Yosys::log_streams.push_back(&std::cout);
Yosys::log_error_stderr = true;
Yosys::yosys_setup();
Yosys::yosys_banner();
}
void run(std::string command)
{
Yosys::run_pass(command);
}
void yosys_shutdown()
{
Yosys::yosys_shutdown();
}
struct Cell
{
unsigned int id;
@ -292,10 +278,29 @@ namespace YOSYS_PYTHON {
return 0;
}
struct Initializer
{
Initializer() {
Yosys::log_streams.push_back(&std::cout);
Yosys::log_error_stderr = true;
Yosys::yosys_setup();
Yosys::yosys_banner();
}
Initializer(Initializer const &) {}
~Initializer() {
Yosys::yosys_shutdown();
}
};
BOOST_PYTHON_MODULE(libyosys)
{
using namespace boost::python;
class_<Initializer>("Initializer");
scope().attr("_hidden") = new Initializer();
class_<Design>("Design", init<unsigned int>())
.def(boost::python::self_ns::str(boost::python::self_ns::self))
.def(boost::python::self_ns::repr(boost::python::self_ns::self))
@ -329,10 +334,8 @@ namespace YOSYS_PYTHON {
.def("py_notify_blackout", &Monitor::py_notify_blackout, &MonitorWrap::default_py_notify_blackout)
;
def("yosys_setup",yosys_setup);
def("run",run);
def("get_active_design_id",get_active_design_id);
def("yosys_shutdown",yosys_shutdown);
}
}