Skip to content

Commit

Permalink
vcd: creates gtkw file if filter_*.txt file is present
Browse files Browse the repository at this point in the history
  • Loading branch information
fjullien committed Jun 20, 2022
1 parent 878f21a commit d7b84df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions litescope/software/dump/vcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +52,7 @@ def __init__(self, dump=None, samplerate=1e-12, timescale="1ps", comment=""):
# 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 = ""
Expand Down Expand Up @@ -128,6 +130,16 @@ def generate_valuechange(self):
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("@2023\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
Expand All @@ -147,5 +159,12 @@ def write(self, filename):
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!")

0 comments on commit d7b84df

Please sign in to comment.