mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-11-04 13:29:12 +00:00 
			
		
		
		
	Merge pull request #4252 from zapta/master
Added to the Show command a -wireshape <graphviz-shape> flag.
This commit is contained in:
		
						commit
						a2fc7e4dd7
					
				
					 1 changed files with 19 additions and 7 deletions
				
			
		| 
						 | 
					@ -59,6 +59,7 @@ struct ShowWorker
 | 
				
			||||||
	RTLIL::Module *module;
 | 
						RTLIL::Module *module;
 | 
				
			||||||
	uint32_t currentColor;
 | 
						uint32_t currentColor;
 | 
				
			||||||
	bool genWidthLabels;
 | 
						bool genWidthLabels;
 | 
				
			||||||
 | 
						std::string wireshape;
 | 
				
			||||||
	bool genSignedLabels;
 | 
						bool genSignedLabels;
 | 
				
			||||||
	bool stretchIO;
 | 
						bool stretchIO;
 | 
				
			||||||
	bool enumerateIds;
 | 
						bool enumerateIds;
 | 
				
			||||||
| 
						 | 
					@ -428,16 +429,19 @@ struct ShowWorker
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::map<std::string, std::string> wires_on_demand;
 | 
							std::map<std::string, std::string> wires_on_demand;
 | 
				
			||||||
		for (auto wire : module->selected_wires()) {
 | 
							for (auto wire : module->selected_wires()) {
 | 
				
			||||||
			const char *shape = "diamond";
 | 
							    std::string shape = wireshape;
 | 
				
			||||||
			if (wire->port_input || wire->port_output)
 | 
								if (wire->port_input || wire->port_output)
 | 
				
			||||||
				shape = "octagon";
 | 
									shape = "octagon";
 | 
				
			||||||
 | 
								const bool is_borderless = (shape == "plaintext") || (shape == "plain") || (shape == "none");
 | 
				
			||||||
			if (wire->name.isPublic()) {
 | 
								if (wire->name.isPublic()) {
 | 
				
			||||||
				std::string src_href;
 | 
									std::string src_href;
 | 
				
			||||||
				if (href && wire->attributes.count(ID::src) > 0)
 | 
									if (href && wire->attributes.count(ID::src) > 0)
 | 
				
			||||||
					src_href = stringf(", href=\"%s\" ", escape(wire->attributes.at(ID::src).decode_string()));
 | 
										src_href = stringf(", href=\"%s\" ", escape(wire->attributes.at(ID::src).decode_string()));
 | 
				
			||||||
				fprintf(f, "n%d [ shape=%s, label=\"%s\", %s%s];\n",
 | 
									fprintf(f, "n%d [ shape=%s,%s label=\"%s\", %s%s];\n",
 | 
				
			||||||
						id2num(wire->name), shape, findLabel(wire->name.str()),
 | 
											id2num(wire->name), shape.c_str(), is_borderless? " margin=0, width=0" : "",  findLabel(wire->name.str()),
 | 
				
			||||||
						nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(),
 | 
											is_borderless
 | 
				
			||||||
 | 
											    ? "color=\"none\", fontcolor=\"black\""
 | 
				
			||||||
 | 
												: nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(), 
 | 
				
			||||||
						src_href.c_str());
 | 
											src_href.c_str());
 | 
				
			||||||
				if (wire->port_input)
 | 
									if (wire->port_input)
 | 
				
			||||||
					all_sources.insert(stringf("n%d", id2num(wire->name)));
 | 
										all_sources.insert(stringf("n%d", id2num(wire->name)));
 | 
				
			||||||
| 
						 | 
					@ -616,10 +620,10 @@ struct ShowWorker
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ShowWorker(FILE *f, RTLIL::Design *design, std::vector<RTLIL::Design*> &libs, uint32_t colorSeed, bool genWidthLabels,
 | 
						ShowWorker(FILE *f, RTLIL::Design *design, std::vector<RTLIL::Design*> &libs, uint32_t colorSeed, bool genWidthLabels,
 | 
				
			||||||
			bool genSignedLabels, bool stretchIO, bool enumerateIds, bool abbreviateIds, bool notitle, bool href,
 | 
								const std::string wireshape, bool genSignedLabels, bool stretchIO, bool enumerateIds, bool abbreviateIds, bool notitle, bool href,
 | 
				
			||||||
			const std::vector<std::pair<std::string, RTLIL::Selection>> &color_selections,
 | 
								const std::vector<std::pair<std::string, RTLIL::Selection>> &color_selections,
 | 
				
			||||||
			const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections, RTLIL::IdString colorattr) :
 | 
								const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections, RTLIL::IdString colorattr) :
 | 
				
			||||||
			f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels),
 | 
								f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels), wireshape(wireshape),
 | 
				
			||||||
			genSignedLabels(genSignedLabels), stretchIO(stretchIO), enumerateIds(enumerateIds), abbreviateIds(abbreviateIds),
 | 
								genSignedLabels(genSignedLabels), stretchIO(stretchIO), enumerateIds(enumerateIds), abbreviateIds(abbreviateIds),
 | 
				
			||||||
			notitle(notitle), href(href), color_selections(color_selections), label_selections(label_selections), colorattr(colorattr)
 | 
								notitle(notitle), href(href), color_selections(color_selections), label_selections(label_selections), colorattr(colorattr)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
| 
						 | 
					@ -712,6 +716,9 @@ struct ShowPass : public Pass {
 | 
				
			||||||
		log("        Use the specified attribute to assign colors. A unique color is\n");
 | 
							log("        Use the specified attribute to assign colors. A unique color is\n");
 | 
				
			||||||
		log("        assigned to each unique value of this attribute.\n");
 | 
							log("        assigned to each unique value of this attribute.\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
 | 
							log("    -wireshape <graphviz_shape>\n");
 | 
				
			||||||
 | 
							log("        Use the specified shape for wire nodes. E.g. plaintext.\n");
 | 
				
			||||||
 | 
							log("\n");
 | 
				
			||||||
		log("    -width\n");
 | 
							log("    -width\n");
 | 
				
			||||||
		log("        annotate buses with a label indicating the width of the bus.\n");
 | 
							log("        annotate buses with a label indicating the width of the bus.\n");
 | 
				
			||||||
		log("\n");
 | 
							log("\n");
 | 
				
			||||||
| 
						 | 
					@ -770,6 +777,7 @@ struct ShowPass : public Pass {
 | 
				
			||||||
		std::string prefix = stringf("%s/.yosys_show", getenv("HOME") ? getenv("HOME") : ".");
 | 
							std::string prefix = stringf("%s/.yosys_show", getenv("HOME") ? getenv("HOME") : ".");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		std::string viewer_exe;
 | 
							std::string viewer_exe;
 | 
				
			||||||
 | 
							std::string flag_wireshape = "diamond";
 | 
				
			||||||
		std::vector<std::string> libfiles;
 | 
							std::vector<std::string> libfiles;
 | 
				
			||||||
		std::vector<RTLIL::Design*> libs;
 | 
							std::vector<RTLIL::Design*> libs;
 | 
				
			||||||
		uint32_t colorSeed = 0;
 | 
							uint32_t colorSeed = 0;
 | 
				
			||||||
| 
						 | 
					@ -834,6 +842,10 @@ struct ShowPass : public Pass {
 | 
				
			||||||
				format = args[++argidx];
 | 
									format = args[++argidx];
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
								if (arg == "-wireshape" && argidx+1 < args.size()) {
 | 
				
			||||||
 | 
									flag_wireshape = args[++argidx];
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			if (arg == "-width") {
 | 
								if (arg == "-width") {
 | 
				
			||||||
				flag_width= true;
 | 
									flag_width= true;
 | 
				
			||||||
				continue;
 | 
									continue;
 | 
				
			||||||
| 
						 | 
					@ -916,7 +928,7 @@ struct ShowPass : public Pass {
 | 
				
			||||||
				delete lib;
 | 
									delete lib;
 | 
				
			||||||
			log_cmd_error("Can't open dot file `%s' for writing.\n", dot_file.c_str());
 | 
								log_cmd_error("Can't open dot file `%s' for writing.\n", dot_file.c_str());
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_signed, flag_stretch, flag_enum, flag_abbreviate, flag_notitle, flag_href, color_selections, label_selections, colorattr);
 | 
							ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_wireshape, flag_signed, flag_stretch, flag_enum, flag_abbreviate, flag_notitle, flag_href, color_selections, label_selections, colorattr);
 | 
				
			||||||
		fclose(f);
 | 
							fclose(f);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (auto lib : libs)
 | 
							for (auto lib : libs)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue