Skip to main content

rustdv_sim/
rustdv_sim.rs

1//! # rustdv-sim
2//!
3//! The cocotb-analog core (design-doc §4): a bespoke single-threaded
4//! executor driven by simulator callbacks (D4.1 — not tokio), the task
5//! model, the trigger inventory, typed signal handles with buffered
6//! writes, `Clock`, and sim-aware `Event`/`Lock`/`Queue`.
7//!
8//! Control-flow contract (§4.1): a GPI/VPI callback fires → subscribed
9//! tasks are woken → the run queue is drained to exhaustion
10//! ([`Executor::run_until_idle`]) → control returns to the simulator.
11
12// Test executables need vpi_* symbol definitions (the simulator provides
13// them for the real cdylib) — see rustdv-vpi-stubs.
14#[cfg(test)]
15use rustdv_vpi_stubs as _;
16
17pub mod clock;
18pub mod combinators;
19pub mod executor;
20pub mod handle;
21pub mod log;
22pub mod path;
23pub mod phase;
24pub mod queue;
25pub mod rng;
26pub mod sync;
27pub mod testing;
28pub mod time;
29pub mod triggers;
30
31pub use clock::Clock;
32pub use combinators::{first2, join2, join_all, with_timeout, Either, TimeoutError};
33pub use executor::{spawn, spawn_named, Executor, TaskError, TaskHandle, TaskId, TaskState};
34pub use path::RustdvPath;
35pub use handle::{AnyHandle, HierarchyHandle, LogicHandle};
36pub use phase::{read_only, read_write, next_time_step};
37pub use queue::Queue;
38pub use rng::Rng;
39pub use sync::{Event, Lock, LockGuard};
40pub use time::{sim_time_ns, sim_time_steps, SimDuration};
41pub use triggers::{NullTrigger, Timer};
42
43pub use rustdv_gpi::{HandleError, Logic, LogicArray, ValueError};
44
45/// Initialize the sim context: install a fresh executor and phase hub on
46/// this thread. Called once by the runner at start-of-simulation.
47pub fn init() -> Executor {
48    phase::init_hub();
49    executor::init()
50}