/**Function************************************************************* Synopsis [Collects internal nodes in the DFS order.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Ptr_t * Aig_ManDfsNodes( Aig_Man_t * p, Aig_Obj_t ** ppNodes, int nNodes ) { Vec_Ptr_t * vNodes; Aig_Obj_t * pObj; int i; assert( Aig_ManLatchNum(p) == 0 ); Aig_ManIncrementTravId( p ); // mark constant and PIs Aig_ObjSetTravIdCurrent( p, Aig_ManConst1(p) ); Aig_ManForEachPi( p, pObj, i ) Aig_ObjSetTravIdCurrent( p, pObj ); // go through the nodes vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) ); for ( i = 0; i < nNodes; i++ ) Aig_ManDfs_rec( p, ppNodes[i], vNodes ); return vNodes; }
/**Function************************************************************* Synopsis [Collects internal nodes in the reverse DFS order.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Vec_Ptr_t * Aig_ManDfsReverse( Aig_Man_t * p ) { Vec_Ptr_t * vNodes; Aig_Obj_t * pObj; int i; Aig_ManIncrementTravId( p ); // mark POs Aig_ManForEachPo( p, pObj, i ) Aig_ObjSetTravIdCurrent( p, pObj ); // if there are latches, mark them if ( Aig_ManLatchNum(p) > 0 ) Aig_ManForEachObj( p, pObj, i ) if ( Aig_ObjIsLatch(pObj) ) Aig_ObjSetTravIdCurrent( p, pObj ); // go through the nodes vNodes = Vec_PtrAlloc( Aig_ManNodeNum(p) ); Aig_ManForEachObj( p, pObj, i ) if ( Aig_ObjIsNode(pObj) || Aig_ObjIsBuf(pObj) ) Aig_ManDfsReverse_rec( p, pObj, vNodes ); return vNodes; }
/**Function************************************************************* Synopsis [Checks the consistency of the AIG manager.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Aig_ManCheck( Aig_Man_t * p ) { Aig_Obj_t * pObj, * pObj2; int i; // check primary inputs Aig_ManForEachPi( p, pObj, i ) { if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) ) { printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj ); return 0; } } // check primary outputs Aig_ManForEachPo( p, pObj, i ) { if ( !Aig_ObjFanin0(pObj) ) { printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj ); return 0; } if ( Aig_ObjFanin1(pObj) ) { printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj ); return 0; } } // check internal nodes Aig_ManForEachObj( p, pObj, i ) { if ( !Aig_ObjIsNode(pObj) ) continue; if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) ) { printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj ); return 0; } if ( Aig_ObjFanin0(pObj)->Id >= Aig_ObjFanin1(pObj)->Id ) { printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj ); return 0; } pObj2 = Aig_TableLookup( p, pObj ); if ( pObj2 != pObj ) { printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj ); return 0; } } // count the total number of nodes if ( Aig_ManObjNum(p) != 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) ) { printf( "Aig_ManCheck: The number of created nodes is wrong.\n" ); printf( "C1 = %d. Pi = %d. Po = %d. Buf = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n", 1, Aig_ManPiNum(p), Aig_ManPoNum(p), Aig_ManBufNum(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p), 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) ); printf( "Created = %d. Deleted = %d. Existing = %d.\n", p->nCreated, p->nDeleted, p->nCreated - p->nDeleted ); return 0; } // count the number of nodes in the table if ( Aig_TableCountEntries(p) != Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) ) { printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" ); printf( "Entries = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n", Aig_TableCountEntries(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p), Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) ); return 0; } // if ( !Aig_ManIsAcyclic(p) ) // return 0; return 1; }