abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fsimMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [fsimMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Fast sequential AIG simulator.]
8 
9  Synopsis [Simulation 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: fsimMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "fsimInt.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Creates fast simulation manager.]
37 
38  Description []
39 
40  SideEffects []
41 
42  SeeAlso []
43 
44 ***********************************************************************/
46 {
47  int iFan0, iFan1, iTemp;
48  assert( !Aig_IsComplement(pObj) );
49  if ( pObj->iData )
50  return pObj->iData;
51  assert( !Aig_ObjIsConst1(pObj) );
52  if ( Aig_ObjIsNode(pObj) )
53  {
54  iFan0 = Fsim_ManCreate_rec( p, Aig_ObjFanin0(pObj) );
55  iFan1 = Fsim_ManCreate_rec( p, Aig_ObjFanin1(pObj) );
56  assert( iFan0 != iFan1 );
57  if ( --p->pRefs[iFan0] == 0 )
58  p->nCrossCut--;
59  iFan0 = Fsim_Var2Lit( iFan0, Aig_ObjFaninC0(pObj) );
60  if ( --p->pRefs[iFan1] == 0 )
61  p->nCrossCut--;
62  iFan1 = Fsim_Var2Lit( iFan1, Aig_ObjFaninC1(pObj) );
63  if ( p->pAig->pEquivs )
64  Fsim_ManCreate_rec( p, Aig_ObjEquiv(p->pAig, pObj) );
65  }
66  else if ( Aig_ObjIsPo(pObj) )
67  {
68  assert( Aig_ObjRefs(pObj) == 0 );
69  iFan0 = Fsim_ManCreate_rec( p, Aig_ObjFanin0(pObj) );
70  if ( --p->pRefs[iFan0] == 0 )
71  p->nCrossCut--;
72  iFan0 = Fsim_Var2Lit( iFan0, Aig_ObjFaninC0(pObj) );
73  iFan1 = 0;
74  }
75  else
76  {
77  iFan0 = iFan1 = 0;
78  Vec_IntPush( p->vCis2Ids, Aig_ObjPioNum(pObj) );
79  }
80  if ( iFan0 < iFan1 )
81  iTemp = iFan0, iFan0 = iFan1, iFan1 = iTemp;
82  p->pFans0[p->nObjs] = iFan0;
83  p->pFans1[p->nObjs] = iFan1;
84  p->pRefs[p->nObjs] = Aig_ObjRefs(pObj);
85  if ( p->pRefs[p->nObjs] )
86  if ( p->nCrossCutMax < ++p->nCrossCut )
87  p->nCrossCutMax = p->nCrossCut;
88  return pObj->iData = p->nObjs++;
89 }
90 
91 /**Function*************************************************************
92 
93  Synopsis [Creates fast simulation manager.]
94 
95  Description []
96 
97  SideEffects []
98 
99  SeeAlso []
100 
101 ***********************************************************************/
103 {
104  Fsim_Man_t * p;
105  Aig_Obj_t * pObj;
106  int i, nObjs;
107  Aig_ManCleanData( pAig );
108  p = (Fsim_Man_t *)ABC_ALLOC( Fsim_Man_t, 1 );
109  memset( p, 0, sizeof(Fsim_Man_t) );
110  p->pAig = pAig;
111  p->nPis = Saig_ManPiNum(pAig);
112  p->nPos = Saig_ManPoNum(pAig);
113  p->nCis = Aig_ManPiNum(pAig);
114  p->nCos = Aig_ManPoNum(pAig);
115  p->nNodes = Aig_ManNodeNum(pAig);
116  nObjs = p->nCis + p->nCos + p->nNodes + 2;
117  p->pFans0 = ABC_ALLOC( int, nObjs );
118  p->pFans1 = ABC_ALLOC( int, nObjs );
119  p->pRefs = ABC_ALLOC( int, nObjs );
120  p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) );
121  // add objects (0=unused; 1=const1)
122  p->pFans0[0] = p->pFans1[0] = 0;
123  p->pFans0[1] = p->pFans1[1] = 0;
124  p->pRefs[0] = 0;
125  p->nObjs = 2;
126  pObj = Aig_ManConst1( pAig );
127  pObj->iData = 1;
128  p->pRefs[1] = Aig_ObjRefs(pObj);
129  if ( p->pRefs[1] )
130  p->nCrossCut = 1;
131  Aig_ManForEachPi( pAig, pObj, i )
132  if ( Aig_ObjRefs(pObj) == 0 )
133  Fsim_ManCreate_rec( p, pObj );
134  Aig_ManForEachPo( pAig, pObj, i )
135  Fsim_ManCreate_rec( p, pObj );
136  assert( Vec_IntSize(p->vCis2Ids) == Aig_ManPiNum(pAig) );
137  assert( p->nObjs == nObjs );
138  // check references
139  assert( p->nCrossCut == 0 );
140  Aig_ManForEachObj( pAig, pObj, i )
141  {
142  assert( p->pRefs[pObj->iData] == 0 );
143  p->pRefs[pObj->iData] = Aig_ObjRefs(pObj);
144  }
145  // collect flop outputs
146  p->vLos = Vec_IntAlloc( Aig_ManRegNum(pAig) );
147  Saig_ManForEachLo( pAig, pObj, i )
148  Vec_IntPush( p->vLos, pObj->iData );
149  // collect flop inputs
150  p->vLis = Vec_IntAlloc( Aig_ManRegNum(pAig) );
151  Saig_ManForEachLi( pAig, pObj, i )
152  Vec_IntPush( p->vLis, pObj->iData );
153  // determine the frontier size
154  p->nFront = 1 + (int)(1.1 * p->nCrossCutMax);
155  return p;
156 }
157 
158 /**Function*************************************************************
159 
160  Synopsis [Deletes fast simulation manager.]
161 
162  Description []
163 
164  SideEffects []
165 
166  SeeAlso []
167 
168 ***********************************************************************/
170 {
171  Vec_IntFree( p->vCis2Ids );
172  Vec_IntFree( p->vLos );
173  Vec_IntFree( p->vLis );
174  ABC_FREE( p->pDataAig2 );
175  ABC_FREE( p->pDataAig );
176  ABC_FREE( p->pFans0 );
177  ABC_FREE( p->pFans1 );
178  ABC_FREE( p->pRefs );
179  ABC_FREE( p->pDataSim );
180  ABC_FREE( p->pDataSimCis );
181  ABC_FREE( p->pDataSimCos );
182  ABC_FREE( p->pData1 );
183  ABC_FREE( p->pData2 );
184  ABC_FREE( p );
185 }
186 
187 /**Function*************************************************************
188 
189  Synopsis [Testing procedure.]
190 
191  Description []
192 
193  SideEffects []
194 
195  SeeAlso []
196 
197 ***********************************************************************/
198 void Fsim_ManTest( Aig_Man_t * pAig )
199 {
200  Fsim_Man_t * p;
201  p = Fsim_ManCreate( pAig );
202  Fsim_ManFront( p, 0 );
203  Fsim_ManDelete( p );
204 }
205 
206 ////////////////////////////////////////////////////////////////////////
207 /// END OF FILE ///
208 ////////////////////////////////////////////////////////////////////////
209 
210 
212 
char * memset()
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
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 Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
static int Aig_IsComplement(Aig_Obj_t *p)
Definition: aig.h:249
void Fsim_ManFront(Fsim_Man_t *p, int fCompressAig)
FUNCTION DECLARATIONS ///.
Definition: fsimFront.c:245
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Aig_Obj_t * Aig_ObjFanin1(Aig_Obj_t *pObj)
Definition: aig.h:309
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
ABC_NAMESPACE_IMPL_START int Fsim_ManCreate_rec(Fsim_Man_t *p, Aig_Obj_t *pObj)
DECLARATIONS ///.
Definition: fsimMan.c:45
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Fsim_Var2Lit(int Var, int fCompl)
MACRO DEFINITIONS ///.
Definition: fsimInt.h:105
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define Saig_ManForEachLi(p, pObj, i)
Definition: saig.h:98
typedefABC_NAMESPACE_HEADER_START struct Fsim_Man_t_ Fsim_Man_t
INCLUDES ///.
Definition: fsim.h:42
Fsim_Man_t * Fsim_ManCreate(Aig_Man_t *pAig)
Definition: fsimMan.c:102
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
static int Aig_ObjIsConst1(Aig_Obj_t *pObj)
Definition: aig.h:274
static Aig_Obj_t * Aig_ObjEquiv(Aig_Man_t *p, Aig_Obj_t *pObj)
Definition: aig.h:328
Definition: aig.h:69
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
#define Saig_ManForEachLo(p, pObj, i)
Definition: saig.h:96
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
int iData
Definition: aig.h:88
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
void Fsim_ManTest(Aig_Man_t *pAig)
Definition: fsimMan.c:198
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static int Saig_ManPiNum(Aig_Man_t *p)
MACRO DEFINITIONS ///.
Definition: saig.h:73
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Fsim_ManDelete(Fsim_Man_t *p)
Definition: fsimMan.c:169
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
#define assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205