00001
00021 #include "aig.h"
00022
00026
00030
00042 int Aig_ManCheck( Aig_Man_t * p )
00043 {
00044 Aig_Obj_t * pObj, * pObj2;
00045 int i;
00046
00047 Aig_ManForEachPi( p, pObj, i )
00048 {
00049 if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) )
00050 {
00051 printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
00052 return 0;
00053 }
00054 }
00055
00056 Aig_ManForEachPo( p, pObj, i )
00057 {
00058 if ( !Aig_ObjFanin0(pObj) )
00059 {
00060 printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
00061 return 0;
00062 }
00063 if ( Aig_ObjFanin1(pObj) )
00064 {
00065 printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
00066 return 0;
00067 }
00068 }
00069
00070 Aig_ManForEachObj( p, pObj, i )
00071 {
00072 if ( !Aig_ObjIsNode(pObj) )
00073 continue;
00074 if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) )
00075 {
00076 printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
00077 return 0;
00078 }
00079 if ( Aig_ObjFanin0(pObj)->Id >= Aig_ObjFanin1(pObj)->Id )
00080 {
00081 printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
00082 return 0;
00083 }
00084 pObj2 = Aig_TableLookup( p, pObj );
00085 if ( pObj2 != pObj )
00086 {
00087 printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
00088 return 0;
00089 }
00090 }
00091
00092 if ( Aig_ManObjNum(p) != 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) +
00093 Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) )
00094 {
00095 printf( "Aig_ManCheck: The number of created nodes is wrong.\n" );
00096 printf( "C1 = %d. Pi = %d. Po = %d. Buf = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n",
00097 1, Aig_ManPiNum(p), Aig_ManPoNum(p), Aig_ManBufNum(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p),
00098 1 + Aig_ManPiNum(p) + Aig_ManPoNum(p) + Aig_ManBufNum(p) + Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) );
00099 printf( "Created = %d. Deleted = %d. Existing = %d.\n",
00100 p->nCreated, p->nDeleted, p->nCreated - p->nDeleted );
00101 return 0;
00102 }
00103
00104 if ( Aig_TableCountEntries(p) != Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) )
00105 {
00106 printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
00107 printf( "Entries = %d. And = %d. Xor = %d. Lat = %d. Total = %d.\n",
00108 Aig_TableCountEntries(p), Aig_ManAndNum(p), Aig_ManExorNum(p), Aig_ManLatchNum(p),
00109 Aig_ManAndNum(p) + Aig_ManExorNum(p) + Aig_ManLatchNum(p) );
00110
00111 return 0;
00112 }
00113
00114
00115 return 1;
00116 }
00117
00129 void Aig_ManCheckMarkA( Aig_Man_t * p )
00130 {
00131 Aig_Obj_t * pObj;
00132 int i;
00133 Aig_ManForEachObj( p, pObj, i )
00134 assert( pObj->fMarkA == 0 );
00135 }
00136
00148 void Aig_ManCheckPhase( Aig_Man_t * p )
00149 {
00150 Aig_Obj_t * pObj;
00151 int i;
00152 Aig_ManForEachObj( p, pObj, i )
00153 if ( Aig_ObjIsPi(pObj) )
00154 assert( (int)pObj->fPhase == 0 );
00155 else
00156 assert( (int)pObj->fPhase == (Aig_ObjPhaseReal(Aig_ObjChild0(pObj)) & Aig_ObjPhaseReal(Aig_ObjChild1(pObj))) );
00157 }
00158
00162
00163