Skip to main content

FancyBinary

Trait FancyBinary 

Source
pub trait FancyBinary: Fancy {
    // Required methods
    fn xor(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item;
    fn and(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item>;
    fn negate(&mut self, x: &Self::Item) -> Self::Item;

    // Provided methods
    fn or(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
    fn adder(
        &mut self,
        x: &Self::Item,
        y: &Self::Item,
        carry_in: Option<&Self::Item>,
        channel: &mut Channel<'_>,
    ) -> Result<(Self::Item, Self::Item)> { ... }
    fn and_many(
        &mut self,
        args: &[Self::Item],
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
    fn or_many(
        &mut self,
        args: &[Self::Item],
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
    fn xor_many(&mut self, args: &[Self::Item]) -> Self::Item { ... }
    fn mux_constant_bits(
        &mut self,
        x: &Self::Item,
        b1: bool,
        b2: bool,
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
    fn mux(
        &mut self,
        b: &Self::Item,
        x: &Self::Item,
        y: &Self::Item,
        channel: &mut Channel<'_>,
    ) -> Result<Self::Item> { ... }
}
Expand description

Extension trait for Fancy that provides binary operations.

Required Methods§

Source

fn xor(&mut self, x: &Self::Item, y: &Self::Item) -> Self::Item

Binary XOR.

Source

fn and( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary AND.

Source

fn negate(&mut self, x: &Self::Item) -> Self::Item

Binary negation.

Provided Methods§

Source

fn or( &mut self, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

Binary OR.

Source

fn adder( &mut self, x: &Self::Item, y: &Self::Item, carry_in: Option<&Self::Item>, channel: &mut Channel<'_>, ) -> Result<(Self::Item, Self::Item)>

Binary adder. Returns the result and the carry.

Source

fn and_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>

Return 1 if all wirelabels equal 1.

§Panics

Panics if args is empty.

Source

fn or_many( &mut self, args: &[Self::Item], channel: &mut Channel<'_>, ) -> Result<Self::Item>

Return 1 if any wirelabel equals 1.

§Panics

Panics if args is empty.

Source

fn xor_many(&mut self, args: &[Self::Item]) -> Self::Item

XOR many wirelabels together.

§Panics

Panics if args.len() < 2.

Source

fn mux_constant_bits( &mut self, x: &Self::Item, b1: bool, b2: bool, channel: &mut Channel<'_>, ) -> Result<Self::Item>

If x = 0 return the constant b1, otherwise return b2.

Source

fn mux( &mut self, b: &Self::Item, x: &Self::Item, y: &Self::Item, channel: &mut Channel<'_>, ) -> Result<Self::Item>

If b = 0 return x, otherwise return y.

Implementors§