Struct volute::sop::Cube

source ·
pub struct Cube { /* private fields */ }
Expand description

Representation of the And of variables (a cube in Sum-of-Products representations)

Each variable is represented by a pair of bits, representing respectively the positive and negative literal. If none is set, the variable is unused. If both are set, the cube is 0.

It only supports And operations. Anything else must be implemented by more complex representations that use it, such as sum-of-products.

Implementations§

source§

impl Cube

source

pub fn one() -> Cube

The empty cube

source

pub fn zero() -> Cube

The zero cube (not strictly a cube, so it gets a special representation)

source

pub fn is_constant(&self) -> bool

Check whether the cube is a constant

source

pub fn is_zero(&self) -> bool

Check whether the cube is a constant zero

This can happen after And operations, so we check if any variable has the two bits set.

source

pub fn is_one(&self) -> bool

Check whether the cube is the constant one

source

pub fn nth_var(var: usize) -> Cube

Return the cube representing the nth variable

source

pub fn nth_var_inv(var: usize) -> Cube

Return the cube representing the nth variable, inverted

source

pub fn minterm(num_vars: usize, mask: usize) -> Cube

Obtain the minterm for a value of the variables

source

pub fn value(&self, mask: usize) -> bool

Get the value of the Cube for these inputs (input bits packed in the mask)

source

pub fn from_vars(pos_vars: &[usize], neg_vars: &[usize]) -> Cube

Build a cube from the literals in it

source

pub fn from_mask(pos: u32, neg: u32) -> Cube

Build a cube directly from the integer masks

source

pub fn num_lits(&self) -> usize

Return the number of literals

source

pub fn num_gates(&self) -> usize

Return the number of And2 gates necessary to implement the cube

source

pub fn pos_vars(&self) -> impl Iterator<Item = usize> + '_

Returns the variables that are positive in the cube

source

pub fn neg_vars(&self) -> impl Iterator<Item = usize> + '_

Returns the variables that are negative in the cube

source

pub fn intersects(&self, o: Cube) -> bool

Returns whether the cube intersects another

source

pub fn implies(&self, o: Cube) -> bool

Returns whether the cube implies another

source

pub fn implies_lut(&self, lut: &Lut) -> bool

Return whether the cube implies the given Lut

source

pub fn all(vars: usize) -> impl Iterator<Item = Cube>

Return all possible cubes with a given number of variables

Trait Implementations§

source§

impl BitAnd<&Cube> for &Cube

§

type Output = Cube

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Cube) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd<&Cube> for Cube

§

type Output = Cube

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: &Cube) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd<Cube> for &Cube

§

type Output = Cube

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Cube) -> Self::Output

Performs the & operation. Read more
source§

impl BitAnd for Cube

§

type Output = Cube

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Cube) -> Self::Output

Performs the & operation. Read more
source§

impl Clone for Cube

source§

fn clone(&self) -> Cube

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Cube

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Cube

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Cube

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Cube

source§

fn cmp(&self, other: &Cube) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Cube

source§

fn eq(&self, other: &Cube) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Cube

source§

fn partial_cmp(&self, other: &Cube) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for Cube

source§

impl Eq for Cube

source§

impl StructuralEq for Cube

source§

impl StructuralPartialEq for Cube

Auto Trait Implementations§

§

impl RefUnwindSafe for Cube

§

impl Send for Cube

§

impl Sync for Cube

§

impl Unpin for Cube

§

impl UnwindSafe for Cube

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V