Commit d4f073ba by Alan Mishchenko

Various changes.

parent abc54a2d
......@@ -217,6 +217,7 @@ struct Gia_Man_t_
Vec_Int_t * vClassOld;
Vec_Int_t * vClassNew;
Vec_Int_t * vPats;
Vec_Bit_t * vPolars;
// incremental simulation
int fIncrSim;
int iNextPi;
......@@ -1592,6 +1593,12 @@ extern int Gia_ManIncrSimCheckEqual( Gia_Man_t * p, int iLit0, i
/*=== giaSimBase.c ============================================================*/
extern Vec_Wrd_t * Gia_ManSimPatSim( Gia_Man_t * p );
extern Vec_Wrd_t * Gia_ManSimPatSimOut( Gia_Man_t * pGia, Vec_Wrd_t * vSimsPi, int fOuts );
extern void Gia_ManSim2ArrayOne( Vec_Wrd_t * vSimsPi, Vec_Int_t * vRes );
extern Vec_Wec_t * Gia_ManSim2Array( Vec_Ptr_t * vSims );
extern Vec_Wrd_t * Gia_ManArray2SimOne( Vec_Int_t * vRes );
extern Vec_Ptr_t * Gia_ManArray2Sim( Vec_Wec_t * vRes );
extern void Gia_ManPtrWrdDumpBin( char * pFileName, Vec_Ptr_t * p, int fVerbose );
extern Vec_Ptr_t * Gia_ManPtrWrdReadBin( char * pFileName, int fVerbose );
/*=== giaSpeedup.c ============================================================*/
extern float Gia_ManDelayTraceLut( Gia_Man_t * p );
extern float Gia_ManDelayTraceLutPrint( Gia_Man_t * p, int fVerbose );
......
......@@ -95,6 +95,7 @@ void Gia_ManStop( Gia_Man_t * p )
Vec_IntFreeP( &p->vClassNew );
Vec_IntFreeP( &p->vClassOld );
Vec_IntFreeP( &p->vPats );
Vec_BitFreeP( &p->vPolars );
Vec_WrdFreeP( &p->vSims );
Vec_WrdFreeP( &p->vSimsT );
Vec_WrdFreeP( &p->vSimsPi );
......
......@@ -2622,6 +2622,84 @@ void Gia_ManSimArrayTest( Vec_Wrd_t * vSimsPi )
}
Vec_PtrFree( vTemp );
}
/**Function*************************************************************
Synopsis [Serialization.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManPtrWrdDumpBin( char * pFileName, Vec_Ptr_t * p, int fVerbose )
{
Vec_Wrd_t * vLevel;
int i, nSize, RetValue;
FILE * pFile = fopen( pFileName, "wb" );
if ( pFile == NULL )
{
printf( "Cannot open file \"%s\" for writing.\n", pFileName );
return;
}
nSize = Vec_PtrSize(p);
RetValue = fwrite( &nSize, 1, sizeof(int), pFile );
Vec_PtrForEachEntry( Vec_Wrd_t *, p, vLevel, i )
{
nSize = Vec_WrdSize(vLevel);
RetValue += fwrite( &nSize, 1, sizeof(int), pFile );
RetValue += fwrite( Vec_WrdArray(vLevel), 1, sizeof(word)*nSize, pFile );
}
fclose( pFile );
if ( fVerbose )
printf( "Written %d arrays into file \"%s\".\n", Vec_PtrSize(p), pFileName );
}
Vec_Ptr_t * Gia_ManPtrWrdReadBin( char * pFileName, int fVerbose )
{
Vec_Ptr_t * p = NULL; Vec_Wrd_t * vLevel; int i, nSize, RetValue;
FILE * pFile = fopen( pFileName, "rb" );
if ( pFile == NULL )
{
printf( "Cannot open file \"%s\" for reading.\n", pFileName );
return NULL;
}
fseek( pFile, 0, SEEK_END );
nSize = ftell( pFile );
if ( nSize == 0 )
{
printf( "The input file is empty.\n" );
fclose( pFile );
return NULL;
}
if ( nSize % (int)sizeof(int) > 0 )
{
printf( "Cannot read file with integers because it is not aligned at 4 bytes (remainder = %d).\n", nSize % (int)sizeof(int) );
fclose( pFile );
return NULL;
}
rewind( pFile );
RetValue = fread( &nSize, 1, sizeof(int), pFile );
assert( RetValue == 4 );
p = Vec_PtrAlloc( nSize );
for ( i = 0; i < nSize; i++ )
Vec_PtrPush( p, Vec_WrdAlloc(100) );
Vec_PtrForEachEntry( Vec_Wrd_t *, p, vLevel, i )
{
RetValue = fread( &nSize, 1, sizeof(int), pFile );
assert( RetValue == 4 );
Vec_WrdFill( vLevel, nSize, 0 );
RetValue = fread( Vec_WrdArray(vLevel), 1, sizeof(word)*nSize, pFile );
assert( RetValue == 8*nSize );
}
fclose( pFile );
if ( fVerbose )
printf( "Read %d arrays from file \"%s\".\n", Vec_PtrSize(p), pFileName );
return p;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -43,26 +43,6 @@ ABC_NAMESPACE_IMPL_START
SeeAlso []
***********************************************************************/
static void Vec_PtrFreeFunc( Vec_Ptr_t * p, void (*pFuncItemFree)(void *) ) ___unused;
static void Vec_PtrFreeFunc( Vec_Ptr_t * p, void (*pFuncItemFree)(void *) )
{
void * pItem; int i;
Vec_PtrForEachEntry( void *, p, pItem, i )
pFuncItemFree( pItem );
Vec_PtrFree( p );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManDupMapping( Gia_Man_t * pNew, Gia_Man_t * p )
{
Gia_Obj_t * pObj, * pFanin; int i, k;
......
......@@ -506,6 +506,7 @@ Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fN
// create names
if ( fNames )
{
pNew->vPolars = Vec_BitStart( Gia_ManObjNum(pNew) );
pNew->vNamesNode = Vec_PtrStart( Gia_ManObjNum(pNew) );
Vec_IntForEachEntry( vMap, iLit, Token )
{
......@@ -514,6 +515,7 @@ Gia_Man_t * Gia_FileSimpleParse( Vec_Int_t * vBuffer, Abc_Nam_t * pNames, int fN
sprintf( Buffer, "%c_%s", Abc_LitIsCompl(iLit) ? 'c' : 'd', Abc_NamStr(pNames, Token) );
assert( Vec_PtrEntry(pNew->vNamesNode, Abc_Lit2Var(iLit)) == NULL );
Vec_PtrWriteEntry( pNew->vNamesNode, Abc_Lit2Var(iLit), Abc_UtilStrsav(Buffer) );
Vec_BitWriteEntry( pNew->vPolars, Abc_Lit2Var(iLit), Abc_LitIsCompl(iLit) );
}
}
else
......
......@@ -2106,12 +2106,15 @@ static inline int Abc_TtCountOnes( word x )
x = x + (x >> 32);
return (int)(x & 0xFF);
}
static inline int Abc_TtCountOnes2( word x )
{
return x ? Abc_TtCountOnes(x) : 0;
}
static inline int Abc_TtCountOnesVec( word * x, int nWords )
{
int w, Count = 0;
for ( w = 0; w < nWords; w++ )
if ( x[w] )
Count += Abc_TtCountOnes( x[w] );
Count += Abc_TtCountOnes2( x[w] );
return Count;
}
static inline int Abc_TtCountOnesVecMask( word * x, word * pMask, int nWords, int fCompl )
......@@ -2120,14 +2123,12 @@ static inline int Abc_TtCountOnesVecMask( word * x, word * pMask, int nWords, in
if ( fCompl )
{
for ( w = 0; w < nWords; w++ )
if ( pMask[w] & ~x[w] )
Count += Abc_TtCountOnes( pMask[w] & ~x[w] );
Count += Abc_TtCountOnes2( pMask[w] & ~x[w] );
}
else
{
for ( w = 0; w < nWords; w++ )
if ( pMask[w] & x[w] )
Count += Abc_TtCountOnes( pMask[w] & x[w] );
Count += Abc_TtCountOnes2( pMask[w] & x[w] );
}
return Count;
}
......@@ -2136,24 +2137,23 @@ static inline int Abc_TtCountOnesVecMask2( word * x0, word * x1, int fComp0, int
int w, Count = 0;
if ( !fComp0 && !fComp1 )
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & x0[w] & x1[w] );
Count += Abc_TtCountOnes2( pMask[w] & x0[w] & x1[w] );
else if ( fComp0 && !fComp1 )
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & ~x0[w] & x1[w] );
Count += Abc_TtCountOnes2( pMask[w] & ~x0[w] & x1[w] );
else if ( !fComp0 && fComp1 )
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & x0[w] & ~x1[w] );
Count += Abc_TtCountOnes2( pMask[w] & x0[w] & ~x1[w] );
else
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & ~x0[w] & ~x1[w] );
Count += Abc_TtCountOnes2( pMask[w] & ~x0[w] & ~x1[w] );
return Count;
}
static inline int Abc_TtCountOnesVecXor( word * x, word * y, int nWords )
{
int w, Count = 0;
for ( w = 0; w < nWords; w++ )
if ( x[w] ^ y[w] )
Count += Abc_TtCountOnes( x[w] ^ y[w] );
Count += Abc_TtCountOnes2( x[w] ^ y[w] );
return Count;
}
static inline int Abc_TtCountOnesVecXorMask( word * x, word * y, int fCompl, word * pMask, int nWords )
......@@ -2161,10 +2161,10 @@ static inline int Abc_TtCountOnesVecXorMask( word * x, word * y, int fCompl, wor
int w, Count = 0;
if ( fCompl )
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & (x[w] ^ ~y[w]) );
Count += Abc_TtCountOnes2( pMask[w] & (x[w] ^ ~y[w]) );
else
for ( w = 0; w < nWords; w++ )
Count += Abc_TtCountOnes( pMask[w] & (x[w] ^ y[w]) );
Count += Abc_TtCountOnes2( pMask[w] & (x[w] ^ y[w]) );
return Count;
}
static inline int Abc_TtAndXorSum( word * pOut, word * pIn1, word * pIn2, int nWords )
......@@ -2173,7 +2173,7 @@ static inline int Abc_TtAndXorSum( word * pOut, word * pIn1, word * pIn2, int nW
for ( w = 0; w < nWords; w++ )
{
pOut[w] &= pIn1[w] ^ pIn2[w];
Count += Abc_TtCountOnes( pOut[w] );
Count += Abc_TtCountOnes2( pOut[w] );
}
return Count;
}
......
......@@ -607,6 +607,26 @@ static inline void Vec_PtrFreeFree( Vec_Ptr_t * p )
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static void Vec_PtrFreeFunc( Vec_Ptr_t * p, void (*pFuncItemFree)(void *) ) ___unused;
static void Vec_PtrFreeFunc( Vec_Ptr_t * p, void (*pFuncItemFree)(void *) )
{
void * pItem; int i;
Vec_PtrForEachEntry( void *, p, pItem, i )
if ( pItem ) pFuncItemFree( pItem );
Vec_PtrFree( p );
}
/**Function*************************************************************
Synopsis [Copies the interger array.]
Description []
......
......@@ -382,6 +382,10 @@ static inline int Vec_WrdSize( Vec_Wrd_t * p )
{
return p->nSize;
}
static inline int Vec_WrdChangeSize( Vec_Wrd_t * p, int Shift )
{
return p->nSize += Shift;
}
/**Function*************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment