abc/src/aig/aig/aigDup.c
/**Function*************************************************************

  Synopsis    [Duplicates the AIG manager.]

  Description [Orders nodes as follows: PIs, ANDs, POs.]
               
  SideEffects [This procedure assumes that buffers are not used during
  HAIG recording. This way, each HAIG node is in one-to-one correspondence 
  with old HAIG node. There is no need to create new nodes, just reassign 
  the pointers. If it were not the case, we would need to create HAIG nodes 
  for each new node duplicated. ]

  SeeAlso     []

***********************************************************************/
Function
Synopsis    [Duplicates the AIG manager.]



SideEffects [This procedure assumes that buffers are not used during
HAIG recording. This way, each HAIG node is in one-to-one correspondence
with old HAIG node. There is no need to create new nodes, just reassign
the pointers. If it were not the case, we would need to create HAIG nodes
for each new node duplicated.


Function Synopsis [ Duplicates the AIG manager . ] SideEffects [ This procedure assumes that buffers are not used during HAIG recording . This way each HAIG node is in one - to - one correspondence with old HAIG node . There is no need to create new nodes just reassign the pointers . If it were not the case we would need to create HAIG nodes for each new node duplicated .
Aig_Man_t * Aig_ManDupSimpleDfs( Aig_Man_t * p )
{
    Aig_Man_t * pNew;
    Aig_Obj_t * pObj, * pObjNew = NULL;
    int i;
    assert( p->pManTime == NULL );
    pNew = Aig_ManStart( Aig_ManObjNumMax(p) );
    pNew->pName = Abc_UtilStrsav( p->pName );
    pNew->pSpec = Abc_UtilStrsav( p->pSpec );
    pNew->nAsserts = p->nAsserts;
    pNew->nConstrs = p->nConstrs;
    pNew->nBarBufs = p->nBarBufs;
    if ( p->vFlopNums )
        pNew->vFlopNums = Vec_IntDup( p->vFlopNums );
    Aig_ManCleanData( p );
    Aig_ManConst1(p)->pData = Aig_ManConst1(pNew);
    Aig_ManForEachCi( p, pObj, i )
    {
        pObjNew = Aig_ObjCreateCi( pNew );
        pObjNew->Level = pObj->Level;
        pObj->pData = pObjNew;
    }
    Aig_ManForEachObj( p, pObj, i )
        if ( !Aig_ObjIsCo(pObj) )
        {
            Aig_ManDupSimpleDfs_rec( pNew, p, pObj );        
            assert( pObj->Level == ((Aig_Obj_t*)pObj->pData)->Level );
        }
    Aig_ManForEachCo( p, pObj, i )
    {
        pObjNew = Aig_ObjCreateCo( pNew, Aig_ObjChild0Copy(pObj) );
        pObj->pData = pObjNew;
    }
    assert( Aig_ManBufNum(p) != 0 || Aig_ManNodeNum(p) == Aig_ManNodeNum(pNew) );
    Aig_ManSetRegNum( pNew, Aig_ManRegNum(p) );
    if ( !Aig_ManCheck(pNew) )
        printf( "Aig_ManDupSimple(): The check has failed.\n" );
    return pNew;
}
Aig_Man_t * Aig_ManDupSimpleDfs ( Aig_Man_t * p ) { Aig_Man_t * pNew ; Aig_Obj_t * pObj , * pObjNew = NULL ; int i ; assert ( p -> pManTime == NULL ) ; pNew = Aig_ManStart ( Aig_ManObjNumMax ( p ) ) ; pNew -> pName = Abc_UtilStrsav ( p -> pName ) ; pNew -> pSpec = Abc_UtilStrsav ( p -> pSpec ) ; pNew -> nAsserts = p -> nAsserts ; pNew -> nConstrs = p -> nConstrs ; pNew -> nBarBufs = p -> nBarBufs ; if ( p -> vFlopNums ) pNew -> vFlopNums = Vec_IntDup ( p -> vFlopNums ) ; Aig_ManCleanData ( p ) ; Aig_ManConst1 ( p ) -> pData = Aig_ManConst1 ( pNew ) ; Aig_ManForEachCi ( p , pObj , i ) { pObjNew = Aig_ObjCreateCi ( pNew ) ; pObjNew -> Level = pObj -> Level ; pObj -> pData = pObjNew ; } Aig_ManForEachObj ( p , pObj , i ) if ( ! Aig_ObjIsCo ( pObj ) ) { Aig_ManDupSimpleDfs_rec ( pNew , p , pObj ) ; assert ( pObj -> Level == ( ( Aig_Obj_t * ) pObj -> pData ) -> Level ) ; } Aig_ManForEachCo ( p , pObj , i ) { pObjNew = Aig_ObjCreateCo ( pNew , Aig_ObjChild0Copy ( pObj ) ) ; pObj -> pData = pObjNew ; } assert ( Aig_ManBufNum ( p ) != 0 || Aig_ManNodeNum ( p ) == Aig_ManNodeNum ( pNew ) ) ; Aig_ManSetRegNum ( pNew , Aig_ManRegNum ( p ) ) ; if ( ! Aig_ManCheck ( pNew ) ) printf ( " \n " ) ; return pNew ; }
Function
Synopsis    [Duplicates the AIG manager.]
Function Synopsis [ Duplicates the AIG manager . ]
// create the new manager // create the PIs // duplicate internal nodes // add the POs // check the resulting network