diff options
Diffstat (limited to 'passes/cmds')
| -rw-r--r-- | passes/cmds/add.cc | 2 | ||||
| -rw-r--r-- | passes/cmds/bugpoint.cc | 8 | ||||
| -rw-r--r-- | passes/cmds/plugin.cc | 50 | ||||
| -rw-r--r-- | passes/cmds/setattr.cc | 39 | ||||
| -rw-r--r-- | passes/cmds/show.cc | 27 | ||||
| -rw-r--r-- | passes/cmds/trace.cc | 34 | 
6 files changed, 151 insertions, 9 deletions
diff --git a/passes/cmds/add.cc b/passes/cmds/add.cc index cfccca966..af6f7043d 100644 --- a/passes/cmds/add.cc +++ b/passes/cmds/add.cc @@ -71,7 +71,7 @@ static void add_wire(RTLIL::Design *design, RTLIL::Module *module, std::string n  		RTLIL::Module *mod = design->modules_.at(it.second->type);  		if (!design->selected_whole_module(mod->name))  			continue; -		if (mod->get_bool_attribute("\\blackbox")) +		if (mod->get_blackbox_attribute())  			continue;  		if (it.second->hasPort(name))  			continue; diff --git a/passes/cmds/bugpoint.cc b/passes/cmds/bugpoint.cc index 606276e64..4b22f6d2d 100644 --- a/passes/cmds/bugpoint.cc +++ b/passes/cmds/bugpoint.cc @@ -128,7 +128,7 @@ struct BugpointPass : public Pass {  		{  			for (auto &it : design_copy->modules_)  			{ -				if (it.second->get_bool_attribute("\\blackbox")) +				if (it.second->get_blackbox_attribute())  					continue;  				if (index++ == seed) @@ -143,7 +143,7 @@ struct BugpointPass : public Pass {  		{  			for (auto mod : design_copy->modules())  			{ -				if (mod->get_bool_attribute("\\blackbox")) +				if (mod->get_blackbox_attribute())  					continue;  				for (auto wire : mod->wires()) @@ -168,7 +168,7 @@ struct BugpointPass : public Pass {  		{  			for (auto mod : design_copy->modules())  			{ -				if (mod->get_bool_attribute("\\blackbox")) +				if (mod->get_blackbox_attribute())  					continue;  				for (auto &it : mod->cells_) @@ -186,7 +186,7 @@ struct BugpointPass : public Pass {  		{  			for (auto mod : design_copy->modules())  			{ -				if (mod->get_bool_attribute("\\blackbox")) +				if (mod->get_blackbox_attribute())  					continue;  				for (auto cell : mod->cells()) 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/cmds/setattr.cc b/passes/cmds/setattr.cc index d38a6b3da..b9fcc3e7a 100644 --- a/passes/cmds/setattr.cc +++ b/passes/cmds/setattr.cc @@ -128,6 +128,45 @@ struct SetattrPass : public Pass {  	}  } SetattrPass; +struct WbflipPass : public Pass { +	WbflipPass() : Pass("wbflip", "flip the whitebox attribute") { } +	void help() YS_OVERRIDE +	{ +		//   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| +		log("\n"); +		log("    wbflip [selection]\n"); +		log("\n"); +		log("Flip the whitebox attribute on selected cells. I.e. if it's set, unset it, and\n"); +		log("vice-versa. Blackbox cells are not effected by this command.\n"); +		log("\n"); +	} +	void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE +	{ +		size_t argidx; +		for (argidx = 1; argidx < args.size(); argidx++) +		{ +			std::string arg = args[argidx]; +			// if (arg == "-mod") { +			// 	flag_mod = true; +			// 	continue; +			// } +			break; +		} +		extra_args(args, argidx, design); + +		for (Module *module : design->modules()) +		{ +			if (!design->selected(module)) +				continue; + +			if (module->get_bool_attribute("\\blackbox")) +				continue; + +			module->set_bool_attribute("\\whitebox", !module->get_bool_attribute("\\whitebox")); +		} +	} +} WbflipPass; +  struct SetparamPass : public Pass {  	SetparamPass() : Pass("setparam", "set/unset parameters on objects") { }  	void help() YS_OVERRIDE diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc index 58acd302d..cf729215f 100644 --- a/passes/cmds/show.cc +++ b/passes/cmds/show.cc @@ -237,15 +237,34 @@ struct ShowWorker  			int idx = single_idx_count++;  			for (int rep, i = int(sig.chunks().size())-1; i >= 0; i -= rep) {  				const RTLIL::SigChunk &c = sig.chunks().at(i); -				net = gen_signode_simple(c, false); -				log_assert(!net.empty()); +				if (!driver && c.wire == nullptr) { +					RTLIL::State s1 = c.data.front(); +					for (auto s2 : c.data) +						if (s1 != s2) +							goto not_const_stream; +					net.clear(); +				} else { +			not_const_stream: +					net = gen_signode_simple(c, false); +					log_assert(!net.empty()); +				}  				for (rep = 1; i-rep >= 0 && c == sig.chunks().at(i-rep); rep++) {}  				std::string repinfo = rep > 1 ? stringf("%dx ", rep) : "";  				if (driver) { +					log_assert(!net.empty());  					label_string += stringf("<s%d> %d:%d - %s%d:%d |", i, pos, pos-c.width+1, repinfo.c_str(), c.offset+c.width-1, c.offset);  					net_conn_map[net].in.insert(stringf("x%d:s%d", idx, i));  					net_conn_map[net].bits = rep*c.width;  					net_conn_map[net].color = nextColor(c, net_conn_map[net].color); +				} else +				if (net.empty()) { +					log_assert(rep == 1); +					label_string += stringf("%c -> %d:%d |", +							c.data.front() == State::S0 ? '0' : +							c.data.front() == State::S1 ? '1' : +							c.data.front() == State::Sx ? 'X' : +							c.data.front() == State::Sz ? 'Z' : '?', +							pos, pos-rep*c.width+1);  				} else {  					label_string += stringf("<s%d> %s%d:%d - %d:%d |", i, repinfo.c_str(), c.offset+c.width-1, c.offset, pos, pos-rep*c.width+1);  					net_conn_map[net].out.insert(stringf("x%d:s%d", idx, i)); @@ -555,7 +574,7 @@ struct ShowWorker  			if (!design->selected_module(module->name))  				continue;  			if (design->selected_whole_module(module->name)) { -				if (module->get_bool_attribute("\\blackbox")) { +				if (module->get_blackbox_attribute()) {  					// log("Skipping blackbox module %s.\n", id2cstr(module->name));  					continue;  				} else @@ -771,7 +790,7 @@ struct ShowPass : public Pass {  		if (format != "ps" && format != "dot") {  			int modcount = 0;  			for (auto &mod_it : design->modules_) { -				if (mod_it.second->get_bool_attribute("\\blackbox")) +				if (mod_it.second->get_blackbox_attribute())  					continue;  				if (mod_it.second->cells_.empty() && mod_it.second->connections().empty())  					continue; diff --git a/passes/cmds/trace.cc b/passes/cmds/trace.cc index f5305cde9..cf3e46ace 100644 --- a/passes/cmds/trace.cc +++ b/passes/cmds/trace.cc @@ -94,4 +94,38 @@ struct TracePass : public Pass {  	}  } TracePass; +struct DebugPass : public Pass { +	DebugPass() : Pass("debug", "run command with debug log messages enabled") { } +	void help() YS_OVERRIDE +	{ +		//   |---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---|---v---| +		log("\n"); +		log("    debug cmd\n"); +		log("\n"); +		log("Execute the specified command with debug log messages enabled\n"); +		log("\n"); +	} +	void execute(std::vector<std::string> args, RTLIL::Design *design) YS_OVERRIDE +	{ +		size_t argidx; +		for (argidx = 1; argidx < args.size(); argidx++) +		{ +			// .. parse options .. +			break; +		} + +		log_force_debug++; + +		try { +			std::vector<std::string> new_args(args.begin() + argidx, args.end()); +			Pass::call(design, new_args); +		} catch (...) { +			log_force_debug--; +			throw; +		} + +		log_force_debug--; +	} +} DebugPass; +  PRIVATE_NAMESPACE_END  | 
