Skip to content

TraceContainer

class TraceContainer

Central hub for managing multiple loaded waveform traces

The TraceContainer: - Manages multiple traces - Keeps all loaded traces - Routes signal queries - Directs lookups to correct trace - Coordinates time - Steps all traces in sync - Handles format loading - Auto-detects VCD/FST/CSV

Usage Flow:

auto container = std::make_shared<TraceContainer>();
container->load("trace1.vcd", "t1");    // Load VCD
container->load("trace2.fst", "t2");    // Load FST

// Access signals from any trace
Value clk = container->signal_value("clk");      // From t1
Value data = container->signal_value("t2~data"); // From t2

// Step all traces in sync
container->step(10);  // All traces forward 10 cycles

Signal Name Resolution: - Format: [trace-id~]signal-name - If trace-id omitted, searches all traces - Returns first match found - Use explicit prefix for disambiguation

See
Trace for signal access details
See
for loading interface

Functions

Name Description
load @name Trace Loading @{ Load a waveform file into container Auto-detects format from file extension: - .vcd → VCD format (Verilog Change Dump) - .fst → FST format (Fast Signal Trace, requires pylibfst) - .csv → CSV format (Comma-Separated Values) Trace ID: If not specified, auto-generated from timestamp. Use explicit IDs for consistent access: cpp container->load("trace.vcd", "my-trace"); // Access as: (signal "signal-name") // from "my-trace" Signal filtering: Optional keep_signals list to load only specific signals. Useful for large traces with many irrelevant signals. cpp std::vector<std::string> keep{"clk", "reset", "data_*"}; container->load("trace.vcd", "t1", &keep); file : Path to waveform file tid : Trace ID (auto-generated if empty) keep_signals : Optional filter (default: load all) @throws TraceError if file not found, parse fails, or format invalid See : "Parser" for trace format support
unload Unload a trace and free memory After unload, signals from that trace are no longer accessible.
signal_value @} @name Signal Access @{ Get a signal value from any loaded trace Signal name formats: - signal-name - searches all traces, first match - trace-id~signal-name - specific trace - ~scope.signal-name - scoped lookup Offset semantics: - offset=0: current time (default) - offset>0: future value (lookahead) - offset<0: past value (lookbehind) Example: cpp // Get current clock value Value clk = container->signal_value("clk"); // Get data 10 cycles ahead Value future_data = container->signal_value("data", 10); // Get from specific trace Value data2 = container->signal_value("trace2~data"); // Scoped signal Value sig = container->signal_value("~cpu.alu.result"); name : Signal name (possibly with trace ID and scope) offset : Time offset (default: 0 = current) scope : Optional scope prefix Return : Signal value at specified time @throws TraceError if signal not found or time out of bounds
signal_width Get signal width in bits name : Signal name Return : Width in bits (1+ for vectors) @throws TraceError if signal not found
contains Check if a signal exists in any loaded trace name : Signal name Return : true if signal is available
step @} @name Time Navigation @{ Step all traces through time Advances or rewinds all loaded traces synchronously.
set_index Seek all traces to an absolute time index The counterpart of step(), which is relative.
indices Get current time index of all traces Return : Map from trace ID to current time index
get_trace_ids @} @name Introspection @{ Get list of loaded trace IDs Return : Vector of trace IDs
get_trace Get a specific trace object For advanced operations requiring direct trace access.
size Get number of loaded traces Return : Count of traces
empty Check if any traces are loaded Return : true if no traces loaded
set_streaming_config @} @name Streaming Configuration @{ Configure streaming behavior for trace loading By default, the container auto-enables streaming for files > 100 MB.
get_streaming_config Get current streaming configuration Return : Reference to current StreamingConfig
set_streaming_enabled Enable or disable streaming mode globally enable : true to enable, false to disable
is_streaming_enabled Check if streaming is enabled Return : true if streaming is active
set_auto_streaming_threshold Set file size threshold for automatic streaming Files larger than this size will automatically use streaming even if streaming is disabled.
get_cache_statistics Get cache statistics for a loaded trace Only available for streaming traces.
new_virtual_trace @} @name Management @{ Clear all loaded traces Frees all loaded traces.
get_traces Get all loaded traces (internal use) Return : Const reference to trace map
load_vcd @} Load VCD (Verilog Change Dump) format
load_fst Load FST (Fast Signal Trace) format
load_csv Load CSV (Comma-Separated Values) format
load_streaming_vcd Load VCD using streaming reader
load_streaming_csv Load CSV using streaming reader
load_streaming_fst Load FST using streaming reader

Function Details

contains

bool contains(const std::string& name)

Check if a signal exists in any loaded trace

name
Signal name
Return
true if signal is available

empty

bool empty() const

Check if any traces are loaded

Return
true if no traces loaded

get_cache_statistics

std::string get_cache_statistics(const std::string& tid) const

Get cache statistics for a loaded trace

Only available for streaming traces. Returns cache hit rate, misses, and evictions.

tid
Trace ID
Return
Statistics string, or empty if trace not streaming

get_streaming_config

const StreamingConfig& get_streaming_config() const

Get current streaming configuration

Return
Reference to current StreamingConfig

get_trace

std::shared_ptr<Trace> get_trace(const std::string& tid) const

Get a specific trace object

For advanced operations requiring direct trace access.

tid
Trace ID
Return
Shared pointer to trace, or nullptr if not found

get_trace_ids

std::vector<std::string> get_trace_ids() const

@} @name Introspection @{ Get list of loaded trace IDs

Return
Vector of trace IDs

get_traces

const std::unordered_map<std::string, std::shared_ptr<Trace>>& get_traces() const

Get all loaded traces (internal use)

Return
Const reference to trace map

indices

std::unordered_map<std::string, int> indices() const

Get current time index of all traces

Return
Map from trace ID to current time index

is_streaming_enabled

bool is_streaming_enabled() const

Check if streaming is enabled

Return
true if streaming is active

load

void load(const std::string& file, const std::string& tid = "", const std::vector<std::string>* keep_signals = nullptr)

@name Trace Loading @{ Load a waveform file into container

Auto-detects format from file extension: - .vcd → VCD format (Verilog Change Dump) - .fst → FST format (Fast Signal Trace, requires pylibfst) - .csv → CSV format (Comma-Separated Values)

Trace ID: If not specified, auto-generated from timestamp. Use explicit IDs for consistent access:

container->load("trace.vcd", "my-trace");
// Access as: (signal "signal-name")  // from "my-trace"

Signal filtering: Optional keep_signals list to load only specific signals. Useful for large traces with many irrelevant signals.

std::vector<std::string> keep{"clk", "reset", "data_*"};
container->load("trace.vcd", "t1", &keep);

file
Path to waveform file
tid
Trace ID (auto-generated if empty)
keep_signals
Optional filter (default: load all) @throws TraceError if file not found, parse fails, or format invalid
See
"Parser" for trace format support

load_csv

void load_csv(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

Load CSV (Comma-Separated Values) format

load_fst

void load_fst(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

Load FST (Fast Signal Trace) format

load_streaming_csv

void load_streaming_csv(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

Load CSV using streaming reader

load_streaming_fst

void load_streaming_fst(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

Load FST using streaming reader

load_streaming_vcd

void load_streaming_vcd(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

Load VCD using streaming reader

load_vcd

void load_vcd(const std::string& file, const std::string& tid, const std::vector<std::string>* keep_signals)

@} Load VCD (Verilog Change Dump) format

new_virtual_trace

void new_virtual_trace(const std::string& tid, int max_index)

@} @name Management @{ Clear all loaded traces

Frees all loaded traces. Useful for clean reset. @brief Register an empty trace with only a timeline, for (new-trace ...).

It has no file and no samples; defsig gives it signals.

set_auto_streaming_threshold

void set_auto_streaming_threshold(size_t bytes)

Set file size threshold for automatic streaming

Files larger than this size will automatically use streaming even if streaming is disabled. Set to 0 to disable auto-detection.

bytes
Threshold in bytes (e.g., 10010241024 for 100 MB)

set_index

std::string set_index(int idx, const std::string& tid = "")

Seek all traces to an absolute time index

The counterpart of step(), which is relative. Random access is what a waveform query language needs most: (set-index 4096) should not have to be expressed as a step from wherever the traces happen to be.

Out-of-range indices are clamped by the individual traces.

idx
Absolute time index
tid
Optional specific trace to seek (empty=all)
Return
Empty string on success, or trace ID if seeking failed

set_streaming_config

void set_streaming_config(const StreamingConfig& config)

@} @name Streaming Configuration @{ Configure streaming behavior for trace loading

By default, the container auto-enables streaming for files > 100 MB. This can be customized globally or per-load.

Examples:

1
2
3
4
5
6
7
8
9
// Enable streaming for all files
StreamingConfig cfg;
cfg.enabled = true;
cfg.chunk_size_bytes = 50 * 1024 * 1024;  // 50 MB chunks
container->set_streaming_config(cfg);

// Disable streaming
cfg.enabled = false;
container->set_streaming_config(cfg);

config
StreamingConfig with desired settings
See
StreamingConfig for available options

set_streaming_enabled

void set_streaming_enabled(bool enable)

Enable or disable streaming mode globally

enable
true to enable, false to disable

signal_value

Value signal_value(const std::string& name, int offset = 0, const std::string& scope = "")

@} @name Signal Access @{ Get a signal value from any loaded trace

Signal name formats: - signal-name - searches all traces, first match - trace-id~signal-name - specific trace - ~scope.signal-name - scoped lookup

Offset semantics: - offset=0: current time (default) - offset>0: future value (lookahead) - offset<0: past value (lookbehind)

Example:

// Get current clock value
Value clk = container->signal_value("clk");

// Get data 10 cycles ahead
Value future_data = container->signal_value("data", 10);

// Get from specific trace
Value data2 = container->signal_value("trace2~data");

// Scoped signal
Value sig = container->signal_value("~cpu.alu.result");

name
Signal name (possibly with trace ID and scope)
offset
Time offset (default: 0 = current)
scope
Optional scope prefix
Return
Signal value at specified time @throws TraceError if signal not found or time out of bounds

signal_width

int signal_width(const std::string& name)

Get signal width in bits

name
Signal name
Return
Width in bits (1+ for vectors) @throws TraceError if signal not found

size

size_t size() const

Get number of loaded traces

Return
Count of traces

step

std::string step(int steps = 1, const std::string& tid = "")

@} @name Time Navigation @{ Step all traces through time

Advances or rewinds all loaded traces synchronously. Useful for sequential time-series analysis.

Stepping by trace:

1
2
3
container->step(5);          // All traces forward 5 cycles
container->step(-3);         // All traces backward 3 cycles
container->step(1, "trace1"); // Only trace1 forward 1 cycle

steps
Number of steps (positive=forward, negative=backward)
tid
Optional specific trace to step (empty=all)
Return
Empty string on success, or trace ID if stepping failed

unload

void unload(const std::string& tid)

Unload a trace and free memory

After unload, signals from that trace are no longer accessible. Safe to call if trace doesn't exist (no-op).

tid
Trace ID to unload