mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Merge pull request #3791 from nakengelhardt/nak/show_attr_wires
This commit is contained in:
commit
7c606bd5a3
|
@ -84,7 +84,7 @@ struct ShowWorker
|
||||||
std::string nextColor()
|
std::string nextColor()
|
||||||
{
|
{
|
||||||
if (currentColor == 0)
|
if (currentColor == 0)
|
||||||
return "color=\"black\"";
|
return "color=\"black\", fontcolor=\"black\"";
|
||||||
return stringf("colorscheme=\"dark28\", color=\"%d\", fontcolor=\"%d\"", currentColor%8+1, currentColor%8+1);
|
return stringf("colorscheme=\"dark28\", color=\"%d\", fontcolor=\"%d\"", currentColor%8+1, currentColor%8+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,19 +97,16 @@ struct ShowWorker
|
||||||
|
|
||||||
std::string nextColor(RTLIL::SigSpec sig, std::string defaultColor)
|
std::string nextColor(RTLIL::SigSpec sig, std::string defaultColor)
|
||||||
{
|
{
|
||||||
sig.sort_and_unify();
|
std::string color = findColor(sig);
|
||||||
for (auto &c : sig.chunks()) {
|
if (!color.empty()) return color;
|
||||||
if (c.wire != nullptr)
|
|
||||||
for (auto &s : color_selections)
|
|
||||||
if (s.second.selected_members.count(module->name) > 0 && s.second.selected_members.at(module->name).count(c.wire->name) > 0)
|
|
||||||
return stringf("color=\"%s\"", s.first.c_str());
|
|
||||||
}
|
|
||||||
return defaultColor;
|
return defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string nextColor(const RTLIL::SigSig &conn, std::string defaultColor)
|
std::string nextColor(const RTLIL::SigSig &conn, std::string defaultColor)
|
||||||
{
|
{
|
||||||
return nextColor(conn.first, nextColor(conn.second, defaultColor));
|
std::string color = findColor(conn);
|
||||||
|
if (!color.empty()) return color;
|
||||||
|
return defaultColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string nextColor(const RTLIL::SigSpec &sig)
|
std::string nextColor(const RTLIL::SigSpec &sig)
|
||||||
|
@ -131,12 +128,28 @@ struct ShowWorker
|
||||||
return stringf("style=\"setlinewidth(3)\", label=\"<%d>\"", bits);
|
return stringf("style=\"setlinewidth(3)\", label=\"<%d>\"", bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *findColor(std::string member_name)
|
std::string findColor(RTLIL::SigSpec sig)
|
||||||
|
{
|
||||||
|
sig.sort_and_unify();
|
||||||
|
for (auto &c : sig.chunks()) {
|
||||||
|
if (c.wire != nullptr)
|
||||||
|
return findColor(c.wire->name);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string findColor(const RTLIL::SigSig &conn)
|
||||||
|
{
|
||||||
|
std::string firstColor = findColor(conn.first);
|
||||||
|
if (findColor(conn.second) == firstColor) return firstColor;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string findColor(IdString member_name)
|
||||||
{
|
{
|
||||||
for (auto &s : color_selections)
|
for (auto &s : color_selections)
|
||||||
if (s.second.selected_member(module->name, member_name)) {
|
if (s.second.selected_member(module->name, member_name)) {
|
||||||
dot_escape_store.push_back(stringf(", color=\"%s\"", s.first.c_str()));
|
return stringf("color=\"%s\", fontcolor=\"%s\"", s.first.c_str(), s.first.c_str());
|
||||||
return dot_escape_store.back().c_str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RTLIL::Const colorattr_value;
|
RTLIL::Const colorattr_value;
|
||||||
|
@ -155,8 +168,7 @@ struct ShowWorker
|
||||||
colorattr_cache[colorattr_value] = (next_id % 8) + 1;
|
colorattr_cache[colorattr_value] = (next_id % 8) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dot_escape_store.push_back(stringf(", colorscheme=\"dark28\", color=\"%d\", fontcolor=\"%d\"", colorattr_cache.at(colorattr_value), colorattr_cache.at(colorattr_value)));
|
return stringf("colorscheme=\"dark28\", color=\"%d\", fontcolor=\"%d\"", colorattr_cache.at(colorattr_value), colorattr_cache.at(colorattr_value));
|
||||||
return dot_escape_store.back().c_str();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *findLabel(std::string member_name)
|
const char *findLabel(std::string member_name)
|
||||||
|
@ -317,7 +329,7 @@ struct ShowWorker
|
||||||
}
|
}
|
||||||
|
|
||||||
code += stringf("x%d [ shape=record, style=rounded, label=\"", dot_idx) \
|
code += stringf("x%d [ shape=record, style=rounded, label=\"", dot_idx) \
|
||||||
+ join_label_pieces(label_pieces) + "\" ];\n";
|
+ join_label_pieces(label_pieces) + stringf("\", %s ];\n", nextColor(sig).c_str());
|
||||||
|
|
||||||
if (!port.empty()) {
|
if (!port.empty()) {
|
||||||
currentColor = xorshift32(currentColor);
|
currentColor = xorshift32(currentColor);
|
||||||
|
@ -414,9 +426,9 @@ struct ShowWorker
|
||||||
if (wire->port_input || wire->port_output)
|
if (wire->port_input || wire->port_output)
|
||||||
shape = "octagon";
|
shape = "octagon";
|
||||||
if (wire->name.isPublic()) {
|
if (wire->name.isPublic()) {
|
||||||
fprintf(f, "n%d [ shape=%s, label=\"%s\", %s, fontcolor=\"black\" ];\n",
|
fprintf(f, "n%d [ shape=%s, label=\"%s\", %s ];\n",
|
||||||
id2num(wire->name), shape, findLabel(wire->name.str()),
|
id2num(wire->name), shape, findLabel(wire->name.str()),
|
||||||
nextColor(RTLIL::SigSpec(wire), "color=\"black\"").c_str());
|
nextColor(RTLIL::SigSpec(wire), "color=\"black\", fontcolor=\"black\"").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)));
|
||||||
else if (wire->port_output)
|
else if (wire->port_output)
|
||||||
|
@ -481,11 +493,11 @@ struct ShowWorker
|
||||||
#ifdef CLUSTER_CELLS_AND_PORTBOXES
|
#ifdef CLUSTER_CELLS_AND_PORTBOXES
|
||||||
if (!code.empty())
|
if (!code.empty())
|
||||||
fprintf(f, "subgraph cluster_c%d {\nc%d [ shape=record, label=\"%s\"%s ];\n%s}\n",
|
fprintf(f, "subgraph cluster_c%d {\nc%d [ shape=record, label=\"%s\"%s ];\n%s}\n",
|
||||||
id2num(cell->name), id2num(cell->name), label_string.c_str(), findColor(cell->name), code.c_str());
|
id2num(cell->name), id2num(cell->name), label_string.c_str(), color.c_str(), code.c_str());
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
fprintf(f, "c%d [ shape=record, label=\"%s\"%s ];\n%s",
|
fprintf(f, "c%d [ shape=record, label=\"%s\", %s ];\n%s",
|
||||||
id2num(cell->name), label_string.c_str(), findColor(cell->name.str()), code.c_str());
|
id2num(cell->name), label_string.c_str(), findColor(cell->name).c_str(), code.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &it : module->processes)
|
for (auto &it : module->processes)
|
||||||
|
@ -555,9 +567,9 @@ struct ShowWorker
|
||||||
} else if (right_node[0] == 'x') {
|
} else if (right_node[0] == 'x') {
|
||||||
net_conn_map[left_node].out.insert({right_node, GetSize(conn.first)});
|
net_conn_map[left_node].out.insert({right_node, GetSize(conn.first)});
|
||||||
} else {
|
} else {
|
||||||
net_conn_map[right_node].in.insert({stringf("x%d:e", single_idx_count), GetSize(conn.first)});
|
net_conn_map[right_node].in.insert({stringf("x%d", single_idx_count), GetSize(conn.first)});
|
||||||
net_conn_map[left_node].out.insert({stringf("x%d:w", single_idx_count), GetSize(conn.first)});
|
net_conn_map[left_node].out.insert({stringf("x%d", single_idx_count), GetSize(conn.first)});
|
||||||
fprintf(f, "x%d [shape=box, style=rounded, label=\"BUF\"];\n", single_idx_count++);
|
fprintf(f, "x%d [shape=box, style=rounded, label=\"BUF\", %s];\n", single_idx_count++, findColor(conn).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -643,6 +655,7 @@ struct ShowPass : public Pass {
|
||||||
log(" -viewer <viewer>\n");
|
log(" -viewer <viewer>\n");
|
||||||
log(" Run the specified command with the graphics file as parameter.\n");
|
log(" Run the specified command with the graphics file as parameter.\n");
|
||||||
log(" On Windows, this pauses yosys until the viewer exits.\n");
|
log(" On Windows, this pauses yosys until the viewer exits.\n");
|
||||||
|
log(" Use \"-viewer none\" to not run any command.\n");
|
||||||
log("\n");
|
log("\n");
|
||||||
log(" -format <format>\n");
|
log(" -format <format>\n");
|
||||||
log(" Generate a graphics file in the specified format. Use 'dot' to just\n");
|
log(" Generate a graphics file in the specified format. Use 'dot' to just\n");
|
||||||
|
@ -903,28 +916,30 @@ struct ShowPass : public Pass {
|
||||||
#if defined(YOSYS_DISABLE_SPAWN)
|
#if defined(YOSYS_DISABLE_SPAWN)
|
||||||
log_assert(viewer_exe.empty() && !format.empty());
|
log_assert(viewer_exe.empty() && !format.empty());
|
||||||
#else
|
#else
|
||||||
if (!viewer_exe.empty()) {
|
if (viewer_exe != "none") {
|
||||||
#ifdef _WIN32
|
if (!viewer_exe.empty()) {
|
||||||
// system()/cmd.exe does not understand single quotes nor
|
#ifdef _WIN32
|
||||||
// background tasks on Windows. So we have to pause yosys
|
// system()/cmd.exe does not understand single quotes nor
|
||||||
// until the viewer exits.
|
// background tasks on Windows. So we have to pause yosys
|
||||||
std::string cmd = stringf("%s \"%s\"", viewer_exe.c_str(), out_file.c_str());
|
// until the viewer exits.
|
||||||
#else
|
std::string cmd = stringf("%s \"%s\"", viewer_exe.c_str(), out_file.c_str());
|
||||||
std::string cmd = stringf("%s '%s' %s", viewer_exe.c_str(), out_file.c_str(), background.c_str());
|
#else
|
||||||
#endif
|
std::string cmd = stringf("%s '%s' %s", viewer_exe.c_str(), out_file.c_str(), background.c_str());
|
||||||
log("Exec: %s\n", cmd.c_str());
|
#endif
|
||||||
if (run_command(cmd) != 0)
|
log("Exec: %s\n", cmd.c_str());
|
||||||
log_cmd_error("Shell command failed!\n");
|
if (run_command(cmd) != 0)
|
||||||
} else
|
log_cmd_error("Shell command failed!\n");
|
||||||
if (format.empty()) {
|
} else
|
||||||
#ifdef __APPLE__
|
if (format.empty()) {
|
||||||
std::string cmd = stringf("ps -fu %d | grep -q '[ ]%s' || xdot '%s' %s", getuid(), dot_file.c_str(), dot_file.c_str(), background.c_str());
|
#ifdef __APPLE__
|
||||||
#else
|
std::string cmd = stringf("ps -fu %d | grep -q '[ ]%s' || xdot '%s' %s", getuid(), dot_file.c_str(), dot_file.c_str(), background.c_str());
|
||||||
std::string cmd = stringf("{ test -f '%s.pid' && fuser -s '%s.pid' 2> /dev/null; } || ( echo $$ >&3; exec xdot '%s'; ) 3> '%s.pid' %s", dot_file.c_str(), dot_file.c_str(), dot_file.c_str(), dot_file.c_str(), background.c_str());
|
#else
|
||||||
#endif
|
std::string cmd = stringf("{ test -f '%s.pid' && fuser -s '%s.pid' 2> /dev/null; } || ( echo $$ >&3; exec xdot '%s'; ) 3> '%s.pid' %s", dot_file.c_str(), dot_file.c_str(), dot_file.c_str(), dot_file.c_str(), background.c_str());
|
||||||
log("Exec: %s\n", cmd.c_str());
|
#endif
|
||||||
if (run_command(cmd) != 0)
|
log("Exec: %s\n", cmd.c_str());
|
||||||
log_cmd_error("Shell command failed!\n");
|
if (run_command(cmd) != 0)
|
||||||
|
log_cmd_error("Shell command failed!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue