pub struct Simulation<T> { /* private fields */ }
Expand description

This type represents a simulation over a circuit T. To simulate a circuit, you will need to construct one of these structs.

Implementations§

Construct a simulation struct

Add a clock function to the simulation

Arguments
  • interval - the number of picoseconds between calls to the clock closure
  • clock_fn - a closure to change the clock state of the circuit
Example

#[derive(LogicBlock)]
struct Foo {
   pub clock: Signal<In, Clock>
}

impl Logic for Foo {
  #[hdl_gen]
  fn update(&mut self) {
  }
}

let mut sim : Simulation<Foo> = Default::default();
sim.add_clock(5, |x| x.clock.next = !x.clock.val()); // Toggles the clock every 5 picoseconds.

Add a phased clock to the simulation

Sometimes you will need to control the phasing of a clock so that it starts at some non-zero time. This method allows you to add a clock to a simulation and control the initial delay.

Arguments
  • interval - the delay in picoseconds between the clock function being called
  • phase_delay - the number of picoseconds to wait before the clock starts being toggled
  • clock_fn - the function that toggles the actual clock.
Example

#[derive(LogicBlock)]
struct Foo {
   pub clock: Signal<In, Clock>
}

impl Logic for Foo {
  #[hdl_gen]
  fn update(&mut self) {
  }
}

let mut sim : Simulation<Foo> = Default::default();
// Toggles every 5 picoseconds, starting after 15 picoseconds
sim.add_phased_clock(5, 15, |x| x.clock.next = !x.clock.val());

Add a testbench to the simulation

Arguments
  • testbench - a testbench function that will be executed through the simulation. Needs to return a simulation Result, be Send and [RefUnwindSafe] (no FFI).
Example

Trait Implementations§

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.