rust_play_digital 0.1.3

This crate implements analog functions of digital circuits.You can build and match different circuits as you want.
Documentation
  • Coverage
  • 76.19%
    16 out of 21 items documented5 out of 5 items with examples
  • Size
  • Source code size: 2.16 MB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.91 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • JIMARK3

rust_play_digital

DESCRIBE

WHAT THIS CRATE FUNCTION

This crate implements analog functions of digital circuits.You can build and match different circuits as you want.

WHAT THIS CRATE PROVIDE FOR YOU

A total of 6 structures are provided

  • The four structures represent the AND, OR, NOT, and XOR logic circuits
  • One structure represents the initial set of signals provided by the power supply
  • One structure represents the high and low levels, or sampling points.

NOTES

Do not use this crate to design unstable circuits. crate will not give correct simulation results in unstable circuits

WHAT IS UNSTABLE CIRCUITS

A circuit contains inputs, logic gates, and outputs. Unstable circuits can occur in the loop circuit, and the loop circuit can occur in the latch circuit. A latch is a special circuit that can maintain the previous output state. It can be used to implement storage units and registers. Suppose you have an OR gate circuit that has one output (o) and two inputs (i1,i2). We connect the output (o) to the input (i1). You can use this crate to simulate this circuit in any input situation. Because the circuit provides a constant fixed output based on the input. When the input (i2) is low, the output (o) will continue to have no electrical signal. When the input (i2) is high once, the output (o) will remain high forever. Suppose you have an XOR gate circuit with one output (o) and two inputs (i1,i2). We connect the output (o) to the input (i1). You cannot use this crate to simulate certain input situations. Because the circuit can't determine the output in those situations. In the real world this circuit is always stable ,and you will never have an active level output because XOR can't provide an output with only one input, We just use the following example to show what you can't simulate with this crate. Suppose at this time the output (o) is high for some reason, and input i2 inputs a high level, the output will be low for the first time, high for the second time, and low for the third time.... We only provide this input and the output will never be certain, that's what you can't simulate with this crate,crate doesn't simulate this phenomenon.

EXAMPLE

use rust_play_digital::{Digital, Digital1Line, InitSig, OrElectric, TwoInputDigital};
use rust_play_digital::State::{ONE, ZERO};

fn or_loop_circuit() {

    let times = 3;
    let sig = InitSig::new(vec![Some(ZERO), Some(ONE), Some(ZERO)]);
    // OrElectric::process(input_a, input_b)
    let or_electric = OrElectric::process(Some(sig),None);
    let or_electric = or_electric.set_input_b(Some(or_electric.clone()));
   println!("{:?}", or_electric.get_digital_output().output_line_x(0));

}

License: MIT OR Apache-2.0