Enum quaigh::network::Gate

source ·
pub enum Gate {
    Binary([Signal; 2], BinaryType),
    Ternary([Signal; 3], TernaryType),
    Nary(Box<[Signal]>, NaryType),
    Buf(Signal),
    Dff([Signal; 3]),
    Lut(Box<LutGate>),
}
Expand description

Logic gate representation

Logic gates have a canonical form. The canonical form is unique, making it easier to simplify and deduplicate the logic. Inputs and output may be negated, and constant inputs are simplified.

Canonical form includes:

  • And gates (with optional negated inputs)
  • Xor gates (no negated input)
  • Mux/Maj/Dff Or/Nor/Nand gates are replaced by And gates. Xnor gates are replaced by Xor gates. Buf/Not and trivial gates are omitted.

Variants§

§

Binary([Signal; 2], BinaryType)

Arbitrary 2-input gate (And/Xor)

§

Ternary([Signal; 3], TernaryType)

Arbitrary 3-input gate (And/Xor/Mux/Maj)

§

Nary(Box<[Signal]>, NaryType)

Arbitrary N-input gate (And/Or/Xor/Nand/Nor/Xnor)

§

Buf(Signal)

Buf or Not

§

Dff([Signal; 3])

D flip-flop with enable and reset

§

Lut(Box<LutGate>)

LUT

Implementations§

source§

impl Gate

source

pub fn and(a: Signal, b: Signal) -> Gate

Create a 2-input And

source

pub fn xor(a: Signal, b: Signal) -> Gate

Create a 2-input Xor

source

pub fn and3(a: Signal, b: Signal, c: Signal) -> Gate

Create a 3-input And

source

pub fn xor3(a: Signal, b: Signal, c: Signal) -> Gate

Create a 3-input Xor

source

pub fn andn(v: &[Signal]) -> Gate

Create a n-input And

source

pub fn xorn(v: &[Signal]) -> Gate

Create a n-input Xor

source

pub fn lut(v: &[Signal], lut: Lut) -> Gate

Create a n-input Lut

source

pub fn mux(s: Signal, a: Signal, b: Signal) -> Gate

Create a Mux

source

pub fn maj(a: Signal, b: Signal, c: Signal) -> Gate

Create a Maj

source

pub fn dff(d: Signal, en: Signal, res: Signal) -> Gate

Create a Dff

source

pub fn is_canonical(&self) -> bool

Returns whether the gate is in canonical form

source

pub fn make_canonical(&self) -> Normalization

Obtain the canonical form of the gate

source

pub fn dependencies(&self) -> &[Signal]

Obtain all signals feeding this gate

source

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

Obtain all internal variables feeding this gate (not inputs or constants)

source

pub fn is_comb(&self) -> bool

Returns whether the gate is combinatorial

source

pub fn is_and(&self) -> bool

Returns whether the gate is an And of any arity

source

pub fn is_xor(&self) -> bool

Returns whether the gate is a Xor of any arity

source

pub fn is_and_like(&self) -> bool

Returns whether the gate is an And, Or, Nand or Nor of any arity

source

pub fn is_xor_like(&self) -> bool

Returns whether the gate is a Xor, Xnor of any arity

source

pub fn is_buf_like(&self) -> bool

Returns whether the gate is a Buf

Trait Implementations§

source§

impl Clone for Gate

source§

fn clone(&self) -> Gate

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 Gate

source§

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

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

impl Display for Gate

source§

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

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

impl Hash for Gate

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 PartialEq for Gate

source§

fn eq(&self, other: &Gate) -> 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 Eq for Gate

source§

impl StructuralEq for Gate

source§

impl StructuralPartialEq for Gate

Auto Trait Implementations§

§

impl RefUnwindSafe for Gate

§

impl Send for Gate

§

impl Sync for Gate

§

impl Unpin for Gate

§

impl UnwindSafe for Gate

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