abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
aigCheck.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [aigCheck.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [AIG package.]
8 
9  Synopsis [AIG checking procedures.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: aigCheck.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "aig.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Checks the consistency of the AIG manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  Aig_Obj_t * pObj, * pObj2;
48  int i;
49  // check primary inputs
50  Aig_ManForEachCi( p, pObj, i )
51  {
52  if ( Aig_ObjFanin0(pObj) || Aig_ObjFanin1(pObj) )
53  {
54  printf( "Aig_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
55  return 0;
56  }
57  }
58  // check primary outputs
59  Aig_ManForEachCo( p, pObj, i )
60  {
61  if ( !Aig_ObjFanin0(pObj) )
62  {
63  printf( "Aig_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
64  return 0;
65  }
66  if ( Aig_ObjFanin1(pObj) )
67  {
68  printf( "Aig_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
69  return 0;
70  }
71  }
72  // check internal nodes
73  Aig_ManForEachObj( p, pObj, i )
74  {
75  if ( !Aig_ObjIsNode(pObj) )
76  continue;
77  if ( !Aig_ObjFanin0(pObj) || !Aig_ObjFanin1(pObj) )
78  {
79  printf( "Aig_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
80  return 0;
81  }
82  if ( Aig_ObjFanin0(pObj)->Id >= Aig_ObjFanin1(pObj)->Id )
83  {
84  printf( "Aig_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
85  return 0;
86  }
87  pObj2 = Aig_TableLookup( p, pObj );
88  if ( pObj2 != pObj )
89  {
90  printf( "Aig_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
91  return 0;
92  }
93  }
94  // count the total number of nodes
95  if ( Aig_ManObjNum(p) != 1 + Aig_ManCiNum(p) + Aig_ManCoNum(p) +
97  {
98  printf( "Aig_ManCheck: The number of created nodes is wrong.\n" );
99  printf( "C1 = %d. Pi = %d. Po = %d. Buf = %d. And = %d. Xor = %d. Total = %d.\n",
102  printf( "Created = %d. Deleted = %d. Existing = %d.\n",
103  Aig_ManObjNumMax(p), p->nDeleted, Aig_ManObjNum(p) );
104  return 0;
105  }
106  // count the number of nodes in the table
108  {
109  printf( "Aig_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
110  printf( "Entries = %d. And = %d. Xor = %d. Total = %d.\n",
112  Aig_ManAndNum(p) + Aig_ManExorNum(p) );
113 
114  return 0;
115  }
116 // if ( !Aig_ManIsAcyclic(p) )
117 // return 0;
118  return 1;
119 }
120 
121 /**Function*************************************************************
122 
123  Synopsis [Checks if the markA is reset.]
124 
125  Description []
126 
127  SideEffects []
128 
129  SeeAlso []
130 
131 ***********************************************************************/
133 {
134  Aig_Obj_t * pObj;
135  int i;
136  Aig_ManForEachObj( p, pObj, i )
137  assert( pObj->fMarkA == 0 );
138 }
139 
140 /**Function*************************************************************
141 
142  Synopsis [Checks the consistency of phase assignment.]
143 
144  Description []
145 
146  SideEffects []
147 
148  SeeAlso []
149 
150 ***********************************************************************/
152 {
153  Aig_Obj_t * pObj;
154  int i;
155  Aig_ManForEachObj( p, pObj, i )
156  if ( Aig_ObjIsCi(pObj) )
157  assert( (int)pObj->fPhase == 0 );
158  else
159  assert( (int)pObj->fPhase == (Aig_ObjPhaseReal(Aig_ObjChild0(pObj)) & Aig_ObjPhaseReal(Aig_ObjChild1(pObj))) );
160 }
161 
162 ////////////////////////////////////////////////////////////////////////
163 /// END OF FILE ///
164 ////////////////////////////////////////////////////////////////////////
165 
166 
168 
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Aig_Obj_t * Aig_ObjChild0(Aig_Obj_t *pObj)
Definition: aig.h:310
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Aig_Obj_t * Aig_TableLookup(Aig_Man_t *p, Aig_Obj_t *pGhost)
Definition: aigTable.c:116
static int Aig_ManObjNum(Aig_Man_t *p)
Definition: aig.h:258
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
unsigned int fMarkA
Definition: aig.h:79
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
ABC_NAMESPACE_IMPL_START int Aig_ManCheck(Aig_Man_t *p)
DECLARATIONS ///.
Definition: aigCheck.c:45
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
void Aig_ManCheckMarkA(Aig_Man_t *p)
Definition: aigCheck.c:132
static int Aig_ManBufNum(Aig_Man_t *p)
Definition: aig.h:253
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ManCoNum(Aig_Man_t *p)
Definition: aig.h:252
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static Aig_Obj_t * Aig_ObjChild1(Aig_Obj_t *pObj)
Definition: aig.h:311
static int Aig_ObjPhaseReal(Aig_Obj_t *pObj)
Definition: aig.h:299
Definition: aig.h:69
void Aig_ManCheckPhase(Aig_Man_t *p)
Definition: aigCheck.c:151
int Aig_TableCountEntries(Aig_Man_t *p)
Definition: aigTable.c:218
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
unsigned int fPhase
Definition: aig.h:78
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static int Aig_ManAndNum(Aig_Man_t *p)
Definition: aig.h:254
#define assert(ex)
Definition: util_old.h:213
static int Aig_ManExorNum(Aig_Man_t *p)
Definition: aig.h:255
static int Aig_ObjIsCi(Aig_Obj_t *pObj)
Definition: aig.h:275