Module libreda_logic::network_simulator
source · Expand description
Simulate logic networks.
use libreda_logic::network::*;
use libreda_logic::networks::mig::*;
use libreda_logic::network_simulator::*;
// Create a new logic network based on majority gates and inverters.
let mut mig = Mig::new();
// Create some primary inputs.
let [a, b, c, d] = mig.create_primary_inputs();
// Construct the network.
let maj = mig.create_maj3(a, b, c);
let maj_or_d = mig.create_or(maj, d);
// Create primary outputs.
mig.create_primary_output(maj);
mig.create_primary_output(maj_or_d);
// Wrap the network into a network simulator.
let simulator = RecursiveSim::new(&mig);
// Evaluate the network by simulation.
let output_values: Vec<_> = simulator
.simulate(&[maj, maj_or_d], &[true, false, false, true])
.collect();
assert_eq!(output_values, vec![false, true]);
Structs§
- Very simple network simulator. Not so efficient though.