pub trait FancyBinary: Fancy {
// Required methods
fn xor(
&mut self,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error>;
fn and(
&mut self,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error>;
fn negate(&mut self, x: &Self::Item) -> Result<Self::Item, Self::Error>;
// Provided methods
fn or(
&mut self,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error> { ... }
fn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>,
) -> Result<(Self::Item, Self::Item), Self::Error> { ... }
fn and_many(
&mut self,
args: &[Self::Item],
) -> Result<Self::Item, Self::Error> { ... }
fn or_many(
&mut self,
args: &[Self::Item],
) -> Result<Self::Item, Self::Error> { ... }
fn xor_many(
&mut self,
args: &[Self::Item],
) -> Result<Self::Item, Self::Error> { ... }
fn mux_constant_bits(
&mut self,
x: &Self::Item,
b1: bool,
b2: bool,
) -> Result<Self::Item, Self::Error> { ... }
fn mux(
&mut self,
b: &Self::Item,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error> { ... }
}Expand description
Fancy DSL providing binary operations
Required Methods§
Sourcefn xor(
&mut self,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error>
fn xor( &mut self, x: &Self::Item, y: &Self::Item, ) -> Result<Self::Item, Self::Error>
Binary Xor
Provided Methods§
Sourcefn or(
&mut self,
x: &Self::Item,
y: &Self::Item,
) -> Result<Self::Item, Self::Error>
fn or( &mut self, x: &Self::Item, y: &Self::Item, ) -> Result<Self::Item, Self::Error>
Uses Demorgan’s Rule implemented with an and gate and negation.
Sourcefn adder(
&mut self,
x: &Self::Item,
y: &Self::Item,
carry_in: Option<&Self::Item>,
) -> Result<(Self::Item, Self::Item), Self::Error>
fn adder( &mut self, x: &Self::Item, y: &Self::Item, carry_in: Option<&Self::Item>, ) -> Result<(Self::Item, Self::Item), Self::Error>
Binary adder. Returns the result and the carry.
Sourcefn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn and_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
Returns 1 if all wires equal 1.
Sourcefn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn or_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
Returns 1 if any wire equals 1.
Sourcefn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
fn xor_many(&mut self, args: &[Self::Item]) -> Result<Self::Item, Self::Error>
XOR many wires together