abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fsimInt.h File Reference
#include "aig/saig/saig.h"
#include "fsim.h"

Go to the source code of this file.

Data Structures

struct  Fsim_Obj_t_
 
struct  Fsim_Man_t_
 

Macros

#define Fsim_ManForEachObj(p, pObj, i)
 

Typedefs

typedef
typedefABC_NAMESPACE_HEADER_START
struct Fsim_Obj_t_ 
Fsim_Obj_t
 INCLUDES ///. More...
 

Functions

static unsigned * Fsim_SimData (Fsim_Man_t *p, int i)
 
static unsigned * Fsim_SimDataCi (Fsim_Man_t *p, int i)
 
static unsigned * Fsim_SimDataCo (Fsim_Man_t *p, int i)
 
static int Fsim_Var2Lit (int Var, int fCompl)
 MACRO DEFINITIONS ///. More...
 
static int Fsim_Lit2Var (int Lit)
 
static int Fsim_LitIsCompl (int Lit)
 
static int Fsim_LitNot (int Lit)
 
static int Fsim_LitNotCond (int Lit, int c)
 
static int Fsim_LitRegular (int Lit)
 
void Fsim_ManFront (Fsim_Man_t *p, int fCompressAig)
 FUNCTION DECLARATIONS ///. More...
 
Fsim_Man_tFsim_ManCreate (Aig_Man_t *pAig)
 
void Fsim_ManDelete (Fsim_Man_t *p)
 
void Fsim_ManTest (Aig_Man_t *pAig)
 

Macro Definition Documentation

#define Fsim_ManForEachObj (   p,
  pObj,
 
)
Value:
for ( i = 2, p->pDataCur = p->pDataAig, p->iNodePrev = 0, pObj = &p->Obj;\
i < p->nObjs && Fsim_ManRestoreObj( p, pObj ); i++ )
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Fsim_ManRestoreObj(Fsim_Man_t *p, Fsim_Obj_t *pObj)
Definition: fsimFront.c:137

Definition at line 112 of file fsimInt.h.

Typedef Documentation

typedef typedefABC_NAMESPACE_HEADER_START struct Fsim_Obj_t_ Fsim_Obj_t

INCLUDES ///.

CFile****************************************************************

FileName [fsimInt.h]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Fast sequential AIG simulator.]

Synopsis [Internal declarations.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
fsimInt.h,v 1.00 2005/06/20 00:00:00 alanmi Exp

]PARAMETERS ///BASIC TYPES ///

Definition at line 46 of file fsimInt.h.

Function Documentation

static int Fsim_Lit2Var ( int  Lit)
inlinestatic

Definition at line 106 of file fsimInt.h.

106 { return Lit >> 1; }
static int Fsim_LitIsCompl ( int  Lit)
inlinestatic

Definition at line 107 of file fsimInt.h.

107 { return Lit & 1; }
static int Fsim_LitNot ( int  Lit)
inlinestatic

Definition at line 108 of file fsimInt.h.

108 { return Lit ^ 1; }
static int Fsim_LitNotCond ( int  Lit,
int  c 
)
inlinestatic

Definition at line 109 of file fsimInt.h.

109 { return Lit ^ (int)(c > 0); }
static int Fsim_LitRegular ( int  Lit)
inlinestatic

Definition at line 110 of file fsimInt.h.

110 { return Lit & ~01; }
Fsim_Man_t* Fsim_ManCreate ( Aig_Man_t pAig)

Function*************************************************************

Synopsis [Creates fast simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 102 of file fsimMan.c.

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 }
char * memset()
static int Saig_ManPoNum(Aig_Man_t *p)
Definition: saig.h:74
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
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 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
if(last==0)
Definition: sparse_int.h:34
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 Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
int iData
Definition: aig.h:88
static int Aig_ManRegNum(Aig_Man_t *p)
Definition: aig.h:260
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 assert(ex)
Definition: util_old.h:213
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
void Fsim_ManDelete ( Fsim_Man_t p)

Function*************************************************************

Synopsis [Deletes fast simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 169 of file fsimMan.c.

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 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
void Fsim_ManFront ( Fsim_Man_t p,
int  fCompressAig 
)

FUNCTION DECLARATIONS ///.

Function*************************************************************

Synopsis [Determine the frontier.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file fsimFront.c.

246 {
247  Fsim_Obj_t Obj, * pObj = &Obj;
248  char * pFront; // places used for the frontier
249  int * pIdToFront; // mapping of nodes into frontier places
250  int i, iVar0, iVar1, nCrossCut = 0, nCrossCutMax = 0;
251  // start the frontier
252  pFront = ABC_CALLOC( char, p->nFront );
253  pIdToFront = ABC_ALLOC( int, p->nObjs );
254  pIdToFront[0] = -1;
255  pIdToFront[1] = -1;
256  // add constant node
257  p->iNumber = 1;
258  if ( p->pRefs[1] )
259  {
260  pIdToFront[1] = Fsim_ManFrontFindNext( p, pFront );
261  nCrossCut = 1;
262  }
263  // allocate room for data
264  if ( fCompressAig )
265  {
266  p->nDataAig = p->nObjs * 6;
267  p->pDataAig = ABC_ALLOC( unsigned char, p->nDataAig );
268  p->pDataCur = p->pDataAig;
269  p->iNodePrev = 0;
270  }
271  else
272  {
273  p->pDataAig2 = ABC_ALLOC( int, 3 * p->nObjs );
274  p->pDataCur2 = p->pDataAig2 + 6;
275  }
276  // iterate through the objects
277  for ( i = 2; i < p->nObjs; i++ )
278  {
279  if ( p->pFans0[i] == 0 ) // ci
280  {
281  // store node
282  pIdToFront[i] = Fsim_ManFrontFindNext( p, pFront );
283  pObj->iNode = pIdToFront[i];
284  pObj->iFan0 = 0;
285  pObj->iFan1 = 0;
286  Fsim_ManStoreObj( p, pObj );
287  // handle CIs without fanout
288  if ( p->pRefs[i] == 0 )
289  {
290  pFront[pIdToFront[i] % p->nFront] = 0;
291  pIdToFront[i] = -1;
292  }
293  }
294  else if ( p->pFans1[i] == 0 ) // co
295  {
296  assert( p->pRefs[i] == 0 );
297  // get the fanin
298  iVar0 = Fsim_Lit2Var(p->pFans0[i]);
299  assert( pIdToFront[iVar0] > 0 );
300  // store node
301  pObj->iNode = 0;
302  pObj->iFan0 = Fsim_Var2Lit(pIdToFront[iVar0], Fsim_LitIsCompl(p->pFans0[i]));
303  pObj->iFan1 = 0;
304  Fsim_ManStoreObj( p, pObj );
305  // deref the fanin
306  if ( --p->pRefs[iVar0] == 0 )
307  {
308  pFront[pIdToFront[iVar0] % p->nFront] = 0;
309  pIdToFront[iVar0] = -1;
310  nCrossCut--;
311  }
312  }
313  else
314  {
315  // get the fanins
316  iVar0 = Fsim_Lit2Var(p->pFans0[i]);
317  assert( pIdToFront[iVar0] > 0 );
318  iVar1 = Fsim_Lit2Var(p->pFans1[i]);
319  assert( pIdToFront[iVar1] > 0 );
320  // store node
321  pIdToFront[i] = Fsim_ManFrontFindNext( p, pFront );
322  pObj->iNode = pIdToFront[i];
323  pObj->iFan0 = Fsim_Var2Lit(pIdToFront[iVar0], Fsim_LitIsCompl(p->pFans0[i]));
324  pObj->iFan1 = Fsim_Var2Lit(pIdToFront[iVar1], Fsim_LitIsCompl(p->pFans1[i]));
325  Fsim_ManStoreObj( p, pObj );
326  // deref the fanins
327  if ( --p->pRefs[iVar0] == 0 )
328  {
329  pFront[pIdToFront[iVar0] % p->nFront] = 0;
330  pIdToFront[iVar0] = -1;
331  nCrossCut--;
332  }
333  if ( --p->pRefs[iVar1] == 0 )
334  {
335  pFront[pIdToFront[iVar1] % p->nFront] = 0;
336  pIdToFront[iVar1] = -1;
337  nCrossCut--;
338  }
339  // handle nodes without fanout (choice nodes)
340  if ( p->pRefs[i] == 0 )
341  {
342  pFront[pIdToFront[i] % p->nFront] = 0;
343  pIdToFront[i] = -1;
344  }
345  }
346  if ( p->pRefs[i] )
347  if ( nCrossCutMax < ++nCrossCut )
348  nCrossCutMax = nCrossCut;
349  }
350  assert( p->pDataAig2 == NULL || p->pDataCur2 - p->pDataAig2 == (3 * p->nObjs) );
351  assert( nCrossCut == 0 );
352  assert( nCrossCutMax == p->nCrossCutMax );
353  for ( i = 0; i < p->nFront; i++ )
354  assert( pFront[i] == 0 );
355  ABC_FREE( pFront );
356  ABC_FREE( pIdToFront );
357 // Fsim_ManVerifyFront( p );
358  ABC_FREE( p->pFans0 );
359  ABC_FREE( p->pFans1 );
360  ABC_FREE( p->pRefs );
361 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static void Fsim_ManStoreObj(Fsim_Man_t *p, Fsim_Obj_t *pObj)
Definition: fsimFront.c:89
static int Fsim_ManFrontFindNext(Fsim_Man_t *p, char *pFront)
Definition: fsimFront.c:174
static int Fsim_LitIsCompl(int Lit)
Definition: fsimInt.h:107
static int Fsim_Lit2Var(int Lit)
Definition: fsimInt.h:106
static int Fsim_Var2Lit(int Var, int fCompl)
MACRO DEFINITIONS ///.
Definition: fsimInt.h:105
typedefABC_NAMESPACE_HEADER_START struct Fsim_Obj_t_ Fsim_Obj_t
INCLUDES ///.
Definition: fsimInt.h:46
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
void Fsim_ManTest ( Aig_Man_t pAig)

Function*************************************************************

Synopsis [Testing procedure.]

Description []

SideEffects []

SeeAlso []

Definition at line 198 of file fsimMan.c.

199 {
200  Fsim_Man_t * p;
201  p = Fsim_ManCreate( pAig );
202  Fsim_ManFront( p, 0 );
203  Fsim_ManDelete( p );
204 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Fsim_ManFront(Fsim_Man_t *p, int fCompressAig)
FUNCTION DECLARATIONS ///.
Definition: fsimFront.c:245
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
void Fsim_ManDelete(Fsim_Man_t *p)
Definition: fsimMan.c:169
static unsigned* Fsim_SimData ( Fsim_Man_t p,
int  i 
)
inlinestatic

Definition at line 97 of file fsimInt.h.

97 { return p->pDataSim + i * p->nWords; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static unsigned* Fsim_SimDataCi ( Fsim_Man_t p,
int  i 
)
inlinestatic

Definition at line 98 of file fsimInt.h.

98 { return p->pDataSimCis + i * p->nWords; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static unsigned* Fsim_SimDataCo ( Fsim_Man_t p,
int  i 
)
inlinestatic

Definition at line 99 of file fsimInt.h.

99 { return p->pDataSimCos + i * p->nWords; }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Fsim_Var2Lit ( int  Var,
int  fCompl 
)
inlinestatic

MACRO DEFINITIONS ///.

Definition at line 105 of file fsimInt.h.

105 { return Var + Var + fCompl; }
int Var
Definition: SolverTypes.h:42