aboutsummaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-03-01 14:15:27 +0100
committerClifford Wolf <clifford@clifford.at>2018-03-01 14:15:27 +0100
commit90ae42607850a51da55fd5c6fba20ebb02ef6226 (patch)
tree1c4ae35d183cb4254efb49cd4bedec4471b307eb /backends
parent9a2a8cd97b8ff155c137045ee3654dcdc046c401 (diff)
downloadyosys-90ae42607850a51da55fd5c6fba20ebb02ef6226.tar.gz
yosys-90ae42607850a51da55fd5c6fba20ebb02ef6226.tar.bz2
yosys-90ae42607850a51da55fd5c6fba20ebb02ef6226.zip
Mangle names with square brackets in VCD files to work around issues in gtkwave
Signed-off-by: Clifford Wolf <clifford@clifford.at>
Diffstat (limited to 'backends')
-rw-r--r--backends/smt2/smtio.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py
index 4e5359795..5bc43acae 100644
--- a/backends/smt2/smtio.py
+++ b/backends/smt2/smtio.py
@@ -913,6 +913,12 @@ class MkVcd:
if path not in self.clocks:
print("b%s %s" % (bits, self.nets[path][0]), file=self.f)
+ def escape_name(self, name):
+ name = re.sub(r"\[([a-zA-Z_][0-9a-zA-Z_]*)\]", r".\1", name)
+ if re.match("[\[\]]", name) and name[0] != "\\":
+ name = "\\" + name
+ return name
+
def set_time(self, t):
assert t >= self.t
if t != self.t:
@@ -929,9 +935,9 @@ class MkVcd:
scope.append(path[len(scope)-1])
key, width = self.nets[path]
if path in self.clocks and self.clocks[path][1] == "event":
- print("$var event 1 %s %s $end" % (key, path[-1]), file=self.f)
+ print("$var event 1 %s %s $end" % (key, self.escape_name(path[-1])), file=self.f)
else:
- print("$var wire %d %s %s $end" % (width, key, path[-1]), file=self.f)
+ print("$var wire %d %s %s $end" % (width, key, self.escape_name(path[-1])), file=self.f)
for i in range(len(scope)):
print("$upscope $end", file=self.f)
print("$enddefinitions $end", file=self.f)