StreamingVCDTrace
class StreamingVCDTrace : public Trace
@brief Streaming VCD trace reader with lazy evaluation
Extends the Trace base class to provide memory-efficient access to large VCD files using streaming chunks and sparse indexing.
Memory characteristics: - Chunk: 100 MB (configurable) - Index: ~1 MB per billion timestamps - Cache: Configurable per-signal LRU - Total: ~116 MB for 1 TB files (vs 5 TB with load-all)
Usage:
Types
| Name | Description |
|---|---|
| Change | @name Demand-loaded signal histories A VCD is a change log, so answering "value of S at index i" needs either the whole log in memory or another read of the file. |
Variables
| Name | Description |
|---|---|
| timestamp_count | how many '#' records were seen; drives max_index |
| signal_order | declaration order, for SIGNALS |
| index_timestamps | index -> simulation time, for TS |
Functions
| Name | Description |
|---|---|
| ensure_history | Build (or extend) the histories so that name is covered. |
| scan_for | One forward pass recording the changes of every requested signal. |
| parse_header_from_chunks | @} |
| StreamingVCDTrace | @brief Constructor tid : Trace ID for identification filename : Path to VCD file container : Parent TraceContainer chunk_sz : Chunk size in bytes (default: 100 MB) cache_sz : Cache capacity per signal (default: 1000) |
| load | @brief Load and parse VCD file with streaming Starts streaming the file, builds sparse index, and parses header. |
| signal_value | @brief Get signal value with lazy evaluation First checks cache, then seeks to appropriate chunk using sparse index, and parses the necessary data. |
| signal_width | @brief Get signal width in bits name : Signal name Return : Width in bits |
| contains_signal | @brief Check if signal exists name : Signal name Return : true if signal is present |
| get_all_signals | @brief Get all signal names Return : Vector of signal names |
| get_memory_stats | @brief Get memory usage statistics Return : String with memory breakdown |
| warm_cache | @brief Warm cache for frequently accessed signals signal_names : Vector of signal names to pre-initialize |
| get_cache_statistics | @brief Get cache statistics for reporting Return : String with cache hit rate, evictions, etc |
| profile_cache_performance | @brief Profile and log cache performance |
Variable Details
index_timestamps
std::vector<int64_t> index_timestamps
index -> simulation time, for TS
signal_order
std::vector<std::string> signal_order
declaration order, for SIGNALS
timestamp_count
int timestamp_count
how many '#' records were seen; drives max_index
Function Details
StreamingVCDTrace
StreamingVCDTrace(const std::string& tid, const std::string& filename, std::shared_ptr<TraceContainer> container, size_t chunk_sz = 100 * 1024 * 1024, size_t cache_sz = 1000)
@brief Constructor
-
tid - Trace ID for identification
-
filename - Path to VCD file
-
container - Parent TraceContainer
-
chunk_sz - Chunk size in bytes (default: 100 MB)
-
cache_sz - Cache capacity per signal (default: 1000)
contains_signal
bool contains_signal(const std::string& name) const override
@brief Check if signal exists
-
name - Signal name
- Return
- true if signal is present
ensure_history
void ensure_history(const std::string& name)
Build (or extend) the histories so that name is covered.
get_all_signals
std::vector<std::string> get_all_signals() const override
@brief Get all signal names
- Return
- Vector of signal names
get_cache_statistics
std::string get_cache_statistics() const
@brief Get cache statistics for reporting
- Return
- String with cache hit rate, evictions, etc
get_memory_stats
std::string get_memory_stats() const
@brief Get memory usage statistics
- Return
- String with memory breakdown
load
void load()
@brief Load and parse VCD file with streaming
Starts streaming the file, builds sparse index, and parses header. Data is parsed on-demand as needed.
@throws std::ios_base::failure if file cannot be opened
parse_header_from_chunks
bool parse_header_from_chunks()
@}
profile_cache_performance
void profile_cache_performance()
@brief Profile and log cache performance
scan_for
void scan_for(const std::vector<std::string>& wanted)
One forward pass recording the changes of every requested signal.
signal_value
Value signal_value(const std::string& name, int offset = 0, const std::string& scope = "") override
@brief Get signal value with lazy evaluation
First checks cache, then seeks to appropriate chunk using sparse index, and parses the necessary data.
-
name - Signal name
-
offset - Time offset from current index
-
scope - Optional scope prefix
- Return
- Signal value at specified time
signal_width
int signal_width(const std::string& name) override
@brief Get signal width in bits
-
name - Signal name
- Return
- Width in bits
warm_cache
void warm_cache(const std::vector<std::string>& signal_names)
@brief Warm cache for frequently accessed signals
-
signal_names - Vector of signal names to pre-initialize