4
4
# Copyright (c) 2015-2018 Florent Kermarrec <[email protected] >
5
5
# SPDX-License-Identifier: BSD-2-Clause
6
6
7
+ from os .path import exists
7
8
from itertools import count
8
9
import datetime
9
10
import re
@@ -51,6 +52,7 @@ def __init__(self, dump=None, samplerate=1e-12, timescale="1ps", comment=""):
51
52
# factor of 2 scale is because of 2x samples from fake clock
52
53
self .count_timescale = int (1 / (timescale_seconds * samplerate * 2 ))
53
54
self .timescale_unit_str = si_prefix + "s"
55
+ self .filtered = []
54
56
55
57
def change (self ):
56
58
r = ""
@@ -128,6 +130,16 @@ def generate_valuechange(self):
128
130
self .cnt += 1
129
131
return r
130
132
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
+
131
143
def __repr__ (self ):
132
144
r = ""
133
145
return r
@@ -147,5 +159,12 @@ def write(self, filename):
147
159
f .write (self .generate_valuechange ())
148
160
f .close ()
149
161
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
+
150
169
def read (self , filename ):
151
170
raise NotImplementedError ("VCD files can not (yet) be read, please contribute!" )
0 commit comments