[−][src]Struct logicsim::circuits::Wire
Data structure that helps with connecting wires to many different components.
It is basically syntactic sugar for an or gate.
Example
let mut reset = Wire::new(&mut g, "reset"); let reset_lever = reset.make_lever(&mut g); let clock = g.lever("clock"); let counter_output = counter( &mut g, clock.bit(), ON, // enable OFF, // write ON, // read reset.bit(), &zeros(4), // input "counter" ); // Notice I connect the third (index 2) bit of the output to reset. // so as soon as the counter reaches 4 (0b100) it will reset. reset.connect(&mut g, counter_output[2]); let output = g.output(&counter_output, "result"); let ig = &mut g.init(); ig.pulse_lever_stable(reset_lever); assert_eq!(output.u8(ig), 0); ig.pulse_lever_stable(clock); assert_eq!(output.u8(ig), 1); ig.pulse_lever_stable(clock); assert_eq!(output.u8(ig), 2); ig.pulse_lever_stable(clock); assert_eq!(output.u8(ig), 3); ig.pulse_lever_stable(clock); assert_eq!(output.u8(ig), 0);
Fields
name: String
Implementations
impl Wire
[src]
pub fn new<S: Into<String>>(g: &mut GateGraphBuilder, name: S) -> Self
[src]
Returns a new Wire with name name
.
pub fn make_lever(&mut self, g: &mut GateGraphBuilder) -> LeverHandle
[src]
Makes a new lever for the wire, stores it for easy access later and returns its LeverHandle.
pub fn lever(&self) -> Option<LeverHandle>
[src]
Returns Some(LeverHandle) if make_lever has been called before. None otherwise.
pub fn connect(&self, g: &mut GateGraphBuilder, other: GateIndex)
[src]
Connects a new GateIndex to the wire.
pub fn bit(&self) -> GateIndex
[src]
Returns the GateIndex of the wire.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Wire
impl Send for Wire
impl Sync for Wire
impl Unpin for Wire
impl UnwindSafe for Wire
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,