00001
00021 #include "kit.h"
00022 #include "aig.h"
00023
00027
00031
00043 Aig_Obj_t * Kit_GraphToAigInternal( Aig_Man_t * pMan, Kit_Graph_t * pGraph )
00044 {
00045 Kit_Node_t * pNode = NULL;
00046 Aig_Obj_t * pAnd0, * pAnd1;
00047 int i;
00048
00049 if ( Kit_GraphIsConst(pGraph) )
00050 return Aig_NotCond( Aig_ManConst1(pMan), Kit_GraphIsComplement(pGraph) );
00051
00052 if ( Kit_GraphIsVar(pGraph) )
00053 return Aig_NotCond( Kit_GraphVar(pGraph)->pFunc, Kit_GraphIsComplement(pGraph) );
00054
00055 Kit_GraphForEachNode( pGraph, pNode, i )
00056 {
00057 pAnd0 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge0.Node)->pFunc, pNode->eEdge0.fCompl );
00058 pAnd1 = Aig_NotCond( Kit_GraphNode(pGraph, pNode->eEdge1.Node)->pFunc, pNode->eEdge1.fCompl );
00059 pNode->pFunc = Aig_And( pMan, pAnd0, pAnd1 );
00060 }
00061
00062 return Aig_NotCond( pNode->pFunc, Kit_GraphIsComplement(pGraph) );
00063 }
00064
00076 Aig_Obj_t * Kit_GraphToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, Kit_Graph_t * pGraph )
00077 {
00078 Kit_Node_t * pNode = NULL;
00079 int i;
00080
00081 Kit_GraphForEachLeaf( pGraph, pNode, i )
00082 pNode->pFunc = pFanins[i];
00083
00084 return Kit_GraphToAigInternal( pMan, pGraph );
00085 }
00086
00098 Aig_Obj_t * Kit_TruthToAig( Aig_Man_t * pMan, Aig_Obj_t ** pFanins, unsigned * pTruth, int nVars, Vec_Int_t * vMemory )
00099 {
00100 Aig_Obj_t * pObj;
00101 Kit_Graph_t * pGraph;
00102
00103 if ( vMemory == NULL )
00104 {
00105 vMemory = Vec_IntAlloc( 0 );
00106 pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
00107 Vec_IntFree( vMemory );
00108 }
00109 else
00110 pGraph = Kit_TruthToGraph( pTruth, nVars, vMemory );
00111
00112 pObj = Kit_GraphToAig( pMan, pFanins, pGraph );
00113 Kit_GraphFree( pGraph );
00114 return pObj;
00115 }
00116
00120
00121