3 This is a multipurpose utility for handling VCD files.
4 It started as a fork of the excellent Verilog VCD Parser, therefore keeping its original README file below.
7 * Display full path of signals contained within th VCD file.
8 * Display the list of scopes within the VCD file.
9 * Display VCD file header
10 * Display number of toggles for each signal
11 * Restrict VCD file to a range of timestamps
14 * Export VCD file (useful for producing a cut-down VCD file)
15 * Filter some signals/scopes (useful for the VCD export)
17 Please see below for the original Verilog VCD Parser README.md file:
22 [](https://codedocs.xyz/ben-marshall/verilog-vcd-parser/)
24 This project implements a no-frills *Value Change Dump* (VCD) file parser, as
25 described in the IEEE System Verilog 1800-2012 standard. It can be used to
26 write custom tools which need to read signal traces dumped out by Verilog (or
33 After cloning the repository to your local machine, run the following in a
37 $> cd ./verilog-vcd-parser
41 This will build both the demonstration executable in `build/vcd-parser` and
42 the API documentation in `build/docs`.
46 This code will load up a VCD file and print the hierarchy of the scopes
47 and signals declared in it.
52 VCDFile * trace = parser.parse_file("path-to-my-file.vcd");
54 if(trace == nullptr) {
55 // Something went wrong.
58 for(VCDScope * scope : *trace -> get_scopes()) {
60 std::cout << "Scope: " << scope -> name << std::endl;
62 for(VCDSignal * signal : scope -> signals) {
64 std::cout << "\t" << signal -> hash << "\t"
65 << signal -> reference;
67 if(signal -> size > 1) {
68 std::cout << " [" << signal -> size << ":0]";
71 std::cout << std::endl;
79 We can also query the value of a signal at a particular time. Because a VCD
80 file can have multiple signals in multiple scopes which represent the same
81 physical signal, we use the signal hash to access it's value at a particular
85 // Get the first signal we fancy.
86 VCDSignal * mysignal = trace -> get_scope("$root") -> signals[0];
88 // Print the value of this signal at every time step.
90 for (VCDTime time : *trace -> get_timestamps()) {
92 VCDValue * val = trace -> get_signal_value_at( mysignal -> hash, time);
94 std::cout << "t = " << time
95 << ", " << mysignal -> reference
98 // Assumes val is not nullptr!
99 switch(val -> get_type()) {
101 std::cout << VCDValue::VCDBit2Char(val -> get_value_bit());
104 VCDBitVector * vecval = val -> get_value_vector()
105 for(auto it = vecval -> begin();
106 it != vecval -> end();
108 std::cout << VCDValue::VCDBit2Char(*it);
112 std::cout << val -> get_value_real();
123 The example above is deliberately verbose to show how common variables and
124 signal attributes can be accessed.
129 It is assumed that given a set of source files, it will be easy for people to
130 integrate this as a submodule of their own projects. However, Flex and Bison
131 *must* be run before all compilable source files are present. If integrating
132 this into a larger project, you will want to ensure the following commands are
133 run before compiling any of the VCD parser sources.
139 This will run flex and bison on the `.ypp` and `.l` files in `src/` and put
140 the generated parser and lexer code in `build/`. The complete file list for
141 inclusion in a larger project is:
145 src/VCDFileParser.cpp
151 With header files located in both `src/` and `build/`.
153 ## Integration using static link library
155 `build/libverilog-vcd-parser.a` and the required .hpp files are copied into `build/`.
157 To use these from another application add -I and the .a file to your gcc command line:
160 $ gcc -Ibuild/ build/libverilog-vcd-parser.a myapp.cpp
166 - The parser and lexical analyser are written using Bison and Flex
168 - The data structures and other functions are written using C++ 2011.
169 - The build system is GNU Make.
170 - The codebase is documented using Doxygen.