#waveform #fst #signal #vcd #api-bindings

fstapi

API for manipulating Fast Signal Trace (FST) format waveforms

2 releases

0.0.2 Apr 14, 2024
0.0.1 Feb 17, 2023

#629 in Encoding

Download history 28/week @ 2024-02-11 45/week @ 2024-02-18 16/week @ 2024-02-25 1/week @ 2024-03-03 22/week @ 2024-03-31 1/week @ 2024-04-07 203/week @ 2024-04-14

226 downloads per month

MIT/Apache

365KB
8K SLoC

C 7K SLoC // 0.1% comments Rust 804 SLoC // 0.0% comments

fstapi

github crates.io docs.rs build status

Rust wrapper of APIs for manipulating Fast Signal Trace (FST) format waveforms.

FST is an open source file format for storing digital waveforms from HDL simulations. It was created by the author of GTKWave in 2014, as an alternate to the VCD (Value Change Dump) format.

For more details, please see:

Usage

Add fstapi to your projects by running cargo add:

cargo add fstapi

Examples

Create an FST waveform:

use fstapi::{Writer, var_type, var_dir};

// Create the waveform.
let mut writer = Writer::create("hello.fst", true)?
  .comment("FST waveform example")?
  .timescale_from_str("1ns")?;

// Create a variable.
let var = writer.create_var(var_type::VCD_REG, var_dir::OUTPUT, 8, "var", None)?;

// Emit value change data and time change data.
writer.emit_value_change(var, b"10001000")?;
writer.emit_time_change(10)?;
writer.emit_value_change(var, b"10011100")?;
writer.emit_time_change(42)?;
writer.emit_value_change(var, b"00111001")?;
writer.emit_time_change(100)?;

Print all variables of an FST waveform:

let mut reader = fstapi::Reader::open("hello.fst")?;
for var in reader.vars() {
  let (name, _) = var?;
  println!("{name}");
}

More Examples

See the GitHub repository: fst-tools, which contains 3 command line tools with this library for manipulating FST waveforms.

License

Copyright (C) 2023 MaxXing. Licensed under either of Apache 2.0 or MIT at your option.

No runtime deps

~0–2MB
~40K SLoC