ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
saigSimFast.c File Reference
#include "saig.h"
#include "base/main/main.h"
Include dependency graph for saigSimFast.c:

Go to the source code of this file.

Classes

struct  Faig_Man_t_
 

Typedefs

typedef typedefABC_NAMESPACE_IMPL_START struct Faig_Man_t_ Faig_Man_t
 DECLARATIONS ///.
 

Functions

int Faig_ManIsCorrect (Aig_Man_t *pAig)
 FUNCTION DEFINITIONS ///.
 
Faig_Man_tFaig_ManAlloc (Aig_Man_t *pAig)
 
Faig_Man_tFaig_ManCreate (Aig_Man_t *pAig)
 
int * Faig_ManSimulateFrames (Faig_Man_t *p, int nFrames, int nPref, int fTrans)
 
float Faig_ManComputeSwitching (int nOnes, int nSimWords)
 
float Faig_ManComputeProbOne (int nOnes, int nSimWords)
 
Vec_Int_tFaig_ManComputeSwitchProbs4 (Aig_Man_t *p, int nFrames, int nPref, int fProbOne)
 
Vec_Int_tSaig_ManComputeSwitchProb3s (Aig_Man_t *p, int nFrames, int nPref, int fProbOne)
 

Typedef Documentation

◆ Faig_Man_t

typedef typedefABC_NAMESPACE_IMPL_START struct Faig_Man_t_ Faig_Man_t

DECLARATIONS ///.

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

FileName [saigSimFast.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Sequential AIG package.]

