[][src]Crate logical

Logical is a digital network simulator. It is named after the german word "Logical" which describes a puzzle that follows the rules of logic.

You can build arbitrary complex networks, which then can be simulated. It supports Ieee1164 conform values, like strong and weak drives, uninitialized, high impedance and don't care logic. For more information about these take a look at Ieee1164 Type

It is also possible to generate tracefiles in various formats, see the the dump module.

Usage

This crate will be on crates.io and can be used by adding logical to your dependencies in your projects Cargo.toml.

[dependencies]
logical = "0.1"

Afterwards you can use it in your 2018-rust-project

use logical;

Example: connect one port to an other

Normally you will connect one Port to one Signal as input and then connect an other port as output to that same signal. On Updateable::update the value from the input will be transfered to the output.

use logical::{Ieee1164, Port, Signal, Updateable};
use logical::direction::{Input, Output};

let from = Port::<_, Output>::new(Ieee1164::from('1'));
let to = Port::<_, Input>::default();
let mut signal = Signal::new();

signal.connect_as_input(&from);
signal.connect_as_output(&to);

signal.update();

assert_eq!(Ieee1164::from('1'), to.value());

Example: multiple ports

If you have more than one connector the value on the signal will be determined based on the Resolve trait. In this case a high-impedance value will be overriden by the Strong zero value and therefore result in 0.

use logical::{Ieee1164, Port, Signal, Updateable};
use logical::direction::{Input, Output};

let from1 = Port::<_, Output>::new(Ieee1164::from('z'));
let from2 = Port::<_, Output>::new(Ieee1164::from('0'));
let to = Port::<_, Input>::default();
let mut signal = Signal::new();

signal.connect_as_input(&from1);
signal.connect_as_input(&from2);
signal.connect_as_output(&to);

signal.update();

assert_eq!(Ieee1164::from('0'), to.value());

Modules

direction
dump

TODO

models

Structs

Circuit
Integer
Port
Signal

Enums

Ieee1164
Ieee1164Value

An Ieee1164Value is either Zero, One or Unknown, also known as Three-valued logic. You can use any binary, logical operation on it (or, and, xor) or use not and combine them as needed.

Traits

Resolve

This trait is similar to Add, Sub, Mul, ... and is used to describe how values on the same line should be resolved to one T.

Updateable