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