Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcd: creates gtkw file if filter_*.txt file is present #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 <[email protected]>
# 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("@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
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!")