-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vcd: creates gtkw file if filter_*.txt file is present
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 = "" | ||
|
@@ -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 | ||
|
@@ -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!") |