4 releases
Uses new Rust 2024
new 0.1.3 | Apr 12, 2025 |
---|---|
0.1.2 | Apr 11, 2025 |
0.1.1 | Apr 11, 2025 |
0.1.0 | Apr 11, 2025 |
#51 in Simulation
329 downloads per month
1MB
973 lines
Contains (WOFF font, 400KB) NanumBarunGothic-13b3dcba.ttf.woff2, (WOFF font, 135KB) FiraSans-Medium-e1aa3f0a.woff2, (WOFF font, 130KB) FiraSans-Regular-0fe48ade.woff2, (WOFF font, 82KB) SourceSerif4-Bold-6d4fd4c0.ttf.woff2, (WOFF font, 77KB) SourceSerif4-Regular-6b053e98.ttf.woff2, (WOFF font, 45KB) SourceCodePro-It-fc8b9304.ttf.woff2 and 3 more.
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