abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
hopCheck.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [hopCheck.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Minimalistic And-Inverter Graph package.]
8 
9  Synopsis [AIG checking procedures.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - May 11, 2006.]
16 
17  Revision [$Id: hopCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "hop.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  Hop_Obj_t * pObj, * pObj2;
48  int i;
49  // check primary inputs
50  Hop_ManForEachPi( p, pObj, i )
51  {
52  if ( Hop_ObjFanin0(pObj) || Hop_ObjFanin1(pObj) )
53  {
54  printf( "Hop_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
55  return 0;
56  }
57  }
58  // check primary outputs
59  Hop_ManForEachPo( p, pObj, i )
60  {
61  if ( !Hop_ObjFanin0(pObj) )
62  {
63  printf( "Hop_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
64  return 0;
65  }
66  if ( Hop_ObjFanin1(pObj) )
67  {
68  printf( "Hop_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
69  return 0;
70  }
71  }
72  // check internal nodes
73  Hop_ManForEachNode( p, pObj, i )
74  {
75  if ( !Hop_ObjFanin0(pObj) || !Hop_ObjFanin1(pObj) )
76  {
77  printf( "Hop_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
78  return 0;
79  }
80  if ( Hop_ObjFanin0(pObj)->Id >= Hop_ObjFanin1(pObj)->Id )
81  {
82  printf( "Hop_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
83  return 0;
84  }
85  pObj2 = Hop_TableLookup( p, pObj );
86  if ( pObj2 != pObj )
87  {
88  printf( "Hop_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
89  return 0;
90  }
91  }
92  // count the total number of nodes
93  if ( Hop_ManObjNum(p) != 1 + Hop_ManPiNum(p) + Hop_ManPoNum(p) + Hop_ManAndNum(p) + Hop_ManExorNum(p) )
94  {
95  printf( "Hop_ManCheck: The number of created nodes is wrong.\n" );
96  return 0;
97  }
98  // count the number of nodes in the table
100  {
101  printf( "Hop_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
102  return 0;
103  }
104 // if ( !Hop_ManIsAcyclic(p) )
105 // return 0;
106  return 1;
107 }
108 
109 ////////////////////////////////////////////////////////////////////////
110 /// END OF FILE ///
111 ////////////////////////////////////////////////////////////////////////
112 
113 
115 
static Hop_Obj_t * Hop_ObjFanin1(Hop_Obj_t *pObj)
Definition: hop.h:183
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define Hop_ManForEachNode(p, pObj, i)
Definition: hop.h:265
#define Hop_ManForEachPi(p, pObj, i)
ITERATORS ///.
Definition: hop.h:259
#define Hop_ManForEachPo(p, pObj, i)
Definition: hop.h:262
static int Hop_ManPoNum(Hop_Man_t *p)
Definition: hop.h:146
static int Hop_ManObjNum(Hop_Man_t *p)
Definition: hop.h:151
Definition: hop.h:65
static int Hop_ManAndNum(Hop_Man_t *p)
Definition: hop.h:147
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static Hop_Obj_t * Hop_ObjFanin0(Hop_Obj_t *pObj)
Definition: hop.h:182
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static int Hop_ManExorNum(Hop_Man_t *p)
Definition: hop.h:148
ABC_NAMESPACE_IMPL_START int Hop_ManCheck(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopCheck.c:45
int Hop_TableCountEntries(Hop_Man_t *p)
Definition: hopTable.c:145
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Hop_Obj_t * Hop_TableLookup(Hop_Man_t *p, Hop_Obj_t *pGhost)
FUNCTION DEFINITIONS ///.
Definition: hopTable.c:71
static int Hop_ManPiNum(Hop_Man_t *p)
Definition: hop.h:145