Commit 8c8f39ad by Alan Mishchenko

Adding several new utilities.

parent 8eb6aed5
...@@ -1685,7 +1685,7 @@ word * Gia_SimRsbFunc( Gia_SimRsbMan_t * p, int iObj, Vec_Int_t * vFanins, int f ...@@ -1685,7 +1685,7 @@ word * Gia_SimRsbFunc( Gia_SimRsbMan_t * p, int iObj, Vec_Int_t * vFanins, int f
pFanins[i] = Vec_WrdEntryP( p->vSimsObj, p->nWords*iFanin ); pFanins[i] = Vec_WrdEntryP( p->vSimsObj, p->nWords*iFanin );
for ( s = 0; s < 64*p->nWords; s++ ) for ( s = 0; s < 64*p->nWords; s++ )
{ {
if ( !Abc_TtGetBit(p->pFunc[2], s) || !Abc_TtGetBit(pFunc, s) == fOnSet ) if ( !Abc_TtGetBit(p->pFunc[2], s) || Abc_TtGetBit(pFunc, s) != fOnSet )
continue; continue;
iMint = 0; iMint = 0;
for ( b = 0; b < Vec_IntSize(vFanins); b++ ) for ( b = 0; b < Vec_IntSize(vFanins); b++ )
...@@ -1846,6 +1846,7 @@ Extra_PrintBinary( stdout, (unsigned *)p->pFunc[1], 64 ); printf( "\n" ); ...@@ -1846,6 +1846,7 @@ Extra_PrintBinary( stdout, (unsigned *)p->pFunc[1], 64 ); printf( "\n" );
int Gia_ManSimRsb( Gia_Man_t * pGia, int nCands, int fVerbose ) int Gia_ManSimRsb( Gia_Man_t * pGia, int nCands, int fVerbose )
{ {
abctime clk = Abc_Clock();
Gia_Obj_t * pObj; int iObj, nCount = 0, nBufs = 0, nInvs = 0; Gia_Obj_t * pObj; int iObj, nCount = 0, nBufs = 0, nInvs = 0;
Gia_SimRsbMan_t * p = Gia_SimRsbAlloc( pGia ); Gia_SimRsbMan_t * p = Gia_SimRsbAlloc( pGia );
assert( pGia->vSimsPi != NULL ); assert( pGia->vSimsPi != NULL );
...@@ -1853,8 +1854,9 @@ int Gia_ManSimRsb( Gia_Man_t * pGia, int nCands, int fVerbose ) ...@@ -1853,8 +1854,9 @@ int Gia_ManSimRsb( Gia_Man_t * pGia, int nCands, int fVerbose )
Gia_ManForEachAnd( pGia, pObj, iObj ) Gia_ManForEachAnd( pGia, pObj, iObj )
//if ( iObj == 6 ) //if ( iObj == 6 )
nCount += Gia_ObjSimRsb( p, iObj, nCands, fVerbose, &nBufs, &nInvs ); nCount += Gia_ObjSimRsb( p, iObj, nCands, fVerbose, &nBufs, &nInvs );
printf( "Resubstitution is possible for %d nodes (%.2f %% out of %d) (Bufs = %d Invs = %d)\n", printf( "Can resubstitute %d nodes (%.2f %% out of %d) (Bufs = %d Invs = %d) ",
nCount, 100.0*nCount/Gia_ManAndNum(pGia), Gia_ManAndNum(pGia), nBufs, nInvs ); nCount, 100.0*nCount/Gia_ManAndNum(pGia), Gia_ManAndNum(pGia), nBufs, nInvs );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
Gia_SimRsbFree( p ); Gia_SimRsbFree( p );
return nCount; return nCount;
} }
......
...@@ -443,6 +443,108 @@ static inline void Abc_TtIthVar( word * pOut, int iVar, int nVars ) ...@@ -443,6 +443,108 @@ static inline void Abc_TtIthVar( word * pOut, int iVar, int nVars )
/**Function************************************************************* /**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Abc_TtIsAndCompl( word * pOut, int fCompl, word * pIn1, int fCompl1, word * pIn2, int fCompl2, word * pCare, int nWords )
{
int w;
if ( fCompl )
{
if ( fCompl1 )
{
if ( fCompl2 )
{
for ( w = 0; w < nWords; w++ )
if ( (~pOut[w] & pCare[w]) != (~pIn1[w] & ~pIn2[w] & pCare[w]) )
return 0;
}
else
{
for ( w = 0; w < nWords; w++ )
if ( (~pOut[w] & pCare[w]) != (~pIn1[w] & pIn2[w] & pCare[w]) )
return 0;
}
}
else
{
if ( fCompl2 )
{
for ( w = 0; w < nWords; w++ )
if ( (~pOut[w] & pCare[w]) != (pIn1[w] & ~pIn2[w] & pCare[w]) )
return 0;
}
else
{
for ( w = 0; w < nWords; w++ )
if ( (~pOut[w] & pCare[w]) != (pIn1[w] & pIn2[w] & pCare[w]) )
return 0;
}
}
}
else
{
if ( fCompl1 )
{
if ( fCompl2 )
{
for ( w = 0; w < nWords; w++ )
if ( (pOut[w] & pCare[w]) != (~pIn1[w] & ~pIn2[w] & pCare[w]) )
return 0;
}
else
{
for ( w = 0; w < nWords; w++ )
if ( (pOut[w] & pCare[w]) != (~pIn1[w] & pIn2[w] & pCare[w]) )
return 0;
}
}
else
{
if ( fCompl2 )
{
for ( w = 0; w < nWords; w++ )
if ( (pOut[w] & pCare[w]) != (pIn1[w] & ~pIn2[w] & pCare[w]) )
return 0;
}
else
{
for ( w = 0; w < nWords; w++ )
if ( (pOut[w] & pCare[w]) != (pIn1[w] & pIn2[w] & pCare[w]) )
return 0;
}
}
}
return 1;
}
static inline int Abc_TtIsXorCompl( word * pOut, int fCompl, word * pIn1, word * pIn2, word * pCare, int nWords )
{
int w;
if ( fCompl )
{
for ( w = 0; w < nWords; w++ )
if ( (~pOut[w] & pCare[w]) != ((pIn1[w] ^ pIn2[w]) & pCare[w]) )
return 0;
}
else
{
for ( w = 0; w < nWords; w++ )
if ( ( pOut[w] & pCare[w]) != ((pIn1[w] ^ pIn2[w]) & pCare[w]) )
return 0;
}
return 1;
}
/**Function*************************************************************
Synopsis [Compares Cof0 and Cof1.] Synopsis [Compares Cof0 and Cof1.]
Description [] Description []
......
...@@ -68,6 +68,8 @@ struct Vec_Wec_t_ ...@@ -68,6 +68,8 @@ struct Vec_Wec_t_
for ( i = LevelStart-1; (i >= LevelStop) && (((vVec) = Vec_WecEntry(vGlob, i)), 1); i-- ) for ( i = LevelStart-1; (i >= LevelStop) && (((vVec) = Vec_WecEntry(vGlob, i)), 1); i-- )
#define Vec_WecForEachLevelTwo( vGlob1, vGlob2, vVec1, vVec2, i ) \ #define Vec_WecForEachLevelTwo( vGlob1, vGlob2, vVec1, vVec2, i ) \
for ( i = 0; (i < Vec_WecSize(vGlob1)) && (((vVec1) = Vec_WecEntry(vGlob1, i)), 1) && (((vVec2) = Vec_WecEntry(vGlob2, i)), 1); i++ ) for ( i = 0; (i < Vec_WecSize(vGlob1)) && (((vVec1) = Vec_WecEntry(vGlob1, i)), 1) && (((vVec2) = Vec_WecEntry(vGlob2, i)), 1); i++ )
#define Vec_WecForEachLevelDouble( vGlob, vVec1, vVec2, i ) \
for ( i = 0; (i < Vec_WecSize(vGlob)) && (((vVec1) = Vec_WecEntry(vGlob, i)), 1) && (((vVec2) = Vec_WecEntry(vGlob, i+1)), 1); i += 2 )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
...@@ -247,6 +249,9 @@ static inline int Vec_WecSizeUsedLimits( Vec_Wec_t * p, int iStart, int iStop ) ...@@ -247,6 +249,9 @@ static inline int Vec_WecSizeUsedLimits( Vec_Wec_t * p, int iStart, int iStop )
***********************************************************************/ ***********************************************************************/
static inline void Vec_WecShrink( Vec_Wec_t * p, int nSizeNew ) static inline void Vec_WecShrink( Vec_Wec_t * p, int nSizeNew )
{ {
Vec_Int_t * vVec; int i;
Vec_WecForEachLevelStart( p, vVec, i, nSizeNew )
Vec_IntShrink( vVec, 0 );
assert( p->nSize >= nSizeNew ); assert( p->nSize >= nSizeNew );
p->nSize = nSizeNew; p->nSize = nSizeNew;
} }
......
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