Skip to content

Commit 29706eb

Browse files
committed
Bug with LUT cascade mapping.
1 parent 80becaf commit 29706eb

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/misc/util/utilBSet.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ struct Abc_BSEval_t_
5252
Vec_Wrd_t * vCofs; // cofactors
5353
};
5454

55+
#define MAX_PAT_WORD_SIZE 1024 // 64 cofs * 16 words
56+
5557
////////////////////////////////////////////////////////////////////////
5658
/// FUNCTION DEFINITIONS ///
5759
////////////////////////////////////////////////////////////////////////
@@ -197,7 +199,7 @@ int Abc_TtGetCMCount( word * p, int nVars, int nFVars, Vec_Int_t * vCounts, Vec_
197199
return Abc_TtGetCM4( p, nVars, Vec_IntArray(vCounts), vUsed );
198200
if ( nFVars == 5 )
199201
return Abc_TtGetCM5( p, nVars, vTable, vStore, vUsed );
200-
if ( nFVars == 6 )
202+
if ( nFVars >= 6 && nFVars <= 10 )
201203
return Abc_TtGetCM6( p, nVars, nFVars, vTable, vStore, vUsed );
202204
assert( 0 );
203205
return 0;
@@ -345,7 +347,7 @@ int Abc_TtGetCMInt( word * p, int nVars, int nFVars, Vec_Int_t * vCounts, Vec_In
345347
{
346348
int nMintsBS = 1 << (nVars - nFVars);
347349
int nWordsBS = Abc_TtWordNum(nVars - nFVars);
348-
assert( nMintsBS * nWordsBS <= 1024 );
350+
assert( nMintsBS * nWordsBS <= MAX_PAT_WORD_SIZE );
349351
memset( pPat, 0, 8 * nMintsBS * nWordsBS );
350352
int nMyu = 0;
351353
if ( nFVars == 1 )
@@ -358,15 +360,15 @@ int Abc_TtGetCMInt( word * p, int nVars, int nFVars, Vec_Int_t * vCounts, Vec_In
358360
nMyu = Abc_TtGetCM4Pat( p, nVars, Vec_IntArray(vCounts), vUsed, pPat );
359361
else if ( nFVars == 5 )
360362
nMyu = Abc_TtGetCM5Pat( p, nVars, vTable, vStore, vUsed, pPat );
361-
else if ( nFVars == 6 )
363+
else if ( nFVars >= 6 && nFVars <= 10 )
362364
nMyu = Abc_TtGetCM6Pat( p, nVars, nFVars, vTable, vStore, vUsed, pPat );
363365
else assert( 0 );
364366
return nMyu;
365367
}
366368

367369
int Abc_TtGetCMPat( word * p, int nVars, int nFVars, Vec_Int_t * vCounts, Vec_Int_t * vTable, Vec_Wrd_t * vStore, Vec_Int_t * vUsed )
368370
{
369-
word pPat[1024];
371+
word pPat[MAX_PAT_WORD_SIZE];
370372
int nRails, nMyu = Abc_TtGetCMInt( p, nVars, nFVars, vCounts, vTable, vStore, vUsed, pPat );
371373
if ( nMyu <= 2 )
372374
nRails = 1;
@@ -620,7 +622,7 @@ int Abc_BSEvalBest( Abc_BSEval_t * p, word * pIn, word * pBest, int nVars, int n
620622
//printf( "\n" );
621623
}
622624
if ( 0 ) {
623-
word pPat[1024];
625+
word pPat[MAX_PAT_WORD_SIZE];
624626
int nRails = 1, Shared = 0;
625627
if ( CostThis > (1 << nRails) ) {
626628
extern int Abc_SharedEvalBest( Abc_BSEval_t * p, word * pTruth, int nVars, int nCVars, int nFVars, int MyuMin, int nRails, int fVerbose, int * pSetShared, word * pPat );
@@ -921,7 +923,8 @@ word * Abc_LutCascade2( word * pFunc, int nVars, int nLutSize, int nLuts, int nR
921923
word * pTruth = ABC_ALLOC( word, Abc_TtWordNum(nVars) );
922924
word * pBest = ABC_ALLOC( word, Abc_TtWordNum(nVars) );
923925
Abc_TtCopy( pTruth, pFunc, Abc_TtWordNum(nVars), 0 );
924-
int i, nVarsCur = nVars, nOutVars = 0; word pPat[1024];
926+
int i, nVarsCur = nVars, nOutVars = 0;
927+
word pPat[MAX_PAT_WORD_SIZE];
925928
while ( nVarsCur > nLutSize )
926929
{
927930
int pPerm[32] = {0};
@@ -1001,9 +1004,7 @@ word Abc_TtFindBVarsSVars( word * pTruth, int nVars, int nRVars, int nRails, int
10011004
int v, nWords = Abc_TtWordNum(nVars);
10021005
word * pCopy = ABC_ALLOC( word, nWords );
10031006
Abc_TtCopy( pCopy, pTruth, nWords, 0 );
1004-
word pPat[1024];
1005-
1006-
//Abc_TtPrintHexRev( stdout, pTruth, nVars ); printf( "\n" );
1007+
word pPat[MAX_PAT_WORD_SIZE];
10071008

10081009
int pPermBest[32] = {0};
10091010
word * pBest = ABC_ALLOC( word, nWords );

0 commit comments

Comments
 (0)