wellen/
lib.rs

1// Copyright 2023-2024 The Regents of the University of California
2// Copyright 2024-2025 Cornell University
3// released under BSD 3-Clause License
4// author: Kevin Laeufer <laeufer@cornell.edu>
5
6mod compressed;
7mod fst;
8mod ghw;
9mod hierarchy;
10mod signals;
11pub mod simple;
12pub mod stream;
13mod vcd;
14pub mod viewers;
15mod wavemem;
16
17/// Cargo.toml version of this library.
18pub const VERSION: &str = env!("CARGO_PKG_VERSION");
19
20#[derive(Debug, PartialEq, Copy, Clone)]
21#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
22pub enum FileFormat {
23    Vcd,
24    Fst,
25    Ghw,
26    Unknown,
27}
28#[derive(Debug, Copy, Clone)]
29pub struct LoadOptions {
30    /// Indicates that the loader should use multiple threads if possible.
31    pub multi_thread: bool,
32    /// Indicates that scopes with empty names should not be part of the hierarchy.
33    pub remove_scopes_with_empty_name: bool,
34}
35
36impl Default for LoadOptions {
37    fn default() -> Self {
38        Self {
39            multi_thread: true,
40            remove_scopes_with_empty_name: false,
41        }
42    }
43}
44
45pub type TimeTable = Vec<Time>;
46
47#[derive(Debug, thiserror::Error)]
48pub enum WellenError {
49    #[error("failed to load {0:?}:\n{1}")]
50    FailedToLoad(FileFormat, String),
51    #[error("unknown file format, only GHW, FST and VCD are supported")]
52    UnknownFileFormat,
53    #[error("io error")]
54    Io(#[from] std::io::Error),
55}
56
57pub type Result<T> = std::result::Result<T, WellenError>;
58
59pub use compressed::{CompressedSignal, CompressedTimeTable, Compression};
60pub use hierarchy::{
61    Hierarchy, Scope, ScopeOrVar, ScopeOrVarRef, ScopeRef, ScopeType, SignalEncoding, SignalRef,
62    Timescale, TimescaleUnit, Var, VarDirection, VarIndex, VarRef, VarType,
63};
64pub use signals::{Real, Signal, SignalSource, SignalValue, Time, TimeTableIdx};
65
66#[cfg(feature = "benchmark")]
67pub use wavemem::check_states_pub;