nwkCheck.c 2.56 KB
Newer Older
Alan Mishchenko committed
1 2
/**CFile****************************************************************

Alan Mishchenko committed
3
  FileName    [nwkCheck.c]
Alan Mishchenko committed
4 5 6

  SystemName  [ABC: Logic synthesis and verification system.]

Alan Mishchenko committed
7
  PackageName [Logic network representation.]
Alan Mishchenko committed
8

Alan Mishchenko committed
9
  Synopsis    [Consistency checking procedures.]
Alan Mishchenko committed
10 11 12 13 14 15 16

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 20, 2005.]

Alan Mishchenko committed
17
  Revision    [$Id: nwkCheck.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
Alan Mishchenko committed
18 19 20

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

Alan Mishchenko committed
21
#include "nwk.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
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

Alan Mishchenko committed
36
  Synopsis    [Checking the logic network for consistency.]
Alan Mishchenko committed
37 38 39 40 41 42 43 44

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Alan Mishchenko committed
45 46
int Nwk_ManCheck( Nwk_Man_t * p )
{
Alan Mishchenko committed
47
    Nwk_Obj_t * pObj, * pNext;
Alan Mishchenko committed
48 49 50 51 52 53 54 55 56 57 58 59 60
    int i, k, m;
    // check if the nodes have duplicated fanins
    Nwk_ManForEachNode( p, pObj, i )
    {
        for ( k = 0; k < pObj->nFanins; k++ )
            for ( m = k + 1; m < pObj->nFanins; m++ )
                if ( pObj->pFanio[k] == pObj->pFanio[m] )
                    printf( "Node %d has duplicated fanin %d.\n", pObj->Id, pObj->pFanio[k]->Id );
    }
    // check if all nodes are in the correct fanin/fanout relationship
    Nwk_ManForEachObj( p, pObj, i )
    {
        Nwk_ObjForEachFanin( pObj, pNext, k )
Alan Mishchenko committed
61
            if ( Nwk_ObjFanoutNum(pNext) < 100 && Nwk_ObjFindFanout( pNext, pObj ) == -1 )
Alan Mishchenko committed
62 63 64 65 66 67 68
                printf( "Nwk_ManCheck(): Object %d has fanin %d which does not have a corresponding fanout.\n", pObj->Id, pNext->Id );
        Nwk_ObjForEachFanout( pObj, pNext, k )
            if ( Nwk_ObjFindFanin( pNext, pObj ) == -1 )
                printf( "Nwk_ManCheck(): Object %d has fanout %d which does not have a corresponding fanin.\n", pObj->Id, pNext->Id );
    }
    return 1;
}
Alan Mishchenko committed
69 70 71 72 73 74

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


75 76
ABC_NAMESPACE_IMPL_END