Struct Aig

Source
pub struct Aig { /* private fields */ }
Expand description

A whole AIG.

Nodes are kept alive artificially to allow rewrites of the structure. Once you are done with rewriting (ie, your AIG should now be in a relevant state), you can call the .update() method to remove all unused nodes.

For example, if you just created a node using .new_and(id, fanin0, fanin1), this node isn’t used as a fanin to any other node for now. It won’t be deleted directly (fortunately!). But if after finishing your rewrite you call .update() and the node still is not used by any other node, then, it will get deleted.

The use of Rc allows us not to worry about having to drop manually nodes that are no longer used, eg. nodes that were used before by node A as their fanin0, but A is rewritten to use another fanin0.

Implementations§

Source§

impl Aig

Source

pub fn new() -> Self

Create a brand new (and empty) AIG.

Source

pub fn get_node(&self, id: NodeId) -> Option<AigNodeRef>

Retrieves a node from its id.

Source

pub fn update(&mut self)

Call this function when you are done with your rewrite. All nodes that are not part of the AIG anymore (ie not reachable from an output) will be deleted.

Source

pub fn get_inputs(&self) -> Vec<AigNodeRef>

Retrieves valid inputs reference.

Source

pub fn get_inputs_id(&self) -> HashSet<NodeId>

Retrieves inputs id.

Source

pub fn get_outputs(&self) -> Vec<AigNodeRef>

Retrieves outputs reference.

Source

pub fn get_outputs_id(&self) -> HashSet<NodeId>

Retrieves outputs id.

Source

pub fn new_and( &mut self, id: NodeId, fanin0: AigEdge, fanin1: AigEdge, ) -> Result<AigNodeRef>

Create a new and node (or retrieve it if the exact same node already exists).

Source

pub fn add_output(&mut self, id: NodeId) -> Result<()>

Mark an existing node as an output.

Source

pub fn remove_output(&mut self, id: NodeId) -> Option<AigNodeRef>

Remove a node from the outputs. Do not error if node does not exist or was not an output, simply returns None instead of the node.

Source

pub fn replace_fanin( &mut self, parent_id: NodeId, fanin_id: FaninId, child_id: NodeId, complement: bool, ) -> Result<()>

Replace the given fanin of a node by a new fanin Both nodes need to already exist in the AIG

Source

pub fn check_integrity(&self) -> Result<()>

Checking if the AIG structure is correct. This function was written for debug purposes, as the library is supposed to maintain integrity of the AIG at any moment.

Trait Implementations§

Source§

impl Clone for Aig

Source§

fn clone(&self) -> Aig

Returns a duplicate 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 Aig

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Aig

§

impl !RefUnwindSafe for Aig

§

impl !Send for Aig

§

impl !Sync for Aig

§

impl Unpin for Aig

§

impl !UnwindSafe for Aig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.