Skip to content

VCDParser

class VCDParser

@brief Fast VCD parser with delta compression

Type Aliases

Name Description
DeltaSink Receives each timestamp's changes as they are parsed.

Functions

Name Description
parse @brief Parse VCD file filename : Path to VCD file scope_filter : Optional scope prefix for filtering (e.g., "top.cpu")
parse_fst @brief Parse FST file using GTKWave fstapi filename : Path to FST file scope_filter : Optional scope prefix for filtering (e.g., "top.cpu")
get_signal_info @brief Get signal info by ID
get_signal_ids @brief Get all signal IDs
get_deltas @brief Get delta timestamps Empty when a sink is installed: see set_delta_sink().
set_delta_sink @brief Stream deltas to sink instead of accumulating them.
streaming Whether deltas are being streamed rather than stored.
get_initial_values @brief Get initial signal values from $dumpvars / FST time-0 callback Maps signal_id -> initial value.
get_initial_wide_values @brief Get initial values for signals >64 bits wide (see get_initial_values()).
is_wide_signal @brief Whether a signal's declared width exceeds 64 bits (see DeltaTimestamp::wide_changes).
num_signals @brief Get number of signals
num_timestamps @brief Get number of timestamps
get_signals_in_scope @brief Get signals in a specific scope
get_signal_ids_by_names @brief Get signal IDs from a list of signal names signal_names : Vector of full hierarchical signal names Return : Vector of signal IDs (signals not found are skipped)
get_timescale @brief Trace timescale, e.g. "1ps" / "10ns" (default "1ns" if absent).

Type Alias Details

DeltaSink

using DeltaSink = std::function<void(const DeltaTimestamp&)>

Receives each timestamp's changes as they are parsed.

Function Details

get_deltas

const std::vector<DeltaTimestamp>& get_deltas() const

@brief Get delta timestamps

Empty when a sink is installed: see set_delta_sink().

get_initial_values

const std::unordered_map<uint32_t, int64_t>& get_initial_values() const

@brief Get initial signal values from $dumpvars / FST time-0 callback Maps signal_id -> initial value. Signals absent have implicit value 0. Only covers signals <=64 bits wide; see get_initial_wide_values() for wider ones.

get_initial_wide_values

const std::unordered_map<uint32_t, std::vector<uint64_t>>& get_initial_wide_values() const

@brief Get initial values for signals >64 bits wide (see get_initial_values()). Maps signal_id -> word vector (low word first).

get_signal_ids

const std::vector<uint32_t>& get_signal_ids() const

@brief Get all signal IDs

get_signal_ids_by_names

std::vector<uint32_t> get_signal_ids_by_names(const std::vector<std::string>& signal_names) const

@brief Get signal IDs from a list of signal names

signal_names
Vector of full hierarchical signal names
Return
Vector of signal IDs (signals not found are skipped)

get_signal_info

const SignalInfo& get_signal_info(uint32_t signal_id) const

@brief Get signal info by ID

get_signals_in_scope

std::vector<uint32_t> get_signals_in_scope(const std::string& scope_prefix) const

@brief Get signals in a specific scope

get_timescale

const std::string& get_timescale() const

@brief Trace timescale, e.g. "1ps" / "10ns" (default "1ns" if absent).

is_wide_signal

bool is_wide_signal(uint32_t signal_id) const

@brief Whether a signal's declared width exceeds 64 bits (see DeltaTimestamp::wide_changes).

num_signals

size_t num_signals() const

@brief Get number of signals

num_timestamps

size_t num_timestamps() const

@brief Get number of timestamps

parse

void parse(const std::string& filename, const std::string& scope_filter = "")

@brief Parse VCD file

filename
Path to VCD file
scope_filter
Optional scope prefix for filtering (e.g., "top.cpu")

parse_fst

void parse_fst(const std::string& filename, const std::string& scope_filter = "")

@brief Parse FST file using GTKWave fstapi

filename
Path to FST file
scope_filter
Optional scope prefix for filtering (e.g., "top.cpu")

set_delta_sink

void set_delta_sink(DeltaSink sink)

@brief Stream deltas to sink instead of accumulating them.

Without a sink the parser builds the complete deltas_ vector before any consumer runs, so peak memory grows with the trace: about three times the file, measured at 137 MB for a 50 MB VCD. Every extraction kernel walks that vector strictly forward, carrying a running state, so none of them needs it to exist. With a sink installed each timestamp is handed over and dropped, and memory becomes O(signals), independent of how long the trace is.

Install it before parse(). The header is read first, so by the time the first delta arrives the signal table is complete and the sink can size itself.

streaming

bool streaming() const

Whether deltas are being streamed rather than stored.