hopCheck.c 3.46 KB
Newer Older
Alan Mishchenko committed
1 2
/**CFile****************************************************************

Alan Mishchenko committed
3
  FileName    [hopCheck.c]
Alan Mishchenko committed
4 5 6 7 8 9 10 11 12 13 14 15 16

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Minimalistic And-Inverter Graph package.]

  Synopsis    [AIG checking procedures.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - May 11, 2006.]

Alan Mishchenko committed
17
  Revision    [$Id: hopCheck.c,v 1.00 2006/05/11 00:00:00 alanmi Exp $]
Alan Mishchenko committed
18 19 20

***********************************************************************/

Alan Mishchenko committed
21
#include "hop.h"
Alan Mishchenko committed
22

23 24 25
ABC_NAMESPACE_IMPL_START


Alan Mishchenko committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                     FUNCTION DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

/**Function*************************************************************

  Synopsis    [Checks the consistency of the AIG manager.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
45
int Hop_ManCheck( Hop_Man_t * p )
Alan Mishchenko committed
46
{
Alan Mishchenko committed
47
    Hop_Obj_t * pObj, * pObj2;
Alan Mishchenko committed
48 49
    int i;
    // check primary inputs
Alan Mishchenko committed
50
    Hop_ManForEachPi( p, pObj, i )
Alan Mishchenko committed
51
    {
Alan Mishchenko committed
52
        if ( Hop_ObjFanin0(pObj) || Hop_ObjFanin1(pObj) )
Alan Mishchenko committed
53
        {
Alan Mishchenko committed
54
            printf( "Hop_ManCheck: The PI node \"%p\" has fanins.\n", pObj );
Alan Mishchenko committed
55 56 57 58
            return 0;
        }
    }
    // check primary outputs
Alan Mishchenko committed
59
    Hop_ManForEachPo( p, pObj, i )
Alan Mishchenko committed
60
    {
Alan Mishchenko committed
61
        if ( !Hop_ObjFanin0(pObj) )
Alan Mishchenko committed
62
        {
Alan Mishchenko committed
63
            printf( "Hop_ManCheck: The PO node \"%p\" has NULL fanin.\n", pObj );
Alan Mishchenko committed
64 65
            return 0;
        }
Alan Mishchenko committed
66
        if ( Hop_ObjFanin1(pObj) )
Alan Mishchenko committed
67
        {
Alan Mishchenko committed
68
            printf( "Hop_ManCheck: The PO node \"%p\" has second fanin.\n", pObj );
Alan Mishchenko committed
69 70 71 72
            return 0;
        }
    }
    // check internal nodes
Alan Mishchenko committed
73
    Hop_ManForEachNode( p, pObj, i )
Alan Mishchenko committed
74
    {
Alan Mishchenko committed
75
        if ( !Hop_ObjFanin0(pObj) || !Hop_ObjFanin1(pObj) )
Alan Mishchenko committed
76
        {
Alan Mishchenko committed
77
            printf( "Hop_ManCheck: The AIG has internal node \"%p\" with a NULL fanin.\n", pObj );
Alan Mishchenko committed
78 79
            return 0;
        }
Alan Mishchenko committed
80
        if ( Hop_ObjFanin0(pObj)->Id >= Hop_ObjFanin1(pObj)->Id )
Alan Mishchenko committed
81
        {
Alan Mishchenko committed
82
            printf( "Hop_ManCheck: The AIG has node \"%p\" with a wrong ordering of fanins.\n", pObj );
Alan Mishchenko committed
83 84
            return 0;
        }
Alan Mishchenko committed
85
        pObj2 = Hop_TableLookup( p, pObj );
Alan Mishchenko committed
86 87
        if ( pObj2 != pObj )
        {
Alan Mishchenko committed
88
            printf( "Hop_ManCheck: Node \"%p\" is not in the structural hashing table.\n", pObj );
Alan Mishchenko committed
89 90 91 92
            return 0;
        }
    }
    // count the total number of nodes
Alan Mishchenko committed
93
    if ( Hop_ManObjNum(p) != 1 + Hop_ManPiNum(p) + Hop_ManPoNum(p) + Hop_ManAndNum(p) + Hop_ManExorNum(p) )
Alan Mishchenko committed
94
    {
Alan Mishchenko committed
95
        printf( "Hop_ManCheck: The number of created nodes is wrong.\n" );
Alan Mishchenko committed
96 97 98
        return 0;
    }
    // count the number of nodes in the table
Alan Mishchenko committed
99
    if ( Hop_TableCountEntries(p) != Hop_ManAndNum(p) + Hop_ManExorNum(p) )
Alan Mishchenko committed
100
    {
Alan Mishchenko committed
101
        printf( "Hop_ManCheck: The number of nodes in the structural hashing table is wrong.\n" );
Alan Mishchenko committed
102 103
        return 0;
    }
Alan Mishchenko committed
104
//    if ( !Hop_ManIsAcyclic(p) )
Alan Mishchenko committed
105 106 107 108 109 110 111 112 113
//        return 0;
    return 1; 
}

////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////


114 115
ABC_NAMESPACE_IMPL_END