Expand description
GWR - The Great Western Runtime
This library provides the core of the GWR Engine which executes event driven asynchronous simulation components.
§Developer Guide
The Developer Guide provides a document that goes through the GWR engine
and related libraries in a more directed approach than the API guide can.
See the gwr-developer-guide/ folder.
§Examples
Make sure you look at the examples/ folder which includes worked/documented examples. The current examples are:
- examples/flaky-component: a worked example of a simple two-port component.
- examples/flaky-with-delay: a worked example of a simple two-port component that has some subcomponents.
- examples/scrambler: a worked example of a component that registers a a vector of subcomponents.
- examples/sim-pipe: simulate a flow-controlled pipeline.
- examples/sim-ring: simulate a device comprising a ring of nodes.
- examples/sim-fabric: simulate a device comprising a rectangular fabric.
§Simple Application
A very simple application would look like:
use gwr_components::sink::Sink;
use gwr_components::source::Source;
use gwr_components::{connect_port, option_box_repeat};
use gwr_engine::engine::Engine;
use gwr_engine::run_simulation;
let mut engine = Engine::default();
let mut source = Source::new_and_register(&engine, engine.top(), "source", option_box_repeat!(0x123 ; 10))
.expect("should be able to create and register `Source`");
let sink = Sink::new_and_register(&engine, engine.top(), "sink")
.expect("should be able to create and register `Sink`");
connect_port!(source, tx => sink, rx)
.expect("should be able to connect `Source` to `Sink`");
run_simulation!(engine);
assert_eq!(sink.num_sunk(), 10);Simulations can be run as purely event driven (where one event triggers one or more others) or the use of clocks can be introduced to model time. The combination of both is the most common.
The engine manages the clocks. A simple example of a component that uses the clock is the rate limiter which models the amount of time it takes for objects to pass through it.
Modules§
- engine
- events
- Different types of events.
- executor
- port
- Port
- test_
helpers - time
- Modules that model time within the simulations.
- traits
- A set of common traits used across GWR Engine.
- types
- Shared types.
Macros§
- run_
simulation - Spawn all component run() functions and then run the simulation.
- sim_
error - Build a SimError from a message that supports
to_string - spawn_
subcomponent - Spawn a sub-component that is stored in an
RefCell<Option<>>