vcd: creates gtkw file if filter_*.txt file is present
This commit is contained in:
parent
878f21a647
commit
8299105b7f
|
@ -4,6 +4,7 @@
|
|||
# Copyright (c) 2015-2018 Florent Kermarrec <florent@enjoy-digital.fr>
|
||||
# SPDX-License-Identifier: BSD-2-Clause
|
||||
|
||||
from os.path import exists
|
||||
from itertools import count
|
||||
import datetime
|
||||
import re
|
||||
|
@ -51,6 +52,7 @@ class VCDDump(Dump):
|
|||
# factor of 2 scale is because of 2x samples from fake clock
|
||||
self.count_timescale = int(1 / (timescale_seconds * samplerate * 2))
|
||||
self.timescale_unit_str = si_prefix + "s"
|
||||
self.filtered = []
|
||||
|
||||
def change(self):
|
||||
r = ""
|
||||
|
@ -128,6 +130,16 @@ class VCDDump(Dump):
|
|||
self.cnt += 1
|
||||
return r
|
||||
|
||||
def generate_gtkw(self, filename):
|
||||
base_name = filename.split(".")[0]
|
||||
with open("{}.gtkw".format(base_name), "w") as f:
|
||||
f.write(f"[*] Auto-Generated by Litex\n")
|
||||
f.write(f"[dumpfile] {filename}\n")
|
||||
for s in self.filtered:
|
||||
f.write("@2025\n")
|
||||
f.write(f"^1 filter_{s.name}.txt\n")
|
||||
f.write("{}[{}:0]\n".format(s.name, s.width - 1))
|
||||
|
||||
def __repr__(self):
|
||||
r = ""
|
||||
return r
|
||||
|
@ -147,5 +159,12 @@ class VCDDump(Dump):
|
|||
f.write(self.generate_valuechange())
|
||||
f.close()
|
||||
|
||||
for v in self.variables:
|
||||
if exists(f"filter_{v.name}.txt"):
|
||||
self.filtered.append(v)
|
||||
|
||||
if self.filtered:
|
||||
self.generate_gtkw(filename)
|
||||
|
||||
def read(self, filename):
|
||||
raise NotImplementedError("VCD files can not (yet) be read, please contribute!")
|
||||
|
|
Loading…
Reference in New Issue