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
impl Aig
Sourcepub fn get_node(&self, id: NodeId) -> Option<AigNodeRef>
pub fn get_node(&self, id: NodeId) -> Option<AigNodeRef>
Retrieves a node from its id.
Sourcepub fn update(&mut self)
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.
Sourcepub fn get_inputs(&self) -> Vec<AigNodeRef> ⓘ
pub fn get_inputs(&self) -> Vec<AigNodeRef> ⓘ
Retrieves valid inputs reference.
Sourcepub fn get_inputs_id(&self) -> HashSet<NodeId>
pub fn get_inputs_id(&self) -> HashSet<NodeId>
Retrieves inputs id.
Sourcepub fn get_outputs(&self) -> Vec<AigNodeRef> ⓘ
pub fn get_outputs(&self) -> Vec<AigNodeRef> ⓘ
Retrieves outputs reference.
Sourcepub fn get_outputs_id(&self) -> HashSet<NodeId>
pub fn get_outputs_id(&self) -> HashSet<NodeId>
Retrieves outputs id.
Sourcepub fn new_and(
&mut self,
id: NodeId,
fanin0: AigEdge,
fanin1: AigEdge,
) -> Result<AigNodeRef>
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).
Sourcepub fn add_output(&mut self, id: NodeId) -> Result<()>
pub fn add_output(&mut self, id: NodeId) -> Result<()>
Mark an existing node as an output.
Sourcepub fn remove_output(&mut self, id: NodeId) -> Option<AigNodeRef>
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.
Sourcepub fn replace_fanin(
&mut self,
parent_id: NodeId,
fanin_id: FaninId,
child_id: NodeId,
complement: bool,
) -> Result<()>
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
Sourcepub fn check_integrity(&self) -> Result<()>
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.