mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
Mangle names with square brackets in VCD files to work around issues in gtkwave
Signed-off-by: Clifford Wolf <clifford@clifford.at>
This commit is contained in:
parent
9a2a8cd97b
commit
90ae426078
|
@ -913,6 +913,12 @@ class MkVcd:
|
||||||
if path not in self.clocks:
|
if path not in self.clocks:
|
||||||
print("b%s %s" % (bits, self.nets[path][0]), file=self.f)
|
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):
|
def set_time(self, t):
|
||||||
assert t >= self.t
|
assert t >= self.t
|
||||||
if t != self.t:
|
if t != self.t:
|
||||||
|
@ -929,9 +935,9 @@ class MkVcd:
|
||||||
scope.append(path[len(scope)-1])
|
scope.append(path[len(scope)-1])
|
||||||
key, width = self.nets[path]
|
key, width = self.nets[path]
|
||||||
if path in self.clocks and self.clocks[path][1] == "event":
|
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:
|
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)):
|
for i in range(len(scope)):
|
||||||
print("$upscope $end", file=self.f)
|
print("$upscope $end", file=self.f)
|
||||||
print("$enddefinitions $end", file=self.f)
|
print("$enddefinitions $end", file=self.f)
|
||||||
|
|
Loading…
Reference in a new issue