forked from cirosantilli/vcdvcd
-
Notifications
You must be signed in to change notification settings - Fork 1
/
vcdcat
executable file
·123 lines (106 loc) · 3.11 KB
/
vcdcat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/usr/bin/env python3
from __future__ import print_function
from argparse import ArgumentParser, RawTextHelpFormatter
import re
import sys
import vcdvcd
from vcdvcd import VCDVCD
if __name__ == '__main__':
parser = ArgumentParser(
description='Print Verilog value change dump (VCD) files in tabular form.',
epilog="""
# Examples
Show all signals and values:
vcdcat a.vcd
Will be too large for any non-trivial design.
Get the list of all signals:
vcdcat -l a.vcd
Show only selected signals:
vcdcat -x a.vcd top.module.signal1 top.module.signal2
List all signals that contain the substring "top.":
vcdcat -l a.vcd top.
This would show both:
top.module.signal1
top.module.signal2
Now get the values for signals:
vcdcat a.vcd top.
""".format(
f=sys.argv[0]),
formatter_class=RawTextHelpFormatter,
)
parser.add_argument(
'-d',
'--deltas',
action='store_true',
default=False,
help='https://github.com/cirosantilli/vcdvcd#vcdcat-deltas',
)
parser.add_argument(
'-l',
'--list',
action='store_true',
default=False,
help='list signal names and quit',
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
'-x',
'--exact',
action='store_true',
default=False,
help='signal names must match exactly, instead of the default substring match',
)
group.add_argument(
'-r',
'--regexp',
action='store_true',
default=False,
help='signal names are treated as Python regular expressions',
)
parser.add_argument(
'vcd_path',
metavar='vcd-path',
nargs='?',
)
parser.add_argument(
'signals',
help='only print values for these signals. Substrings of the signal are considered a match by default.',
metavar='signals',
nargs='*'
)
args = parser.parse_args()
if True:
vcd = VCDVCD(args.vcd_path, only_sigs=True)
all_signals = vcd.signals
if args.signals:
selected_signals = []
for s in args.signals:
r = re.compile(s)
for a in all_signals:
if (
(args.regexp and r.search(a)) or
(args.exact and s == a) or
(s in a)
):
selected_signals.append(a)
if args.list:
if args.signals:
signals = selected_signals
else:
signals = all_signals
print('\n'.join(signals))
else:
if args.signals:
signals = selected_signals
else:
signals = []
if args.deltas:
callbacks = vcdvcd.PrintDeltasStreamParserCallbacks()
else:
callbacks = vcdvcd.PrintDumpsStreamParserCallbacks()
VCDVCD(
args.vcd_path,
signals=signals,
store_tvs=False,
callbacks=callbacks,
)