abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cswMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [cswMan.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: cswMan.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 [Starts the cut sweeping manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
45 Csw_Man_t * Csw_ManStart( Aig_Man_t * pMan, int nCutsMax, int nLeafMax, int fVerbose )
46 {
47  Csw_Man_t * p;
48  Aig_Obj_t * pObj;
49  int i;
50  assert( nCutsMax >= 2 );
51  assert( nLeafMax <= 16 );
52  // allocate the fraiging manager
53  p = ABC_ALLOC( Csw_Man_t, 1 );
54  memset( p, 0, sizeof(Csw_Man_t) );
55  p->nCutsMax = nCutsMax;
56  p->nLeafMax = nLeafMax;
57  p->fVerbose = fVerbose;
58  p->pManAig = pMan;
59  // create the new manager
60  p->pManRes = Aig_ManStartFrom( pMan );
61  assert( Aig_ManCiNum(p->pManAig) == Aig_ManCiNum(p->pManRes) );
62  // allocate room for cuts and equivalent nodes
63  p->pnRefs = ABC_ALLOC( int, Aig_ManObjNumMax(pMan) );
64  p->pEquiv = ABC_ALLOC( Aig_Obj_t *, Aig_ManObjNumMax(pMan) );
65  p->pCuts = ABC_ALLOC( Csw_Cut_t *, Aig_ManObjNumMax(pMan) );
66  memset( p->pCuts, 0, sizeof(Aig_Obj_t *) * Aig_ManObjNumMax(pMan) );
67  memset( p->pnRefs, 0, sizeof(int) * Aig_ManObjNumMax(pMan) );
68  // allocate memory manager
69  p->nTruthWords = Abc_TruthWordNum(nLeafMax);
70  p->nCutSize = sizeof(Csw_Cut_t) + sizeof(int) * nLeafMax + sizeof(unsigned) * p->nTruthWords;
71  p->pMemCuts = Aig_MmFixedStart( p->nCutSize * p->nCutsMax, 512 );
72  // allocate hash table for cuts
73  p->nTableSize = Abc_PrimeCudd( Aig_ManNodeNum(pMan) * p->nCutsMax / 2 );
74  p->pTable = ABC_ALLOC( Csw_Cut_t *, p->nTableSize );
75  memset( p->pTable, 0, sizeof(Aig_Obj_t *) * p->nTableSize );
76  // set the pointers to the available fraig nodes
77  Csw_ObjSetEquiv( p, Aig_ManConst1(p->pManAig), Aig_ManConst1(p->pManRes) );
78  Aig_ManForEachCi( p->pManAig, pObj, i )
79  Csw_ObjSetEquiv( p, pObj, Aig_ManCi(p->pManRes, i) );
80  // room for temporary truth tables
81  p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
82  p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
83  p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
84  p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
85  return p;
86 }
87 
88 /**Function*************************************************************
89 
90  Synopsis [Stops the fraiging manager.]
91 
92  Description []
93 
94  SideEffects []
95 
96  SeeAlso []
97 
98 ***********************************************************************/
100 {
101  if ( p->fVerbose )
102  {
103  int nNodesBeg = Aig_ManNodeNum(p->pManAig);
104  int nNodesEnd = Aig_ManNodeNum(p->pManRes);
105  printf( "Beg = %7d. End = %7d. (%6.2f %%) Try = %7d. Cuts = %8d.\n",
106  nNodesBeg, nNodesEnd, 100.0*(nNodesBeg-nNodesEnd)/nNodesBeg,
107  p->nNodesTried, Csw_TableCountCuts( p ) );
108  printf( "Triv0 = %6d. Triv1 = %6d. Triv2 = %6d. Cut-replace = %6d.\n",
109  p->nNodesTriv0, p->nNodesTriv1, p->nNodesTriv2, p->nNodesCuts );
110  ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal );
111  ABC_PRTP( "Hashing ", p->timeHash, p->timeTotal );
112  ABC_PRTP( "Other ", p->timeOther, p->timeTotal );
113  ABC_PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
114  }
115  ABC_FREE( p->puTemp[0] );
116  Aig_MmFixedStop( p->pMemCuts, 0 );
117  ABC_FREE( p->pnRefs );
118  ABC_FREE( p->pEquiv );
119  ABC_FREE( p->pCuts );
120  ABC_FREE( p->pTable );
121  ABC_FREE( p );
122 }
123 
124 ////////////////////////////////////////////////////////////////////////
125 /// END OF FILE ///
126 ////////////////////////////////////////////////////////////////////////
127 
128 
130 
char * memset()
static int Abc_PrimeCudd(unsigned int p)
Definition: abc_global.h:383
int Csw_TableCountCuts(Csw_Man_t *p)
Definition: cswTable.c:82
typedefABC_NAMESPACE_HEADER_START struct Csw_Man_t_ Csw_Man_t
INCLUDES ///.
Definition: cswInt.h:52
void Csw_ManStop(Csw_Man_t *p)
Definition: cswMan.c:99
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
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
ABC_NAMESPACE_IMPL_START Csw_Man_t * Csw_ManStart(Aig_Man_t *pMan, int nCutsMax, int nLeafMax, int fVerbose)
DECLARATIONS ///.
Definition: cswMan.c:45
static int Abc_TruthWordNum(int nVars)
Definition: abc_global.h:256
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition: aigMem.c:96
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
#define ABC_PRTP(a, t, T)
Definition: abc_global.h:223
static Aig_Obj_t * Aig_ManCi(Aig_Man_t *p, int i)
Definition: aig.h:266
static int Aig_ManCiNum(Aig_Man_t *p)
Definition: aig.h:251
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Definition: aig.h:69
Aig_Man_t * Aig_ManStartFrom(Aig_Man_t *p)
Definition: aigMan.c:92
static int Aig_ManObjNumMax(Aig_Man_t *p)
Definition: aig.h:259
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Csw_ObjSetEquiv(Csw_Man_t *p, Aig_Obj_t *pObj, Aig_Obj_t *pEquiv)
Definition: cswInt.h:114
#define assert(ex)
Definition: util_old.h:213
struct Csw_Cut_t_ Csw_Cut_t
Definition: cswInt.h:53