abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cswCore.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cswCore.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Cut sweeping.]
8 
9  Synopsis []
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - July 11, 2007.]
16 
17  Revision [$Id: cswCore.c,v 1.00 2007/07/11 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "cswInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis []
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 Aig_Man_t * Csw_Sweep( Aig_Man_t * pAig, int nCutsMax, int nLeafMax, int fVerbose )
46 {
47  Csw_Man_t * p;
48  Aig_Man_t * pRes;
49  Aig_Obj_t * pObj, * pObjNew, * pObjRes;
50  int i;
51  abctime clk;
52 clk = Abc_Clock();
53  // start the manager
54  p = Csw_ManStart( pAig, nCutsMax, nLeafMax, fVerbose );
55  // set elementary cuts at the PIs
56  Aig_ManForEachCi( p->pManRes, pObj, i )
57  {
58  Csw_ObjPrepareCuts( p, pObj, 1 );
59  Csw_ObjAddRefs( p, pObj, Aig_ManCi(p->pManAig,i)->nRefs );
60  }
61  // process the nodes
62  Aig_ManForEachNode( pAig, pObj, i )
63  {
64  // create the new node
65  pObjNew = Aig_And( p->pManRes, Csw_ObjChild0Equiv(p, pObj), Csw_ObjChild1Equiv(p, pObj) );
66  // check if this node can be represented using another node
67 // pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
68 // pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );
69  // try recursively if resubsitution is used
70  do {
71  pObjRes = Csw_ObjSweep( p, Aig_Regular(pObjNew), pObj->nRefs > 1 );
72  pObjRes = Aig_NotCond( pObjRes, Aig_IsComplement(pObjNew) );
73  pObjNew = pObjRes;
74  } while ( Csw_ObjCuts(p, Aig_Regular(pObjNew)) == NULL && !Aig_ObjIsConst1(Aig_Regular(pObjNew)) );
75  // save the resulting node
76  Csw_ObjSetEquiv( p, pObj, pObjRes );
77  // add to the reference counter
78  Csw_ObjAddRefs( p, Aig_Regular(pObjRes), pObj->nRefs );
79  }
80  // add the POs
81  Aig_ManForEachCo( pAig, pObj, i )
82  Aig_ObjCreateCo( p->pManRes, Csw_ObjChild0Equiv(p, pObj) );
83  // remove dangling nodes
84  Aig_ManCleanup( p->pManRes );
85  // return the resulting manager
86 p->timeTotal = Abc_Clock() - clk;
87 p->timeOther = p->timeTotal - p->timeCuts - p->timeHash;
88  pRes = p->pManRes;
89  Csw_ManStop( p );
90  return pRes;
91 }
92 
93 
94 ////////////////////////////////////////////////////////////////////////
95 /// END OF FILE ///
96 ////////////////////////////////////////////////////////////////////////
97 
98 
100 
Aig_Obj_t * Aig_ObjCreateCo(Aig_Man_t *p, Aig_Obj_t *pDriver)
Definition: aigObj.c:66
typedefABC_NAMESPACE_HEADER_START struct Csw_Man_t_ Csw_Man_t
INCLUDES ///.
Definition: cswInt.h:52
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
ABC_NAMESPACE_IMPL_START Aig_Man_t * Csw_Sweep(Aig_Man_t *pAig, int nCutsMax, int nLeafMax, int fVerbose)
DECLARATIONS ///.
Definition: cswCore.c:45
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
static Aig_Obj_t * Aig_Regular(Aig_Obj_t *p)
Definition: aig.h:246
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static abctime Abc_Clock()
Definition: abc_global.h:279
Aig_Obj_t * Aig_And(Aig_Man_t *p, Aig_Obj_t *p0, Aig_Obj_t *p1)
Definition: aigOper.c:104
static Aig_Obj_t * Csw_ObjChild1Equiv(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:117
static void Csw_ObjAddRefs(Csw_Man_t *p, Aig_Obj_t *pObj, int nRefs)
Definition: cswInt.h:108
Csw_Cut_t * Csw_ObjPrepareCuts(Csw_Man_t *p, Aig_Obj_t *pObj, int fTriv)
FUNCTION DECLARATIONS ///.
Definition: cswCut.c:453
#define Aig_ManForEachNode(p, pObj, i)
Definition: aig.h:413
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Csw_Man_t * Csw_ManStart(Aig_Man_t *pMan, int nCutsMax, int nLeafMax, int fVerbose)
DECLARATIONS ///.
Definition: cswMan.c:45
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
Definition: aig.h:69
static Csw_Cut_t * Csw_ObjCuts(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:110
Aig_Obj_t * Csw_ObjSweep(Csw_Man_t *p, Aig_Obj_t *pObj, int fTriv)
Definition: cswCut.c:492
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static Aig_Obj_t * Csw_ObjChild0Equiv(Csw_Man_t *p, Aig_Obj_t *pObj)
Definition: cswInt.h:116
static void Csw_ObjSetEquiv(Csw_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pEquiv)
Definition: cswInt.h:114
static Aig_Obj_t * Aig_NotCond(Aig_Obj_t *p, int c)
Definition: aig.h:248
ABC_INT64_T abctime
Definition: abc_global.h:278
int Aig_ManCleanup(Aig_Man_t *p)
Definition: aigMan.c:265
unsigned int nRefs
Definition: aig.h:81
void Csw_ManStop(Csw_Man_t *p)
Definition: cswMan.c:99