Commit 12578e62 by Alan Mishchenko

Version abc70127

parent 1c26e2d2
...@@ -278,6 +278,10 @@ SOURCE=.\src\base\abci\abcNtbdd.c ...@@ -278,6 +278,10 @@ SOURCE=.\src\base\abci\abcNtbdd.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\base\abci\abcOdc.c
# End Source File
# Begin Source File
SOURCE=.\src\base\abci\abcOrder.c SOURCE=.\src\base\abci\abcOrder.c
# End Source File # End Source File
# Begin Source File # Begin Source File
...@@ -1670,6 +1674,10 @@ SOURCE=.\src\opt\res\resFilter.c ...@@ -1670,6 +1674,10 @@ SOURCE=.\src\opt\res\resFilter.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\res\resInt.h
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resSat.c SOURCE=.\src\opt\res\resSat.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -237,7 +237,8 @@ static inline int Abc_TruthWordNum( int nVars ) { return nV ...@@ -237,7 +237,8 @@ static inline int Abc_TruthWordNum( int nVars ) { return nV
static inline int Abc_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; } static inline int Abc_InfoHasBit( unsigned * p, int i ) { return (p[(i)>>5] & (1<<((i) & 31))) > 0; }
static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); } static inline void Abc_InfoSetBit( unsigned * p, int i ) { p[(i)>>5] |= (1<<((i) & 31)); }
static inline void Abc_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); } static inline void Abc_InfoXorBit( unsigned * p, int i ) { p[(i)>>5] ^= (1<<((i) & 31)); }
static inline unsigned Abc_InfoRandom() { return ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand())); } // #define RAND_MAX 0x7fff static inline unsigned Abc_InfoRandomWord() { return ((((unsigned)rand()) << 24) ^ (((unsigned)rand()) << 12) ^ ((unsigned)rand())); } // #define RAND_MAX 0x7fff
static inline void Abc_InfoRandom( unsigned * p, int nWords ) { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] = Abc_InfoRandomWord(); }
static inline void Abc_InfoClear( unsigned * p, int nWords ) { memset( p, 0, sizeof(unsigned) * nWords ); } static inline void Abc_InfoClear( unsigned * p, int nWords ) { memset( p, 0, sizeof(unsigned) * nWords ); }
static inline void Abc_InfoFill( unsigned * p, int nWords ) { memset( p, 0xff, sizeof(unsigned) * nWords );} static inline void Abc_InfoFill( unsigned * p, int nWords ) { memset( p, 0xff, sizeof(unsigned) * nWords );}
static inline void Abc_InfoNot( unsigned * p, int nWords ) { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] = ~p[i]; } static inline void Abc_InfoNot( unsigned * p, int nWords ) { int i; for ( i = nWords - 1; i >= 0; i-- ) p[i] = ~p[i]; }
......
...@@ -1450,6 +1450,100 @@ void Abc_NtkTransferCopy( Abc_Ntk_t * pNtk ) ...@@ -1450,6 +1450,100 @@ void Abc_NtkTransferCopy( Abc_Ntk_t * pNtk )
pObj->pCopy = pObj->pCopy? Abc_ObjEquiv(pObj->pCopy) : NULL; pObj->pCopy = pObj->pCopy? Abc_ObjEquiv(pObj->pCopy) : NULL;
} }
/**Function*************************************************************
Synopsis [Increaments the cut counter.]
Description [Returns 1 if it becomes equal to the ref counter.]
SideEffects []
SeeAlso []
***********************************************************************/
static inline int Abc_ObjCrossCutInc( Abc_Obj_t * pObj )
{
pObj->pCopy = (void *)(((int)pObj->pCopy)++);
return (int)pObj->pCopy == Abc_ObjFanoutNum(pObj);
}
/**Function*************************************************************
Synopsis [Computes cross-cut of the circuit.]
Description [Returns 1 if it is the last visit to the node.]
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_NtkCrossCut_rec( Abc_Obj_t * pObj, int * pnCutSize, int * pnCutSizeMax )
{
Abc_Obj_t * pFanin;
int i, nDecrem = 0;
int fReverse = 0;
if ( Abc_ObjIsCi(pObj) )
return 0;
// if visited, increment visit counter
if ( Abc_NodeIsTravIdCurrent( pObj ) )
return Abc_ObjCrossCutInc( pObj );
Abc_NodeSetTravIdCurrent( pObj );
// visit the fanins
if ( !Abc_ObjIsCi(pObj) )
{
if ( fReverse )
{
Abc_ObjForEachFanin( pObj, pFanin, i )
{
pFanin = Abc_ObjFanin( pObj, Abc_ObjFaninNum(pObj) - 1 - i );
nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
}
}
else
{
Abc_ObjForEachFanin( pObj, pFanin, i )
nDecrem += Abc_NtkCrossCut_rec( pFanin, pnCutSize, pnCutSizeMax );
}
}
// count the node
(*pnCutSize)++;
if ( *pnCutSizeMax < *pnCutSize )
*pnCutSizeMax = *pnCutSize;
(*pnCutSize) -= nDecrem;
return Abc_ObjCrossCutInc( pObj );
}
/**Function*************************************************************
Synopsis [Computes cross-cut of the circuit.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_NtkCrossCut( Abc_Ntk_t * pNtk )
{
Abc_Obj_t * pObj;
int nCutSize = 0, nCutSizeMax = 0;
int i;
Abc_NtkCleanCopy( pNtk );
Abc_NtkIncrementTravId( pNtk );
Abc_NtkForEachCo( pNtk, pObj, i )
{
Abc_NtkCrossCut_rec( pObj, &nCutSize, &nCutSizeMax );
nCutSize--;
}
assert( nCutSize == 0 );
printf( "Max cross cut size = %6d. Ratio = %6.2f %%\n", nCutSizeMax, 100.0 * nCutSizeMax/Abc_NtkObjNum(pNtk) );
return nCutSizeMax;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -2999,10 +2999,12 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2999,10 +2999,12 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
int nCutsMax; int nCutsMax;
int nNodesMax; int nNodesMax;
int nLevelsOdc;
bool fUpdateLevel; bool fUpdateLevel;
bool fUseZeros; bool fUseZeros;
bool fVerbose; bool fVerbose;
extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, bool fUpdateLevel, bool fVerbose ); bool fVeryVerbose;
extern int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutsMax, int nNodesMax, int nLevelsOdc, bool fUpdateLevel, bool fVerbose, bool fVeryVerbose );
pNtk = Abc_FrameReadNtk(pAbc); pNtk = Abc_FrameReadNtk(pAbc);
pOut = Abc_FrameReadOut(pAbc); pOut = Abc_FrameReadOut(pAbc);
...@@ -3011,11 +3013,13 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3011,11 +3013,13 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults // set defaults
nCutsMax = 8; nCutsMax = 8;
nNodesMax = 1; nNodesMax = 1;
nLevelsOdc = 0;
fUpdateLevel = 1; fUpdateLevel = 1;
fUseZeros = 0; fUseZeros = 0;
fVerbose = 0; fVerbose = 0;
fVeryVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KNlzvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KNFlzvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -3041,6 +3045,17 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3041,6 +3045,17 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nNodesMax < 0 ) if ( nNodesMax < 0 )
goto usage; goto usage;
break; break;
case 'F':
if ( globalUtilOptind >= argc )
{
fprintf( pErr, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nLevelsOdc = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nLevelsOdc < 0 )
goto usage;
break;
case 'l': case 'l':
fUpdateLevel ^= 1; fUpdateLevel ^= 1;
break; break;
...@@ -3050,6 +3065,9 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3050,6 +3065,9 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'v': case 'v':
fVerbose ^= 1; fVerbose ^= 1;
break; break;
case 'w':
fVeryVerbose ^= 1;
break;
case 'h': case 'h':
goto usage; goto usage;
default: default:
...@@ -3064,7 +3082,12 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3064,7 +3082,12 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX ) if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
{ {
fprintf( pErr, "Can only compute the cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX ); fprintf( pErr, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
return 1;
}
if ( nNodesMax < 0 || nNodesMax > 3 )
{
fprintf( pErr, "Can only resubstitute at most 3 nodes.\n" );
return 1; return 1;
} }
if ( !Abc_NtkIsStrash(pNtk) ) if ( !Abc_NtkIsStrash(pNtk) )
...@@ -3079,7 +3102,7 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3079,7 +3102,7 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// modify the current network // modify the current network
if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, fUpdateLevel, fVerbose ) ) if ( !Abc_NtkResubstitute( pNtk, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose ) )
{ {
fprintf( pErr, "Refactoring has failed.\n" ); fprintf( pErr, "Refactoring has failed.\n" );
return 1; return 1;
...@@ -3087,13 +3110,15 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3087,13 +3110,15 @@ int Abc_CommandResubstitute( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: resub [-K num] [-N num] [-lzvh]\n" ); fprintf( pErr, "usage: resub [-K num] [-N num] [-F num] [-lzvwh]\n" );
fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" ); fprintf( pErr, "\t performs technology-independent restructuring of the AIG\n" );
fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax ); fprintf( pErr, "\t-K num : the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
fprintf( pErr, "\t-N num : the max number of nodes to add [default = %d]\n", nNodesMax ); fprintf( pErr, "\t-N num : the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
fprintf( pErr, "\t-F num : the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" ); fprintf( pErr, "\t-l : toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" ); fprintf( pErr, "\t-z : toggle using zero-cost replacements [default = %s]\n", fUseZeros? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
fprintf( pErr, "\t-w : toggle verbose printout of ODC computation [default = %s]\n", fVeryVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
return 1; return 1;
} }
......
...@@ -111,6 +111,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored ) ...@@ -111,6 +111,7 @@ void Abc_NtkPrintStats( FILE * pFile, Abc_Ntk_t * pNtk, int fFactored )
fprintf( pFile, "\n" ); fprintf( pFile, "\n" );
// Abc_NtkCrossCut( pNtk );
// print the statistic into a file // print the statistic into a file
/* /*
......
...@@ -24,6 +24,7 @@ SRC += src/base/abci/abc.c \ ...@@ -24,6 +24,7 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcMiter.c \ src/base/abci/abcMiter.c \
src/base/abci/abcMulti.c \ src/base/abci/abcMulti.c \
src/base/abci/abcNtbdd.c \ src/base/abci/abcNtbdd.c \
src/base/abci/abcOdc.c \
src/base/abci/abcOrder.c \ src/base/abci/abcOrder.c \
src/base/abci/abcPrint.c \ src/base/abci/abcPrint.c \
src/base/abci/abcProve.c \ src/base/abci/abcProve.c \
......
...@@ -200,8 +200,11 @@ p->timeAig += clock() - clk; ...@@ -200,8 +200,11 @@ p->timeAig += clock() - clk;
if ( p->pPars->fVeryVerbose ) if ( p->pPars->fVeryVerbose )
{ {
printf( "%5d : ", pObj->Id ); printf( "%5d (lev=%2d) : ", pObj->Id, pObj->Level );
printf( "Win = %3d/%4d/%3d ", Vec_PtrSize(p->pWin->vLeaves), Vec_VecSizeSize(p->pWin->vLevels), Vec_PtrSize(p->pWin->vRoots) ); printf( "Win = %3d/%3d/%4d/%3d ",
Vec_PtrSize(p->pWin->vLeaves) - p->pWin->nLeavesPlus,
p->pWin->nLeavesPlus, Vec_VecSizeSize(p->pWin->vLevels),
Vec_PtrSize(p->pWin->vRoots) );
printf( "D = %3d ", Vec_PtrSize(p->pWin->vDivs) ); printf( "D = %3d ", Vec_PtrSize(p->pWin->vDivs) );
printf( "D+ = %3d ", p->pWin->nDivsPlus ); printf( "D+ = %3d ", p->pWin->nDivsPlus );
printf( "AIG = %4d ", Abc_NtkNodeNum(p->pAig) ); printf( "AIG = %4d ", Abc_NtkNodeNum(p->pAig) );
...@@ -242,12 +245,13 @@ p->timeSat += clock() - clk; ...@@ -242,12 +245,13 @@ p->timeSat += clock() - clk;
// printf( " Sat\n" ); // printf( " Sat\n" );
continue; continue;
} }
p->nProvedSets++;
// printf( " Unsat\n" ); // printf( " Unsat\n" );
continue;
// write it into a file // write it into a file
// Sto_ManDumpClauses( p->pCnf, "trace.cnf" ); // Sto_ManDumpClauses( p->pCnf, "trace.cnf" );
p->nProvedSets++;
// interplate the problem if it was UNSAT // interplate the problem if it was UNSAT
clk = clock(); clk = clock();
......
...@@ -60,6 +60,8 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax ) ...@@ -60,6 +60,8 @@ void Res_WinDivisors( Res_Win_t * p, int nLevDivMax )
// mark the MFFC of the node (does not increment trav ID) // mark the MFFC of the node (does not increment trav ID)
Res_WinVisitMffc( p ); Res_WinVisitMffc( p );
// what about the fanouts of the leaves!!!
// go through all the legal levels and check if their fanouts can be divisors // go through all the legal levels and check if their fanouts can be divisors
p->nDivsPlus = 0; p->nDivsPlus = 0;
Vec_VecForEachEntryStartStop( p->vLevels, pObj, i, k, 0, p->nLevDivMax - 1 ) Vec_VecForEachEntryStartStop( p->vLevels, pObj, i, k, 0, p->nLevDivMax - 1 )
......
...@@ -48,6 +48,7 @@ struct Res_Win_t_ ...@@ -48,6 +48,7 @@ struct Res_Win_t_
int nLevLeaves; // the level where leaves begin int nLevLeaves; // the level where leaves begin
int nLevDivMax; // the maximum divisor level int nLevDivMax; // the maximum divisor level
int nDivsPlus; // the number of additional divisors int nDivsPlus; // the number of additional divisors
int nLeavesPlus;// the number of additional leaves
Abc_Obj_t * pNode; // the node in the center Abc_Obj_t * pNode; // the node in the center
// the window data // the window data
Vec_Vec_t * vLevels; // nodes by level Vec_Vec_t * vLevels; // nodes by level
......
...@@ -141,12 +141,11 @@ void Res_SimSetRandom( Res_Sim_t * p ) ...@@ -141,12 +141,11 @@ void Res_SimSetRandom( Res_Sim_t * p )
{ {
Abc_Obj_t * pObj; Abc_Obj_t * pObj;
unsigned * pInfo; unsigned * pInfo;
int i, w; int i;
Abc_NtkForEachPi( p->pAig, pObj, i ) Abc_NtkForEachPi( p->pAig, pObj, i )
{ {
pInfo = Vec_PtrEntry( p->vPats, pObj->Id ); pInfo = Vec_PtrEntry( p->vPats, pObj->Id );
for ( w = 0; w < p->nWords; w++ ) Abc_InfoRandom( pInfo, p->nWords );
pInfo[w] = Abc_InfoRandom();
} }
} }
...@@ -478,7 +477,7 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig ) ...@@ -478,7 +477,7 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig )
// prepare the manager // prepare the manager
Res_SimAdjust( p, pAig ); Res_SimAdjust( p, pAig );
// collect 0/1 simulation info // collect 0/1 simulation info
for ( Limit = 0; Limit < 100; Limit++ ) for ( Limit = 0; Limit < 10; Limit++ )
{ {
Res_SimSetRandom( p ); Res_SimSetRandom( p );
Res_SimPerformRound( p ); Res_SimPerformRound( p );
...@@ -489,10 +488,14 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig ) ...@@ -489,10 +488,14 @@ int Res_SimPrepare( Res_Sim_t * p, Abc_Ntk_t * pAig )
} }
// printf( "%d ", Limit ); // printf( "%d ", Limit );
// report the last set of patterns // report the last set of patterns
// Res_SimReportOne( p ); Res_SimReportOne( p );
printf( "\n" );
// quit if there is not enough // quit if there is not enough
if ( p->nPats0 < 4 || p->nPats1 < 4 ) if ( p->nPats0 < 4 || p->nPats1 < 4 )
{
// Res_SimReportOne( p );
return 0; return 0;
}
// create bit-matrix info // create bit-matrix info
if ( p->nPats0 < p->nPats ) if ( p->nPats0 < p->nPats )
Res_SimPadSimInfo( p->vPats0, p->nPats0, p->nWords ); Res_SimPadSimInfo( p->vPats0, p->nPats0, p->nWords );
......
...@@ -243,6 +243,7 @@ void Res_WinAddMissing_rec( Res_Win_t * p, Abc_Obj_t * pObj ) ...@@ -243,6 +243,7 @@ void Res_WinAddMissing_rec( Res_Win_t * p, Abc_Obj_t * pObj )
return; return;
if ( !Abc_NodeIsTravIdCurrent(pObj) || (int)pObj->Level <= p->nLevLeaves ) if ( !Abc_NodeIsTravIdCurrent(pObj) || (int)pObj->Level <= p->nLevLeaves )
{ {
p->nLeavesPlus++;
Vec_PtrPush( p->vLeaves, pObj ); Vec_PtrPush( p->vLeaves, pObj );
pObj->fMarkA = 1; pObj->fMarkA = 1;
return; return;
...@@ -349,6 +350,7 @@ int Res_WinCompute( Abc_Obj_t * pNode, int nWinTfiMax, int nWinTfoMax, Res_Win_t ...@@ -349,6 +350,7 @@ int Res_WinCompute( Abc_Obj_t * pNode, int nWinTfiMax, int nWinTfoMax, Res_Win_t
p->pNode = pNode; p->pNode = pNode;
p->nWinTfiMax = nWinTfiMax; p->nWinTfiMax = nWinTfiMax;
p->nWinTfoMax = nWinTfoMax; p->nWinTfoMax = nWinTfoMax;
p->nLeavesPlus = 0;
p->nLevLeaves = ABC_MAX( 0, ((int)p->pNode->Level) - p->nWinTfiMax - 1 ); p->nLevLeaves = ABC_MAX( 0, ((int)p->pNode->Level) - p->nWinTfiMax - 1 );
// collect the nodes in TFI cone of pNode above the level of leaves (p->nLevLeaves) // collect the nodes in TFI cone of pNode above the level of leaves (p->nLevLeaves)
Res_WinCollectNodeTfi( p ); Res_WinCollectNodeTfi( p );
......
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