mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-30 19:22:31 +00:00 
			
		
		
		
	Added id2cstr API
This commit is contained in:
		
							parent
							
								
									8a6b0a3520
								
							
						
					
					
						commit
						1bc0f04789
					
				
					 3 changed files with 17 additions and 10 deletions
				
			
		|  | @ -110,6 +110,13 @@ namespace RTLIL | ||||||
| 		return str; | 		return str; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	static const char *id2cstr(std::string str) __attribute__((unused)); | ||||||
|  | 	static const char *id2cstr(std::string str) { | ||||||
|  | 		if (str.size() > 1 && str[0] == '\\' && str[1] != '$') | ||||||
|  | 			return str.c_str() + 1; | ||||||
|  | 		return str.c_str(); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	static IdString new_id(std::string file, int line, std::string func) __attribute__((unused)); | 	static IdString new_id(std::string file, int line, std::string func) __attribute__((unused)); | ||||||
| 	static IdString new_id(std::string file, int line, std::string func) { | 	static IdString new_id(std::string file, int line, std::string func) { | ||||||
| 		std::string str = "$auto$"; | 		std::string str = "$auto$"; | ||||||
|  |  | ||||||
|  | @ -542,7 +542,7 @@ struct SelectPass : public Pass { | ||||||
| 			if (arg == "-module" && argidx+1 < args.size()) { | 			if (arg == "-module" && argidx+1 < args.size()) { | ||||||
| 				RTLIL::IdString mod_name = RTLIL::escape_id(args[++argidx]); | 				RTLIL::IdString mod_name = RTLIL::escape_id(args[++argidx]); | ||||||
| 				if (design->modules.count(mod_name) == 0) | 				if (design->modules.count(mod_name) == 0) | ||||||
| 					log_cmd_error("No such module: %s\n", mod_name.c_str()); | 					log_cmd_error("No such module: %s\n", id2cstr(mod_name)); | ||||||
| 				design->selected_active_module = mod_name; | 				design->selected_active_module = mod_name; | ||||||
| 				got_module = true; | 				got_module = true; | ||||||
| 				continue; | 				continue; | ||||||
|  | @ -597,20 +597,20 @@ struct SelectPass : public Pass { | ||||||
| 			for (auto mod_it : design->modules) | 			for (auto mod_it : design->modules) | ||||||
| 			{ | 			{ | ||||||
| 				if (sel->selected_whole_module(mod_it.first)) | 				if (sel->selected_whole_module(mod_it.first)) | ||||||
| 					log("%s\n", mod_it.first.c_str()); | 					log("%s\n", id2cstr(mod_it.first)); | ||||||
| 				if (sel->selected_module(mod_it.first)) { | 				if (sel->selected_module(mod_it.first)) { | ||||||
| 					for (auto &it : mod_it.second->wires) | 					for (auto &it : mod_it.second->wires) | ||||||
| 						if (sel->selected_member(mod_it.first, it.first)) | 						if (sel->selected_member(mod_it.first, it.first)) | ||||||
| 							log("%s/%s\n", mod_it.first.c_str(), it.first.c_str()); | 							log("%s/%s\n", id2cstr(mod_it.first), id2cstr(it.first)); | ||||||
| 					for (auto &it : mod_it.second->memories) | 					for (auto &it : mod_it.second->memories) | ||||||
| 						if (sel->selected_member(mod_it.first, it.first)) | 						if (sel->selected_member(mod_it.first, it.first)) | ||||||
| 							log("%s/%s\n", mod_it.first.c_str(), it.first.c_str()); | 							log("%s/%s\n", id2cstr(mod_it.first), id2cstr(it.first)); | ||||||
| 					for (auto &it : mod_it.second->cells) | 					for (auto &it : mod_it.second->cells) | ||||||
| 						if (sel->selected_member(mod_it.first, it.first)) | 						if (sel->selected_member(mod_it.first, it.first)) | ||||||
| 							log("%s/%s\n", mod_it.first.c_str(), it.first.c_str()); | 							log("%s/%s\n", id2cstr(mod_it.first), id2cstr(it.first)); | ||||||
| 					for (auto &it : mod_it.second->processes) | 					for (auto &it : mod_it.second->processes) | ||||||
| 						if (sel->selected_member(mod_it.first, it.first)) | 						if (sel->selected_member(mod_it.first, it.first)) | ||||||
| 							log("%s/%s\n", mod_it.first.c_str(), it.first.c_str()); | 							log("%s/%s\n", id2cstr(mod_it.first), id2cstr(it.first)); | ||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 			return; | 			return; | ||||||
|  | @ -648,10 +648,10 @@ struct SelectPass : public Pass { | ||||||
| 			if (sel.full_selection) | 			if (sel.full_selection) | ||||||
| 				log("*\n"); | 				log("*\n"); | ||||||
| 			for (auto &it : sel.selected_modules) | 			for (auto &it : sel.selected_modules) | ||||||
| 				log("%s\n", it.c_str()); | 				log("%s\n", id2cstr(it)); | ||||||
| 			for (auto &it : sel.selected_members) | 			for (auto &it : sel.selected_members) | ||||||
| 				for (auto &it2 : it.second) | 				for (auto &it2 : it.second) | ||||||
| 					log("%s/%s\n", it.first.c_str(), it2.c_str()); | 					log("%s/%s\n", id2cstr(it.first), id2cstr(it2)); | ||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -289,9 +289,9 @@ struct ShowWorker | ||||||
| 			if (!design->selected_module(module->name)) | 			if (!design->selected_module(module->name)) | ||||||
| 				continue; | 				continue; | ||||||
| 			if (design->selected_whole_module(module->name)) | 			if (design->selected_whole_module(module->name)) | ||||||
| 				log("Dumping module %s to page %d.\n", module->name.c_str(), ++page_counter); | 				log("Dumping module %s to page %d.\n", id2cstr(module->name), ++page_counter); | ||||||
| 			else | 			else | ||||||
| 				log("Dumping selected parts of module %s to page %d.\n", module->name.c_str(), ++page_counter); | 				log("Dumping selected parts of module %s to page %d.\n", id2cstr(module->name), ++page_counter); | ||||||
| 			handle_module(); | 			handle_module(); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue