Convert CSV waveform data to Value Change Dump (VCD) format for use with digital waveform viewers and simulators.
csv2vcd is a fast, lightweight C utility that transforms CSV files containing time-series signal data into IEEE 1364 VCD format. Optimized for large files with buffered I/O and efficient parsing.
- Fast: Optimized with large I/O buffers and in-place CSV parsing
- Cross-platform: Compiles on macOS, Linux, and Windows
- Simple: Single C file with no external dependencies
- Smart: Only emits VCD changes when signal values actually change
- Precise: Rounds values to 2 decimals for consistent change detection
Your CSV must follow this structure:
- First row: Header with signal names (column 0 is time, columns 1+ are signal names)
- Second row: Initial values (seeds the VCD dump at time 0)
- Remaining rows: Time-series data (time in seconds, signal values as floating-point)
time,sig_a,sig_b
0.0,0.1,1.2
0.000000001,0.1,1.3
0.000000002,0.2,1.3See examples/ for more samples.
# Using make
make
# Or using build script
chmod +x build.sh
./build.sh
# Or manually
cc -Wall -Wextra -O2 csv2vcd.c -lm -o csv2vcd# Using build script
build.bat
# Or with MinGW
gcc -Wall -Wextra -O2 csv2vcd.c -lm -o csv2vcd.exe
# Or with MSVC
cl /W4 /O2 /Fe:csv2vcd.exe csv2vcd.c./csv2vcd input.csv output.vcdThe tool prints processing statistics:
Done, processed 4 rows. The elapsed time is 0.001 seconds.
The generated VCD file uses:
- Timescale: 1ns (all CSV times must be in seconds)
- Scope: Single module named "dut"
- Variables: Real 64-bit values
- Identifiers: Single ASCII characters starting at '!' (supports up to 20 signals)
Only timestamps where signal values change are emitted to keep output compact.
- Max columns: 20 (configurable via
MAX_COLS) - Max cell size: 50 characters (configurable via
MAXCHAR_COL) - VCD identifiers: Single ASCII chars (supports 20 signals)
Run the test suite:
# Using make
make test
# Or directly
bash tests/run.shTests validate against known fixtures with deterministic output (excluding the $date line).
pwsh tests/run.ps1pip install pytest
pytest -qsudo make install
# Installs to /usr/local/binTo uninstall:
sudo make uninstallCopy csv2vcd.exe to a directory in your PATH.
- Uses 1MB I/O buffers for fast file processing
- In-place CSV parsing avoids string copies
- Cached constants reduce repeated math operations
- Change detection skips unchanged rows
- Rounding: Values rounded to 2 decimals before comparison
- Time conversion: Seconds × 10⁹ → nanoseconds
- Change detection: Emits only when rounded values differ
- Platform timing: POSIX
gettimeofdayon Unix, WindowsGetSystemTimeAsFileTimecompatibility layer
MIT License - see LICENSE file.
Marcel Oosterhuis