Robust, well-tested Value Change Dump (VCD) Parser

October 26, 2024

From: https://github.com/filmil/go-vcd-parser

Value Change Dump (VCD) File parser

Test status

This is a parser for the Value Change Dump files, a.k.a VCD file format. The file format is defined in the IEEE Standard 1800-2003. Specifically, the format supported at the moment is the 4-value format. Some pragmatic extensions are supported, such as those produced by the nvc VHDL simulator.

The correct behavior of the parser is guarded by a suite of tests. Tests include:

  • Unit tests for specific VCD stanzas
  • Unit tests for intersting VCD snippets encountered in the wild.
  • Integration tests that parse realistic VCD files that were sampled from actual uses.

Why?

  • I wanted one written in go (compiled, static, well-tested). Most open source alternatives I could find are written in Python, Perl and C++ (see the References section below), and have hardly any unit tests, let alone realistic file tests.
  • I needed a confirmation that the code can parse realistic VCD files. Hence, the test coverage.

Prerequisites

  • Install bazel using the bazelisk method.

    It should be possible to use the vanilla go environment as well.

Test

From the root directory, run:

bazel test //...

This should always pass. Report a bug if not.

If you have go installed, you can also run:

go test ./...

While this should pass, I will not necessarily spend time to make it work with the go toolkit.

Limitations

The parser is not streaming. It produces an in-memory representation of the VCD file before it is able to write a parsed representation out. As VCD files can get extraordinarily large, you may find that some realistic large files can not be parsed with success.

Troubleshooting

If you find a problem VCD file, file a bug report and consider sending the file. Minimal examples are preferred.

Prior Art