dchAig.c 3.61 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/**CFile****************************************************************

  FileName    [dchAig.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Choice computation for tech-mapping.]

  Synopsis    [AIG manipulation.]

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - June 29, 2008.]

  Revision    [$Id: dchAig.c,v 1.00 2008/07/29 00:00:00 alanmi Exp $]

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

#include "dchInt.h"

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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

  Synopsis    [Derives the cumulative AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
void Dch_DeriveTotalAig_rec( Aig_Man_t * p, Aig_Obj_t * pObj )
{
    if ( pObj->pData )
        return;
    Dch_DeriveTotalAig_rec( p, Aig_ObjFanin0(pObj) );
    Dch_DeriveTotalAig_rec( p, Aig_ObjFanin1(pObj) );
    pObj->pData = Aig_And( p, Aig_ObjChild0Copy(pObj), Aig_ObjChild1Copy(pObj) );
}

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

  Synopsis    [Derives the cumulative AIG.]

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Aig_Man_t * Dch_DeriveTotalAig( Vec_Ptr_t * vAigs )
{
    Aig_Man_t * pAig, * pAig2, * pAigTotal;
    Aig_Obj_t * pObj, * pObjPi, * pObjPo;
    int i, k, nNodes;
    assert( Vec_PtrSize(vAigs) > 0 );
    // make sure they have the same number of PIs/POs
    nNodes = 0;
73 74
    pAig = (Aig_Man_t *)Vec_PtrEntry( vAigs, 0 );
    Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, i )
Alan Mishchenko committed
75 76 77
    {
        assert( Aig_ManPiNum(pAig) == Aig_ManPiNum(pAig2) );
        assert( Aig_ManPoNum(pAig) == Aig_ManPoNum(pAig2) );
Alan Mishchenko committed
78
        nNodes += Aig_ManNodeNum(pAig2);
Alan Mishchenko committed
79 80 81 82
        Aig_ManCleanData( pAig2 );
    }
    // map constant nodes
    pAigTotal = Aig_ManStart( nNodes );
83
    Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Alan Mishchenko committed
84 85 86 87 88
        Aig_ManConst1(pAig2)->pData = Aig_ManConst1(pAigTotal);
    // map primary inputs
    Aig_ManForEachPi( pAig, pObj, i )
    {
        pObjPi = Aig_ObjCreatePi( pAigTotal );
89
        Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Alan Mishchenko committed
90 91 92 93 94
            Aig_ManPi( pAig2, i )->pData = pObjPi;
    }
    // construct the AIG in the order of POs
    Aig_ManForEachPo( pAig, pObj, i )
    {
95
        Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Alan Mishchenko committed
96 97 98 99 100 101
        {
            pObjPo = Aig_ManPo( pAig2, i );
            Dch_DeriveTotalAig_rec( pAigTotal, Aig_ObjFanin0(pObjPo) );
        }
        Aig_ObjCreatePo( pAigTotal, Aig_ObjChild0Copy(pObj) );
    }
Alan Mishchenko committed
102
/*
Alan Mishchenko committed
103 104 105 106 107
    // mark the cone of the first AIG
    Aig_ManIncrementTravId( pAigTotal );
    Aig_ManForEachObj( pAig, pObj, i )
        if ( pObj->pData ) 
            Aig_ObjSetTravIdCurrent( pAigTotal, pObj->pData );
Alan Mishchenko committed
108
*/
Alan Mishchenko committed
109 110 111 112 113 114 115 116 117
    // cleanup should not be done
    return pAigTotal;
}

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


118 119
ABC_NAMESPACE_IMPL_END