aboutsummaryrefslogtreecommitdiffstats
path: root/passes/cmds/show.cc
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-12-23 12:29:29 +0100
committerClifford Wolf <clifford@clifford.at>2014-12-23 12:29:29 +0100
commit4f5b97954e15b1aa40f7b3068865f4d8fcbe9fb7 (patch)
tree082ff4f455ed8cc04baa42b061ca11f9026f1d9d /passes/cmds/show.cc
parenta216df043374f3d3a699889f0bf207491df037ea (diff)
downloadyosys-4f5b97954e15b1aa40f7b3068865f4d8fcbe9fb7.tar.gz
yosys-4f5b97954e15b1aa40f7b3068865f4d8fcbe9fb7.tar.bz2
yosys-4f5b97954e15b1aa40f7b3068865f4d8fcbe9fb7.zip
Added "show -colorattr"
Diffstat (limited to 'passes/cmds/show.cc')
-rw-r--r--passes/cmds/show.cc39
1 files changed, 35 insertions, 4 deletions
diff --git a/passes/cmds/show.cc b/passes/cmds/show.cc
index 715c1de56..f61f195be 100644
--- a/passes/cmds/show.cc
+++ b/passes/cmds/show.cc
@@ -64,6 +64,10 @@ struct ShowWorker
const std::vector<std::pair<std::string, RTLIL::Selection>> &color_selections;
const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections;
+ std::map<RTLIL::Const, int> colorattr_cache;
+ RTLIL::IdString colorattr;
+
+
static uint32_t xorshift32(uint32_t x) {
x ^= x << 13;
x ^= x >> 17;
@@ -128,7 +132,25 @@ struct ShowWorker
dot_escape_store.push_back(stringf(", color=\"%s\"", s.first.c_str()));
return dot_escape_store.back().c_str();
}
- return "";
+
+ RTLIL::Const colorattr_value;
+ RTLIL::Cell *cell = module->cell(member_name);
+ RTLIL::Wire *wire = module->wire(member_name);
+
+ if (cell && cell->attributes.count(colorattr))
+ colorattr_value = cell->attributes.at(colorattr);
+ else if (wire && wire->attributes.count(colorattr))
+ colorattr_value = wire->attributes.at(colorattr);
+ else
+ return "";
+
+ if (colorattr_cache.count(colorattr_value) == 0) {
+ int next_id = GetSize(colorattr_cache);
+ 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 dot_escape_store.back().c_str();
}
const char *findLabel(std::string member_name)
@@ -507,10 +529,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,
const std::vector<std::pair<std::string, RTLIL::Selection>> &color_selections,
- const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections) :
+ const std::vector<std::pair<std::string, RTLIL::Selection>> &label_selections, RTLIL::IdString colorattr) :
f(f), design(design), currentColor(colorSeed), genWidthLabels(genWidthLabels),
genSignedLabels(genSignedLabels), stretchIO(stretchIO), enumerateIds(enumerateIds), abbreviateIds(abbreviateIds),
- notitle(notitle), color_selections(color_selections), label_selections(label_selections)
+ notitle(notitle), color_selections(color_selections), label_selections(label_selections), colorattr(colorattr)
{
ct.setup_internals();
ct.setup_internals_mem();
@@ -586,6 +608,10 @@ struct ShowPass : public Pass {
log(" for the random number generator. Change the seed value if the colored\n");
log(" graph still is ambigous. A seed of zero deactivates the coloring.\n");
log("\n");
+ log(" -colorattr <attribute_name>\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("\n");
log(" -width\n");
log(" annotate busses with a label indicating the width of the bus.\n");
log("\n");
@@ -637,6 +663,7 @@ struct ShowPass : public Pass {
bool flag_enum = false;
bool flag_abbeviate = true;
bool flag_notitle = false;
+ RTLIL::IdString colorattr;
size_t argidx;
for (argidx = 1; argidx < args.size(); argidx++)
@@ -678,6 +705,10 @@ struct ShowPass : public Pass {
colorSeed = ShowWorker::xorshift32(colorSeed);
continue;
}
+ if (arg == "-colorattr" && argidx+1 < args.size()) {
+ colorattr = RTLIL::escape_id(args[++argidx]);
+ continue;
+ }
if (arg == "-format" && argidx+1 < args.size()) {
format = args[++argidx];
continue;
@@ -753,7 +784,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_abbeviate, flag_notitle, color_selections, label_selections);
+ ShowWorker worker(f, design, libs, colorSeed, flag_width, flag_signed, flag_stretch, flag_enum, flag_abbeviate, flag_notitle, color_selections, label_selections, colorattr);
fclose(f);
for (auto lib : libs)