Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added to the Show command a -wireshape <graphviz-shape> flag. #4252

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions passes/cmds/show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct ShowWorker
RTLIL::Module *module;
uint32_t currentColor;
bool genWidthLabels;
std::string wireshape;
bool genSignedLabels;
bool stretchIO;
bool enumerateIds;
Expand Down Expand Up @@ -429,16 +430,19 @@ struct ShowWorker

std::map<std::string, std::string> wires_on_demand;
for (auto wire : module->selected_wires()) {
const char *shape = "diamond";
std::string shape = wireshape;
if (wire->port_input || wire->port_output)
shape = "octagon";
const bool is_borderless = (shape == "plaintext") || (shape == "plain") || (shape == "none");
if (wire->name.isPublic()) {
std::string src_href;
if (href && wire->attributes.count(ID::src) > 0)
src_href = stringf(", href=\"%s\" ", escape(wire->attributes.at(ID::src).decode_string()));
fprintf(f, "n%d [ shape=%s, label=\"%s\", %s%s];\n",
id2num(wire->name), shape, findLabel(wire->name.str()),
nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(),
fprintf(f, "n%d [ shape=%s,%s label=\"%s\", %s%s];\n",
id2num(wire->name), shape.c_str(), is_borderless? " margin=0, width=0" : "", findLabel(wire->name.str()),
is_borderless
? "color=\"none\", fontcolor=\"black\""
: nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").c_str(),
src_href.c_str());
if (wire->port_input)
all_sources.insert(stringf("n%d", id2num(wire->name)));
Expand Down Expand Up @@ -617,10 +621,10 @@ struct ShowWorker
}

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>> &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),
notitle(notitle), href(href), color_selections(color_selections), label_selections(label_selections), colorattr(colorattr)
{
Expand Down Expand Up @@ -708,6 +712,9 @@ struct ShowPass : public Pass {
log(" Use the specified attribute to assign colors. A unique color is\n");
log(" assigned to each unique value of this attribute.\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(" annotate buses with a label indicating the width of the bus.\n");
log("\n");
Expand Down Expand Up @@ -766,6 +773,7 @@ struct ShowPass : public Pass {
std::string prefix = stringf("%s/.yosys_show", getenv("HOME") ? getenv("HOME") : ".");
#endif
std::string viewer_exe;
std::string flag_wireshape = "diamond";
std::vector<std::string> libfiles;
std::vector<RTLIL::Design*> libs;
uint32_t colorSeed = 0;
Expand Down Expand Up @@ -830,6 +838,10 @@ struct ShowPass : public Pass {
format = args[++argidx];
continue;
}
if (arg == "-wireshape" && argidx+1 < args.size()) {
flag_wireshape = args[++argidx];
continue;
}
if (arg == "-width") {
flag_width= true;
continue;
Expand Down Expand Up @@ -912,7 +924,7 @@ struct ShowPass : public Pass {
delete lib;
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);

for (auto lib : libs)
Expand Down
Loading