Commit df6d5090 by Alan Mishchenko

Sequential cleanup with symbolic/ternary simulation.

parent 3469b605
...@@ -349,11 +349,21 @@ static inline int Saig_MvAnd( Saig_MvMan_t * p, int iFan0, int iFan1, int fFirst ...@@ -349,11 +349,21 @@ static inline int Saig_MvAnd( Saig_MvMan_t * p, int iFan0, int iFan1, int fFirst
iFan1 = Temp; iFan1 = Temp;
} }
{ {
int * pPlace; int * pPlace;
pPlace = Saig_MvTableFind( p, iFan0, iFan1 ); pPlace = Saig_MvTableFind( p, iFan0, iFan1 );
if ( *pPlace == 0 ) if ( *pPlace == 0 )
*pPlace = Saig_MvCreateObj( p, iFan0, iFan1 ); {
return Saig_MvVar2Lit( *pPlace ); if ( pPlace >= (int*)p->pAigNew && pPlace < (int*)(p->pAigNew + p->nObjsAlloc) )
{
int iPlace = pPlace - (int*)p->pAigNew;
int iNode = Saig_MvCreateObj( p, iFan0, iFan1 );
((int*)p->pAigNew)[iPlace] = iNode;
return Saig_MvVar2Lit( iNode );
}
else
*pPlace = Saig_MvCreateObj( p, iFan0, iFan1 );
}
return Saig_MvVar2Lit( *pPlace );
} }
} }
...@@ -637,11 +647,11 @@ Vec_Int_t * Saig_MvManFindXFlops( Saig_MvMan_t * p ) ...@@ -637,11 +647,11 @@ Vec_Int_t * Saig_MvManFindXFlops( Saig_MvMan_t * p )
unsigned * pState; unsigned * pState;
int i, k; int i, k;
vXFlops = Vec_IntStart( p->nFlops ); vXFlops = Vec_IntStart( p->nFlops );
Vec_PtrForEachEntry( unsigned *, p->vStates, pState, i ) Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, i, 1 )
{ {
for ( k = 1; k <= p->nFlops; k++ ) for ( k = 0; k < p->nFlops; k++ )
if ( Saig_MvIsUndef(pState[k]) ) if ( Saig_MvIsUndef(pState[k+1]) )
Vec_IntWriteEntry( vXFlops, k-1, 1 ); Vec_IntWriteEntry( vXFlops, k, 1 );
} }
return vXFlops; return vXFlops;
} }
...@@ -657,24 +667,24 @@ Vec_Int_t * Saig_MvManFindXFlops( Saig_MvMan_t * p ) ...@@ -657,24 +667,24 @@ Vec_Int_t * Saig_MvManFindXFlops( Saig_MvMan_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Vec_Ptr_t * Saig_MvManDeriveMap( Saig_MvMan_t * p ) Vec_Ptr_t * Saig_MvManDeriveMap( Saig_MvMan_t * p, int fVerbose )
{ {
Vec_Int_t * vBinValued; Vec_Int_t * vBinValued;
Vec_Ptr_t * vMap = NULL; Vec_Ptr_t * vMap = NULL;
Aig_Obj_t * pObj; Aig_Obj_t * pObj;
unsigned * pState; unsigned * pState;
int i, k, j, fConst0, Counter1 = 0, Counter2 = 0; int i, k, j, FlopK, FlopJ, fConst0, Counter1 = 0, Counter2 = 0;
// prepare CI map // prepare CI map
vMap = Vec_PtrAlloc( Aig_ManPiNum(p->pAig) ); vMap = Vec_PtrAlloc( Aig_ManPiNum(p->pAig) );
Aig_ManForEachPi( p->pAig, pObj, i ) Aig_ManForEachPi( p->pAig, pObj, i )
Vec_PtrPush( vMap, pObj ); Vec_PtrPush( vMap, pObj );
// detect constant flops // detect constant flops
vBinValued = Vec_IntStart( p->nFlops ); vBinValued = Vec_IntAlloc( p->nFlops );
for ( k = 0; k < p->nFlops; k++ ) for ( k = 0; k < p->nFlops; k++ )
{ {
// check if this flop is constant 0 in all states // check if this flop is constant 0 in all states
fConst0 = 1; fConst0 = 1;
Vec_PtrForEachEntry( unsigned *, p->vStates, pState, i ) Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, i, 1 )
{ {
if ( !Saig_MvIsConst0(pState[k+1]) ) if ( !Saig_MvIsConst0(pState[k+1]) )
fConst0 = 0; fConst0 = 0;
...@@ -683,30 +693,34 @@ Vec_Ptr_t * Saig_MvManDeriveMap( Saig_MvMan_t * p ) ...@@ -683,30 +693,34 @@ Vec_Ptr_t * Saig_MvManDeriveMap( Saig_MvMan_t * p )
} }
if ( i < Vec_PtrSize(p->vStates) ) if ( i < Vec_PtrSize(p->vStates) )
continue; continue;
// mark binary values // the flop is binary-valued
Vec_IntWriteEntry( vBinValued, k, 1 ); if ( fConst0 )
// set the constant {
if ( fConst0 ) Vec_PtrWriteEntry( vMap, Saig_ManPiNum(p->pAig) + k, Aig_ManConst0(p->pAig) );
Vec_PtrWriteEntry( vMap, k, Aig_ManConst0(p->pAig) ); Counter1++;
Counter1++; }
else
Vec_IntPush( vBinValued, k );
} }
// detect equivalent (non-ternary flops) // detect equivalent (non-ternary flops)
for ( k = 0; k < p->nFlops; k++ ) Vec_IntForEachEntry( vBinValued, FlopK, k )
if ( Vec_IntEntry(vBinValued, k) ) Vec_IntForEachEntryStart( vBinValued, FlopJ, j, k+1 )
for ( j = k+1; j < p->nFlops; j++ )
if ( Vec_IntEntry(vBinValued, j) )
{ {
// check if they are equal // check if they are equal
Vec_PtrForEachEntry( unsigned *, p->vStates, pState, i ) Vec_PtrForEachEntryStart( unsigned *, p->vStates, pState, i, 1 )
if ( pState[k+1] != pState[j+1] ) if ( pState[FlopK+1] != pState[FlopJ+1] )
break; break;
if ( i < Vec_PtrSize(p->vStates) ) if ( i < Vec_PtrSize(p->vStates) )
continue; continue;
// set the equivalence // set the equivalence
Vec_PtrWriteEntry( vMap, j, Aig_ManPi(p->pAig, k) ); Vec_PtrWriteEntry( vMap, Saig_ManPiNum(p->pAig) + FlopJ, Saig_ManLo(p->pAig, FlopK) );
Counter2++;
} }
printf( "Detected %d const0 flop and %d equivalent non-ternary flops.\n", Counter1, Counter2 ); if ( fVerbose )
printf( "Detected %d const0 flops and %d pairs of equiv binary flops.\n", Counter1, Counter2 );
Vec_IntFree( vBinValued ); Vec_IntFree( vBinValued );
if ( Counter1 == 0 && Counter2 == 0 )
Vec_PtrFreeP( &vMap );
return vMap; return vMap;
} }
...@@ -743,11 +757,14 @@ ABC_PRT( "Constructing the problem", clock() - clk ); ...@@ -743,11 +757,14 @@ ABC_PRT( "Constructing the problem", clock() - clk );
// simulate until convergence // simulate until convergence
clk = clock(); clk = clock();
for ( f = 0; ; f++ ) for ( f = 0; ; f++ )
{ {
// retired some flops // retire some flops
if ( p->vXFlops ) if ( p->vXFlops )
{
Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i ) Vec_PtrForEachEntry( Saig_MvObj_t *, p->vFlops, pEntry, i )
pEntry->Value = SAIG_UNDEF_VALUE; if ( Vec_IntEntry( p->vXFlops, i ) )
pEntry->Value = SAIG_UNDEF_VALUE;
}
// simulate timeframe // simulate timeframe
Saig_MvSimulateFrame( p, (int)(f < nFramesSymb), fVerbose ); Saig_MvSimulateFrame( p, (int)(f < nFramesSymb), fVerbose );
// save and print state // save and print state
...@@ -756,22 +773,25 @@ ABC_PRT( "Constructing the problem", clock() - clk ); ...@@ -756,22 +773,25 @@ ABC_PRT( "Constructing the problem", clock() - clk );
Saig_MvPrintState( f+1, p ); Saig_MvPrintState( f+1, p );
if ( iState >= 0 ) if ( iState >= 0 )
{ {
if ( fVerbose )
printf( "Converged after %d frames with lasso in state %d. Cycle = %d.\n", f+1, iState-1, f+2-iState ); printf( "Converged after %d frames with lasso in state %d. Cycle = %d.\n", f+1, iState-1, f+2-iState );
printf( "Total number of PIs = %d. AND nodes = %d.\n", p->nPis, p->nObjs - p->nPis ); // printf( "Total number of PIs = %d. AND nodes = %d.\n", p->nPis, p->nObjs - p->nPis );
break; break;
} }
if ( f == nFramesSatur ) if ( f == nFramesSatur )
{ {
if ( fVerbose )
printf( "Begining to saturate simulation after %d frames\n", f+1 ); printf( "Begining to saturate simulation after %d frames\n", f+1 );
// find all flops that have at least one X value in the past and set them to X forever // find all flops that have at least one X value in the past and set them to X forever
p->vXFlops = Saig_MvManFindXFlops( p ); p->vXFlops = Saig_MvManFindXFlops( p );
} }
} }
// printf( "Coverged after %d frames.\n", f );
if ( fVerbose ) if ( fVerbose )
ABC_PRT( "Multi-valued simulation", clock() - clk ); ABC_PRT( "Multi-valued simulation", clock() - clk );
// implement equivalences // implement equivalences
// Saig_MvManPostProcess( p, iState-1 ); // Saig_MvManPostProcess( p, iState-1 );
vMap = Saig_MvManDeriveMap( p ); vMap = Saig_MvManDeriveMap( p, fVerbose );
Saig_MvManStop( p ); Saig_MvManStop( p );
// return Aig_ManDupSimple( pAig ); // return Aig_ManDupSimple( pAig );
return vMap; return vMap;
......
...@@ -15482,14 +15482,14 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -15482,14 +15482,14 @@ int Abc_CommandSeqCleanup( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk, * pNtkRes; Abc_Ntk_t * pNtk, * pNtkRes;
int c; int c;
int fLatchConst = 1; int fLatchConst = 1;
int fLatchEqual = 1; int fLatchEqual = 1;
int fSaveNames = 0; int fSaveNames = 1;
int fUseMvSweep = 0; int fUseMvSweep = 0;
int nFramesSymb = 1; int nFramesSymb = 1;
int nFramesSatur = 32; int nFramesSatur = 512;
int fVerbose = 0; int fVerbose = 0;
int fVeryVerbose = 0; int fVeryVerbose = 0;
extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose ); extern Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchEqual, int fSaveNames, int fUseMvSweep, int nFramesSymb, int nFramesSatur, int fVerbose, int fVeryVerbose );
pNtk = Abc_FrameReadNtk(pAbc); pNtk = Abc_FrameReadNtk(pAbc);
......
...@@ -2603,7 +2603,7 @@ Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchE ...@@ -2603,7 +2603,7 @@ Abc_Ntk_t * Abc_NtkDarLatchSweep( Abc_Ntk_t * pNtk, int fLatchConst, int fLatchE
{ {
Aig_ManSeqCleanup( pMan ); Aig_ManSeqCleanup( pMan );
if ( fLatchConst && pMan->nRegs ) if ( fLatchConst && pMan->nRegs )
pMan = Aig_ManConstReduce( pMan, 0, -1, -1, fVerbose, fVeryVerbose ); pMan = Aig_ManConstReduce( pMan, fUseMvSweep, nFramesSymb, nFramesSatur, fVerbose, fVeryVerbose );
if ( fLatchEqual && pMan->nRegs ) if ( fLatchEqual && pMan->nRegs )
pMan = Aig_ManReduceLaches( pMan, fVerbose ); pMan = Aig_ManReduceLaches( pMan, fVerbose );
} }
......
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