Commit 6ab0d68d by Alan Mishchenko

Tuning LUT mapping to work while saving the best network.

parent f6ae0e41
...@@ -15017,8 +15017,8 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -15017,8 +15017,8 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
// enable truth table computation if choices are selected // enable truth table computation if choices are selected
if ( (c = Abc_NtkGetChoiceNum( pNtk )) ) if ( (c = Abc_NtkGetChoiceNum( pNtk )) )
{ {
if ( !Abc_FrameReadFlag("silentmode") ) // if ( !Abc_FrameReadFlag("silentmode") )
Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c ); // Abc_Print( 0, "Performing LUT mapping with %d choices.\n", c );
pPars->fExpRed = 0; pPars->fExpRed = 0;
} }
...@@ -29749,8 +29749,8 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29749,8 +29749,8 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
// enable truth table computation if choices are selected // enable truth table computation if choices are selected
if ( Gia_ManHasChoices(pAbc->pGia) ) if ( Gia_ManHasChoices(pAbc->pGia) )
{ {
if ( !Abc_FrameReadFlag("silentmode") ) // if ( !Abc_FrameReadFlag("silentmode") )
Abc_Print( 0, "Performing LUT mapping with choices.\n" ); // Abc_Print( 0, "Performing LUT mapping with choices.\n" );
pPars->fExpRed = 0; pPars->fExpRed = 0;
} }
...@@ -101,7 +101,10 @@ int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk ) ...@@ -101,7 +101,10 @@ int Abc_NtkCompareAndSaveBest( Abc_Ntk_t * pNtk )
ParsBest.nPis = ParsNew.nPis; ParsBest.nPis = ParsNew.nPis;
ParsBest.nPos = ParsNew.nPos; ParsBest.nPos = ParsNew.nPos;
// writ the network // writ the network
pFileNameOut = Extra_FileNameGenericAppend( pNtk->pSpec, "_best.blif" ); if ( strcmp(pNtk->pSpec + strlen(pNtk->pSpec) - strlen("_best.blif"), "_best.blif") )
pFileNameOut = Extra_FileNameGenericAppend( pNtk->pSpec, "_best.blif" );
else
pFileNameOut = pNtk->pSpec;
Io_Write( pNtk, pFileNameOut, IO_FILE_BLIF ); Io_Write( pNtk, pFileNameOut, IO_FILE_BLIF );
return 1; return 1;
} }
......
...@@ -490,7 +490,7 @@ extern int If_ManPerformMapping( If_Man_t * p ); ...@@ -490,7 +490,7 @@ extern int If_ManPerformMapping( If_Man_t * p );
extern int If_ManPerformMappingComb( If_Man_t * p ); extern int If_ManPerformMappingComb( If_Man_t * p );
/*=== ifCut.c ============================================================*/ /*=== ifCut.c ============================================================*/
extern int If_CutVerifyCuts( If_Set_t * pCutSet, int fOrdered ); extern int If_CutVerifyCuts( If_Set_t * pCutSet, int fOrdered );
extern int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut ); extern int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut, int fSaveCut0 );
extern void If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut ); extern void If_CutSort( If_Man_t * p, If_Set_t * pCutSet, If_Cut_t * pCut );
extern void If_CutOrder( If_Cut_t * pCut ); extern void If_CutOrder( If_Cut_t * pCut );
extern int If_CutMergeOrdered( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut ); extern int If_CutMergeOrdered( If_Man_t * p, If_Cut_t * pCut0, If_Cut_t * pCut1, If_Cut_t * pCut );
......
...@@ -143,7 +143,7 @@ static inline int If_CutCheckDominance( If_Cut_t * pDom, If_Cut_t * pCut ) ...@@ -143,7 +143,7 @@ static inline int If_CutCheckDominance( If_Cut_t * pDom, If_Cut_t * pCut )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut ) int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut, int fSaveCut0 )
{ {
If_Cut_t * pTemp; If_Cut_t * pTemp;
int i, k; int i, k;
...@@ -154,7 +154,7 @@ int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut ) ...@@ -154,7 +154,7 @@ int If_CutFilter( If_Set_t * pCutSet, If_Cut_t * pCut )
if ( pTemp->nLeaves > pCut->nLeaves ) if ( pTemp->nLeaves > pCut->nLeaves )
{ {
// do not fiter the first cut // do not fiter the first cut
if ( i == 0 && pCutSet->nCuts > 1 && pCutSet->ppCuts[1]->fUseless ) if ( i == 0 && ((pCutSet->nCuts > 1 && pCutSet->ppCuts[1]->fUseless) || (fSaveCut0 && pCutSet->nCuts == 1)) )
continue; continue;
// skip the non-contained cuts // skip the non-contained cuts
if ( (pTemp->uSign & pCut->uSign) != pCut->uSign ) if ( (pTemp->uSign & pCut->uSign) != pCut->uSign )
......
...@@ -184,7 +184,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -184,7 +184,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
p->nCutsMerged++; p->nCutsMerged++;
p->nCutsTotal++; p->nCutsTotal++;
// check if this cut is contained in any of the available cuts // check if this cut is contained in any of the available cuts
if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut ) ) if ( !p->pPars->fSkipCutFilter && If_CutFilter( pCutSet, pCut, p->pPars->fUserRecLib || p->pPars->fDelayOpt ) )
continue; continue;
// compute the truth table // compute the truth table
pCut->iCutFunc = -1; pCut->iCutFunc = -1;
...@@ -202,7 +202,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -202,7 +202,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 ); fChange = If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
p->timeCache[4] += Abc_Clock() - clk; p->timeCache[4] += Abc_Clock() - clk;
if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut ) ) if ( !p->pPars->fSkipCutFilter && fChange && If_CutFilter( pCutSet, pCut, p->pPars->fUserRecLib || p->pPars->fDelayOpt ) )
continue; continue;
if ( p->pPars->fUseDsd ) if ( p->pPars->fUseDsd )
{ {
...@@ -385,7 +385,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP ...@@ -385,7 +385,7 @@ void If_ObjPerformMappingChoice( If_Man_t * p, If_Obj_t * pObj, int Mode, int fP
// copy the cut into storage // copy the cut into storage
If_CutCopy( p, pCut, pCutTemp ); If_CutCopy( p, pCut, pCutTemp );
// check if this cut is contained in any of the available cuts // check if this cut is contained in any of the available cuts
if ( If_CutFilter( pCutSet, pCut ) ) if ( If_CutFilter( pCutSet, pCut, p->pPars->fUserRecLib || p->pPars->fDelayOpt ) )
continue; continue;
// check if the cut satisfies the required times // check if the cut satisfies the required times
assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) ); assert( pCut->Delay == If_CutDelay( p, pTemp, pCut ) );
......
...@@ -378,12 +378,17 @@ int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut ) ...@@ -378,12 +378,17 @@ int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut )
} }
// get the cost // get the cost
If_AndClear( &Leaf ); If_AndClear( &Leaf );
if ( Vec_WrdSize(vAnds) ) if ( Vec_WrdSize(vAnds) > 0 )
Leaf = If_WrdToAnd( Vec_WrdEntryLast(vAnds) ); Leaf = If_WrdToAnd( Vec_WrdEntryLast(vAnds) );
if ( pCut->nLeaves > 2 && Vec_WrdSize(vAnds) > (int)pCut->nLeaves )
pCut->Cost = Vec_WrdSize(vAnds) - pCut->nLeaves;
else else
Leaf.Delay = 0;
if ( Vec_WrdSize(vAnds) > (int)pCut->nLeaves )
pCut->Cost = Vec_WrdSize(vAnds) - pCut->nLeaves;
else if ( pCut->nLeaves == 1 )
pCut->Cost = 1; pCut->Cost = 1;
else if ( pCut->nLeaves == 0 )
pCut->Cost = 0;
else assert( 0 );
// get the permutation // get the permutation
for ( i = 0; i < (int)pCut->nLeaves; i++ ) for ( i = 0; i < (int)pCut->nLeaves; i++ )
{ {
......
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