mirror of https://github.com/YosysHQ/abc.git
Improvements to "lutcasdec".
This commit is contained in:
parent
9bb736acee
commit
29c8d3eacf
|
|
@ -9171,12 +9171,12 @@ usage:
|
||||||
int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
{
|
{
|
||||||
extern Abc_Ntk_t * Abc_NtkLutCascadeGen( int nLutSize, int nStages, int nRails, int nShared, int fVerbose );
|
extern Abc_Ntk_t * Abc_NtkLutCascadeGen( int nLutSize, int nStages, int nRails, int nShared, int fVerbose );
|
||||||
extern Abc_Ntk_t * Abc_NtkLutCascade2( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, char * pGuide );
|
extern Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int fXRail, int Seed, int fVerbose, int fVeryVerbose, char * pGuide );
|
||||||
extern void Abc_NtkLutCascadeFile( char * pFileName, int nVarNum, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu );
|
extern void Abc_NtkLutCascadeFile( char * pFileName, int nVarNum, int nLutSize, int nLuts, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail );
|
||||||
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; char * pGuide = NULL, * pFileName = NULL;
|
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; char * pGuide = NULL, * pFileName = NULL;
|
||||||
int c, nVarNum = -1, nLutSize = 6, nStages = 8, nRails = 1, nShared = 2, Seed = 0, nIters = 1, nJRatio = 0, nZParam = 0, fGen = 0, fPrintMyu = 0, fVerbose = 0, fVeryVerbose = 0;
|
int c, nVarNum = -1, nLutSize = 6, nStages = 8, nRails = 1, nShared = 2, Seed = 0, nIters = 1, nJRatio = 0, nZParam = 0, fGen = 0, fPrintMyu = 0, fPrintLev = 0, fXRail = 0, fVerbose = 0, fVeryVerbose = 0;
|
||||||
Extra_UtilGetoptReset();
|
Extra_UtilGetoptReset();
|
||||||
while ( ( c = Extra_UtilGetopt( argc, argv, "KMRSCIJZNFgmvwh" ) ) != EOF )
|
while ( ( c = Extra_UtilGetopt( argc, argv, "KMRSCIJZNFgmlxvwh" ) ) != EOF )
|
||||||
{
|
{
|
||||||
switch ( c )
|
switch ( c )
|
||||||
{
|
{
|
||||||
|
|
@ -9292,6 +9292,12 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
case 'm':
|
case 'm':
|
||||||
fPrintMyu ^= 1;
|
fPrintMyu ^= 1;
|
||||||
break;
|
break;
|
||||||
|
case 'l':
|
||||||
|
fPrintLev ^= 1;
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
fXRail ^= 1;
|
||||||
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
fVerbose ^= 1;
|
fVerbose ^= 1;
|
||||||
break;
|
break;
|
||||||
|
|
@ -9311,7 +9317,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
Abc_Print( -1, "The number of variables should be given on the command line using switch \"-N <num>\".\n" );
|
Abc_Print( -1, "The number of variables should be given on the command line using switch \"-N <num>\".\n" );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
Abc_NtkLutCascadeFile( pFileName, nVarNum, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, Seed, fVerbose, fVeryVerbose, fPrintMyu );
|
Abc_NtkLutCascadeFile( pFileName, nVarNum, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, Seed, fVerbose, fVeryVerbose, fPrintMyu, fPrintLev, fXRail );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( fGen )
|
if ( fGen )
|
||||||
|
|
@ -9348,7 +9354,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
}
|
}
|
||||||
if ( argc == globalUtilOptind + 1 )
|
if ( argc == globalUtilOptind + 1 )
|
||||||
pGuide = argv[globalUtilOptind];
|
pGuide = argv[globalUtilOptind];
|
||||||
pNtkRes = Abc_NtkLutCascade2( pNtk, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, Seed, fVerbose, fVeryVerbose, pGuide );
|
pNtkRes = Abc_NtkLutCascadeOne( pNtk, nLutSize, nStages, nRails, nIters, nJRatio, nZParam, fXRail, Seed, fVerbose, fVeryVerbose, pGuide );
|
||||||
if ( pNtkRes == NULL )
|
if ( pNtkRes == NULL )
|
||||||
{
|
{
|
||||||
Abc_Print( -1, "LUT cascade mapping failed.\n" );
|
Abc_Print( -1, "LUT cascade mapping failed.\n" );
|
||||||
|
|
@ -9358,7 +9364,7 @@ int Abc_CommandLutCasDec( Abc_Frame_t * pAbc, int argc, char ** argv )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
Abc_Print( -2, "usage: lutcasdec [-KMRCSIJZN <num>] [-F <file>] [-gmvwh]\n" );
|
Abc_Print( -2, "usage: lutcasdec [-KMRCSIJZN <num>] [-F <file>] [-gmlxvwh]\n" );
|
||||||
Abc_Print( -2, "\t decomposes the primary output functions into LUT cascades\n" );
|
Abc_Print( -2, "\t decomposes the primary output functions into LUT cascades\n" );
|
||||||
Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
|
Abc_Print( -2, "\t-K <num> : the number of LUT inputs [default = %d]\n", nLutSize );
|
||||||
Abc_Print( -2, "\t-M <num> : the maximum delay (the number of stages) [default = %d]\n", nStages );
|
Abc_Print( -2, "\t-M <num> : the maximum delay (the number of stages) [default = %d]\n", nStages );
|
||||||
|
|
@ -9372,6 +9378,8 @@ usage:
|
||||||
Abc_Print( -2, "\t-F <file>: a text file with truth tables in hexadecimal listed one per line\n");
|
Abc_Print( -2, "\t-F <file>: a text file with truth tables in hexadecimal listed one per line\n");
|
||||||
Abc_Print( -2, "\t-g : toggle generating random cascade with these parameters [default = %s]\n", fGen? "yes": "no" );
|
Abc_Print( -2, "\t-g : toggle generating random cascade with these parameters [default = %s]\n", fGen? "yes": "no" );
|
||||||
Abc_Print( -2, "\t-m : toggle printing column multiplicity statistics [default = %s]\n", fPrintMyu? "yes": "no" );
|
Abc_Print( -2, "\t-m : toggle printing column multiplicity statistics [default = %s]\n", fPrintMyu? "yes": "no" );
|
||||||
|
Abc_Print( -2, "\t-l : toggle printing level counting statistics [default = %s]\n", fPrintLev? "yes": "no" );
|
||||||
|
Abc_Print( -2, "\t-x : toggle using extended cascade decomposition [default = %s]\n", fXRail? "yes": "no" );
|
||||||
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
|
Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
|
||||||
Abc_Print( -2, "\t-w : toggle additional verbose printout [default = %s]\n", fVeryVerbose? "yes": "no" );
|
Abc_Print( -2, "\t-w : toggle additional verbose printout [default = %s]\n", fVeryVerbose? "yes": "no" );
|
||||||
Abc_Print( -2, "\t-h : print the command usage\n");
|
Abc_Print( -2, "\t-h : print the command usage\n");
|
||||||
|
|
|
||||||
|
|
@ -656,22 +656,18 @@ void Abc_LutCascadeDerive( word * p, int nVars, int nBVars, int Myu, word * pRem
|
||||||
}
|
}
|
||||||
|
|
||||||
// performs decomposition of one stage
|
// performs decomposition of one stage
|
||||||
static inline int Abc_LutCascadeDecStage( char * pGuide, int Iter, Vec_Wrd_t * vFuncs[3], Vec_Int_t * vVarIDs, int nRVars, int nRails, int nLutSize, int nJRatio, int nZParam, int fVerbose, Vec_Wrd_t * vCas, int * pMyu )
|
static inline int Abc_LutCascadeDecStage( word Guide0, char * pGuide, int Iter, Vec_Wrd_t * vFuncs[3], Vec_Int_t * vVarIDs, int nRVars, int nRails, int nLutSize, int nJRatio, int nZParam, int fVerbose, Vec_Wrd_t * vCas, int * pMyu )
|
||||||
{
|
{
|
||||||
extern word Abc_TtFindBVarsSVars( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
|
//extern word Abc_TtFindBVarsSVars( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
|
||||||
extern word Abc_TtFindBVarsSVars2( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
|
//extern word Abc_TtFindBVarsSVars2( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
|
||||||
assert( Vec_IntSize(vVarIDs) > nLutSize );
|
assert( Vec_IntSize(vVarIDs) > nLutSize );
|
||||||
assert( Vec_IntSize(vVarIDs) <= 24 );
|
assert( Vec_IntSize(vVarIDs) <= 24 );
|
||||||
//word Guide = pGuide ? 0 : Abc_TtFindBVarsSVars( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nJRatio );
|
//word Guide = pGuide ? 0 : Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nZParam );
|
||||||
word Guide = pGuide ? 0 : Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nZParam );
|
word Guide = pGuide ? 0 : Guide0;
|
||||||
// if ( nZParam )
|
|
||||||
// Guide = pGuide ? 0 : Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nZParam );
|
|
||||||
// else
|
|
||||||
// Guide = pGuide ? 0 : Abc_TtFindBVarsSVars( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nJRatio );
|
|
||||||
if ( !pGuide && !Guide ) {
|
if ( !pGuide && !Guide ) {
|
||||||
if ( fVerbose )
|
if ( fVerbose )
|
||||||
printf( "The function is not decomposable with %d rails.\n", nRails );
|
printf( "The function is not decomposable with %d rails.\n", nRails );
|
||||||
Vec_IntClear( vVarIDs );
|
//Vec_IntClear( vVarIDs );
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int m, Myu = pGuide ? 1 << nRails : (Guide >> 48) & 0xFF;
|
int m, Myu = pGuide ? 1 << nRails : (Guide >> 48) & 0xFF;
|
||||||
|
|
@ -722,23 +718,49 @@ static inline int Abc_LutCascadeDecStage( char * pGuide, int Iter, Vec_Wrd_t * v
|
||||||
Vec_IntShrink( vVarIDs, nFVars+nSVars+nEVars );
|
Vec_IntShrink( vVarIDs, nFVars+nSVars+nEVars );
|
||||||
return nEVars;
|
return nEVars;
|
||||||
}
|
}
|
||||||
word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t * vVarIDs, int nRails, int nLutSize, int nStages, int nJRatio, int nZParam, int fVerbose, int * pnStages, int * pMyu )
|
word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t * vVarIDs, int nRails, int nLutSize, int nStages, int nJRatio, int nZParam, int fXRail, int fVerbose, int * pnStages, int * pMyu )
|
||||||
{
|
{
|
||||||
|
extern Vec_Wrd_t * Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nMyuIncrease );
|
||||||
word * pRes = NULL; int i, nRVars = 0, nVars = Vec_IntSize(vVarIDs);
|
word * pRes = NULL; int i, nRVars = 0, nVars = Vec_IntSize(vVarIDs);
|
||||||
Vec_Wrd_t * vFuncs[3] = { Vec_WrdStart(Abc_TtWordNum(nVars)), Vec_WrdAlloc(0), Vec_WrdAlloc(0) };
|
Vec_Wrd_t * vFuncs[3] = { Vec_WrdStart(Abc_TtWordNum(nVars)), Vec_WrdAlloc(0), Vec_WrdAlloc(0) };
|
||||||
Abc_TtCopy( Vec_WrdArray(vFuncs[0]), pTruth, Abc_TtWordNum(nVars), 0 );
|
Abc_TtCopy( Vec_WrdArray(vFuncs[0]), pTruth, Abc_TtWordNum(nVars), 0 );
|
||||||
Vec_Wrd_t * vCas = Vec_WrdAlloc( 100 ); Vec_WrdPush( vCas, nVarsOrig );
|
Vec_Wrd_t * vCas = Vec_WrdAlloc( 100 ); Vec_WrdPush( vCas, nVarsOrig );
|
||||||
if ( pnStages ) *pnStages = 0;
|
if ( pnStages ) *pnStages = 0;
|
||||||
for ( i = 0; Vec_IntSize(vVarIDs) > nLutSize; i++ ) {
|
for ( i = 0; Vec_IntSize(vVarIDs) > nLutSize; i++ ) {
|
||||||
nRVars = Abc_LutCascadeDecStage( pGuide, i, vFuncs, vVarIDs, nRVars, nRails, nLutSize, nJRatio, nZParam, fVerbose, vCas, i ? NULL : pMyu );
|
int nRVarsOld = nRVars;
|
||||||
|
Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nZParam );
|
||||||
|
if ( vGuides ) {
|
||||||
|
word Guide0 = Vec_WrdEntry(vGuides, 0);
|
||||||
|
Vec_WrdFree( vGuides );
|
||||||
|
nRVars = Abc_LutCascadeDecStage( Guide0, pGuide, i, vFuncs, vVarIDs, nRVars, nRails, nLutSize, nJRatio, nZParam, fVerbose, vCas, i ? NULL : pMyu );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nRVars = -1;
|
||||||
if ( i+2 > nStages ) {
|
if ( i+2 > nStages ) {
|
||||||
if ( fVerbose )
|
if ( fVerbose )
|
||||||
printf( "The length of the cascade (%d) exceeds the max allowed number of stages (%d).\n", i+2, nStages );
|
printf( "The length of the cascade (%d) exceeds the max allowed number of stages (%d).\n", i+2, nStages );
|
||||||
nRVars = -1;
|
nRVars = -1;
|
||||||
}
|
}
|
||||||
if ( nRVars == -1 )
|
if ( nRVars == -1 && Vec_IntSize(vVarIDs) > nLutSize-1 && fXRail ) {
|
||||||
|
Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVarsOld, nRails+1, nLutSize-1, fVerbose, pMyu, nZParam );
|
||||||
|
if ( vGuides ) {
|
||||||
|
word Guide0 = Vec_WrdEntry(vGuides, 0);
|
||||||
|
Vec_WrdFree( vGuides );
|
||||||
|
nRVars = Abc_LutCascadeDecStage( Guide0, pGuide, i, vFuncs, vVarIDs, nRVarsOld, nRails+1, nLutSize-1, nJRatio, nZParam, fVerbose, vCas, NULL );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nRVars = -1;
|
||||||
|
if ( i+2 > nStages ) {
|
||||||
|
if ( fVerbose )
|
||||||
|
printf( "The length of the cascade (%d) exceeds the max allowed number of stages (%d).\n", i+2, nStages );
|
||||||
|
nRVars = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( nRVars == -1 ) {
|
||||||
|
Vec_IntClear( vVarIDs );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( nRVars != -1 && Vec_IntSize(vVarIDs) > 0 ) {
|
if ( nRVars != -1 && Vec_IntSize(vVarIDs) > 0 ) {
|
||||||
Abc_LutCascadeGenOne( vCas, Vec_IntSize(vVarIDs), Vec_IntArray(vVarIDs), Vec_WrdEntry(vCas, 0), Vec_WrdArray(vFuncs[0]) );
|
Abc_LutCascadeGenOne( vCas, Vec_IntSize(vVarIDs), Vec_IntArray(vVarIDs), Vec_WrdEntry(vCas, 0), Vec_WrdArray(vFuncs[0]) );
|
||||||
Vec_WrdAddToEntry( vCas, 0, -nVarsOrig );
|
Vec_WrdAddToEntry( vCas, 0, -nVarsOrig );
|
||||||
|
|
@ -842,7 +864,7 @@ Abc_Ntk_t * Abc_NtkLutCascade( Abc_Ntk_t * pNtk, int nLutSize, int nStages, int
|
||||||
Gia_ManStop( pGia );
|
Gia_ManStop( pGia );
|
||||||
return pNew;
|
return pNew;
|
||||||
}
|
}
|
||||||
Abc_Ntk_t * Abc_NtkLutCascade2( Abc_Ntk_t * pNtk, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, char * pGuide )
|
Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int fXRail, int Seed, int fVerbose, int fVeryVerbose, char * pGuide )
|
||||||
{
|
{
|
||||||
extern Gia_Man_t * Abc_NtkStrashToGia( Abc_Ntk_t * pNtk );
|
extern Gia_Man_t * Abc_NtkStrashToGia( Abc_Ntk_t * pNtk );
|
||||||
int i, nWords = Abc_TtWordNum(Abc_NtkCiNum(pNtk));
|
int i, nWords = Abc_TtWordNum(Abc_NtkCiNum(pNtk));
|
||||||
|
|
@ -870,7 +892,7 @@ Abc_Ntk_t * Abc_NtkLutCascade2( Abc_Ntk_t * pNtk, int nLutSize, int nStages, int
|
||||||
printf( ".\n" );
|
printf( ".\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
word * pLuts = Abc_LutCascadeDec( pGuide, pTruth1, Abc_NtkCiNum(pNtk), vVarIDs, nRails, nLutSize, nStages, Iter >= nIters ? 1 : 0, nZParam, fVeryVerbose, NULL, NULL );
|
word * pLuts = Abc_LutCascadeDec( pGuide, pTruth1, Abc_NtkCiNum(pNtk), vVarIDs, nRails, nLutSize, nStages, Iter >= nIters ? 1 : 0, nZParam, fXRail, fVeryVerbose, NULL, NULL );
|
||||||
pNew = pLuts ? Abc_NtkLutCascadeFromLuts( pLuts, Abc_NtkCiNum(pNtk), pNtk, nLutSize, fVerbose ) : NULL;
|
pNew = pLuts ? Abc_NtkLutCascadeFromLuts( pLuts, Abc_NtkCiNum(pNtk), pNtk, nLutSize, fVerbose ) : NULL;
|
||||||
Vec_IntFree( vVarIDs );
|
Vec_IntFree( vVarIDs );
|
||||||
|
|
||||||
|
|
@ -1383,7 +1405,7 @@ Vec_Wrd_t * Abc_NtkLutCasReadTruths( char * pFileName, int nVarsOrig )
|
||||||
SeeAlso []
|
SeeAlso []
|
||||||
|
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu )
|
void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int nStages, int nRails, int nIters, int nJRatio, int nZParam, int Seed, int fVerbose, int fVeryVerbose, int fPrintMyu, int fPrintLev, int fXRail )
|
||||||
{
|
{
|
||||||
abctime clkStart = Abc_Clock();
|
abctime clkStart = Abc_Clock();
|
||||||
int i, Sum = 0, nStageCount = 0, MyuMin = 0, nTotalLuts = 0, nWords = Abc_TtWordNum(nVarsOrig);
|
int i, Sum = 0, nStageCount = 0, MyuMin = 0, nTotalLuts = 0, nWords = Abc_TtWordNum(nVarsOrig);
|
||||||
|
|
@ -1431,7 +1453,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
|
||||||
printf( "Decomposing %d-var function into %d-rail cascade of %d-LUTs.\n", nVars, nRails, nLutSize );
|
printf( "Decomposing %d-var function into %d-rail cascade of %d-LUTs.\n", nVars, nRails, nLutSize );
|
||||||
}
|
}
|
||||||
|
|
||||||
word * pLuts = Abc_LutCascadeDec( NULL, pTruth, nVarsOrig, vVarIDs, nRails, nLutSize, nStages, (int)(Iter >= nIters), nZParam, fVeryVerbose, &nStageCount, &MyuMin );
|
word * pLuts = Abc_LutCascadeDec( NULL, pTruth, nVarsOrig, vVarIDs, nRails, nLutSize, nStages, (int)(Iter >= nIters), nZParam, fXRail, fVeryVerbose, &nStageCount, &MyuMin );
|
||||||
Vec_IntFree( vVarIDs );
|
Vec_IntFree( vVarIDs );
|
||||||
if ( MyuMin < 50 ) MyuStats[MyuMin]++, IterReal++;
|
if ( MyuMin < 50 ) MyuStats[MyuMin]++, IterReal++;
|
||||||
if ( pLuts == NULL ) {
|
if ( pLuts == NULL ) {
|
||||||
|
|
@ -1473,7 +1495,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
|
||||||
if ( MyuStats[i] )
|
if ( MyuStats[i] )
|
||||||
printf( " %2d Myu : Function count = %8d (%6.2f %%)\n", i, MyuStats[i], 100.0*MyuStats[i]/nFuncs/IterReal );
|
printf( " %2d Myu : Function count = %8d (%6.2f %%)\n", i, MyuStats[i], 100.0*MyuStats[i]/nFuncs/IterReal );
|
||||||
}
|
}
|
||||||
if ( nRails > 1 ) {
|
if ( fPrintLev ) {
|
||||||
printf( "Level count statistics for %d-rail LUT cascade:\n", nRails );
|
printf( "Level count statistics for %d-rail LUT cascade:\n", nRails );
|
||||||
for ( i = 0; i < 50; i++ )
|
for ( i = 0; i < 50; i++ )
|
||||||
if ( StageStats[i] )
|
if ( StageStats[i] )
|
||||||
|
|
|
||||||
|
|
@ -897,7 +897,7 @@ int Abc_SharedEvalBest( Abc_BSEval_t * p, word * pTruth, int nVars, int nCVars,
|
||||||
int nBSWords = Abc_Truth6WordNum( nVars - nFVars ), CVarMask = nCVars ? Abc_InfoMask(nCVars) << (nVars - nCVars - nFVars) : 0;
|
int nBSWords = Abc_Truth6WordNum( nVars - nFVars ), CVarMask = nCVars ? Abc_InfoMask(nCVars) << (nVars - nCVars - nFVars) : 0;
|
||||||
int MyuCur, Myu = Abc_TtGetCMInt( pTruth, nVars, nFVars, p->vCounts, p->vTable, p->vStore, p->vUsed, pPat );
|
int MyuCur, Myu = Abc_TtGetCMInt( pTruth, nVars, nFVars, p->vCounts, p->vTable, p->vStore, p->vUsed, pPat );
|
||||||
int nRailsCur = Abc_Base2Log( Myu ); Vec_Int_t * vLevel;
|
int nRailsCur = Abc_Base2Log( Myu ); Vec_Int_t * vLevel;
|
||||||
assert( Myu == MyuMin && nRailsCur > nRails );
|
assert( Myu == MyuMin && nRailsCur >= nRails );
|
||||||
int i, k, iSet, iStart, nSharedMax = nVars - nFVars - nRails, nRailsMin = 100;
|
int i, k, iSet, iStart, nSharedMax = nVars - nFVars - nRails, nRailsMin = 100;
|
||||||
Vec_WecForEachLevelStartStop( p->vSets, vLevel, i, 1, nSharedMax ) {
|
Vec_WecForEachLevelStartStop( p->vSets, vLevel, i, 1, nSharedMax ) {
|
||||||
Vec_IntForEachEntryDouble( vLevel, iSet, iStart, k ) {
|
Vec_IntForEachEntryDouble( vLevel, iSet, iStart, k ) {
|
||||||
|
|
@ -1018,7 +1018,7 @@ word Abc_BSEvalEncode( int * pPermBest, int nVars, int nLutSize, int Shared, int
|
||||||
mSVars |= (word)1 << (nVars-nLutSize+v);
|
mSVars |= (word)1 << (nVars-nLutSize+v);
|
||||||
return ((word)MyuMin << 48) | (mSVars << 24) | mBVars;
|
return ((word)MyuMin << 48) | (mSVars << 24) | mBVars;
|
||||||
}
|
}
|
||||||
word Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nMyuIncrease )
|
Vec_Wrd_t * Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nMyuIncrease )
|
||||||
{
|
{
|
||||||
Abc_BSEval_t * p = Abc_BSEvalAlloc();
|
Abc_BSEval_t * p = Abc_BSEvalAlloc();
|
||||||
int nFVars = nVars-nLutSize;
|
int nFVars = nVars-nLutSize;
|
||||||
|
|
@ -1043,7 +1043,7 @@ word Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, in
|
||||||
word * pCopy = ABC_ALLOC( word, nWords );
|
word * pCopy = ABC_ALLOC( word, nWords );
|
||||||
Abc_TtCopy( pCopy, pTruth, nWords, 0 );
|
Abc_TtCopy( pCopy, pTruth, nWords, 0 );
|
||||||
|
|
||||||
word Result = 0;
|
Vec_Wrd_t * vRes = Vec_WrdAlloc( 10 );
|
||||||
int i, k, Var0, Var1, Pla2Var[32], Var2Pla[32];
|
int i, k, Var0, Var1, Pla2Var[32], Var2Pla[32];
|
||||||
for ( i = 0; i < nVars; i++ )
|
for ( i = 0; i < nVars; i++ )
|
||||||
Pla2Var[i] = Var2Pla[i] = i;
|
Pla2Var[i] = Var2Pla[i] = i;
|
||||||
|
|
@ -1071,20 +1071,29 @@ word Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, in
|
||||||
int Shared = 0, nSetSize = 0;
|
int Shared = 0, nSetSize = 0;
|
||||||
if ( MyuThis > 2 ) {
|
if ( MyuThis > 2 ) {
|
||||||
int SharedThis = 0, nSetSizeThis = 0;
|
int SharedThis = 0, nSetSizeThis = 0;
|
||||||
int nRailsMin = Abc_SharedEvalBest( p, pCopy, nVars, nCVars, nFVars, MyuThis, nRails, 0, &SharedThis, &nSetSizeThis, p->pPat );
|
int nRailsMin = 100;
|
||||||
|
for ( int r = 1; r <= nRails && nRailsMin > r; r++ ) {
|
||||||
|
int nRailsMinNew = Abc_SharedEvalBest( p, pCopy, nVars, nCVars, nFVars, MyuThis, r, 0, &SharedThis, &nSetSizeThis, p->pPat );
|
||||||
|
if ( nRailsMinNew < 100 )
|
||||||
|
nRailsMin = nRailsMinNew;
|
||||||
|
}
|
||||||
if ( fVerbose )
|
if ( fVerbose )
|
||||||
printf( " RailsMyu = %3d. RailsMin = %3d. Shared = %2d. SetSize = %d.", Abc_Base2Log(MyuThis), nRailsMin, SharedThis, nSetSizeThis );
|
printf( " RailsMyu = %3d. RailsMin = %3d. Shared = %2d. SetSize = %d.", Abc_Base2Log(MyuThis), nRailsMin, SharedThis, nSetSizeThis );
|
||||||
if ( nRailsMin <= nRails ) {
|
if ( nRailsMin <= nRails ) {
|
||||||
assert( Abc_Base2Log(MyuThis) >= nRailsMin );
|
|
||||||
MyuThis = 1 << nRailsMin;
|
MyuThis = 1 << nRailsMin;
|
||||||
Shared = SharedThis;
|
Shared = SharedThis;
|
||||||
nSetSize = nSetSizeThis;
|
nSetSize = nSetSizeThis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( MyuBest > MyuThis || (MyuBest == MyuThis && nSetSizeBest > nSetSize) ) {
|
if ( MyuBest > MyuThis || (MyuBest == MyuThis && nSetSizeBest >= nSetSize) ) {
|
||||||
|
int fSave = MyuBest == MyuThis && nSetSizeBest == nSetSize;
|
||||||
MyuBest = MyuThis;
|
MyuBest = MyuThis;
|
||||||
nSetSizeBest = nSetSize;
|
nSetSizeBest = nSetSize;
|
||||||
Result = Abc_BSEvalEncode( Pla2Var, nVars, p->nBVars, Shared, MyuBest, nSetSize );
|
word Result = Abc_BSEvalEncode( Pla2Var, nVars, p->nBVars, Shared, MyuBest, nSetSize );
|
||||||
|
if ( fSave )
|
||||||
|
Vec_WrdPush( vRes, Result );
|
||||||
|
else
|
||||||
|
Vec_WrdFill( vRes, 1, Result );
|
||||||
if ( fVerbose )
|
if ( fVerbose )
|
||||||
printf( " <== best" );
|
printf( " <== best" );
|
||||||
}
|
}
|
||||||
|
|
@ -1117,11 +1126,14 @@ word Abc_TtFindBVarsSVars2( word * pTruth, int nVars, int nCVars, int nRails, in
|
||||||
}
|
}
|
||||||
if ( !Abc_TtEqual(pCopy, pTruth, nWords) )
|
if ( !Abc_TtEqual(pCopy, pTruth, nWords) )
|
||||||
printf( "Internal truth table check failed.\n" );
|
printf( "Internal truth table check failed.\n" );
|
||||||
|
//printf( "%d ", Count );
|
||||||
|
|
||||||
Abc_BSEvalFree(p);
|
Abc_BSEvalFree(p);
|
||||||
if ( MyuBest > (1 << nRails) )
|
if ( MyuBest > (1 << nRails) ) {
|
||||||
return 0;
|
Vec_WrdFree(vRes);
|
||||||
return Result;
|
return NULL;
|
||||||
|
}
|
||||||
|
return vRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue