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
impl Gate
sourcepub fn is_canonical(&self) -> bool
pub fn is_canonical(&self) -> bool
Returns whether the gate is in canonical form
sourcepub fn make_canonical(&self) -> Normalization
pub fn make_canonical(&self) -> Normalization
Obtain the canonical form of the gate
sourcepub fn dependencies(&self) -> &[Signal]
pub fn dependencies(&self) -> &[Signal]
Obtain all signals feeding this gate
sourcepub fn vars(&self) -> impl Iterator<Item = u32> + '_
pub fn vars(&self) -> impl Iterator<Item = u32> + '_
Obtain all internal variables feeding this gate (not inputs or constants)
sourcepub fn is_and_like(&self) -> bool
pub fn is_and_like(&self) -> bool
Returns whether the gate is an And, Or, Nand or Nor of any arity
sourcepub fn is_xor_like(&self) -> bool
pub fn is_xor_like(&self) -> bool
Returns whether the gate is a Xor, Xnor of any arity
sourcepub fn is_buf_like(&self) -> bool
pub fn is_buf_like(&self) -> bool
Returns whether the gate is a Buf
Trait Implementations§
source§impl PartialEq for Gate
impl PartialEq for Gate
impl Eq for Gate
impl StructuralEq for Gate
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more