diff options
author | Eddie Hung <eddie@fpgeh.com> | 2019-04-22 10:36:27 -0700 |
---|---|---|
committer | Eddie Hung <eddie@fpgeh.com> | 2019-04-22 10:36:27 -0700 |
commit | e300b1922c13b939231072e83f0ae5c5ff6a558b (patch) | |
tree | 20c8ffe7a42a4aa2ae9195957e287c875c3a0594 /passes | |
parent | d342b5b135a85da0df5df0fa2acc25dec5605760 (diff) | |
parent | 9050b5e1915b05f55c1db279566f34202905f02a (diff) | |
download | yosys-e300b1922c13b939231072e83f0ae5c5ff6a558b.tar.gz yosys-e300b1922c13b939231072e83f0ae5c5ff6a558b.tar.bz2 yosys-e300b1922c13b939231072e83f0ae5c5ff6a558b.zip |
Merge remote-tracking branch 'origin/master' into xc7srl
Diffstat (limited to 'passes')
-rw-r--r-- | passes/cmds/plugin.cc | 50 | ||||
-rw-r--r-- | passes/techmap/attrmap.cc | 4 | ||||
-rw-r--r-- | passes/techmap/techmap.cc | 2 |
3 files changed, 54 insertions, 2 deletions
diff --git a/passes/cmds/plugin.cc b/passes/cmds/plugin.cc index aa6d5b6cc..4c16b56c4 100644 --- a/passes/cmds/plugin.cc +++ b/passes/cmds/plugin.cc @@ -23,9 +23,18 @@ # include <dlfcn.h> #endif +#ifdef WITH_PYTHON +# include <boost/algorithm/string/predicate.hpp> +# include <Python.h> +# include <boost/filesystem.hpp> +#endif + YOSYS_NAMESPACE_BEGIN std::map<std::string, void*> loaded_plugins; +#ifdef WITH_PYTHON +std::map<std::string, void*> loaded_python_plugins; +#endif std::map<std::string, std::string> loaded_plugin_aliases; #ifdef YOSYS_ENABLE_PLUGINS @@ -36,7 +45,35 @@ void load_plugin(std::string filename, std::vector<std::string> aliases) if (filename.find('/') == std::string::npos) filename = "./" + filename; + #ifdef WITH_PYTHON + if (!loaded_plugins.count(filename) && !loaded_python_plugins.count(filename)) { + #else if (!loaded_plugins.count(filename)) { + #endif + + #ifdef WITH_PYTHON + + boost::filesystem::path full_path(filename); + + if(strcmp(full_path.extension().c_str(), ".py") == 0) + { + std::string path(full_path.parent_path().c_str()); + filename = full_path.filename().c_str(); + filename = filename.substr(0,filename.size()-3); + PyRun_SimpleString(("sys.path.insert(0,\""+path+"\")").c_str()); + PyErr_Print(); + PyObject *module_p = PyImport_ImportModule(filename.c_str()); + if(module_p == NULL) + { + PyErr_Print(); + log_cmd_error("Can't load python module `%s'\n", full_path.filename().c_str()); + return; + } + loaded_python_plugins[orig_filename] = module_p; + Pass::init_register(); + } else { + #endif + void *hdl = dlopen(filename.c_str(), RTLD_LAZY|RTLD_LOCAL); if (hdl == NULL && orig_filename.find('/') == std::string::npos) hdl = dlopen((proc_share_dirname() + "plugins/" + orig_filename + ".so").c_str(), RTLD_LAZY|RTLD_LOCAL); @@ -44,6 +81,10 @@ void load_plugin(std::string filename, std::vector<std::string> aliases) log_cmd_error("Can't load module `%s': %s\n", filename.c_str(), dlerror()); loaded_plugins[orig_filename] = hdl; Pass::init_register(); + + #ifdef WITH_PYTHON + } + #endif } for (auto &alias : aliases) @@ -107,7 +148,11 @@ struct PluginPass : public Pass { if (list_mode) { log("\n"); +#ifdef WITH_PYTHON + if (loaded_plugins.empty() and loaded_python_plugins.empty()) +#else if (loaded_plugins.empty()) +#endif log("No plugins loaded.\n"); else log("Loaded plugins:\n"); @@ -115,6 +160,11 @@ struct PluginPass : public Pass { for (auto &it : loaded_plugins) log(" %s\n", it.first.c_str()); +#ifdef WITH_PYTHON + for (auto &it : loaded_python_plugins) + log(" %s\n", it.first.c_str()); +#endif + if (!loaded_plugin_aliases.empty()) { log("\n"); int max_alias_len = 1; diff --git a/passes/techmap/attrmap.cc b/passes/techmap/attrmap.cc index 0b5576b06..aa48e1125 100644 --- a/passes/techmap/attrmap.cc +++ b/passes/techmap/attrmap.cc @@ -111,9 +111,10 @@ struct AttrmapMap : AttrmapAction { }; struct AttrmapRemove : AttrmapAction { + bool has_value; string name, value; bool apply(IdString &id, Const &val) YS_OVERRIDE { - return !(match_name(name, id) && match_value(value, val)); + return !(match_name(name, id) && (!has_value || match_value(value, val))); } }; @@ -235,6 +236,7 @@ struct AttrmapPass : public Pass { } auto action = new AttrmapRemove; action->name = arg1; + action->has_value = (p != string::npos); action->value = val1; actions.push_back(std::unique_ptr<AttrmapAction>(action)); continue; diff --git a/passes/techmap/techmap.cc b/passes/techmap/techmap.cc index ee319b6e6..1a4318460 100644 --- a/passes/techmap/techmap.cc +++ b/passes/techmap/techmap.cc @@ -1036,7 +1036,7 @@ struct TechmapPass : public Pass { simplemap_get_mappers(worker.simplemap_mappers); std::vector<std::string> map_files; - std::string verilog_frontend = "verilog -nooverwrite"; + std::string verilog_frontend = "verilog -nooverwrite -noblackbox"; int max_iter = -1; size_t argidx; |