diff options
author | whitequark <whitequark@whitequark.org> | 2021-07-20 09:30:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-20 09:30:08 +0000 |
commit | c2afcbe78d1cc582ad3d2f6809524d9aa8d9cb46 (patch) | |
tree | addd3aaf811686be618034c4a179320946613acd /backends/cxxrtl | |
parent | 9af88951bca3de799b9af121a45ad8c8d41dab2e (diff) | |
parent | fc84f230011b5a2eab1eefc319e8646b3ca2f657 (diff) | |
download | yosys-c2afcbe78d1cc582ad3d2f6809524d9aa8d9cb46.tar.gz yosys-c2afcbe78d1cc582ad3d2f6809524d9aa8d9cb46.tar.bz2 yosys-c2afcbe78d1cc582ad3d2f6809524d9aa8d9cb46.zip |
Merge pull request #2881 from whitequark/cxxrtl-sideways-colon
cxxrtl: escape colon in variable names in VCD writer
Diffstat (limited to 'backends/cxxrtl')
-rw-r--r-- | backends/cxxrtl/cxxrtl_vcd.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/backends/cxxrtl/cxxrtl_vcd.h b/backends/cxxrtl/cxxrtl_vcd.h index 3f40a8d12..b76922bbd 100644 --- a/backends/cxxrtl/cxxrtl_vcd.h +++ b/backends/cxxrtl/cxxrtl_vcd.h @@ -69,12 +69,25 @@ class vcd_writer { } 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, size_t lsb_at, bool multipart) { assert(!streaming); buffer += "$var " + type + " " + std::to_string(var.width) + " "; emit_ident(var.ident); - buffer += " " + name; + buffer += " "; + emit_name(name); if (multipart || name.back() == ']' || lsb_at != 0) { if (var.width == 1) buffer += " [" + std::to_string(lsb_at) + "]"; |