pub struct SimulationContext { /* private fields */ }Expand description
A handle to interact with the simulation and create modules and signals.
§Example
use system_rust::prelude::*;
use system_rust::standard_modules::SRAnd;
let (mut sim_control, sim_context) = SimulationControl::new();
let sig_a = sim_context.create_signal("A", L4::T);
let sig_b = sim_context.create_signal("B", L4::T);
let sig_r = sim_context.create_signal("R", L4::X);
sim_context.add_compute_module("And", |mut and: SRAnd| {
and.in_a.attach(&sig_a);
and.in_b.attach(&sig_b);
and.output.attach(&sig_r);
and
});
sim_control.simulate(sim_context, |waiter| {
waiter.wait(SimDelay::NS(1));
println!("{}" ,sig_r.read());
});Implementations§
Source§impl SimulationContext
impl SimulationContext
pub fn add_compute_module<M, F>(&self, name: &str, set_ports: F)where
M: ComputeModule + 'static,
F: FnOnce(M) -> M,
pub fn add_composite_module<C, F>(&self, name: &str, set_ports: F)where
C: CompositeModule,
F: FnOnce(C) -> C,
pub fn create_signal(&self, name: &str, initial_value: L4) -> Signal
pub fn create_signal_arr<const N: usize>( &self, name: &str, initial_value: L4, ) -> SignalArr<N>
pub fn create_resolved_signal( &self, name: &str, initial_value: L4, ) -> ResolvedSignal
pub fn create_resolved_signal_arr<const N: usize>( &self, name: &str, initial_value: L4, ) -> ResolvedSignalArr<N>
Trait Implementations§
Source§impl Clone for SimulationContext
impl Clone for SimulationContext
Source§fn clone(&self) -> SimulationContext
fn clone(&self) -> SimulationContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for SimulationContext
impl !RefUnwindSafe for SimulationContext
impl Send for SimulationContext
impl !Sync for SimulationContext
impl Unpin for SimulationContext
impl UnwindSafe for SimulationContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more