pub struct Bus { /* private fields */ }Expand description
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§
Source§impl Bus
 
impl Bus
Sourcepub fn new<S: Into<String>>(
    g: &mut GateGraphBuilder,
    width: usize,
    name: S,
) -> Self
 
pub fn new<S: Into<String>>( g: &mut GateGraphBuilder, width: usize, name: S, ) -> Self
Returns a new Bus of width width with name name.
Sourcepub fn connect(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
 
pub fn connect(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
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.
Sourcepub fn connect_some(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
 
pub fn connect_some(&self, g: &mut GateGraphBuilder, other: &[GateIndex])
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.
Sourcepub fn merge(&self, g: &mut GateGraphBuilder, other: Bus) -> Bus
 
pub fn merge(&self, g: &mut GateGraphBuilder, other: Bus) -> Bus
Connects the bits of other to self and returns a clone of self.