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_ManCiNum(pAig) == Aig_ManCiNum(pAig2) );
        assert( Aig_ManCoNum(pAig) == Aig_ManCoNum(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
        Aig_ManConst1(pAig2)->pData = Aig_ManConst1(pAigTotal);
    // map primary inputs
86
    Aig_ManForEachCi( pAig, pObj, i )
Alan Mishchenko committed
87
    {
88
        pObjPi = Aig_ObjCreateCi( pAigTotal );
89
        Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
90
            Aig_ManCi( pAig2, i )->pData = pObjPi;
Alan Mishchenko committed
91 92
    }
    // construct the AIG in the order of POs
93
    Aig_ManForEachCo( pAig, pObj, i )
Alan Mishchenko committed
94
    {
95
        Vec_PtrForEachEntry( Aig_Man_t *, vAigs, pAig2, k )
Alan Mishchenko committed
96
        {
97
            pObjPo = Aig_ManCo( pAig2, i );
Alan Mishchenko committed
98 99
            Dch_DeriveTotalAig_rec( pAigTotal, Aig_ObjFanin0(pObjPo) );
        }
100
        Aig_ObjCreateCo( pAigTotal, Aig_ObjChild0Copy(pObj) );
Alan Mishchenko committed
101
    }
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