summaryrefslogtreecommitdiffstats
path: root/src/aig/fsim
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2009-02-15 08:01:00 -0800
commit0871bffae307e0553e0c5186336189e8b55cf6a6 (patch)
tree4571d1563fe33a53a57fea1c35fb668b9d33265f /src/aig/fsim
parentf936cc0680c98ffe51b3a1716c996072d5dbf76c (diff)
downloadabc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.gz
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.tar.bz2
abc-0871bffae307e0553e0c5186336189e8b55cf6a6.zip
Version abc90215
Diffstat (limited to 'src/aig/fsim')
-rw-r--r--src/aig/fsim/fsim.h8
-rw-r--r--src/aig/fsim/fsimFront.c30
-rw-r--r--src/aig/fsim/fsimInt.h8
-rw-r--r--src/aig/fsim/fsimMan.c30
-rw-r--r--src/aig/fsim/fsimSim.c41
-rw-r--r--src/aig/fsim/fsimSwitch.c553
-rw-r--r--src/aig/fsim/fsimTsim.c22
7 files changed, 71 insertions, 621 deletions
diff --git a/src/aig/fsim/fsim.h b/src/aig/fsim/fsim.h
index c890ff29..4e1588a7 100644
--- a/src/aig/fsim/fsim.h
+++ b/src/aig/fsim/fsim.h
@@ -21,10 +21,6 @@
#ifndef __FSIM_H__
#define __FSIM_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -33,6 +29,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimFront.c b/src/aig/fsim/fsimFront.c
index d40b1c6f..14906c0b 100644
--- a/src/aig/fsim/fsimFront.c
+++ b/src/aig/fsim/fsimFront.c
@@ -202,11 +202,11 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p )
int * pFans0, * pFans1; // representation of fanins
int * pFrontToId; // mapping of nodes into frontier variables
int i, iVar0, iVar1;
- pFans0 = ALLOC( int, p->nObjs );
- pFans1 = ALLOC( int, p->nObjs );
+ pFans0 = ABC_ALLOC( int, p->nObjs );
+ pFans1 = ABC_ALLOC( int, p->nObjs );
pFans0[0] = pFans1[0] = 0;
pFans0[1] = pFans1[1] = 0;
- pFrontToId = CALLOC( int, p->nFront );
+ pFrontToId = ABC_CALLOC( int, p->nFront );
if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) )
pFrontToId[1] = 1;
Fsim_ManForEachObj( p, pObj, i )
@@ -223,9 +223,9 @@ void Fsim_ManVerifyFront( Fsim_Man_t * p )
assert( pFans0[i] == p->pFans0[i] );
assert( pFans1[i] == p->pFans1[i] );
}
- free( pFrontToId );
- free( pFans0 );
- free( pFans1 );
+ ABC_FREE( pFrontToId );
+ ABC_FREE( pFans0 );
+ ABC_FREE( pFans1 );
}
/**Function*************************************************************
@@ -246,8 +246,8 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
int * pIdToFront; // mapping of nodes into frontier places
int i, iVar0, iVar1, nCrossCut = 0, nCrossCutMax = 0;
// start the frontier
- pFront = CALLOC( char, p->nFront );
- pIdToFront = ALLOC( int, p->nObjs );
+ pFront = ABC_CALLOC( char, p->nFront );
+ pIdToFront = ABC_ALLOC( int, p->nObjs );
pIdToFront[0] = -1;
pIdToFront[1] = -1;
// add constant node
@@ -261,13 +261,13 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
if ( fCompressAig )
{
p->nDataAig = p->nObjs * 6;
- p->pDataAig = ALLOC( unsigned char, p->nDataAig );
+ p->pDataAig = ABC_ALLOC( unsigned char, p->nDataAig );
p->pDataCur = p->pDataAig;
p->iNodePrev = 0;
}
else
{
- p->pDataAig2 = ALLOC( int, 3 * p->nObjs );
+ p->pDataAig2 = ABC_ALLOC( int, 3 * p->nObjs );
p->pDataCur2 = p->pDataAig2 + 6;
}
// iterate through the objects
@@ -349,12 +349,12 @@ void Fsim_ManFront( Fsim_Man_t * p, int fCompressAig )
assert( nCrossCutMax == p->nCrossCutMax );
for ( i = 0; i < p->nFront; i++ )
assert( pFront[i] == 0 );
- free( pFront );
- free( pIdToFront );
+ ABC_FREE( pFront );
+ ABC_FREE( pIdToFront );
// Fsim_ManVerifyFront( p );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
}
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimInt.h b/src/aig/fsim/fsimInt.h
index 0944bf0c..f46a9024 100644
--- a/src/aig/fsim/fsimInt.h
+++ b/src/aig/fsim/fsimInt.h
@@ -21,10 +21,6 @@
#ifndef __FSIM_INT_H__
#define __FSIM_INT_H__
-#ifdef __cplusplus
-extern "C" {
-#endif
-
////////////////////////////////////////////////////////////////////////
/// INCLUDES ///
////////////////////////////////////////////////////////////////////////
@@ -36,6 +32,10 @@ extern "C" {
/// PARAMETERS ///
////////////////////////////////////////////////////////////////////////
+#ifdef __cplusplus
+extern "C" {
+#endif
+
////////////////////////////////////////////////////////////////////////
/// BASIC TYPES ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimMan.c b/src/aig/fsim/fsimMan.c
index f7a40f40..872e1604 100644
--- a/src/aig/fsim/fsimMan.c
+++ b/src/aig/fsim/fsimMan.c
@@ -102,7 +102,7 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig )
Aig_Obj_t * pObj;
int i, nObjs;
Aig_ManCleanData( pAig );
- p = (Fsim_Man_t *)ALLOC( Fsim_Man_t, 1 );
+ p = (Fsim_Man_t *)ABC_ALLOC( Fsim_Man_t, 1 );
memset( p, 0, sizeof(Fsim_Man_t) );
p->pAig = pAig;
p->nPis = Saig_ManPiNum(pAig);
@@ -111,9 +111,9 @@ Fsim_Man_t * Fsim_ManCreate( Aig_Man_t * pAig )
p->nCos = Aig_ManPoNum(pAig);
p->nNodes = Aig_ManNodeNum(pAig);
nObjs = p->nCis + p->nCos + p->nNodes + 2;
- p->pFans0 = ALLOC( int, nObjs );
- p->pFans1 = ALLOC( int, nObjs );
- p->pRefs = ALLOC( int, nObjs );
+ p->pFans0 = ABC_ALLOC( int, nObjs );
+ p->pFans1 = ABC_ALLOC( int, nObjs );
+ p->pRefs = ABC_ALLOC( int, nObjs );
p->vCis2Ids = Vec_IntAlloc( Aig_ManPiNum(pAig) );
// add objects (0=unused; 1=const1)
p->pFans0[0] = p->pFans1[0] = 0;
@@ -168,17 +168,17 @@ void Fsim_ManDelete( Fsim_Man_t * p )
Vec_IntFree( p->vCis2Ids );
Vec_IntFree( p->vLos );
Vec_IntFree( p->vLis );
- FREE( p->pDataAig2 );
- FREE( p->pDataAig );
- FREE( p->pFans0 );
- FREE( p->pFans1 );
- FREE( p->pRefs );
- FREE( p->pDataSim );
- FREE( p->pDataSimCis );
- FREE( p->pDataSimCos );
- FREE( p->pData1 );
- FREE( p->pData2 );
- FREE( p );
+ ABC_FREE( p->pDataAig2 );
+ ABC_FREE( p->pDataAig );
+ ABC_FREE( p->pFans0 );
+ ABC_FREE( p->pFans1 );
+ ABC_FREE( p->pRefs );
+ ABC_FREE( p->pDataSim );
+ ABC_FREE( p->pDataSimCis );
+ ABC_FREE( p->pDataSimCos );
+ ABC_FREE( p->pData1 );
+ ABC_FREE( p->pData2 );
+ ABC_FREE( p );
}
/**Function*************************************************************
diff --git a/src/aig/fsim/fsimSim.c b/src/aig/fsim/fsimSim.c
index 320c06a9..52dedc6d 100644
--- a/src/aig/fsim/fsimSim.c
+++ b/src/aig/fsim/fsimSim.c
@@ -385,7 +385,7 @@ void Fsim_ManSimulateRoundTest( Fsim_Man_t * p )
Fsim_ManForEachObj( p, pObj, i )
{
}
-// PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) );
+// ABC_PRT( "Unpacking time", p->pPars->nIters * (clock() - clk) );
}
/**Function*************************************************************
@@ -437,7 +437,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
// fill in the binary data
Aig_ManRandom( 1 );
Counter = p->nRegs;
- pData = ALLOC( unsigned, nWords );
+ pData = ABC_ALLOC( unsigned, nWords );
for ( f = 0; f <= iFrame; f++, Counter += p->nPis )
for ( i = 0; i < Aig_ManPiNum(pAig); i++ )
{
@@ -449,7 +449,7 @@ Ssw_Cex_t * Fsim_ManGenerateCounter( Aig_Man_t * pAig, int iFrame, int iOut, int
if ( Aig_InfoHasBit( pData, iPat ) )
Aig_InfoSetBit( p->pData, Counter + iPioId );
}
- free( pData );
+ ABC_FREE( pData );
return p;
}
@@ -470,16 +470,19 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
Sec_MtrStatus_t Status;
int i, iOut, iPat, clk, clkTotal = clock(), clk2, clk2Total = 0;
assert( Aig_ManRegNum(pAig) > 0 );
- Status = Sec_MiterStatus( pAig );
- if ( Status.nSat > 0 )
+ if ( pPars->fCheckMiter )
{
- printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
- return 1;
- }
- if ( Status.nUndec == 0 )
- {
- printf( "Miter is trivially unsatisfiable.\n" );
- return 0;
+ Status = Sec_MiterStatus( pAig );
+ if ( Status.nSat > 0 )
+ {
+ printf( "Miter is trivially satisfiable (output %d).\n", Status.iOut );
+ return 1;
+ }
+ if ( Status.nUndec == 0 )
+ {
+ printf( "Miter is trivially unsatisfiable.\n" );
+ return 0;
+ }
}
// create manager
clk = clock();
@@ -490,7 +493,7 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
4.0*p->nWords*(p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// create simulation frontier
clk = clock();
@@ -501,14 +504,14 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
p->iNumber, Aig_Base2Log(p->iNumber),
1.0*(p->pDataCur-p->pDataAig)/(1<<20),
1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// perform simulation
Aig_ManRandom( 1 );
assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, p->nWords * p->nFront * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, p->nWords * p->nCis * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, p->nWords * p->nCos * sizeof(unsigned) );
+ p->pDataSim = ABC_ALLOC( unsigned, p->nWords * p->nFront );
+ p->pDataSimCis = ABC_ALLOC( unsigned, p->nWords * p->nCis );
+ p->pDataSimCos = ABC_ALLOC( unsigned, p->nWords * p->nCos );
Fsim_ManSimInfoInit( p );
for ( i = 0; i < pPars->nIters; i++ )
{
@@ -542,9 +545,9 @@ int Fsim_ManSimulate( Aig_Man_t * pAig, Fsim_ParSim_t * pPars )
p->nCrossCutMax,
p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
4.0*p->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
+ ABC_PRT( "Sim time", clock() - clkTotal );
-// PRT( "Additional time", clk2Total );
+// ABC_PRT( "Additional time", clk2Total );
// Fsim_ManSimulateRoundTest( p );
// Fsim_ManSimulateRoundTest2( p );
}
diff --git a/src/aig/fsim/fsimSwitch.c b/src/aig/fsim/fsimSwitch.c
index 00046af6..97cb612f 100644
--- a/src/aig/fsim/fsimSwitch.c
+++ b/src/aig/fsim/fsimSwitch.c
@@ -28,559 +28,6 @@
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoRandom( Fsim_Man_t * p, unsigned * pInfo, int nProbNum )
-{
- unsigned Mask;
- int w, i;
- if ( nProbNum )
- {
- Mask = Aig_ManRandom( 0 );
- for ( i = 0; i < nProbNum; i++ )
- Mask &= Aig_ManRandom( 0 );
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] ^= Mask;
- }
- else
- {
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = Aig_ManRandom( 0 );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoRandomShift( Fsim_Man_t * p, unsigned * pInfo, int nProbNum )
-{
- unsigned Mask;
- int w, i;
- Mask = Aig_ManRandom( 0 );
- for ( i = 0; i < nProbNum; i++ )
- Mask &= Aig_ManRandom( 0 );
- if ( p->nWords == 1 )
- pInfo[0] = (pInfo[0] << 16) | ((pInfo[0] ^ Mask) & 0xffff);
- else
- {
- assert( (p->nWords & 1) == 0 ); // should be even number
- for ( w = p->nWords-1; w >= 0; w-- )
- if ( w >= p->nWords/2 )
- pInfo[w] = pInfo[w - p->nWords/2];
- else
- pInfo[w] ^= Mask;
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoZero( Fsim_Man_t * p, unsigned * pInfo )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = 0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoOne( Fsim_Man_t * p, unsigned * pInfo )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~0;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoCopy( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 )
-{
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoCopyShift( Fsim_Man_t * p, unsigned * pInfo, unsigned * pInfo0 )
-{
- int w;
- if ( p->nWords == 1 )
- pInfo[0] = (pInfo[0] << 16) | (pInfo0[0] & 0xffff);
- else
- {
- assert( (p->nWords & 1) == 0 ); // should be even number
- for ( w = p->nWords-1; w >= 0; w-- )
- {
- if ( w >= p->nWords/2 )
- pInfo[w] = pInfo[w - p->nWords/2];
- else
- pInfo[w] = pInfo0[w];
- }
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateCi( Fsim_Man_t * p, int iNode, int iCi )
-{
- unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront );
- unsigned * pInfo0 = Fsim_SimDataCi( p, iCi );
- int w;
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateCo( Fsim_Man_t * p, int iCo, int iFan0 )
-{
- unsigned * pInfo = Fsim_SimDataCo( p, iCo );
- unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront );
- int w;
- if ( Fsim_LitIsCompl(iFan0) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~pInfo0[w];
- else //if ( !Fsim_LitIsCompl(iFan0) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateNode( Fsim_Man_t * p, int iNode, int iFan0, int iFan1 )
-{
- unsigned * pInfo = Fsim_SimData( p, iNode % p->nFront );
- unsigned * pInfo0 = Fsim_SimData( p, Fsim_Lit2Var(iFan0) % p->nFront );
- unsigned * pInfo1 = Fsim_SimData( p, Fsim_Lit2Var(iFan1) % p->nFront );
- int w;
- if ( Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~(pInfo0[w] | pInfo1[w]);
- else if ( Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = ~pInfo0[w] & pInfo1[w];
- else if ( !Fsim_LitIsCompl(iFan0) && Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w] & ~pInfo1[w];
- else //if ( !Fsim_LitIsCompl(iFan0) && !Fsim_LitIsCompl(iFan1) )
- for ( w = p->nWords-1; w >= 0; w-- )
- pInfo[w] = pInfo0[w] & pInfo1[w];
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoInit( Fsim_Man_t * p )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), 0 );
- else
- Fsim_ManSwitchSimInfoZero( p, Fsim_SimDataCi(p, i) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoTransfer( Fsim_Man_t * p, int nProbNum )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandom( p, Fsim_SimDataCi(p, i), nProbNum );
- else
- Fsim_ManSwitchSimInfoCopy( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimInfoTransferShift( Fsim_Man_t * p, int nProbNum )
-{
- int iPioNum, i;
- Vec_IntForEachEntry( p->vCis2Ids, iPioNum, i )
- {
- if ( iPioNum < p->nPis )
- Fsim_ManSwitchSimInfoRandomShift( p, Fsim_SimDataCi(p, i), nProbNum );
- else
- Fsim_ManSwitchSimInfoCopyShift( p, Fsim_SimDataCi(p, i), Fsim_SimDataCo(p, p->nPos+iPioNum-p->nPis) );
- }
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Fsim_ManSwitchSimInfoCountOnes( Fsim_Man_t * p, int iNode )
-{
- unsigned * pInfo;
- int w, Counter = 0;
- pInfo = Fsim_SimData( p, iNode % p->nFront );
- for ( w = p->nWords-1; w >= 0; w-- )
- Counter += Aig_WordCountOnes( pInfo[w] );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline int Fsim_ManSwitchSimInfoCountTrans( Fsim_Man_t * p, int iNode )
-{
- unsigned * pInfo;
- int w, Counter = 0;
- assert( iNode % p->nFront );
- pInfo = Fsim_SimData( p, iNode % p->nFront );
- if ( p->nWords == 1 )
- return Aig_WordCountOnes( (pInfo[0] ^ (pInfo[0] >> 16)) & 0xffff );
- for ( w = p->nWords/2-1; w >= 0; w-- )
- Counter += Aig_WordCountOnes( pInfo[w] ^ pInfo[w + p->nWords/2] );
- return Counter;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-static inline void Fsim_ManSwitchSimulateRound( Fsim_Man_t * p, int fCount )
-{
- int * pCur, * pEnd;
- int i, iCis = 0, iCos = 0;
- if ( Aig_ObjRefs(Aig_ManConst1(p->pAig)) )
- Fsim_ManSwitchSimInfoOne( p, Fsim_SimData(p, 1) );
- pCur = p->pDataAig2 + 6;
- pEnd = p->pDataAig2 + 3 * p->nObjs;
- for ( i = 2; pCur < pEnd; i++ )
- {
- if ( pCur[1] == 0 )
- Fsim_ManSwitchSimulateCi( p, pCur[0], iCis++ );
- else if ( pCur[2] == 0 )
- Fsim_ManSwitchSimulateCo( p, iCos++, pCur[1] );
- else
- Fsim_ManSwitchSimulateNode( p, pCur[0], pCur[1], pCur[2] );
- if ( fCount && pCur[0] )
- {
- if ( p->pData1 )
- p->pData1[i] += Fsim_ManSwitchSimInfoCountOnes( p, pCur[0] );
- if ( p->pData2 )
- p->pData2[i] += Fsim_ManSwitchSimInfoCountTrans( p, pCur[0] );
- }
- pCur += 3;
- }
- assert( iCis == p->nCis );
- assert( iCos == p->nCos );
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes switching activity of one node.]
-
- Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Fsim_ManSwitchComputeSwitching( int nOnes, int nSimWords )
-{
- int nTotal = 32 * nSimWords;
- return (float)2.0 * nOnes / nTotal * (nTotal - nOnes) / nTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes switching activity of one node.]
-
- Description [Uses the formula: Switching = 2 * nOnes * nZeros / (nTotal ^ 2) ]
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-float Fsim_ManSwitchComputeProbOne( int nOnes, int nSimWords )
-{
- int nTotal = 32 * nSimWords;
- return (float)nOnes / nTotal;
-}
-
-/**Function*************************************************************
-
- Synopsis []
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Fsim_ManSwitchSimulate( Aig_Man_t * pAig, Fsim_ParSwitch_t * pPars )
-{
- Vec_Int_t * vSwitching;
- float * pSwitching;
- Aig_Obj_t * pObj;
- Fsim_Man_t * p;
- int i, clk, clkTotal = clock();
- // create manager
- clk = clock();
- p = Fsim_ManCreate( pAig );
- p->nWords = pPars->nWords;
- // if the number of words is larger then 1, it should be even
- if ( p->nWords > 1 && (p->nWords & 1) )
- p->nWords++;
- // print stats
- if ( pPars->fVerbose )
- {
- printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
- p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
- 4.0*pPars->nWords*(p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
- }
- // create simulation frontier
- clk = clock();
- Fsim_ManFront( p, 0 );
- if ( pPars->fVerbose )
- {
- printf( "Max ID = %8d. Log max ID = %2d. AigMem = %7.2f Mb (%5.2f byte/obj). ",
- p->iNumber, Aig_Base2Log(p->iNumber),
- 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
- 1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
- }
- // perform simulation
- Aig_ManRandom( 1 );
- assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, pPars->nWords * p->nFront * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, pPars->nWords * p->nCis * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, pPars->nWords * p->nCos * sizeof(unsigned) );
- if ( pPars->fProbOne )
- p->pData1 = CALLOC( int, p->nObjs * sizeof(int) );
- if ( pPars->fProbTrans )
- p->pData2 = CALLOC( int, p->nObjs * sizeof(int) );
- Fsim_ManSwitchSimInfoInit( p );
- for ( i = 0; i < pPars->nIters; i++ )
- {
- Fsim_ManSwitchSimulateRound( p, i >= pPars->nPref );
- if ( i < pPars->nIters - 1 )
- {
-// if ( pPars->fProbTrans )
- Fsim_ManSwitchSimInfoTransferShift( p, pPars->nRandPiNum );
-// else
-// Fsim_ManSwitchSimInfoTransfer( p, pPars->nRandPiNum );
- }
- }
- if ( pPars->fVerbose )
- {
- printf( "Maxcut = %8d. AigMem = %7.2f Mb. SimMem = %7.2f Mb. ",
- p->nCrossCutMax,
- p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
- 4.0*pPars->nWords*(p->nFront+p->nCis+p->nCos)/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
- }
- // derive the result
- vSwitching = Vec_IntStart( Aig_ManObjNumMax(pAig) );
- pSwitching = (float *)vSwitching->pArray;
-/*
- if ( pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
-// pSwitching[pObj->Id] = Fsim_ManSwitchComputeSwitching( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else if ( !pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else if ( pPars->fProbOne && !pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- }
- else
- assert( 0 );
-*/
- if ( pPars->fProbOne && !pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData1[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref) );
- }
- else if ( !pPars->fProbOne && pPars->fProbTrans )
- {
- Aig_ManForEachObj( pAig, pObj, i )
- pSwitching[pObj->Id] = Fsim_ManSwitchComputeProbOne( p->pData2[pObj->iData], pPars->nWords*(pPars->nIters-pPars->nPref)/2 );
- }
- else
- assert( 0 );
- Fsim_ManDelete( p );
- return vSwitching;
-
-}
-
-/**Function*************************************************************
-
- Synopsis [Computes probability of switching (or of being 1).]
-
- Description []
-
- SideEffects []
-
- SeeAlso []
-
-***********************************************************************/
-Vec_Int_t * Saig_ManComputeSwitchProbs4( Aig_Man_t * p, int nFrames, int nPref, int fProbOne )
-{
- Fsim_ParSwitch_t Pars, * pPars = &Pars;
- Fsim_ManSetDefaultParamsSwitch( pPars );
- pPars->nWords = 1;
- pPars->nIters = nFrames;
- pPars->nPref = nPref;
- if ( fProbOne )
- {
- pPars->fProbOne = 1;
- pPars->fProbTrans = 0;
- }
- else
- {
- pPars->fProbOne = 0;
- pPars->fProbTrans = 1;
- }
- pPars->fVerbose = 0;
- return Fsim_ManSwitchSimulate( p, pPars );
-}
-
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
diff --git a/src/aig/fsim/fsimTsim.c b/src/aig/fsim/fsimTsim.c
index 963d7581..0de283e4 100644
--- a/src/aig/fsim/fsimTsim.c
+++ b/src/aig/fsim/fsimTsim.c
@@ -36,7 +36,7 @@ static inline int Aig_XsimNotCond( int Value, int fCompl )
return FSIM_ZER;
return FSIM_ONE;
}
-static inline int Aig_XsimAndCond( int Value0, int Value1, int fCompl0, int fCompl1 )
+static inline int Aig_XsimAndCond( int Value0, int fCompl0, int Value1, int fCompl1 )
{
if ( Value0 == FSIM_UND || Value1 == FSIM_UND )
return FSIM_UND;
@@ -111,7 +111,7 @@ static inline void Fsim_ManTerSimulateNode( Fsim_Man_t * p, int iNode, int iFan0
{
int Value0 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan0) );
int Value1 = Fsim_ManTerSimInfoGet( p->pDataSim, Fsim_Lit2Var(iFan1) );
- Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Value1, Fsim_LitIsCompl(iFan0), Fsim_LitIsCompl(iFan1) ) );
+ Fsim_ManTerSimInfoSet( p->pDataSim, iNode, Aig_XsimAndCond( Value0, Fsim_LitIsCompl(iFan0), Value1, Fsim_LitIsCompl(iFan1) ) );
}
/**Function*************************************************************
@@ -253,7 +253,7 @@ unsigned * Fsim_ManTerStateCreate( unsigned * pInfo, int nPis, int nCis, int nWo
{
unsigned * pRes;
int i;
- pRes = (unsigned *)CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) );
+ pRes = (unsigned *)ABC_CALLOC( char, sizeof(unsigned) * nWords + sizeof(unsigned *) );
for ( i = nPis; i < nCis; i++ )
Fsim_ManTerSimInfoSet( pRes, i-nPis, Fsim_ManTerSimInfoGet(pInfo, i) );
return pRes;
@@ -348,7 +348,7 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
printf( "Obj = %8d (%8d). Cut = %6d. Front = %6d. FrtMem = %7.2f Mb. ",
p->nObjs, p->nCis + p->nNodes, p->nCrossCutMax, p->nFront,
4.0*Aig_BitWordNum(2 * p->nFront)/(1<<20) );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// create simulation frontier
clk = clock();
@@ -359,19 +359,19 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
p->iNumber, Aig_Base2Log(p->iNumber),
1.0*(p->pDataCur-p->pDataAig)/(1<<20),
1.0*(p->pDataCur-p->pDataAig)/p->nObjs );
- PRT( "Time", clock() - clk );
+ ABC_PRT( "Time", clock() - clk );
}
// allocate storage for terminary states
nWords = Aig_BitWordNum( 2*Aig_ManRegNum(pAig) );
vStates = Vec_PtrAlloc( 1000 );
nBins = Aig_PrimeCudd( 500 );
- pBins = ALLOC( unsigned *, nBins );
+ pBins = ABC_ALLOC( unsigned *, nBins );
memset( pBins, 0, sizeof(unsigned *) * nBins );
// perform simulation
assert( p->pDataSim == NULL );
- p->pDataSim = ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) );
- p->pDataSimCis = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) );
- p->pDataSimCos = ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) );
+ p->pDataSim = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nFront) * sizeof(unsigned) );
+ p->pDataSimCis = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCis) * sizeof(unsigned) );
+ p->pDataSimCos = ABC_ALLOC( unsigned, Aig_BitWordNum(2 * p->nCos) * sizeof(unsigned) );
Fsim_ManTerSimInfoInit( p );
// hash the first state
pState = Fsim_ManTerStateCreate( p->pDataSimCis, p->nPis, p->nCis, nWords );
@@ -395,9 +395,9 @@ Vec_Ptr_t * Fsim_ManTerSimulate( Aig_Man_t * pAig, int fVerbose )
p->nCrossCutMax,
p->pDataAig2? 12.0*p->nObjs/(1<<20) : 1.0*(p->pDataCur-p->pDataAig)/(1<<20),
4.0*(Aig_BitWordNum(2 * p->nFront)+Aig_BitWordNum(2 * p->nCis)+Aig_BitWordNum(2 * p->nCos))/(1<<20) );
- PRT( "Sim time", clock() - clkTotal );
+ ABC_PRT( "Sim time", clock() - clkTotal );
}
- free( pBins );
+ ABC_FREE( pBins );
Fsim_ManDelete( p );
return vStates;