SILICON
Loading...
Searching...
No Matches
TraceWriter Class Referencefinal

Writes named vector signals from already-sampled FST value strings. More...

#include <fstTraceWriter.hpp>

Collaboration diagram for TraceWriter:

Classes

struct  TraceSignal
 Static description of a signal to register in the FST hierarchy. More...
struct  Options
 FST file metadata and hierarchy options. More...
struct  RegisteredSignal

Public Member Functions

 TraceWriter (std::string_view fileName, const std::vector< TraceSignal > &traceSignals)
 TraceWriter (std::string_view fileName, const std::vector< TraceSignal > &traceSignals, Options options)
 Creates an FST file and registers all non-zero-width trace signals.
 TraceWriter (const TraceWriter &)=delete
TraceWriter & operator= (const TraceWriter &)=delete
 TraceWriter (TraceWriter &&) noexcept=default
TraceWriter & operator= (TraceWriter &&) noexcept=default
void emitSnapshot (uint64_t time, std::span< const std::string > values)
 Emits one timestamped snapshot of already-sampled signal values.
void flush ()
 Flushes pending FST data so external tools can read recent snapshots.
std::optional< fstHandle > handleForSignal (std::string_view name) const
 Returns the libfst handle associated with a registered signal name.
std::size_t signalCount () const
 Number of non-zero-width signals registered in the FST hierarchy.

Static Private Member Functions

static std::string normalizeValue (std::string_view value, std::size_t width)

Private Attributes

std::vector< RegisteredSignal > registeredSignals
std::unordered_map< std::string, fstHandle, TransparentStringHash, TransparentStringEqual > handlesBySignalName
DataWriter writer

Detailed Description

Writes named vector signals from already-sampled FST value strings.

This class owns the generic FST trace behavior: signal registration, value normalization, timestamp emission, and flushing. Circuit-specific adapters can use it without exposing libfst handles or hierarchy construction to their callers.

Definition at line 44 of file fstTraceWriter.hpp.

Constructor & Destructor Documentation

◆ TraceWriter() [1/4]

TraceWriter ( std::string_view fileName,
const std::vector< TraceSignal > & traceSignals )

Definition at line 43 of file fstTraceWriter.cpp.

◆ TraceWriter() [2/4]

TraceWriter ( std::string_view fileName,
const std::vector< TraceSignal > & traceSignals,
Options options )

Creates an FST file and registers all non-zero-width trace signals.

The constructor completes the FST hierarchy immediately. Subsequent calls to emitSnapshot() only emit timestamped value changes for the registered signals.

Parameters
fileNameDestination FST file path.
traceSignalsOrdered signal descriptors. This order defines value indexes for snapshots.
optionsFile metadata and top-level scope settings.

Definition at line 49 of file fstTraceWriter.cpp.

◆ TraceWriter() [3/4]

TraceWriter ( const TraceWriter & )
delete

◆ TraceWriter() [4/4]

TraceWriter ( TraceWriter && )
defaultnoexcept

Member Function Documentation

◆ emitSnapshot()

void emitSnapshot ( uint64_t time,
std::span< const std::string > values )

Emits one timestamped snapshot of already-sampled signal values.

Values are matched to registered signals by index. Missing or empty values are emitted as unknowns, invalid characters are normalized to unknowns, shorter values are left-padded, and longer values keep their rightmost bits.

Parameters
timeTimestamp for this snapshot.
valuesEncoded FST/VCD-style values using 0, 1, x, and z symbols.

Definition at line 79 of file fstTraceWriter.cpp.

◆ flush()

void flush ( )

Flushes pending FST data so external tools can read recent snapshots.

Definition at line 92 of file fstTraceWriter.cpp.

◆ handleForSignal()

std::optional< fstHandle > handleForSignal ( std::string_view name) const
nodiscard

Returns the libfst handle associated with a registered signal name.

Definition at line 97 of file fstTraceWriter.cpp.

◆ normalizeValue()

std::string normalizeValue ( std::string_view value,
std::size_t width )
staticnodiscardprivate

Definition at line 106 of file fstTraceWriter.cpp.

◆ operator=() [1/2]

TraceWriter & operator= ( const TraceWriter & )
delete

◆ operator=() [2/2]

TraceWriter & operator= ( TraceWriter && )
defaultnoexcept

◆ signalCount()

std::size_t signalCount ( ) const
inlinenodiscard

Number of non-zero-width signals registered in the FST hierarchy.

Definition at line 128 of file fstTraceWriter.hpp.

Member Data Documentation

◆ handlesBySignalName

std::unordered_map<std::string, fstHandle, TransparentStringHash, TransparentStringEqual> handlesBySignalName
private

Definition at line 144 of file fstTraceWriter.hpp.

◆ registeredSignals

std::vector<RegisteredSignal> registeredSignals
private

Definition at line 141 of file fstTraceWriter.hpp.

◆ writer

DataWriter writer
private

Definition at line 145 of file fstTraceWriter.hpp.


The documentation for this class was generated from the following files: