cswCore.c 3.23 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    [cswCore.c]

  SystemName  [ABC: Logic synthesis and verification system.]

  PackageName [Cut sweeping.]

  Synopsis    []

  Author      [Alan Mishchenko]
  
  Affiliation [UC Berkeley]

  Date        [Ver. 1.0. Started - July 11, 2007.]

  Revision    [$Id: cswCore.c,v 1.00 2007/07/11 00:00:00 alanmi Exp $]

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

#include "cswInt.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
////////////////////////////////////////////////////////////////////////
///                        DECLARATIONS                              ///
////////////////////////////////////////////////////////////////////////

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

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

  Synopsis    []

  Description []
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose )
{
    Csw_Man_t * p;
    Aig_Man_t * pRes;
    Aig_Obj_t * pObj, * pObjNew, * pObjRes;
50
    int i;
51 52
    abctime clk;
clk = Abc_Clock();
Alan Mishchenko committed
53 54 55
    // start the manager
    p = Csw_ManStart( pAig, nCutsMax, nLeafMax, fVerbose );
    // set elementary cuts at the PIs
56
    Aig_ManForEachCi( p->pManRes, pObj, i )
Alan Mishchenko committed
57 58
    {
        Csw_ObjPrepareCuts( p, pObj, 1 );
59
        Csw_ObjAddRefs( p, pObj, Aig_ManCi(p->pManAig,i)->nRefs );
Alan Mishchenko committed
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    }
    // process the nodes
    Aig_ManForEachNode( pAig, pObj, i )
    {
        // create the new node
        pObjNew = Aig_And( p->pManRes, Csw_ObjChild0Equiv(p, pObj), Csw_ObjChild1Equiv(p, pObj) );
        // check if this node can be represented using another node
//        pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
//        pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );
        // try recursively if resubsitution is used
        do {
            pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
            pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );        
            pObjNew = pObjRes;
        } while ( Csw_ObjCuts(p, Aig_Regular(pObjNew)) == NULL && !Aig_ObjIsConst1(Aig_Regular(pObjNew)) );
        // save the resulting node
        Csw_ObjSetEquiv( p, pObj, pObjRes );
        // add to the reference counter
        Csw_ObjAddRefs( p, Aig_Regular(pObjRes), pObj->nRefs );
    }
    // add the POs
81 82
    Aig_ManForEachCo( pAig, pObj, i )
        Aig_ObjCreateCo( p->pManRes, Csw_ObjChild0Equiv(p, pObj) );
Alan Mishchenko committed
83 84 85
    // remove dangling nodes 
    Aig_ManCleanup( p->pManRes );
    // return the resulting manager
86
p->timeTotal = Abc_Clock() - clk;
Alan Mishchenko committed
87 88 89 90 91 92 93 94 95 96 97 98
p->timeOther = p->timeTotal - p->timeCuts - p->timeHash;
    pRes = p->pManRes;
    Csw_ManStop( p );
    return pRes;
}


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


99 100
ABC_NAMESPACE_IMPL_END