Skip to content

FSTTrace

class FSTTrace : public Trace

@brief FST (Fast Signal Trace) file format trace reader

Reads and parses FST waveform files produced by simulators like Icarus Verilog, Verilator, and others. FST is a compressed binary format designed for efficient waveform storage and fast access.

Features: - Compressed binary format (significantly smaller than VCD) - Efficient random access to timesteps - Hierarchical signal organization - Multi-bit value support - Fast parsing and low memory footprint

Note: This is a simplified FST parser that handles the most common FST files. For full FST format support, consider using the libfst C library directly.

Functions

Name Description
FSTTrace @brief Constructor
load @brief Parse and load FST file
signal_value @brief Get signal value at given index + offset
signal_width @brief Get signal width in bits
contains_signal @brief Check if signal exists
get_all_signals @brief Get all signal names
get_timestamp @brief Get actual simulation timestamp at current index
parse_header @brief Parse FST header section
parse_hierarchy @brief Parse FST hierarchy section (scopes and variables)
parse_value_changes @brief Parse FST value changes (compressed)
decompress_data @brief Decompress FST data (LZ4 or similar)
read_vli @brief Read variable-length integer (VLI)
read_string @brief Read length-prefixed string
parse_bit_value @brief Parse a single bit value
bits_to_value @brief Convert bit string to Value
read_file @brief Read entire file into memory
infer_width @brief Infer bit width from maximum value

Function Details

FSTTrace

FSTTrace(const std::string& tid, const std::string& filename, std::shared_ptr<TraceContainer> container)

@brief Constructor

bits_to_value

static Value bits_to_value(const std::string& bits)

@brief Convert bit string to Value

contains_signal

bool contains_signal(const std::string& name) const override

@brief Check if signal exists

decompress_data

static std::vector<uint8_t> decompress_data(const std::vector<uint8_t>& compressed)

@brief Decompress FST data (LZ4 or similar)

get_all_signals

std::vector<std::string> get_all_signals() const override

@brief Get all signal names

get_timestamp

int64_t get_timestamp() const override

@brief Get actual simulation timestamp at current index

infer_width

static int infer_width(int64_t max_value)

@brief Infer bit width from maximum value

load

void load()

@brief Parse and load FST file

parse_bit_value

static char parse_bit_value(uint8_t byte)

@brief Parse a single bit value

parse_header

void parse_header(const std::vector<uint8_t>& data, size_t& pos)

@brief Parse FST header section

parse_hierarchy

void parse_hierarchy(const std::vector<uint8_t>& data, size_t& pos)

@brief Parse FST hierarchy section (scopes and variables)

parse_value_changes

void parse_value_changes(const std::vector<uint8_t>& data, size_t& pos)

@brief Parse FST value changes (compressed)

read_file

static std::vector<uint8_t> read_file(const std::string& filename)

@brief Read entire file into memory

read_string

static std::string read_string(const std::vector<uint8_t>& data, size_t& pos)

@brief Read length-prefixed string

read_vli

static uint64_t read_vli(const std::vector<uint8_t>& data, size_t& pos)

@brief Read variable-length integer (VLI)

signal_value

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

@brief Get signal value at given index + offset

signal_width

int signal_width(const std::string& name) override

@brief Get signal width in bits