Synopsis [Fast sequential AIG simulator.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

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

Revision [

Id
saigSimFast.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 33 of file saigSimFast.c.

Function Documentation

◆ Faig_ManAlloc()

Faig_Man_t * Faig_ManAlloc ( Aig_Man_t * pAig)

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

Synopsis [Creates fast simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 110 of file saigSimFast.c.

111{
112 Faig_Man_t * p;
113 int nWords;
114// assert( Faig_ManIsCorrect(pAig) );
115 nWords = 2 * Aig_ManNodeNum(pAig) + Aig_ManCoNum(pAig);
116 p = (Faig_Man_t *)ABC_ALLOC( char, sizeof(Faig_Man_t) + sizeof(int) * nWords );
117//printf( "Allocating %7.2f MB.\n", 1.0 * (sizeof(Faig_Man_t) + sizeof(int) * nWords)/(1<<20) );
118 memset( p, 0, sizeof(Faig_Man_t) );
119 p->nPis = Aig_ManCiNum(pAig) - Aig_ManRegNum(pAig);
120 p->nPos = Aig_ManCoNum(pAig) - Aig_ManRegNum(pAig);
121 p->nCis = Aig_ManCiNum(pAig);
122 p->nCos = Aig_ManCoNum(pAig);
123 p->nFfs = Aig_ManRegNum(pAig);
124 p->nNos = Aig_ManNodeNum(pAig);
125 // offsets
126 p->nPis1 = p->nPis + 1;
127 p->nCis1 = p->nCis + 1;
128 p->nCisNos1 = p->nCis + p->nNos + 1;
129 p->nCisNosPos1 = p->nCis + p->nNos + p->nPos + 1;
130 p->nObjs = p->nCis + p->nNos + p->nCos + 1;
131 p->nWords = nWords;
132 return p;
133}
int nWords
Definition abcNpn.c:127
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
Cube * p
Definition exorList.c:222
typedefABC_NAMESPACE_IMPL_START struct Faig_Man_t_ Faig_Man_t
DECLARATIONS ///.
Definition saigSimFast.c:33
char * memset()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Faig_ManComputeProbOne()

float Faig_ManComputeProbOne ( int nOnes,
int nSimWords )

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

Synopsis [Computes switching activity of one node.]

Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]

SideEffects []

SeeAlso []

Definition at line 327 of file saigSimFast.c.

328{
329 int nTotal = 32 * nSimWords;
330 return (float)nOnes / nTotal;
331}
int nTotal
DECLARATIONS ///.
Definition cutTruth.c:37
Here is the caller graph for this function:

◆ Faig_ManComputeSwitching()

float Faig_ManComputeSwitching ( int nOnes,
int nSimWords )

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

Synopsis [Computes switching activity of one node.]

Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]

SideEffects []

SeeAlso []

Definition at line 310 of file saigSimFast.c.

311{
312 int nTotal = 32 * nSimWords;
313 return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
314}
Here is the caller graph for this function:

◆ Faig_ManComputeSwitchProbs4()

Vec_Int_t * Faig_ManComputeSwitchProbs4 ( Aig_Man_t * p,
int nFrames,
int nPref,
int fProbOne )

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 344 of file saigSimFast.c.

345{
346 int fTrans = 1;
347 Faig_Man_t * pAig;
348 Vec_Int_t * vSwitching;
349 int * pProbs;
350 float * pSwitching;
351 int nFramesReal;
352 abctime clk;//, clkTotal = Abc_Clock();
353 if ( fProbOne )
354 fTrans = 0;
355 vSwitching = Vec_IntStart( Aig_ManObjNumMax(p) );
356 pSwitching = (float *)vSwitching->pArray;
357clk = Abc_Clock();
358 pAig = Faig_ManCreate( p );
359//ABC_PRT( "\nCreation ", Abc_Clock() - clk );
360 Aig_ManRandom( 1 );
361 // get the number of frames to simulate
362 // if the parameter "seqsimframes" is defined, use it
363 // otherwise, use the given number of frames "nFrames"
364 nFramesReal = nFrames;
365 if ( Abc_FrameReadFlag("seqsimframes") )
366 nFramesReal = atoi( Abc_FrameReadFlag("seqsimframes") );
367 if ( nFramesReal <= nPref )
368 {
369 printf( "The total number of frames (%d) should exceed prefix (%d).\n", nFramesReal, nPref );
370 printf( "Setting the total number of frames to be %d.\n", nFrames );
371 nFramesReal = nFrames;
372 }
373//printf( "Simulating %d frames.\n", nFramesReal );
374clk = Abc_Clock();
375 pProbs = Faig_ManSimulateFrames( pAig, nFramesReal, nPref, fTrans );
376//ABC_PRT( "Simulation", Abc_Clock() - clk );
377clk = Abc_Clock();
378 if ( fTrans )
379 {
380 Aig_Obj_t * pObj;
381 int i, Counter = 0;
382 pObj = Aig_ManConst1(p);
383 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], (nFramesReal - nPref)/2 );
384 Aig_ManForEachCi( p, pObj, i )
385 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], (nFramesReal - nPref)/2 );
386 Aig_ManForEachNode( p, pObj, i )
387 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], (nFramesReal - nPref)/2 );
388 Aig_ManForEachCo( p, pObj, i )
389 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], (nFramesReal - nPref)/2 );
390 assert( Counter == pAig->nObjs );
391 }
392 else if ( fProbOne )
393 {
394 Aig_Obj_t * pObj;
395 int i, Counter = 0;
396 pObj = Aig_ManConst1(p);
397 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], nFramesReal - nPref );
398 Aig_ManForEachCi( p, pObj, i )
399 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], nFramesReal - nPref );
400 Aig_ManForEachNode( p, pObj, i )
401 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], nFramesReal - nPref );
402 Aig_ManForEachCo( p, pObj, i )
403 pSwitching[pObj->Id] = Faig_ManComputeProbOne( pProbs[Counter++], nFramesReal - nPref );
404 assert( Counter == pAig->nObjs );
405 }
406 else
407 {
408 Aig_Obj_t * pObj;
409 int i, Counter = 0;
410 pObj = Aig_ManConst1(p);
411 pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref );
412 Aig_ManForEachCi( p, pObj, i )
413 pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref );
414 Aig_ManForEachNode( p, pObj, i )
415 pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref );
416 Aig_ManForEachCo( p, pObj, i )
417 pSwitching[pObj->Id] = Faig_ManComputeSwitching( pProbs[Counter++], nFramesReal - nPref );
418 assert( Counter == pAig->nObjs );
419 }
420 ABC_FREE( pProbs );
421 ABC_FREE( pAig );
422//ABC_PRT( "Switch ", Abc_Clock() - clk );
423//ABC_PRT( "TOTAL ", Abc_Clock() - clkTotal );
424 return vSwitching;
425}
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_FREE(obj)
Definition abc_global.h:267
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition aig.h:393
struct Aig_Obj_t_ Aig_Obj_t
Definition aig.h:51
#define Aig_ManForEachNode(p, pObj, i)
Definition aig.h:413
#define Aig_ManForEachCo(p, pObj, i)
Definition aig.h:398
unsigned Aig_ManRandom(int fReset)
Definition aigUtil.c:1170
ABC_DLL char * Abc_FrameReadFlag(char *pFlag)
Definition mainFrame.c:69
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
int * Faig_ManSimulateFrames(Faig_Man_t *p, int nFrames, int nPref, int fTrans)
float Faig_ManComputeSwitching(int nOnes, int nSimWords)
float Faig_ManComputeProbOne(int nOnes, int nSimWords)
Faig_Man_t * Faig_ManCreate(Aig_Man_t *pAig)
int Id
Definition aig.h:85
#define assert(ex)
Definition util_old.h:213
Here is the call graph for this function:

