Skip to main content

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 fst;
7mod ghw;
8mod hierarchy;
9mod signal;
10pub mod simple;
11pub mod stream;
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 hierarchy::PublicHierarchyBuilder as HierarchyBuilder;
59pub use hierarchy::{
60    Hierarchy, Item, ItemRef, Scope, ScopeRef, ScopeType, SignalEncoding, SignalRef, Timescale,
61    TimescaleUnit, Var, VarDirection, VarIndex, VarRef, VarType,
62};
63pub use signal::{
64    BitVecRef, Real, Signal, SignalChangeData, SignalSource, SignalValue, SignalValueRef, States,
65    Time, TimeTableIdx,
66};
67pub use signal::{CompressedSignal, CompressedTimeTable, Compression};
68pub use wavemem::PublicEncoder as Encoder;