Commit 39bc4842 by Alan Mishchenko

Version abc70706

parent 0c1e87bc
...@@ -1902,10 +1902,6 @@ SOURCE=.\src\opt\res\resStrash.c ...@@ -1902,10 +1902,6 @@ SOURCE=.\src\opt\res\resStrash.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\res\resUpdate.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\res\resWin.c SOURCE=.\src\opt\res\resWin.c
# End Source File # End Source File
# End Group # End Group
......
...@@ -143,14 +143,6 @@ alias qsA "qvar -I 96 -u; qvar -I 97 -u; qvar -I 98 -u; qvar -I 99 -u; qvar ...@@ -143,14 +143,6 @@ alias qsA "qvar -I 96 -u; qvar -I 97 -u; qvar -I 98 -u; qvar -I 99 -u; qvar
alias chnew "st; haig_start; resyn2; haig_use" alias chnew "st; haig_start; resyn2; haig_use"
alias chnewrs "st; haig_start; resyn2rs; haig_use" alias chnewrs "st; haig_start; resyn2rs; haig_use"
alias t0 "read_dsd a*(b+(c*d)+e); clp -r; print_dsd"
alias t1 "read_dsd a*(b+(c*d)); clp -r; print_dsd"
alias t2 "read_dsd 56BA(a,b,c,d); clp -r; print_dsd"
alias t3 "read_dsd 56BA(a,b*c,e,d); clp -r; print_dsd"
alias t4 "read_dsd 56BA(a,b*c,e+d,f); clp -r; print_dsd"
alias t5 "read_dsd 56BA(a,CA(b,c,d),e,f); clp -r; print_dsd"
alias t6 "read_dsd f*CA(b,c,d)*CA(e,a,g); clp -r; print_dsd"
alias stdsd "r test/6in.blif; st; ps; u; bdd; dsd -g; st; ps" alias stdsd "r test/6in.blif; st; ps; u; bdd; dsd -g; st; ps"
alias trec "rec_start; r c.blif; st; rec_add; rec_use" alias trec "rec_start; r c.blif; st; rec_add; rec_use"
alias trec4 "rec_start -K 4; r i10.blif; st; rec_add; rec_use" alias trec4 "rec_start -K 4; r i10.blif; st; rec_add; rec_use"
...@@ -166,12 +158,10 @@ alias tst4 "r i10_if4.blif; st; ps; r x/rec4_.blif; st; rec_start; r i10_if4 ...@@ -166,12 +158,10 @@ alias tst4 "r i10_if4.blif; st; ps; r x/rec4_.blif; st; rec_start; r i10_if4
alias tst4n "r i10_if4.blif; st; ps; r 5npn/all_functions.aig; st; rec_start; r i10_if4.blif; st -r; ps; cec" alias tst4n "r i10_if4.blif; st; ps; r 5npn/all_functions.aig; st; rec_start; r i10_if4.blif; st -r; ps; cec"
alias tst6 "r i10_if6.blif; st; ps; r x/rec6_16_.blif; st; rec_start; r i10_if6.blif; st -r; ps; cec" alias tst6 "r i10_if6.blif; st; ps; r x/rec6_16_.blif; st; rec_start; r i10_if6.blif; st -r; ps; cec"
alias bug "r pj1_if3.blif; lp"
alias table "r lutexp.baf; test"
#alias t "r c.blif; st; wc c.cnf" #alias t "r c.blif; st; wc c.cnf"
#alias t "r test/dsdmap6.blif; lutpack -vw; cec" #alias t "r test/dsdmap6.blif; lutpack -vw; cec"
alias t "r i10_if4.blif; lp" alias t "r i10_if4.blif; lp"
alias t1 "r pj1_if4.blif; lp"
alias t2 "r pj1_if6.blif; lp"
...@@ -354,6 +354,7 @@ static inline Hop_Obj_t * Abc_ObjEquiv( Abc_Obj_t * pObj ) { return pO ...@@ -354,6 +354,7 @@ static inline Hop_Obj_t * Abc_ObjEquiv( Abc_Obj_t * pObj ) { return pO
static inline Abc_Obj_t * Abc_ObjCopyCond( Abc_Obj_t * pObj ) { return Abc_ObjRegular(pObj)->pCopy? Abc_ObjNotCond(Abc_ObjRegular(pObj)->pCopy, Abc_ObjIsComplement(pObj)) : NULL; } static inline Abc_Obj_t * Abc_ObjCopyCond( Abc_Obj_t * pObj ) { return Abc_ObjRegular(pObj)->pCopy? Abc_ObjNotCond(Abc_ObjRegular(pObj)->pCopy, Abc_ObjIsComplement(pObj)) : NULL; }
// setting data members of the network // setting data members of the network
static inline void Abc_ObjSetLevel( Abc_Obj_t * pObj, int Level ) { pObj->Level = Level; }
static inline void Abc_ObjSetCopy( Abc_Obj_t * pObj, Abc_Obj_t * pCopy ) { pObj->pCopy = pCopy; } static inline void Abc_ObjSetCopy( Abc_Obj_t * pObj, Abc_Obj_t * pCopy ) { pObj->pCopy = pCopy; }
static inline void Abc_ObjSetData( Abc_Obj_t * pObj, void * pData ) { pObj->pData = pData; } static inline void Abc_ObjSetData( Abc_Obj_t * pObj, void * pData ) { pObj->pData = pData; }
...@@ -852,11 +853,16 @@ extern void Abc_NtkSetNodeLevelsArrival( Abc_Ntk_t * pNtk ); ...@@ -852,11 +853,16 @@ extern void Abc_NtkSetNodeLevelsArrival( Abc_Ntk_t * pNtk );
extern float * Abc_NtkGetCiArrivalFloats( Abc_Ntk_t * pNtk ); extern float * Abc_NtkGetCiArrivalFloats( Abc_Ntk_t * pNtk );
extern Abc_Time_t * Abc_NtkGetCiArrivalTimes( Abc_Ntk_t * pNtk ); extern Abc_Time_t * Abc_NtkGetCiArrivalTimes( Abc_Ntk_t * pNtk );
extern float Abc_NtkDelayTrace( Abc_Ntk_t * pNtk ); extern float Abc_NtkDelayTrace( Abc_Ntk_t * pNtk );
extern void Abc_NtkStartReverseLevels( Abc_Ntk_t * pNtk ); extern int Abc_ObjLevelNew( Abc_Obj_t * pObj );
extern int Abc_ObjReverseLevelNew( Abc_Obj_t * pObj );
extern int Abc_ObjRequiredLevel( Abc_Obj_t * pObj );
extern int Abc_ObjReverseLevel( Abc_Obj_t * pObj );
extern void Abc_ObjSetReverseLevel( Abc_Obj_t * pObj, int LevelR );
extern void Abc_NtkStartReverseLevels( Abc_Ntk_t * pNtk, int nMaxLevelIncrease );
extern void Abc_NtkStopReverseLevels( Abc_Ntk_t * pNtk ); extern void Abc_NtkStopReverseLevels( Abc_Ntk_t * pNtk );
extern void Abc_NodeSetReverseLevel( Abc_Obj_t * pObj, int LevelR ); extern void Abc_NtkUpdateLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels );
extern int Abc_NodeReadReverseLevel( Abc_Obj_t * pObj ); extern void Abc_NtkUpdateReverseLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels );
extern int Abc_NodeReadRequiredLevel( Abc_Obj_t * pObj ); extern void Abc_NtkUpdate( Abc_Obj_t * pObj, Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels );
/*=== abcUtil.c ==========================================================*/ /*=== abcUtil.c ==========================================================*/
extern void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan ); extern void * Abc_NtkAttrFree( Abc_Ntk_t * pNtk, int Attr, int fFreeMan );
extern void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk ); extern void Abc_NtkIncrementTravId( Abc_Ntk_t * pNtk );
......
...@@ -923,7 +923,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, i ...@@ -923,7 +923,7 @@ void Abc_AigReplace_int( Abc_Aig_t * pMan, Abc_Obj_t * pOld, Abc_Obj_t * pNew, i
{ {
assert( pFanout->fMarkB == 0 ); assert( pFanout->fMarkB == 0 );
pFanout->fMarkB = 1; pFanout->fMarkB = 1;
Vec_VecPush( pMan->vLevelsR, Abc_NodeReadReverseLevel(pFanout), pFanout ); Vec_VecPush( pMan->vLevelsR, Abc_ObjReverseLevel(pFanout), pFanout );
} }
} }
...@@ -1094,7 +1094,7 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan ) ...@@ -1094,7 +1094,7 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan )
if ( pNode == NULL ) if ( pNode == NULL )
continue; continue;
assert( Abc_ObjIsNode(pNode) ); assert( Abc_ObjIsNode(pNode) );
assert( Abc_NodeReadReverseLevel(pNode) == i ); assert( Abc_ObjReverseLevel(pNode) == i );
// clean the mark // clean the mark
assert( pNode->fMarkB == 1 ); assert( pNode->fMarkB == 1 );
pNode->fMarkB = 0; pNode->fMarkB = 0;
...@@ -1106,17 +1106,17 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan ) ...@@ -1106,17 +1106,17 @@ void Abc_AigUpdateLevelR_int( Abc_Aig_t * pMan )
// get the new reverse level of this fanin // get the new reverse level of this fanin
LevelNew = 0; LevelNew = 0;
Abc_ObjForEachFanout( pFanin, pFanout, j ) Abc_ObjForEachFanout( pFanin, pFanout, j )
if ( LevelNew < Abc_NodeReadReverseLevel(pFanout) ) if ( LevelNew < Abc_ObjReverseLevel(pFanout) )
LevelNew = Abc_NodeReadReverseLevel(pFanout); LevelNew = Abc_ObjReverseLevel(pFanout);
LevelNew += 1; LevelNew += 1;
assert( LevelNew > i ); assert( LevelNew > i );
if ( Abc_NodeReadReverseLevel(pFanin) == LevelNew ) // no change if ( Abc_ObjReverseLevel(pFanin) == LevelNew ) // no change
continue; continue;
// if the fanin is present in the data structure, pull it out // if the fanin is present in the data structure, pull it out
if ( pFanin->fMarkB ) if ( pFanin->fMarkB )
Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanin ); Abc_AigRemoveFromLevelStructureR( pMan->vLevelsR, pFanin );
// update the reverse level // update the reverse level
Abc_NodeSetReverseLevel( pFanin, LevelNew ); Abc_ObjSetReverseLevel( pFanin, LevelNew );
// add the fanin to the data structure to update its fanins // add the fanin to the data structure to update its fanins
assert( pFanin->fMarkB == 0 ); assert( pFanin->fMarkB == 0 );
pFanin->fMarkB = 1; pFanin->fMarkB = 1;
...@@ -1173,7 +1173,7 @@ void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode ) ...@@ -1173,7 +1173,7 @@ void Abc_AigRemoveFromLevelStructureR( Vec_Vec_t * vStruct, Abc_Obj_t * pNode )
Abc_Obj_t * pTemp; Abc_Obj_t * pTemp;
int m; int m;
assert( pNode->fMarkB ); assert( pNode->fMarkB );
vVecTemp = Vec_VecEntry( vStruct, Abc_NodeReadReverseLevel(pNode) ); vVecTemp = Vec_VecEntry( vStruct, Abc_ObjReverseLevel(pNode) );
Vec_PtrForEachEntry( vVecTemp, pTemp, m ) Vec_PtrForEachEntry( vVecTemp, pTemp, m )
{ {
if ( pTemp != pNode ) if ( pTemp != pNode )
......
...@@ -447,7 +447,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName ) ...@@ -447,7 +447,7 @@ Abc_Obj_t * Abc_NtkFindNode( Abc_Ntk_t * pNtk, char * pName )
if ( Num >= 0 ) if ( Num >= 0 )
return Abc_NtkObj( pNtk, Num ); return Abc_NtkObj( pNtk, Num );
// find the internal node // find the internal node
if ( pName[0] != '[' || pName[strlen(pName)-1] != ']' ) if ( pName[0] != 'n' )
{ {
printf( "Name \"%s\" is not found among CO or node names (internal names often look as \"n<num>\").\n", pName ); printf( "Name \"%s\" is not found among CO or node names (internal names often look as \"n<num>\").\n", pName );
return NULL; return NULL;
......
...@@ -2805,7 +2805,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2805,7 +2805,7 @@ int Abc_CommandImfs( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults // set defaults
pPars->nWindow = 62; pPars->nWindow = 62;
pPars->nGrowthLevel = 3; pPars->nGrowthLevel = 1;
pPars->nCands = 5; pPars->nCands = 5;
pPars->nSimWords = 4; pPars->nSimWords = 4;
pPars->fArea = 0; pPars->fArea = 0;
...@@ -2936,13 +2936,14 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2936,13 +2936,14 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->nLutsMax = 4; // (N) the maximum number of LUTs in the structure pPars->nLutsMax = 4; // (N) the maximum number of LUTs in the structure
pPars->nLutsOver = 3; // (Q) the maximum number of LUTs not in the MFFC pPars->nLutsOver = 3; // (Q) the maximum number of LUTs not in the MFFC
pPars->nVarsShared = 0; // (S) the maximum number of shared variables (crossbars) pPars->nVarsShared = 0; // (S) the maximum number of shared variables (crossbars)
pPars->nGrowthLevel = 9; // (L) the maximum number of increased levels pPars->nGrowthLevel = 1; // (L) the maximum number of increased levels
pPars->fSatur = 1; pPars->fSatur = 1;
pPars->fZeroCost = 0; pPars->fZeroCost = 0;
pPars->fVerbose = 1; pPars->fFirst = 0;
pPars->fVerbose = 0;
pPars->fVeryVerbose = 0; pPars->fVeryVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "NQSLszfvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -2996,6 +2997,9 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -2996,6 +2997,9 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'z': case 'z':
pPars->fZeroCost ^= 1; pPars->fZeroCost ^= 1;
break; break;
case 'f':
pPars->fFirst ^= 1;
break;
case 'v': case 'v':
pPars->fVerbose ^= 1; pPars->fVerbose ^= 1;
break; break;
...@@ -3029,7 +3033,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -3029,7 +3033,7 @@ int Abc_CommandLutpack( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szvwh]\n" ); fprintf( pErr, "usage: lutpack [-N <num>] [-Q <num>] [-S <num>] [-L <num>] [-szfvwh]\n" );
fprintf( pErr, "\t performs \"rewriting\" for LUT networks\n" ); fprintf( pErr, "\t performs \"rewriting\" for LUT networks\n" );
fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax ); fprintf( pErr, "\t-N <num> : the max number of LUTs in the structure (2 <= num) [default = %d]\n", pPars->nLutsMax );
fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver ); fprintf( pErr, "\t-Q <num> : the max number of LUTs not in MFFC (0 <= num) [default = %d]\n", pPars->nLutsOver );
...@@ -3037,6 +3041,7 @@ usage: ...@@ -3037,6 +3041,7 @@ usage:
fprintf( pErr, "\t-L <num> : the largest increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel ); fprintf( pErr, "\t-L <num> : the largest increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
fprintf( pErr, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" ); fprintf( pErr, "\t-s : toggle iteration till saturation [default = %s]\n", pPars->fSatur? "yes": "no" );
fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" ); fprintf( pErr, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
fprintf( pErr, "\t-f : toggle using only first node and first cut [default = %s]\n", pPars->fFirst? "yes": "no" );
fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", pPars->fVerbose? "yes": "no" );
fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); fprintf( pErr, "\t-w : toggle printout subgraph statistics [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t-h : print the command usage\n");
......
...@@ -55,7 +55,7 @@ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective, ...@@ -55,7 +55,7 @@ Abc_Ntk_t * Abc_NtkBalance( Abc_Ntk_t * pNtk, bool fDuplicate, bool fSelective,
// compute the required times // compute the required times
if ( fSelective ) if ( fSelective )
{ {
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk, 0 );
Abc_NtkMarkCriticalNodes( pNtk ); Abc_NtkMarkCriticalNodes( pNtk );
} }
// perform balancing // perform balancing
...@@ -600,7 +600,7 @@ void Abc_NtkMarkCriticalNodes( Abc_Ntk_t * pNtk ) ...@@ -600,7 +600,7 @@ void Abc_NtkMarkCriticalNodes( Abc_Ntk_t * pNtk )
Abc_Obj_t * pNode; Abc_Obj_t * pNode;
int i, Counter = 0; int i, Counter = 0;
Abc_NtkForEachNode( pNtk, pNode, i ) Abc_NtkForEachNode( pNtk, pNode, i )
if ( Abc_NodeReadRequiredLevel(pNode) - pNode->Level <= 1 ) if ( Abc_ObjRequiredLevel(pNode) - pNode->Level <= 1 )
pNode->fMarkA = 1, Counter++; pNode->fMarkA = 1, Counter++;
printf( "The number of nodes on the critical paths = %6d (%5.2f %%)\n", Counter, 100.0 * Counter / Abc_NtkNodeNum(pNtk) ); printf( "The number of nodes on the critical paths = %6d (%5.2f %%)\n", Counter, 100.0 * Counter / Abc_NtkNodeNum(pNtk) );
} }
......
...@@ -263,10 +263,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t ...@@ -263,10 +263,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
Abc_ObjAddFanin( pNodeNew, Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover) ); Abc_ObjAddFanin( pNodeNew, Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover) );
} }
// set the level of the new node // set the level of the new node
{ pNodeNew->Level = Abc_ObjLevelNew( pNodeNew );
extern int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj );
pNodeNew->Level = Res_UpdateNetworkLevelNew( pNodeNew );
}
// derive the function of this node // derive the function of this node
if ( pIfMan->pPars->fTruth ) if ( pIfMan->pPars->fTruth )
{ {
......
...@@ -100,7 +100,7 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool ...@@ -100,7 +100,7 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nConeSizeMax, bool
pManRef->vLeaves = Abc_NtkManCutReadCutLarge( pManCut ); pManRef->vLeaves = Abc_NtkManCutReadCutLarge( pManCut );
// compute the reverse levels if level update is requested // compute the reverse levels if level update is requested
if ( fUpdateLevel ) if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk, 0 );
// resynthesize each node once // resynthesize each node once
nNodes = Abc_NtkObjNumMax(pNtk); nNodes = Abc_NtkObjNumMax(pNtk);
...@@ -187,7 +187,7 @@ Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * ...@@ -187,7 +187,7 @@ Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t *
char * pSop; char * pSop;
int Required; int Required;
Required = fUpdateLevel? Abc_NodeReadRequiredLevel(pNode) : ABC_INFINITY; Required = fUpdateLevel? Abc_ObjRequiredLevel(pNode) : ABC_INFINITY;
p->nNodesConsidered++; p->nNodesConsidered++;
......
...@@ -114,7 +114,7 @@ int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, bool fUpdateLevel, bool f ...@@ -114,7 +114,7 @@ int Abc_NtkRestructure( Abc_Ntk_t * pNtk, int nCutMax, bool fUpdateLevel, bool f
// compute the reverse levels if level update is requested // compute the reverse levels if level update is requested
if ( fUpdateLevel ) if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk, 0 );
// start the restructuring manager // start the restructuring manager
pManRst = Abc_NtkManRstStart( nCutMax, fUpdateLevel, fUseZeros, fVerbose ); pManRst = Abc_NtkManRstStart( nCutMax, fUpdateLevel, fUseZeros, fVerbose );
...@@ -324,7 +324,7 @@ Dec_Graph_t * Abc_NodeRestructureCut( Abc_ManRst_t * p, Abc_Obj_t * pRoot, Cut_C ...@@ -324,7 +324,7 @@ Dec_Graph_t * Abc_NodeRestructureCut( Abc_ManRst_t * p, Abc_Obj_t * pRoot, Cut_C
p->nCutsConsidered++; p->nCutsConsidered++;
// get the required time for the node // get the required time for the node
Required = p->fUpdateLevel? Abc_NodeReadRequiredLevel(pRoot) : ABC_INFINITY; Required = p->fUpdateLevel? Abc_ObjRequiredLevel(pRoot) : ABC_INFINITY;
// collect the leaves of the cut // collect the leaves of the cut
Vec_PtrClear( p->vLeaves ); Vec_PtrClear( p->vLeaves );
......
...@@ -159,7 +159,7 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLeve ...@@ -159,7 +159,7 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nLeve
// compute the reverse levels if level update is requested // compute the reverse levels if level update is requested
if ( fUpdateLevel ) if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk, 0 );
if ( Abc_NtkLatchNum(pNtk) ) if ( Abc_NtkLatchNum(pNtk) )
Abc_NtkForEachLatch(pNtk, pNode, i) Abc_NtkForEachLatch(pNtk, pNode, i)
...@@ -1617,7 +1617,7 @@ Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t * ...@@ -1617,7 +1617,7 @@ Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t *
int Required; int Required;
int clk; int clk;
Required = fUpdateLevel? Abc_NodeReadRequiredLevel(pRoot) : ABC_INFINITY; Required = fUpdateLevel? Abc_ObjRequiredLevel(pRoot) : ABC_INFINITY;
assert( nSteps >= 0 ); assert( nSteps >= 0 );
assert( nSteps <= 3 ); assert( nSteps <= 3 );
......
...@@ -83,7 +83,7 @@ int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerb ...@@ -83,7 +83,7 @@ int Abc_NtkRewrite( Abc_Ntk_t * pNtk, int fUpdateLevel, int fUseZeros, int fVerb
return 0; return 0;
// compute the reverse levels if level update is requested // compute the reverse levels if level update is requested
if ( fUpdateLevel ) if ( fUpdateLevel )
Abc_NtkStartReverseLevels( pNtk ); Abc_NtkStartReverseLevels( pNtk, 0 );
// start the cut manager // start the cut manager
clk = clock(); clk = clock();
pManCut = Abc_NtkStartCutManForRewrite( pNtk ); pManCut = Abc_NtkStartCutManForRewrite( pNtk );
......
...@@ -705,7 +705,7 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode ...@@ -705,7 +705,7 @@ void Abc_NtkVerifyReportError( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pMode
nErrors = 0; nErrors = 0;
for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ ) for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
nErrors += (int)( pValues1[i] != pValues2[i] ); nErrors += (int)( pValues1[i] != pValues2[i] );
printf( "Verification failed for %d outputs: ", nErrors ); printf( "Verification failed for at least %d outputs: ", nErrors );
// print the first 3 outputs // print the first 3 outputs
nPrinted = 0; nPrinted = 0;
for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ ) for ( i = 0; i < Abc_NtkCoNum(pNtk1); i++ )
...@@ -860,7 +860,7 @@ void Abc_NtkVerifyReportErrorSeq( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pM ...@@ -860,7 +860,7 @@ void Abc_NtkVerifyReportErrorSeq( Abc_Ntk_t * pNtk1, Abc_Ntk_t * pNtk2, int * pM
return; return;
} }
printf( "Verification failed for %d output%s of frame %d: ", nErrors, (nErrors>1? "s":""), iFrameError+1 ); printf( "Verification failed for at least %d output%s of frame %d: ", nErrors, (nErrors>1? "s":""), iFrameError+1 );
// print the first 3 outputs // print the first 3 outputs
nPrinted = 0; nPrinted = 0;
Abc_NtkForEachPo( pNtk1, pObj1, o ) Abc_NtkForEachPo( pNtk1, pObj1, o )
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
***********************************************************************/ ***********************************************************************/
void Cmd_HistoryAddCommand( Abc_Frame_t * p, char * command ) void Cmd_HistoryAddCommand( Abc_Frame_t * p, char * command )
{ {
char Buffer[500]; static char Buffer[MAX_STR];
strcpy( Buffer, command ); strcpy( Buffer, command );
if ( command[strlen(command)-1] != '\n' ) if ( command[strlen(command)-1] != '\n' )
strcat( Buffer, "\n" ); strcat( Buffer, "\n" );
......
...@@ -77,6 +77,9 @@ struct Vec_Vec_t_ ...@@ -77,6 +77,9 @@ struct Vec_Vec_t_
#define Vec_VecForEachEntryReverseReverse( vGlob, pEntry, i, k ) \ #define Vec_VecForEachEntryReverseReverse( vGlob, pEntry, i, k ) \
for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \ for ( i = Vec_VecSize(vGlob) - 1; i >= 0; i-- ) \
Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k ) Vec_PtrForEachEntryReverse( Vec_VecEntry(vGlob, i), pEntry, k )
#define Vec_VecForEachEntryReverseStart( vGlob, pEntry, i, k, LevelStart ) \
for ( i = LevelStart; i >= 0; i-- ) \
Vec_PtrForEachEntry( Vec_VecEntry(vGlob, i), pEntry, k )
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
......
...@@ -121,7 +121,7 @@ struct Kit_DsdNtk_t_ ...@@ -121,7 +121,7 @@ struct Kit_DsdNtk_t_
unsigned char Root; // the root of the tree unsigned char Root; // the root of the tree
unsigned * pMem; // memory for the truth tables (memory manager?) unsigned * pMem; // memory for the truth tables (memory manager?)
unsigned * pSupps; // supports of the nodes unsigned * pSupps; // supports of the nodes
Kit_DsdObj_t * pNodes[0]; // the nodes Kit_DsdObj_t** pNodes; // the nodes
}; };
// DSD manager // DSD manager
...@@ -260,7 +260,15 @@ static inline int Kit_TruthFindFirstBit( unsigned * pIn, int nVars ) ...@@ -260,7 +260,15 @@ static inline int Kit_TruthFindFirstBit( unsigned * pIn, int nVars )
int w; int w;
for ( w = 0; w < Kit_TruthWordNum(nVars); w++ ) for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
if ( pIn[w] ) if ( pIn[w] )
return Kit_WordFindFirstBit(pIn[w]); return 32*w + Kit_WordFindFirstBit(pIn[w]);
return -1;
}
static inline int Kit_TruthFindFirstZero( unsigned * pIn, int nVars )
{
int w;
for ( w = 0; w < Kit_TruthWordNum(nVars); w++ )
if ( ~pIn[w] )
return 32*w + Kit_WordFindFirstBit(~pIn[w]);
return -1; return -1;
} }
static inline int Kit_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars ) static inline int Kit_TruthIsEqual( unsigned * pIn0, unsigned * pIn1, int nVars )
...@@ -444,12 +452,18 @@ extern DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars ...@@ -444,12 +452,18 @@ extern DdNode * Kit_SopToBdd( DdManager * dd, Kit_Sop_t * cSop, int nVars
extern DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph ); extern DdNode * Kit_GraphToBdd( DdManager * dd, Kit_Graph_t * pGraph );
extern DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop ); extern DdNode * Kit_TruthToBdd( DdManager * dd, unsigned * pTruth, int nVars, int fMSBonTop );
/*=== kitDsd.c ==========================================================*/ /*=== kitDsd.c ==========================================================*/
extern Kit_DsdMan_t * Kit_DsdManAlloc( int nVars );
extern void Kit_DsdManFree( Kit_DsdMan_t * p );
extern Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize ); extern Kit_DsdNtk_t * Kit_DsdDeriveNtk( unsigned * pTruth, int nVars, int nLutSize );
extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk ); extern unsigned * Kit_DsdTruthCompute( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned uSupp );
extern void Kit_DsdTruth( Kit_DsdNtk_t * pNtk, unsigned * pTruthRes ); extern void Kit_DsdTruth( Kit_DsdNtk_t * pNtk, unsigned * pTruthRes );
extern void Kit_DsdTruthPartial( Kit_DsdMan_t * p, Kit_DsdNtk_t * pNtk, unsigned * pTruthRes, unsigned uSupp );
extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk ); extern void Kit_DsdPrint( FILE * pFile, Kit_DsdNtk_t * pNtk );
extern void Kit_DsdPrintExpanded( Kit_DsdNtk_t * pNtk ); extern void Kit_DsdPrintExpanded( Kit_DsdNtk_t * pNtk );
extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars ); extern Kit_DsdNtk_t * Kit_DsdDecompose( unsigned * pTruth, int nVars );
extern Kit_DsdNtk_t * Kit_DsdDecomposeMux( unsigned * pTruth, int nVars, int nDecMux );
extern void Kit_DsdVerify( Kit_DsdNtk_t * pNtk, unsigned * pTruth, int nVars );
extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk ); extern void Kit_DsdNtkFree( Kit_DsdNtk_t * pNtk );
extern int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk ); extern int Kit_DsdNonDsdSizeMax( Kit_DsdNtk_t * pNtk );
extern void Kit_DsdGetSupports( Kit_DsdNtk_t * p ); extern void Kit_DsdGetSupports( Kit_DsdNtk_t * p );
...@@ -510,10 +524,12 @@ extern void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, i ...@@ -510,10 +524,12 @@ extern void Kit_TruthUniqueNew( unsigned * pRes, unsigned * pTruth, i
extern void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar ); extern void Kit_TruthMuxVar( unsigned * pOut, unsigned * pCof0, unsigned * pCof1, int nVars, int iVar );
extern void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar ); extern void Kit_TruthChangePhase( unsigned * pTruth, int nVars, int iVar );
extern int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin ); extern int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin );
extern int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 );
extern void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore ); extern void Kit_TruthCountOnesInCofs( unsigned * pTruth, int nVars, short * pStore );
extern void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVars, short * pStore, unsigned * pAux ); extern void Kit_TruthCountOnesInCofsSlow( unsigned * pTruth, int nVars, short * pStore, unsigned * pAux );
extern unsigned Kit_TruthHash( unsigned * pIn, int nWords ); extern unsigned Kit_TruthHash( unsigned * pIn, int nWords );
extern unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore ); extern unsigned Kit_TruthSemiCanonicize( unsigned * pInOut, unsigned * pAux, int nVars, char * pCanonPerm, short * pStore );
extern char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile );
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -354,9 +354,10 @@ Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemor ...@@ -354,9 +354,10 @@ Kit_Graph_t * Kit_TruthToGraph( unsigned * pTruth, int nVars, Vec_Int_t * vMemor
Kit_Graph_t * pGraph; Kit_Graph_t * pGraph;
int RetValue; int RetValue;
// derive SOP // derive SOP
RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 0 ); // tried 1 and found not useful in "renode" RetValue = Kit_TruthIsop( pTruth, nVars, vMemory, 1 ); // tried 1 and found not useful in "renode"
if ( RetValue == -1 ) if ( RetValue == -1 )
return NULL; return NULL;
// printf( "Isop size = %d.\n", Vec_IntSize(vMemory) );
assert( RetValue == 0 || RetValue == 1 ); assert( RetValue == 0 || RetValue == 1 );
// derive factored form // derive factored form
pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory ); pGraph = Kit_SopFactor( vMemory, RetValue, nVars, vMemory );
......
...@@ -1061,6 +1061,48 @@ int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin ) ...@@ -1061,6 +1061,48 @@ int Kit_TruthMinCofSuppOverlap( unsigned * pTruth, int nVars, int * pVarMin )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Find the best cofactoring variable.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Kit_TruthBestCofVar( unsigned * pTruth, int nVars, unsigned * pCof0, unsigned * pCof1 )
{
int i, iBestVar, nSuppSizeCur0, nSuppSizeCur1, nSuppSizeCur, nSuppSizeMin;
if ( Kit_TruthIsConst0(pTruth, nVars) || Kit_TruthIsConst1(pTruth, nVars) )
return -1;
// iterate through variables
iBestVar = -1;
nSuppSizeMin = KIT_INFINITY;
for ( i = 0; i < nVars; i++ )
{
// cofactor the functiona and get support sizes
Kit_TruthCofactor0New( pCof0, pTruth, nVars, i );
Kit_TruthCofactor1New( pCof1, pTruth, nVars, i );
nSuppSizeCur0 = Kit_TruthSupportSize( pCof0, nVars );
nSuppSizeCur1 = Kit_TruthSupportSize( pCof1, nVars );
nSuppSizeCur = nSuppSizeCur0 + nSuppSizeCur1;
// compare this variable with other variables
if ( nSuppSizeMin > nSuppSizeCur )
{
nSuppSizeMin = nSuppSizeCur;
iBestVar = i;
}
}
assert( iBestVar != -1 );
// cofactor w.r.t. this variable
Kit_TruthCofactor0New( pCof0, pTruth, nVars, iBestVar );
Kit_TruthCofactor1New( pCof1, pTruth, nVars, iBestVar );
return iBestVar;
}
/**Function*************************************************************
Synopsis [Counts the number of 1's in each cofactor.] Synopsis [Counts the number of 1's in each cofactor.]
Description [The resulting numbers are stored in the array of shorts, Description [The resulting numbers are stored in the array of shorts,
...@@ -1566,6 +1608,31 @@ void Kit_TruthCountMintermsPrecomp() ...@@ -1566,6 +1608,31 @@ void Kit_TruthCountMintermsPrecomp()
} }
} }
/**Function*************************************************************
Synopsis [Dumps truth table into a file.]
Description [Generates script file for reading into ABC.]
SideEffects []
SeeAlso []
***********************************************************************/
char * Kit_TruthDumpToFile( unsigned * pTruth, int nVars, int nFile )
{
static char pFileName[100];
FILE * pFile;
sprintf( pFileName, "s%03d", nFile );
pFile = fopen( pFileName, "w" );
fprintf( pFile, "rt " );
Extra_PrintHexadecimal( pFile, pTruth, nVars );
fprintf( pFile, "; bdd; sop; ps\n" );
fclose( pFile );
return pFileName;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -47,6 +47,7 @@ struct Lpk_Par_t_ ...@@ -47,6 +47,7 @@ struct Lpk_Par_t_
int nGrowthLevel; // (L) the maximum increase in the node level after resynthesis int nGrowthLevel; // (L) the maximum increase in the node level after resynthesis
int fSatur; // iterate till saturation int fSatur; // iterate till saturation
int fZeroCost; // accept zero-cost replacements int fZeroCost; // accept zero-cost replacements
int fFirst; // use root node and first cut only
int fVerbose; // the verbosiness flag int fVerbose; // the verbosiness flag
int fVeryVerbose; // additional verbose info printout int fVeryVerbose; // additional verbose info printout
// internal parameters // internal parameters
......
...@@ -545,11 +545,11 @@ int Lpk_NodeCuts( Lpk_Man_t * p ) ...@@ -545,11 +545,11 @@ int Lpk_NodeCuts( Lpk_Man_t * p )
pCut = p->pCuts + i; pCut = p->pCuts + i;
if ( pCut->nLeaves < 2 ) if ( pCut->nLeaves < 2 )
continue; continue;
// compute the number of LUTs neede to implement this cut // compute the minimum number of LUTs needed to implement this cut
// V = N * (K-1) + 1 ~~~~~ N = Ceiling[(V-1)/(K-1)] = (V-1)/(K-1) + [(V-1)%(K-1) > 0] // V = N * (K-1) + 1 ~~~~~ N = Ceiling[(V-1)/(K-1)] = (V-1)/(K-1) + [(V-1)%(K-1) > 0]
pCut->nLuts = (pCut->nLeaves-1)/(p->pPars->nLutSize-1) + ( (pCut->nLeaves-1)%(p->pPars->nLutSize-1) > 0 ); pCut->nLuts = (pCut->nLeaves-1)/(p->pPars->nLutSize-1) + ( (pCut->nLeaves-1)%(p->pPars->nLutSize-1) > 0 );
pCut->Weight = (float)1.0 * (pCut->nNodes - pCut->nNodesDup) / pCut->nLuts; //p->pPars->nLutsMax; pCut->Weight = (float)1.0 * (pCut->nNodes - pCut->nNodesDup) / pCut->nLuts; //p->pPars->nLutsMax;
if ( pCut->Weight <= 1.0 ) if ( pCut->Weight <= 1.001 )
continue; continue;
pCut->fHasDsd = Lpk_NodeCutsCheckDsd( p, pCut ); pCut->fHasDsd = Lpk_NodeCutsCheckDsd( p, pCut );
if ( pCut->fHasDsd ) if ( pCut->fHasDsd )
...@@ -566,7 +566,7 @@ int Lpk_NodeCuts( Lpk_Man_t * p ) ...@@ -566,7 +566,7 @@ int Lpk_NodeCuts( Lpk_Man_t * p )
{ {
pCut = p->pCuts + p->pEvals[i]; pCut = p->pCuts + p->pEvals[i];
pCut2 = p->pCuts + p->pEvals[i+1]; pCut2 = p->pCuts + p->pEvals[i+1];
if ( pCut->Weight >= pCut2->Weight ) if ( pCut->Weight >= pCut2->Weight - 0.001 )
continue; continue;
Temp = p->pEvals[i]; Temp = p->pEvals[i];
p->pEvals[i] = p->pEvals[i+1]; p->pEvals[i] = p->pEvals[i+1];
...@@ -574,6 +574,14 @@ int Lpk_NodeCuts( Lpk_Man_t * p ) ...@@ -574,6 +574,14 @@ int Lpk_NodeCuts( Lpk_Man_t * p )
fChanges = 1; fChanges = 1;
} }
} while ( fChanges ); } while ( fChanges );
/*
for ( i = 0; i < p->nEvals; i++ )
{
pCut = p->pCuts + p->pEvals[i];
printf( "Cut %3d : W = %5.2f.\n", i, pCut->Weight );
}
printf( "\n" );
*/
return 1; return 1;
} }
......
...@@ -87,6 +87,7 @@ struct Lpk_Man_t_ ...@@ -87,6 +87,7 @@ struct Lpk_Man_t_
// temporary variables // temporary variables
int fCofactoring; // working in the cofactoring mode int fCofactoring; // working in the cofactoring mode
int fCalledOnce; // limits the depth of MUX cofactoring int fCalledOnce; // limits the depth of MUX cofactoring
int nCalledSRed; // the number of called to SRed
int pRefs[LPK_SIZE_MAX]; // fanin reference counters int pRefs[LPK_SIZE_MAX]; // fanin reference counters
int pCands[LPK_SIZE_MAX]; // internal nodes pointing only to the leaves int pCands[LPK_SIZE_MAX]; // internal nodes pointing only to the leaves
// truth table representation // truth table representation
...@@ -94,6 +95,7 @@ struct Lpk_Man_t_ ...@@ -94,6 +95,7 @@ struct Lpk_Man_t_
Vec_Ptr_t * vTtNodes; // storage for temporary truth tables of the nodes Vec_Ptr_t * vTtNodes; // storage for temporary truth tables of the nodes
// variable sets // variable sets
Vec_Int_t * vSets[8]; Vec_Int_t * vSets[8];
Kit_DsdMan_t * pDsdMan;
// statistics // statistics
int nNodesTotal; // total number of nodes int nNodesTotal; // total number of nodes
int nNodesOver; // nodes with cuts over the limit int nNodesOver; // nodes with cuts over the limit
...@@ -101,6 +103,9 @@ struct Lpk_Man_t_ ...@@ -101,6 +103,9 @@ struct Lpk_Man_t_
int nCutsUseful; // useful cuts int nCutsUseful; // useful cuts
int nGainTotal; // the gain in LUTs int nGainTotal; // the gain in LUTs
int nChanges; // the number of changed nodes int nChanges; // the number of changed nodes
int nBenefited; // the number of gainful that benefited from decomposition
int nTotalNets;
int nTotalNets2;
// counter of non-DSD blocks // counter of non-DSD blocks
int nBlocks[17]; int nBlocks[17];
// rutime // rutime
...@@ -138,7 +143,6 @@ extern int Lpk_NodeCuts( Lpk_Man_t * p ); ...@@ -138,7 +143,6 @@ extern int Lpk_NodeCuts( Lpk_Man_t * p );
extern Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ); extern Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars );
extern void Lpk_ManStop( Lpk_Man_t * p ); extern void Lpk_ManStop( Lpk_Man_t * p );
/*=== lpkMap.c =========================================================*/ /*=== lpkMap.c =========================================================*/
extern int Lpk_CutExplore( Lpk_Man_t * p, Lpk_Cut_t * pCut, Kit_DsdNtk_t * pNtk );
extern If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves ); extern If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t ** ppLeaves );
extern If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult ); extern If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult );
/*=== lpkMulti.c =======================================================*/ /*=== lpkMulti.c =======================================================*/
......
...@@ -54,6 +54,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ) ...@@ -54,6 +54,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars )
p->vCover = Vec_IntAlloc( 1 << 12 ); p->vCover = Vec_IntAlloc( 1 << 12 );
for ( i = 0; i < 8; i++ ) for ( i = 0; i < 8; i++ )
p->vSets[i] = Vec_IntAlloc(100); p->vSets[i] = Vec_IntAlloc(100);
p->pDsdMan = Kit_DsdManAlloc( pPars->nVarsMax );
return p; return p;
} }
...@@ -71,6 +72,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars ) ...@@ -71,6 +72,7 @@ Lpk_Man_t * Lpk_ManStart( Lpk_Par_t * pPars )
void Lpk_ManStop( Lpk_Man_t * p ) void Lpk_ManStop( Lpk_Man_t * p )
{ {
int i; int i;
Kit_DsdManFree( p->pDsdMan );
for ( i = 0; i < 8; i++ ) for ( i = 0; i < 8; i++ )
Vec_IntFree(p->vSets[i]); Vec_IntFree(p->vSets[i]);
if ( p->pIfMan ) if ( p->pIfMan )
......
...@@ -24,62 +24,12 @@ ...@@ -24,62 +24,12 @@
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
extern void Res_UpdateNetworkLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/**Function************************************************************* /**Function*************************************************************
Synopsis [Prepares the mapping manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Lpk_IfManStart( Lpk_Man_t * p )
{
If_Par_t * pPars;
assert( p->pIfMan == NULL );
// set defaults
pPars = ALLOC( If_Par_t, 1 );
memset( pPars, 0, sizeof(If_Par_t) );
// user-controlable paramters
pPars->nLutSize = p->pPars->nLutSize;
pPars->nCutsMax = 16;
pPars->nFlowIters = 0; // 1
pPars->nAreaIters = 0; // 1
pPars->DelayTarget = -1;
pPars->fPreprocess = 0;
pPars->fArea = 1;
pPars->fFancy = 0;
pPars->fExpRed = 0; //
pPars->fLatchPaths = 0;
pPars->fSeqMap = 0;
pPars->fVerbose = 0;
// internal parameters
pPars->fTruth = 0;
pPars->fUsePerm = 0;
pPars->nLatches = 0;
pPars->pLutLib = NULL; // Abc_FrameReadLibLut();
pPars->pTimesArr = NULL;
pPars->pTimesArr = NULL;
pPars->fUseBdds = 0;
pPars->fUseSops = 0;
pPars->fUseCnfs = 0;
pPars->fUseMv = 0;
// start the mapping manager and set its parameters
p->pIfMan = If_ManStart( pPars );
If_ManSetupSetAll( p->pIfMan, 1000 );
p->pIfMan->pPars->pTimesArr = ALLOC( float, 32 );
}
/**Function*************************************************************
Synopsis [Transforms the decomposition graph into the AIG.] Synopsis [Transforms the decomposition graph into the AIG.]
Description [] Description []
...@@ -154,122 +104,10 @@ If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t * ...@@ -154,122 +104,10 @@ If_Obj_t * Lpk_MapPrime( Lpk_Man_t * p, unsigned * pTruth, int nVars, If_Obj_t *
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Lpk_CutExplore( Lpk_Man_t * p, Lpk_Cut_t * pCut, Kit_DsdNtk_t * pNtk )
{
extern Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t * pIfObj, Vec_Int_t * vCover );
Kit_DsdObj_t * pRoot;
If_Obj_t * pDriver, * ppLeaves[16];
Abc_Obj_t * pLeaf, * pObjNew;
int nGain, i;
// int nOldShared;
// check special cases
pRoot = Kit_DsdNtkRoot( pNtk );
if ( pRoot->Type == KIT_DSD_CONST1 )
{
if ( Kit_DsdLitIsCompl(pNtk->Root) )
pObjNew = Abc_NtkCreateNodeConst0( p->pNtk );
else
pObjNew = Abc_NtkCreateNodeConst1( p->pNtk );
// perform replacement
pObjNew->Level = p->pObj->Level;
Abc_ObjReplace( p->pObj, pObjNew );
Res_UpdateNetworkLevel( pObjNew, p->vLevels );
p->nGainTotal += pCut->nNodes - pCut->nNodesDup;
return 1;
}
if ( pRoot->Type == KIT_DSD_VAR )
{
pObjNew = Abc_NtkObj( p->pNtk, pCut->pLeaves[ Kit_DsdLit2Var(pRoot->pFans[0]) ] );
if ( Kit_DsdLitIsCompl(pNtk->Root) ^ Kit_DsdLitIsCompl(pRoot->pFans[0]) )
pObjNew = Abc_NtkCreateNodeInv( p->pNtk, pObjNew );
// perform replacement
pObjNew->Level = p->pObj->Level;
Abc_ObjReplace( p->pObj, pObjNew );
Res_UpdateNetworkLevel( pObjNew, p->vLevels );
p->nGainTotal += pCut->nNodes - pCut->nNodesDup;
return 1;
}
assert( pRoot->Type == KIT_DSD_AND || pRoot->Type == KIT_DSD_XOR || pRoot->Type == KIT_DSD_PRIME );
// start the mapping manager
if ( p->pIfMan == NULL )
Lpk_IfManStart( p );
// prepare the mapping manager
If_ManRestart( p->pIfMan );
// create the PI variables
for ( i = 0; i < p->pPars->nVarsMax; i++ )
ppLeaves[i] = If_ManCreateCi( p->pIfMan );
// set the arrival times
Lpk_CutForEachLeaf( p->pNtk, pCut, pLeaf, i )
p->pIfMan->pPars->pTimesArr[i] = (float)pLeaf->Level;
// prepare the PI cuts
If_ManSetupCiCutSets( p->pIfMan );
// create the internal nodes
p->fCalledOnce = 0;
pDriver = Lpk_MapTree_rec( p, pNtk, ppLeaves, pNtk->Root, NULL );
if ( pDriver == NULL )
return 0;
// create the PO node
If_ManCreateCo( p->pIfMan, If_Regular(pDriver) );
// perform mapping
p->pIfMan->pPars->fAreaOnly = 1;
If_ManPerformMappingComb( p->pIfMan );
// compute the gain in area
nGain = pCut->nNodes - pCut->nNodesDup - (int)p->pIfMan->AreaGlo;
if ( p->pPars->fVeryVerbose )
printf( " Mffc = %2d. Mapped = %2d. Gain = %3d. Depth increase = %d.\n",
pCut->nNodes - pCut->nNodesDup, (int)p->pIfMan->AreaGlo, nGain, (int)p->pIfMan->RequiredGlo - (int)p->pObj->Level );
// quit if there is no gain
if ( !(nGain > 0 || (p->pPars->fZeroCost && nGain == 0)) )
return 0;
// quit if depth increases too much
if ( (int)p->pIfMan->RequiredGlo - (int)p->pObj->Level > p->pPars->nGrowthLevel )
return 0;
// perform replacement
p->nGainTotal += nGain;
p->nChanges++;
// prepare the mapping manager
If_ManCleanNodeCopy( p->pIfMan );
If_ManCleanCutData( p->pIfMan );
// set the PIs of the cut
Lpk_CutForEachLeaf( p->pNtk, pCut, pLeaf, i )
If_ObjSetCopy( If_ManCi(p->pIfMan, i), pLeaf );
// get the area of mapping
pObjNew = Abc_NodeFromIf_rec( p->pNtk, p->pIfMan, If_Regular(pDriver), p->vCover );
pObjNew->pData = Hop_NotCond( pObjNew->pData, If_IsComplement(pDriver) );
// perform replacement
pObjNew->Level = p->pObj->Level;
Abc_ObjReplace( p->pObj, pObjNew );
Res_UpdateNetworkLevel( pObjNew, p->vLevels );
return 1;
}
/**Function*************************************************************
Synopsis [Prepares the mapping manager.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult ) If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLeaves, int iLit, If_Obj_t * pResult )
{ {
Kit_DsdObj_t * pObj; Kit_DsdObj_t * pObj;
If_Obj_t * pObjNew, * pFansNew[16]; If_Obj_t * pObjNew = NULL, * pObjNew2 = NULL, * pFansNew[16];
unsigned i, iLitFanin; unsigned i, iLitFanin;
assert( iLit >= 0 ); assert( iLit >= 0 );
...@@ -332,13 +170,31 @@ If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLe ...@@ -332,13 +170,31 @@ If_Obj_t * Lpk_MapTree_rec( Lpk_Man_t * p, Kit_DsdNtk_t * pNtk, If_Obj_t ** ppLe
return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) ); return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
} }
*/ */
/*
if ( (int)pObj->nFans > p->pPars->nLutSize )
{
pObjNew2 = Lpk_MapTreeMux_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
// if ( pObjNew2 )
// return If_NotCond( pObjNew2, Kit_DsdLitIsCompl(iLit) );
}
*/
// find best cofactoring variable // find best cofactoring variable
if ( pObj->nFans > 3 && !p->fCalledOnce ) if ( p->pPars->nVarsShared > 0 && (int)pObj->nFans > p->pPars->nLutSize )
// pObjNew = Lpk_MapTreeMux_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew ); {
pObjNew = Lpk_MapSuppRedDec_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew ); pObjNew2 = Lpk_MapSuppRedDec_rec( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
else if ( pObjNew2 )
return If_NotCond( pObjNew2, Kit_DsdLitIsCompl(iLit) );
}
pObjNew = Lpk_MapPrime( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew ); pObjNew = Lpk_MapPrime( p, Kit_DsdObjTruth(pObj), pObj->nFans, pFansNew );
// add choice
if ( pObjNew && pObjNew2 )
{
If_ObjSetChoice( If_Regular(pObjNew), If_Regular(pObjNew2) );
If_ManCreateChoice( p->pIfMan, If_Regular(pObjNew) );
}
return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) ); return If_NotCond( pObjNew, Kit_DsdLitIsCompl(iLit) );
} }
......
...@@ -104,7 +104,8 @@ unsigned Lpk_ComputeSets_rec( Kit_DsdNtk_t * p, int iLit, Vec_Int_t * vSets ) ...@@ -104,7 +104,8 @@ unsigned Lpk_ComputeSets_rec( Kit_DsdNtk_t * p, int iLit, Vec_Int_t * vSets )
***********************************************************************/ ***********************************************************************/
unsigned Lpk_ComputeSets( Kit_DsdNtk_t * p, Vec_Int_t * vSets ) unsigned Lpk_ComputeSets( Kit_DsdNtk_t * p, Vec_Int_t * vSets )
{ {
unsigned uSupport, Entry, i; unsigned uSupport, Entry;
int Number, i;
assert( p->nVars <= 16 ); assert( p->nVars <= 16 );
Vec_IntClear( vSets ); Vec_IntClear( vSets );
Vec_IntPush( vSets, 0 ); Vec_IntPush( vSets, 0 );
...@@ -120,8 +121,11 @@ unsigned Lpk_ComputeSets( Kit_DsdNtk_t * p, Vec_Int_t * vSets ) ...@@ -120,8 +121,11 @@ unsigned Lpk_ComputeSets( Kit_DsdNtk_t * p, Vec_Int_t * vSets )
assert( (uSupport & 0xFFFF0000) == 0 ); assert( (uSupport & 0xFFFF0000) == 0 );
Vec_IntPush( vSets, uSupport ); Vec_IntPush( vSets, uSupport );
// set the remaining variables // set the remaining variables
Vec_IntForEachEntry( vSets, Entry, i ) Vec_IntForEachEntry( vSets, Number, i )
{
Entry = Number;
Vec_IntWriteEntry( vSets, i, Entry | ((uSupport & ~Entry) << 16) ); Vec_IntWriteEntry( vSets, i, Entry | ((uSupport & ~Entry) << 16) );
}
return uSupport; return uSupport;
} }
...@@ -157,10 +161,14 @@ void Lpk_PrintSetOne( int uSupport ) ...@@ -157,10 +161,14 @@ void Lpk_PrintSetOne( int uSupport )
***********************************************************************/ ***********************************************************************/
void Lpk_PrintSets( Vec_Int_t * vSets ) void Lpk_PrintSets( Vec_Int_t * vSets )
{ {
unsigned uSupport, i; unsigned uSupport;
int Number, i;
printf( "Subsets(%d): ", Vec_IntSize(vSets) ); printf( "Subsets(%d): ", Vec_IntSize(vSets) );
Vec_IntForEachEntry( vSets, uSupport, i ) Vec_IntForEachEntry( vSets, Number, i )
{
uSupport = Number;
Lpk_PrintSetOne( uSupport ); Lpk_PrintSetOne( uSupport );
}
printf( "\n" ); printf( "\n" );
} }
...@@ -237,7 +245,7 @@ void Lpk_ComposeSets( Vec_Int_t * vSets0, Vec_Int_t * vSets1, int nVars, int iCo ...@@ -237,7 +245,7 @@ void Lpk_ComposeSets( Vec_Int_t * vSets0, Vec_Int_t * vSets1, int nVars, int iCo
} }
} }
// check if there are non-overlapping // find the minimum overlap
nMinOver = 1000; nMinOver = 1000;
for ( s = 0; s < nUsed; s++ ) for ( s = 0; s < nUsed; s++ )
if ( nMinOver > Over[Used[s]] ) if ( nMinOver > Over[Used[s]] )
...@@ -318,13 +326,21 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i ...@@ -318,13 +326,21 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
Vec_Int_t * vSets1 = p->vSets[1]; Vec_Int_t * vSets1 = p->vSets[1];
unsigned * pCof0 = Vec_PtrEntry( p->vTtNodes, 0 ); unsigned * pCof0 = Vec_PtrEntry( p->vTtNodes, 0 );
unsigned * pCof1 = Vec_PtrEntry( p->vTtNodes, 1 ); unsigned * pCof1 = Vec_PtrEntry( p->vTtNodes, 1 );
int nSets, i, SizeMax; int nSets, i, SizeMax;//, SRedMax;
unsigned Entry; unsigned Entry;
int fVerbose = p->pPars->fVeryVerbose;
// int fVerbose = 0;
// collect decomposable subsets for each pair of cofactors // collect decomposable subsets for each pair of cofactors
if ( fVerbose )
{
printf( "\nExploring support-reducing bound-sets of function:\n" );
Kit_DsdPrintFromTruth( pTruth, nVars );
}
nSets = 0; nSets = 0;
for ( i = 0; i < nVars; i++ ) for ( i = 0; i < nVars; i++ )
{ {
if ( fVerbose )
printf( "Evaluating variable %c:\n", 'a'+i ); printf( "Evaluating variable %c:\n", 'a'+i );
// evaluate the cofactor pair // evaluate the cofactor pair
Kit_TruthCofactor0New( pCof0, pTruth, nVars, i ); Kit_TruthCofactor0New( pCof0, pTruth, nVars, i );
...@@ -334,13 +350,17 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i ...@@ -334,13 +350,17 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
ppNtks[1] = Kit_DsdDecompose( pCof1, nVars ); ppNtks[1] = Kit_DsdDecompose( pCof1, nVars );
ppNtks[0] = Kit_DsdExpand( pTemp = ppNtks[0] ); Kit_DsdNtkFree( pTemp ); ppNtks[0] = Kit_DsdExpand( pTemp = ppNtks[0] ); Kit_DsdNtkFree( pTemp );
ppNtks[1] = Kit_DsdExpand( pTemp = ppNtks[1] ); Kit_DsdNtkFree( pTemp ); ppNtks[1] = Kit_DsdExpand( pTemp = ppNtks[1] ); Kit_DsdNtkFree( pTemp );
if ( fVerbose )
Kit_DsdPrint( stdout, ppNtks[0] ); Kit_DsdPrint( stdout, ppNtks[0] );
if ( fVerbose )
Kit_DsdPrint( stdout, ppNtks[1] ); Kit_DsdPrint( stdout, ppNtks[1] );
// compute subsets // compute subsets
Lpk_ComputeSets( ppNtks[0], vSets0 ); Lpk_ComputeSets( ppNtks[0], vSets0 );
Lpk_ComputeSets( ppNtks[1], vSets1 ); Lpk_ComputeSets( ppNtks[1], vSets1 );
// print subsets // print subsets
if ( fVerbose )
Lpk_PrintSets( vSets0 ); Lpk_PrintSets( vSets0 );
if ( fVerbose )
Lpk_PrintSets( vSets1 ); Lpk_PrintSets( vSets1 );
// free the networks // free the networks
Kit_DsdNtkFree( ppNtks[0] ); Kit_DsdNtkFree( ppNtks[0] );
...@@ -350,7 +370,9 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i ...@@ -350,7 +370,9 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
} }
// print the results // print the results
if ( fVerbose )
printf( "\n" ); printf( "\n" );
if ( fVerbose )
for ( i = 0; i < nSets; i++ ) for ( i = 0; i < nSets; i++ )
Lpk_MapSuppPrintSet( pStore + i, i ); Lpk_MapSuppPrintSet( pStore + i, i );
...@@ -368,14 +390,33 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i ...@@ -368,14 +390,33 @@ unsigned Lpk_MapSuppRedDecSelect( Lpk_Man_t * p, unsigned * pTruth, int nVars, i
SizeMax = pSet->Size; SizeMax = pSet->Size;
} }
} }
/*
// if the best is not choosen, select the one with largest reduction
SRedMax = 0;
if ( pSetBest == NULL )
{
for ( i = 0; i < nSets; i++ )
{
pSet = pStore + i;
if ( SRedMax < pSet->SRed )
{
pSetBest = pSet;
SRedMax = pSet->SRed;
}
}
}
*/
if ( pSetBest == NULL ) if ( pSetBest == NULL )
{ {
if ( fVerbose )
printf( "Could not select a subset.\n" ); printf( "Could not select a subset.\n" );
return 0; return 0;
} }
else else
{ {
if ( fVerbose )
printf( "Selected the following subset:\n" ); printf( "Selected the following subset:\n" );
if ( fVerbose )
Lpk_MapSuppPrintSet( pSetBest, pSetBest - pStore ); Lpk_MapSuppPrintSet( pSetBest, pSetBest - pStore );
} }
......
...@@ -4,5 +4,4 @@ SRC += src/opt/res/resCore.c \ ...@@ -4,5 +4,4 @@ SRC += src/opt/res/resCore.c \
src/opt/res/resSat.c \ src/opt/res/resSat.c \
src/opt/res/resSim.c \ src/opt/res/resSim.c \
src/opt/res/resStrash.c \ src/opt/res/resStrash.c \
src/opt/res/resUpdate.c \
src/opt/res/resWin.c src/opt/res/resWin.c
...@@ -123,6 +123,14 @@ void Res_ManFree( Res_Man_t * p ) ...@@ -123,6 +123,14 @@ void Res_ManFree( Res_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
{ {
printf( "Reduction in nodes = %5d. (%.2f %%) ",
p->nTotalNodes-p->nTotalNodes2,
100.0*(p->nTotalNodes-p->nTotalNodes2)/p->nTotalNodes );
printf( "Reduction in edges = %5d. (%.2f %%) ",
p->nTotalNets-p->nTotalNets2,
100.0*(p->nTotalNets-p->nTotalNets2)/p->nTotalNets );
printf( "\n" );
printf( "Winds = %d. ", p->nWins ); printf( "Winds = %d. ", p->nWins );
printf( "Nodes = %d. (Ave = %5.1f) ", p->nWinNodes, 1.0*p->nWinNodes/p->nWins ); printf( "Nodes = %d. (Ave = %5.1f) ", p->nWinNodes, 1.0*p->nWinNodes/p->nWins );
printf( "Divs = %d. (Ave = %5.1f) ", p->nDivNodes, 1.0*p->nDivNodes/p->nWins ); printf( "Divs = %d. (Ave = %5.1f) ", p->nDivNodes, 1.0*p->nDivNodes/p->nWins );
...@@ -134,13 +142,6 @@ void Res_ManFree( Res_Man_t * p ) ...@@ -134,13 +142,6 @@ void Res_ManFree( Res_Man_t * p )
printf( "Cands = %d. ", p->nCandSets ); printf( "Cands = %d. ", p->nCandSets );
printf( "Proved = %d.", p->nProvedSets ); printf( "Proved = %d.", p->nProvedSets );
printf( "\n" ); printf( "\n" );
printf( "Reduction in nodes = %d. (%.2f %%) ",
p->nTotalNodes-p->nTotalNodes2,
100.0*(p->nTotalNodes-p->nTotalNodes2)/p->nTotalNodes );
printf( "Reduction in nets = %d. (%.2f %%) ",
p->nTotalNets-p->nTotalNets2,
100.0*(p->nTotalNets-p->nTotalNets2)/p->nTotalNets );
printf( "\n" );
PRTP( "Windowing ", p->timeWin, p->timeTotal ); PRTP( "Windowing ", p->timeWin, p->timeTotal );
PRTP( "Divisors ", p->timeDiv, p->timeTotal ); PRTP( "Divisors ", p->timeDiv, p->timeTotal );
...@@ -153,7 +154,7 @@ void Res_ManFree( Res_Man_t * p ) ...@@ -153,7 +154,7 @@ void Res_ManFree( Res_Man_t * p )
PRTP( " simul ", p->timeSatSim, p->timeTotal ); PRTP( " simul ", p->timeSatSim, p->timeTotal );
PRTP( "Interpol ", p->timeInt, p->timeTotal ); PRTP( "Interpol ", p->timeInt, p->timeTotal );
PRTP( "Undating ", p->timeUpd, p->timeTotal ); PRTP( "Undating ", p->timeUpd, p->timeTotal );
PRT( "TOTAL ", p->timeTotal ); PRTP( "TOTAL ", p->timeTotal, p->timeTotal );
} }
Res_WinFree( p->pWin ); Res_WinFree( p->pWin );
if ( p->pAig ) Abc_NtkDelete( p->pAig ); if ( p->pAig ) Abc_NtkDelete( p->pAig );
...@@ -169,6 +170,31 @@ void Res_ManFree( Res_Man_t * p ) ...@@ -169,6 +170,31 @@ void Res_ManFree( Res_Man_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Incrementally updates level of the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc, Vec_Vec_t * vLevels )
{
Abc_Obj_t * pObjNew, * pFanin;
int k;
// create the new node
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
pObjNew->pData = pFunc;
Vec_PtrForEachEntry( vFanins, pFanin, k )
Abc_ObjAddFanin( pObjNew, pFanin );
// replace the old node by the new node
// update the level of the node
Abc_NtkUpdate( pObj, pObjNew, vLevels );
}
/**Function*************************************************************
Synopsis [Entrace into the resynthesis package.] Synopsis [Entrace into the resynthesis package.]
Description [] Description []
...@@ -210,6 +236,7 @@ int Abc_NtkResynthesize( Abc_Ntk_t * pNtk, Res_Par_t * pPars ) ...@@ -210,6 +236,7 @@ int Abc_NtkResynthesize( Abc_Ntk_t * pNtk, Res_Par_t * pPars )
// set the number of levels // set the number of levels
Abc_NtkLevel( pNtk ); Abc_NtkLevel( pNtk );
Abc_NtkStartReverseLevels( pNtk, pPars->nGrowthLevel );
// try resynthesizing nodes in the topological order // try resynthesizing nodes in the topological order
nNodesOld = Abc_NtkObjNumMax(pNtk); nNodesOld = Abc_NtkObjNumMax(pNtk);
...@@ -242,7 +269,7 @@ p->timeWin += clock() - clk; ...@@ -242,7 +269,7 @@ p->timeWin += clock() - clk;
// collect the divisors // collect the divisors
clk = clock(); clk = clock();
Res_WinDivisors( p->pWin, pObj->Level + pPars->nGrowthLevel - 1 ); Res_WinDivisors( p->pWin, Abc_ObjRequiredLevel(pObj) - 1 );
p->timeDiv += clock() - clk; p->timeDiv += clock() - clk;
p->nWins++; p->nWins++;
...@@ -359,6 +386,7 @@ p->timeUpd += clock() - clk; ...@@ -359,6 +386,7 @@ p->timeUpd += clock() - clk;
// printf( "\n" ); // printf( "\n" );
} }
Extra_ProgressBarStop( pProgress ); Extra_ProgressBarStop( pProgress );
Abc_NtkStopReverseLevels( pNtk );
p->timeSatSim += p->pSim->timeSat; p->timeSatSim += p->pSim->timeSat;
p->timeSatTotal = p->timeSatSat + p->timeSatUnsat + p->timeSatSim; p->timeSatTotal = p->timeSatSat + p->timeSatUnsat + p->timeSatSim;
......
/**CFile****************************************************************
FileName [resUpdate.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Resynthesis package.]
Synopsis [Updates the network after changes.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - January 15, 2007.]
Revision [$Id: resUpdate.c,v 1.00 2007/01/15 00:00:00 alanmi Exp $]
***********************************************************************/
#include "abc.h"
#include "resInt.h"
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis [Computes the level of the node using its fanin levels.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Res_UpdateNetworkLevelNew( Abc_Obj_t * pObj )
{
Abc_Obj_t * pFanin;
int i, Level = 0;
Abc_ObjForEachFanin( pObj, pFanin, i )
Level = ABC_MAX( Level, (int)pFanin->Level );
return Level + 1;
}
/**Function*************************************************************
Synopsis [Incrementally updates level of the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Res_UpdateNetworkLevel( Abc_Obj_t * pObjNew, Vec_Vec_t * vLevels )
{
Abc_Obj_t * pFanout, * pTemp;
int Lev, k, m;
// check if level has changed
if ( (int)pObjNew->Level == Res_UpdateNetworkLevelNew(pObjNew) )
return;
// start the data structure for level update
Vec_VecClear( vLevels );
Vec_VecPush( vLevels, pObjNew->Level, pObjNew );
pObjNew->fMarkA = 1;
// recursively update level
Vec_VecForEachEntryStart( vLevels, pTemp, Lev, k, pObjNew->Level )
{
pTemp->fMarkA = 0;
pTemp->Level = Res_UpdateNetworkLevelNew( pTemp );
// if the level did not change, to need to check the fanout levels
if ( (int)pTemp->Level == Lev )
continue;
// schedule fanout for level update
Abc_ObjForEachFanout( pTemp, pFanout, m )
if ( !Abc_ObjIsCo(pFanout) && !pFanout->fMarkA )
{
Vec_VecPush( vLevels, pFanout->Level, pFanout );
pFanout->fMarkA = 1;
}
}
}
/**Function*************************************************************
Synopsis [Incrementally updates level of the nodes.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Res_UpdateNetwork( Abc_Obj_t * pObj, Vec_Ptr_t * vFanins, Hop_Obj_t * pFunc, Vec_Vec_t * vLevels )
{
Abc_Obj_t * pObjNew, * pFanin;
int k;
// create the new node
pObjNew = Abc_NtkCreateNode( pObj->pNtk );
pObjNew->pData = pFunc;
Vec_PtrForEachEntry( vFanins, pFanin, k )
Abc_ObjAddFanin( pObjNew, pFanin );
// replace the old node by the new node
pObjNew->Level = pObj->Level;
Abc_ObjReplace( pObj, pObjNew );
// update the level of the node
Res_UpdateNetworkLevel( pObjNew, vLevels );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
...@@ -66,7 +66,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int ...@@ -66,7 +66,7 @@ int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int
p->nNodesConsidered++; p->nNodesConsidered++;
// get the required times // get the required times
Required = fUpdateLevel? Abc_NodeReadRequiredLevel(pNode) : ABC_INFINITY; Required = fUpdateLevel? Abc_ObjRequiredLevel(pNode) : ABC_INFINITY;
// get the node's cuts // get the node's cuts
clk = clock(); clk = clock();
......
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