◆ Faig_ManCreate()

Faig_Man_t * Faig_ManCreate ( Aig_Man_t * pAig)

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

Synopsis [Creates fast simulation manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 146 of file saigSimFast.c.

147{
148 Faig_Man_t * p;
149 Aig_Obj_t * pObj;
150 int i, iWord = 0;
151 p = Faig_ManAlloc( pAig );
152 Aig_ManForEachNode( pAig, pObj, i )
153 {
154 p->pObjs[iWord++] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj);
155 p->pObjs[iWord++] = (Aig_ObjFaninId1(pObj) << 1) | Aig_ObjFaninC1(pObj);
156 }
157 Aig_ManForEachCo( pAig, pObj, i )
158 p->pObjs[iWord++] = (Aig_ObjFaninId0(pObj) << 1) | Aig_ObjFaninC0(pObj);
159 assert( iWord == p->nWords );
160 return p;
161}
Faig_Man_t * Faig_ManAlloc(Aig_Man_t *pAig)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Faig_ManIsCorrect()

int Faig_ManIsCorrect ( Aig_Man_t * pAig)

FUNCTION DEFINITIONS ///.

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

Synopsis [Checks if the manager is correct.]

Description []

SideEffects []

SeeAlso []

Definition at line 93 of file saigSimFast.c.

94{
95 return Aig_ManObjNumMax(pAig) ==
96 1 + Aig_ManCiNum(pAig) + Aig_ManNodeNum(pAig) + Aig_ManCoNum(pAig);
97}

◆ Faig_ManSimulateFrames()

int * Faig_ManSimulateFrames ( Faig_Man_t * p,
int nFrames,
int nPref,
int fTrans )

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

Synopsis [Simulates the timeframes.]

Description []

SideEffects []

SeeAlso []

Definition at line 253 of file saigSimFast.c.

254{
255 int * pNumOnes = ABC_CALLOC( int, p->nObjs );
256 unsigned * pSimInfo = ABC_ALLOC( unsigned, p->nObjs );
257 int f, i;
258//printf( "Allocating %7.2f MB.\n", 1.0 * 4 * p->nObjs/(1<<20) );
259//printf( "Allocating %7.2f MB.\n", 1.0 * 4 * p->nObjs/(1<<20) );
260 // set constant 1
261 pSimInfo[0] = ~0;
262 for ( f = 0; f < nFrames; f++ )
263 {
264 if ( fTrans )
265 {
266 for ( i = 1; i < p->nPis1; i++ )
267 pSimInfo[i] = f? Faig_SimulateRandomShift( pSimInfo[i] ) : Aig_ManRandom( 0 );
268 for ( ; i < p->nCis1; i++ )
269 pSimInfo[i] = f? Faig_SimulateTransferShift( pSimInfo[i], pSimInfo[Faig_ObjLoToLi(p,i)] ) : 0;
270 }
271 else
272 {
273 for ( i = 1; i < p->nPis1; i++ )
274 pSimInfo[i] = Aig_ManRandom( 0 );
275 for ( ; i < p->nCis1; i++ )
276 pSimInfo[i] = f? pSimInfo[Faig_ObjLoToLi(p,i)] : 0;
277 }
278 for ( ; i < p->nCisNos1; i++ )
279 pSimInfo[i] = Faig_SimulateNode( p, i, pSimInfo );
280 for ( ; i < p->nObjs; i++ )
281 pSimInfo[i] = Faig_SimulateCo( p, i, pSimInfo );
282 if ( f < nPref )
283 continue;
284 if ( fTrans )
285 {
286 for ( i = 0; i < p->nObjs; i++ )
287 pNumOnes[i] += Aig_WordCountOnes( (pSimInfo[i] ^ (pSimInfo[i] >> 16)) & 0xffff );
288 }
289 else
290 {
291 for ( i = 0; i < p->nObjs; i++ )
292 pNumOnes[i] += Aig_WordCountOnes( pSimInfo[i] );
293 }
294 }
295 ABC_FREE( pSimInfo );
296 return pNumOnes;
297}
#define ABC_CALLOC(type, num)
Definition abc_global.h:265
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Saig_ManComputeSwitchProb3s()

Vec_Int_t * Saig_ManComputeSwitchProb3s ( Aig_Man_t * p,
int nFrames,
int nPref,
int fProbOne )

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

Synopsis [Computes probability of switching (or of being 1).]

Description []

SideEffects []

SeeAlso []

Definition at line 438 of file saigSimFast.c.

439{
440// return Faig_ManComputeSwitchProbs( p, nFrames, nPref, fProbOne );
441 return NULL;
442}