abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
covMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [covMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Mapping into network of SOPs/ESOPs.]
8 
9  Synopsis [Decomposition manager.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: covMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "cov.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 Cov_Man_t * Cov_ManAlloc( Abc_Ntk_t * pNtk, int nFaninMax )
46 {
47  Cov_Man_t * pMan;
48  Cov_Obj_t * pMem;
49  Abc_Obj_t * pObj;
50  int i;
51  assert( pNtk->pManCut == NULL );
52 
53  // start the manager
54  pMan = ABC_ALLOC( Cov_Man_t, 1 );
55  memset( pMan, 0, sizeof(Cov_Man_t) );
56  pMan->nFaninMax = nFaninMax;
57  pMan->nCubesMax = 2 * pMan->nFaninMax;
58  pMan->nWords = Abc_BitWordNum( nFaninMax * 2 );
59 
60  // get the cubes
61  pMan->vComTo0 = Vec_IntAlloc( 2*nFaninMax );
62  pMan->vComTo1 = Vec_IntAlloc( 2*nFaninMax );
63  pMan->vPairs0 = Vec_IntAlloc( nFaninMax );
64  pMan->vPairs1 = Vec_IntAlloc( nFaninMax );
65  pMan->vTriv0 = Vec_IntAlloc( 1 ); Vec_IntPush( pMan->vTriv0, -1 );
66  pMan->vTriv1 = Vec_IntAlloc( 1 ); Vec_IntPush( pMan->vTriv1, -1 );
67 
68  // allocate memory for object structures
69  pMan->pMemory = pMem = ABC_ALLOC( Cov_Obj_t, sizeof(Cov_Obj_t) * Abc_NtkObjNumMax(pNtk) );
70  memset( pMem, 0, sizeof(Cov_Obj_t) * Abc_NtkObjNumMax(pNtk) );
71  // allocate storage for the pointers to the memory
72  pMan->vObjStrs = Vec_PtrAlloc( Abc_NtkObjNumMax(pNtk) );
73  Vec_PtrFill( pMan->vObjStrs, Abc_NtkObjNumMax(pNtk), NULL );
74  Abc_NtkForEachObj( pNtk, pObj, i )
75  Vec_PtrWriteEntry( pMan->vObjStrs, i, pMem + i );
76  // create the cube manager
77  pMan->pManMin = Min_ManAlloc( nFaninMax );
78  return pMan;
79 }
80 
81 /**Function*************************************************************
82 
83  Synopsis []
84 
85  Description []
86 
87  SideEffects []
88 
89  SeeAlso []
90 
91 ***********************************************************************/
93 {
94  Vec_Int_t * vSupp;
95  int i;
96  for ( i = 0; i < p->vObjStrs->nSize; i++ )
97  {
98  vSupp = ((Cov_Obj_t *)p->vObjStrs->pArray[i])->vSupp;
99  if ( vSupp ) Vec_IntFree( vSupp );
100  }
101 
102  Min_ManFree( p->pManMin );
103  Vec_PtrFree( p->vObjStrs );
104  Vec_IntFree( p->vFanCounts );
105  Vec_IntFree( p->vTriv0 );
106  Vec_IntFree( p->vTriv1 );
107  Vec_IntFree( p->vComTo0 );
108  Vec_IntFree( p->vComTo1 );
109  Vec_IntFree( p->vPairs0 );
110  Vec_IntFree( p->vPairs1 );
111  ABC_FREE( p->pMemory );
112  ABC_FREE( p );
113 }
114 
115 /**Function*************************************************************
116 
117  Synopsis [Drop the covers at the node.]
118 
119  Description []
120 
121  SideEffects []
122 
123  SeeAlso []
124 
125 ***********************************************************************/
127 {
128  int nFanouts;
129  assert( p->vFanCounts );
130  nFanouts = Vec_IntEntry( p->vFanCounts, pObj->Id );
131  assert( nFanouts > 0 );
132  if ( --nFanouts == 0 )
133  {
134  Vec_IntFree( Abc_ObjGetSupp(pObj) );
135  Abc_ObjSetSupp( pObj, NULL );
136  Min_CoverRecycle( p->pManMin, Abc_ObjGetCover2(pObj) );
137  Abc_ObjSetCover2( pObj, NULL );
138  p->nSupps--;
139  }
140  Vec_IntWriteEntry( p->vFanCounts, pObj->Id, nFanouts );
141 }
142 
143 ////////////////////////////////////////////////////////////////////////
144 /// END OF FILE ///
145 ////////////////////////////////////////////////////////////////////////
146 
147 
149 
char * memset()
ABC_NAMESPACE_IMPL_START Cov_Man_t * Cov_ManAlloc(Abc_Ntk_t *pNtk, int nFaninMax)
DECLARATIONS ///.
Definition: covMan.c:45
static Vec_Int_t * Abc_ObjGetSupp(Abc_Obj_t *pObj)
Definition: cov.h:74
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
static Llb_Mgr_t * p
Definition: llb3Image.c:950
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static void Vec_PtrFill(Vec_Ptr_t *p, int nSize, void *Entry)
Definition: vecPtr.h:449
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Min_Man_t * Min_ManAlloc(int nVars)
DECLARATIONS ///.
Definition: covMinMan.c:45
static Min_Cube_t * Abc_ObjGetCover2(Abc_Obj_t *pObj)
Definition: cov.h:77
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
void Cov_ManFree(Cov_Man_t *p)
Definition: covMan.c:92
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static void Abc_ObjSetCover2(Abc_Obj_t *pObj, Min_Cube_t *pCov)
Definition: cov.h:76
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void * pManCut
Definition: abc.h:193
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
void Abc_NodeCovDropData(Cov_Man_t *p, Abc_Obj_t *pObj)
Definition: covMan.c:126
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
Definition: cov.h:38
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Id
Definition: abc.h:132
typedefABC_NAMESPACE_HEADER_START struct Cov_Man_t_ Cov_Man_t
DECLARATIONS ///.
Definition: cov.h:34
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
#define assert(ex)
Definition: util_old.h:213
static void Min_CoverRecycle(Min_Man_t *p, Min_Cube_t *pCover)
Definition: covInt.h:205
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Abc_ObjSetSupp(Abc_Obj_t *pObj, Vec_Int_t *vVec)
Definition: cov.h:73
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Min_ManFree(Min_Man_t *p)
Definition: covMinMan.c:104