mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
Merge pull request #2881 from whitequark/cxxrtl-sideways-colon
cxxrtl: escape colon in variable names in VCD writer
This commit is contained in:
commit
c2afcbe78d
|
@ -69,12 +69,25 @@ class vcd_writer {
|
||||||
} while (ident != 0);
|
} while (ident != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void emit_name(const std::string &name) {
|
||||||
|
for (char c : name) {
|
||||||
|
if (c == ':') {
|
||||||
|
// Due to a bug, GTKWave cannot parse a colon in the variable name, causing the VCD file
|
||||||
|
// to be unreadable. It cannot be escaped either, so replace it with the sideways colon.
|
||||||
|
buffer += "..";
|
||||||
|
} else {
|
||||||
|
buffer += c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void emit_var(const variable &var, const std::string &type, const std::string &name,
|
void emit_var(const variable &var, const std::string &type, const std::string &name,
|
||||||
size_t lsb_at, bool multipart) {
|
size_t lsb_at, bool multipart) {
|
||||||
assert(!streaming);
|
assert(!streaming);
|
||||||
buffer += "$var " + type + " " + std::to_string(var.width) + " ";
|
buffer += "$var " + type + " " + std::to_string(var.width) + " ";
|
||||||
emit_ident(var.ident);
|
emit_ident(var.ident);
|
||||||
buffer += " " + name;
|
buffer += " ";
|
||||||
|
emit_name(name);
|
||||||
if (multipart || name.back() == ']' || lsb_at != 0) {
|
if (multipart || name.back() == ']' || lsb_at != 0) {
|
||||||
if (var.width == 1)
|
if (var.width == 1)
|
||||||
buffer += " [" + std::to_string(lsb_at) + "]";
|
buffer += " [" + std::to_string(lsb_at) + "]";
|
||||||
|
|
Loading…
Reference in a new issue