Skip to content

Commit 8299105

Browse files
committed
vcd: creates gtkw file if filter_*.txt file is present
1 parent 878f21a commit 8299105

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

litescope/software/dump/vcd.py

+19
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Copyright (c) 2015-2018 Florent Kermarrec <[email protected]>
55
# SPDX-License-Identifier: BSD-2-Clause
66

7+
from os.path import exists
78
from itertools import count
89
import datetime
910
import re
@@ -51,6 +52,7 @@ def __init__(self, dump=None, samplerate=1e-12, timescale="1ps", comment=""):
5152
# factor of 2 scale is because of 2x samples from fake clock
5253
self.count_timescale = int(1 / (timescale_seconds * samplerate * 2))
5354
self.timescale_unit_str = si_prefix + "s"
55+
self.filtered = []
5456

5557
def change(self):
5658
r = ""
@@ -128,6 +130,16 @@ def generate_valuechange(self):
128130
self.cnt += 1
129131
return r
130132

133+
def generate_gtkw(self, filename):
134+
base_name = filename.split(".")[0]
135+
with open("{}.gtkw".format(base_name), "w") as f:
136+
f.write(f"[*] Auto-Generated by Litex\n")
137+
f.write(f"[dumpfile] {filename}\n")
138+
for s in self.filtered:
139+
f.write("@2025\n")
140+
f.write(f"^1 filter_{s.name}.txt\n")
141+
f.write("{}[{}:0]\n".format(s.name, s.width - 1))
142+
131143
def __repr__(self):
132144
r = ""
133145
return r
@@ -147,5 +159,12 @@ def write(self, filename):
147159
f.write(self.generate_valuechange())
148160
f.close()
149161

162+
for v in self.variables:
163+
if exists(f"filter_{v.name}.txt"):
164+
self.filtered.append(v)
165+
166+
if self.filtered:
167+
self.generate_gtkw(filename)
168+
150169
def read(self, filename):
151170
raise NotImplementedError("VCD files can not (yet) be read, please contribute!")

0 commit comments

Comments
 (0)