[−][src]Struct logicsim::circuits::Bus
Data structure that helps with managing buses, it allows you to connect &[GateIndex] to it as well as providing a &[GateIndex] to connect to other components.
It is basically syntactic sugar for a set of or gates.
Example
let input1 = constant(0x01u8); let input2 = constant(0x10u8); let bus = Bus::new(&mut g, 8, "bus"); bus.connect(&mut g, &input1); bus.connect(&mut g, &input2); let output = g.output(bus.bits(), "result"); let ig = &g.init(); assert_eq!(output.u8(ig), 0x11);
Implementations
impl Bus
[src]
pub fn new<S: Into<String>>(
g: &mut GateGraphBuilder,
width: usize,
name: S
) -> Self
[src]
g: &mut GateGraphBuilder,
width: usize,
name: S
) -> Self
Returns a new Bus of width width
with name name
.
pub fn connect(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
[src]
Connects a &[GateIndex] to the bus, each bit of the output of the bus will be set to the or of every corresponding bit in the inputs.
Panics
Will panic if other.len()
!= self.len()
. Use connect_some
if this is not your desired behavior.
pub fn connect_some(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
[src]
Connects a &[GateIndex] to the bus, each bit of the output of the bus will be set to the or of every corresponding bit in the inputs.
If there are excess bits in other
, they won't get connected to the bus.
If there are missing bits in other
only other.len() will be connected to the bus.
pub fn merge(&self, g: &mut GateGraphBuilder, other: Bus) -> Bus
[src]
Connects the bits of other
to self
and returns a clone of self
.
pub fn len(&self) -> usize
[src]
Returns the width of the bus.
pub fn is_empty(&self) -> bool
[src]
Returns true if self.len()
== 0.
pub fn bits(&self) -> &[GateIndex]
[src]
Returns a &[GateIndex] to connect to other components.
pub fn bx(&self, n: usize) -> GateIndex
[src]
pub fn b0(&self) -> GateIndex
[src]
pub fn split_wires(&self, g: &mut GateGraphBuilder, other: &mut [Wire])
[src]
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bus
impl Send for Bus
impl Sync for Bus
impl Unpin for Bus
impl UnwindSafe for Bus
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>,