diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index 7c3201a1a..0cbdf1989 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -19541,7 +19541,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) If_ManSetDefaultPars( pPars ); pPars->pLutLib = (If_LibLut_t *)Abc_FrameReadLibLut(); Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRNTXYUZDEWSJqaflepmrsdbgxyuojiktncvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGRNTXYUZDEWSJqaflepmrsdbgxyzuojiktncvh" ) ) != EOF ) { switch ( c ) { @@ -19812,6 +19812,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) case 'v': pPars->fVerbose ^= 1; break; + case 'z': + pPars->fReturnDec ^= 1; + break; case 'h': default: goto usage; @@ -19929,6 +19932,11 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) pPars->pFuncCell = pPars->fDelayOptLut ? NULL : If_CutPerformCheck16; } pPars->fCutMin = 1; + pPars->nLutDecSize = pPars->pLutStruct[0] - '0'; + } + else + { + pPars->fReturnDec = 0; } if ( pPars->fUserLutDec || pPars->fUserLut2D ) @@ -20112,7 +20120,7 @@ usage: sprintf(LutSize, "library" ); else sprintf(LutSize, "%d", pPars->nLutSize ); - Abc_Print( -2, "usage: if [-KCFAGRNTXYUZ num] [-DEW float] [-SJ str] [-qarlepmsdbgxyuojiktncvh]\n" ); + Abc_Print( -2, "usage: if [-KCFAGRNTXYUZ num] [-DEW float] [-SJ str] [-qarlepmsdbgxyuojiktnczvh]\n" ); Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" ); Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize ); Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax ); @@ -20152,6 +20160,7 @@ usage: Abc_Print( -2, "\t-t : toggles optimizing average rather than maximum level [default = %s]\n", pPars->fDoAverage? "yes": "no" ); Abc_Print( -2, "\t-n : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" ); Abc_Print( -2, "\t-c : toggles computing truth tables in a new way [default = %s]\n", pPars->fUseTtPerm? "yes": "no" ); + Abc_Print( -2, "\t-z : toggles decomposing LUT structure on the final network [default = %s]\n", pPars->fReturnDec? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : prints the command usage\n"); return 1; diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index 8c4ac1448..db0da36f9 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -465,10 +465,14 @@ void Abc_DecRecordToHop( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Cut_t * pCut { val = acd_decompose( pTruth, pCutBest->nLeaves, pIfMan->pPars->nLutDecSize, &(delayProfile), decompArray ); } - else + else if ( pIfMan->pPars->fUserLut2D ) { val = acd2_decompose( pTruth, pCutBest->nLeaves, pIfMan->pPars->nLutDecSize, &(delayProfile), decompArray ); } + else + { + val = acdXX_decompose( pTruth, pIfMan->pPars->nLutDecSize, pCutBest->nLeaves, decompArray ); + } assert( val == 0 ); // convert the LUT-structure into a set of logic nodes in Abc_Ntk_t @@ -593,7 +597,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t If_CutForEachLeafReverse( pIfMan, pCutBest, pIfLeaf, i ) Abc_ObjAddFanin( pNodeNew, Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover) ); } - else if ( pIfMan->pPars->fUserLutDec || pIfMan->pPars->fUserLut2D ) + else if ( pIfMan->pPars->fUserLutDec || pIfMan->pPars->fUserLut2D || pIfMan->pPars->fReturnDec ) { If_CutForEachLeaf( pIfMan, pCutBest, pIfLeaf, i ) Abc_NodeFromIf_rec(pNtkNew, pIfMan, pIfLeaf, vCover); @@ -651,7 +655,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t extern Hop_Obj_t * Abc_RecToHop3( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut, If_Obj_t * pIfObj ); pNodeNew->pData = Abc_RecToHop3( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest, pIfObj ); } - else if ( pIfMan->pPars->fUserLutDec || pIfMan->pPars->fUserLut2D ) + else if ( pIfMan->pPars->fUserLutDec || pIfMan->pPars->fUserLut2D || pIfMan->pPars->fReturnDec ) { extern void Abc_DecRecordToHop( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Cut_t * pCut, If_Obj_t * pIfObj, Vec_Int_t * vMemory, Abc_Obj_t * pNodeTop ); Abc_DecRecordToHop( pNtkNew, pIfMan, pCutBest, pIfObj, vCover, pNodeNew ); diff --git a/src/map/if/acd/ac_wrapper.cpp b/src/map/if/acd/ac_wrapper.cpp index ad923edd2..ed512961f 100644 --- a/src/map/if/acd/ac_wrapper.cpp +++ b/src/map/if/acd/ac_wrapper.cpp @@ -118,32 +118,25 @@ int acd2_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay return 0; } -inline int acd66_decompose( word * pTruth, unsigned nVars, unsigned char *decomposition ) +inline int acd66_evaluate( word * pTruth, unsigned nVars ) { using namespace acd; + acd66_impl acd( nVars, true, false ); if ( acd.run( pTruth ) == 0 ) return 0; - if ( decomposition == NULL ) - return 1; - int val = acd.compute_decomposition(); - if ( val != 0 ) - { - return 0; - } - acd.get_decomposition( decomposition ); return 1; } -int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition ) +int acdXX_evaluate( word * pTruth, unsigned lutSize, unsigned nVars ) { using namespace acd; if ( lutSize == 6 ) { - return acd66_decompose( pTruth, nVars, decomposition ); + return acd66_evaluate( pTruth, nVars ); } acdXX_params ps; @@ -153,14 +146,29 @@ int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned c if ( acd.run( pTruth ) == 0 ) return 0; - if ( decomposition == NULL ) - return 1; - int val = acd.compute_decomposition(); - if ( val != 0 ) + + return 1; +} + +int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition ) +{ + using namespace acd; + + acdXX_params ps; + ps.lut_size = lutSize; + + for ( int i = 0; i <= lutSize - 2; ++i ) { + ps.max_shared_vars = i; + ps.min_shared_vars = i; + acdXX_impl acd( nVars, ps ); + + if ( acd.run( pTruth ) == 0 ) + continue; + acd.compute_decomposition(); + acd.get_decomposition( decomposition ); return 0; } - acd.get_decomposition( decomposition ); return 1; } diff --git a/src/map/if/acd/ac_wrapper.h b/src/map/if/acd/ac_wrapper.h index edb45ca7f..47c9afe45 100644 --- a/src/map/if/acd/ac_wrapper.h +++ b/src/map/if/acd/ac_wrapper.h @@ -37,6 +37,7 @@ int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, int acd2_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival ); int acd2_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition ); +int acdXX_evaluate( word * pTruth, unsigned lutSize, unsigned nVars ); int acdXX_decompose( word * pTruth, unsigned lutSize, unsigned nVars, unsigned char *decomposition ); ABC_NAMESPACE_HEADER_END diff --git a/src/map/if/acd/acdXX.hpp b/src/map/if/acd/acdXX.hpp index e43404ea9..e57199ce7 100644 --- a/src/map/if/acd/acdXX.hpp +++ b/src/map/if/acd/acdXX.hpp @@ -52,6 +52,9 @@ struct acdXX_params /* Maximum number of variables in the shared set */ uint32_t max_shared_vars{ 4 }; + /* Minimum number of variables in the shared set */ + uint32_t min_shared_vars{ 0 }; + /* Run verification */ bool verify{ false }; }; @@ -795,7 +798,7 @@ private: uint32_t max_shared_vars = std::min( ps.lut_size - best_free_set - 1, ps.max_shared_vars ); /* search for a feasible shared set */ - for ( uint32_t i = target_num_ss; i <= max_shared_vars; ++i ) + for ( uint32_t i = std::max( target_num_ss, ps.min_shared_vars ); i <= max_shared_vars; ++i ) { for ( uint32_t i = 0; i < 6; ++i ) { diff --git a/src/map/if/if.h b/src/map/if/if.h index 723fda780..2efe979d1 100644 --- a/src/map/if/if.h +++ b/src/map/if/if.h @@ -149,6 +149,7 @@ struct If_Par_t_ int fHashMapping; // perform AIG hashing after mapping int fUserLutDec; // perform Boolean decomposition during mapping int fUserLut2D; // perform Boolean decomposition during mapping + int fReturnDec; // perform Boolean decomposition during mapping int fVerbose; // the verbosity flag int fVerboseTrace; // the verbosity flag char * pLutStruct; // LUT structure diff --git a/src/map/if/ifDec66.c b/src/map/if/ifDec66.c index 9c486685c..df29f5292 100644 --- a/src/map/if/ifDec66.c +++ b/src/map/if/ifDec66.c @@ -267,7 +267,7 @@ int If_CluCheckXX( If_Man_t * p, word * pTruth0, int lutSize, int nVars, int fHa /* new entry */ if ( G1.nVars == 0 ) { - G1.nVars = acdXX_decompose( pTruth0, lutSize, nVars, NULL ); + G1.nVars = acdXX_evaluate( pTruth0, lutSize, nVars ); } if ( pHashed )