Struct quaigh::network::Network

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

Representation of a logic network as a gate-inverter-graph, used as the main representation for all logic manipulations

Implementations§

source§

impl Network

source

pub fn new() -> Self

Create a new network

source

pub fn nb_inputs(&self) -> usize

Return the number of primary inputs

source

pub fn nb_outputs(&self) -> usize

Return the number of primary outputs

source

pub fn nb_nodes(&self) -> usize

Return the number of nodes in the network

source

pub fn input(&self, i: usize) -> Signal

Get the input at index i

source

pub fn output(&self, i: usize) -> Signal

Get the output at index i

source

pub fn node(&self, i: usize) -> Signal

Get the variable at index i

source

pub fn gate(&self, i: usize) -> &Gate

Get the gate at index i

source

pub fn add_input(&mut self) -> Signal

Add a new primary input

source

pub fn add_inputs(&mut self, nb: usize)

Add multiple primary inputs

source

pub fn add_output(&mut self, l: Signal)

Add a new primary output based on an existing literal

source

pub fn and(&mut self, a: Signal, b: Signal) -> Signal

Create an And2 gate

source

pub fn xor(&mut self, a: Signal, b: Signal) -> Signal

Create a Xor2 gate

source

pub fn dff(&mut self, data: Signal, enable: Signal, reset: Signal) -> Signal

Create a Dff gate (flip flop)

source

pub fn add_canonical(&mut self, gate: Gate) -> Signal

Add a new gate, and make it canonical. The gate may be simplified immediately

source

pub fn add(&mut self, gate: Gate) -> Signal

Add a new gate

source

pub fn replace(&mut self, i: usize, gate: Gate) -> Signal

Replace an existing gate

source

pub fn is_comb(&self) -> bool

Return whether the network is purely combinatorial

source

pub fn shuffle(&mut self, seed: u64) -> Box<[Signal]>

Shuffle the network randomly; this will invalidate all signals

Returns the mapping of old variable indices to signals, if needed.

source

pub fn cleanup(&mut self) -> Box<[Signal]>

Remove unused logic; this will invalidate all signals

Returns the mapping of old variable indices to signals, if needed. Removed signals are mapped to zero.

source

pub fn make_canonical(&mut self) -> Box<[Signal]>

Remove duplicate logic and make all gates canonical; this will invalidate all signals

Canonical gates are And, Xor, Mux, Maj and Lut. Everything else will be simplified. Returns the mapping of old variable indices to signals, if needed.

source

pub fn deduplicate(&mut self) -> Box<[Signal]>

Remove duplicate logic; this will invalidate all signals

Returns the mapping of old variable indices to signals, if needed.

source

pub fn check(&self)

Check consistency of the datastructure

Trait Implementations§

source§

impl Clone for Network

source§

fn clone(&self) -> Network

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 Network

source§

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

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

impl Default for Network

source§

fn default() -> Network

Returns the “default value” for a type. Read more
source§

impl Display for Network

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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