@@ -656,7 +656,7 @@ void Abc_LutCascadeDerive( word * p, int nVars, int nBVars, int Myu, word * pRem
656656}
657657
658658// performs decomposition of one stage
659- 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 )
659+ 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 nZParam , int fVerbose , Vec_Wrd_t * vCas , int * pMyu )
660660{
661661 assert ( Vec_IntSize (vVarIDs ) > nLutSize );
662662 assert ( Vec_IntSize (vVarIDs ) <= 24 );
@@ -709,20 +709,25 @@ static inline int Abc_LutCascadeDecStage( word Guide0, char * pGuide, int Iter,
709709 Vec_IntShrink ( vVarIDs , nFVars + nSVars + nEVars );
710710 return nEVars ;
711711}
712- 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 )
712+
713+ typedef struct Abc_BSEval_t_ Abc_BSEval_t ;
714+ extern Abc_BSEval_t * Abc_BSEvalAlloc ();
715+ extern void Abc_BSEvalFree ( Abc_BSEval_t * p );
716+
717+ word * Abc_LutCascadeDec ( Abc_BSEval_t * p , char * pGuide , word * pTruth , int nVarsOrig , Vec_Int_t * vVarIDs , int nRails , int nLutSize , int nStages , int fUseRand , int nZParam , int fXRail , int fVerbose , int * pnStages , int * pMyu )
713718{
714- extern Vec_Wrd_t * Abc_TtFindBVarsSVars2 ( word * pTruth , int nVars , int nCVars , int nRails , int nLutSize , int fVerbose , int * pMyu , int nMyuIncrease );
719+ extern Vec_Wrd_t * Abc_TtFindBVarsSVars2 ( Abc_BSEval_t * p , word * pTruth , int nVars , int nCVars , int nRails , int nLutSize , int fVerbose , int * pMyu , int nMyuIncrease );
715720 word * pRes = NULL ; int i , nRVars = 0 , nVars = Vec_IntSize (vVarIDs );
716721 Vec_Wrd_t * vFuncs [3 ] = { Vec_WrdStart (Abc_TtWordNum (nVars )), Vec_WrdAlloc (0 ), Vec_WrdAlloc (0 ) };
717722 Abc_TtCopy ( Vec_WrdArray (vFuncs [0 ]), pTruth , Abc_TtWordNum (nVars ), 0 );
718723 Vec_Wrd_t * vCas = Vec_WrdAlloc ( 100 ); Vec_WrdPush ( vCas , nVarsOrig );
719724 if ( pnStages ) * pnStages = 0 ;
720725 for ( i = 0 ; Vec_IntSize (vVarIDs ) > nLutSize ; i ++ ) {
721726 int nRVarsOld = nRVars ;
722- Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVars , nRails , nLutSize , fVerbose , pMyu , nZParam );
727+ Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( p , Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVars , nRails , nLutSize , fVerbose , pMyu , nZParam );
723728 if ( vGuides ) {
724- int iEntry = nJRatio ? Abc_Random (0 ) % Vec_WrdSize (vGuides ) : 0 ;
725- nRVars = Abc_LutCascadeDecStage ( Vec_WrdEntry (vGuides , iEntry ), pGuide , i , vFuncs , vVarIDs , nRVarsOld , nRails , nLutSize , nJRatio , nZParam , fVerbose , vCas , i ? NULL : pMyu );
729+ int iEntry = fUseRand ? Abc_Random (0 ) % Vec_WrdSize (vGuides ) : 0 ;
730+ nRVars = Abc_LutCascadeDecStage ( Vec_WrdEntry (vGuides , iEntry ), pGuide , i , vFuncs , vVarIDs , nRVarsOld , nRails , nLutSize , nZParam , fVerbose , vCas , i ? NULL : pMyu );
726731 Vec_WrdFree ( vGuides );
727732 }
728733 else
@@ -733,10 +738,10 @@ word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t
733738 nRVars = -1 ;
734739 }
735740 if ( fXRail && nRVars == -1 && Vec_IntSize (vVarIDs ) > nLutSize - 1 ) {
736- Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVarsOld , nRails + 1 , nLutSize - 1 , fVerbose , pMyu , nZParam );
741+ Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( p , Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVarsOld , nRails + 1 , nLutSize - 1 , fVerbose , pMyu , nZParam );
737742 if ( vGuides ) {
738- int iEntry = nJRatio ? Abc_Random (0 ) % Vec_WrdSize (vGuides ) : 0 ;
739- nRVars = Abc_LutCascadeDecStage ( Vec_WrdEntry (vGuides , iEntry ), pGuide , i , vFuncs , vVarIDs , nRVarsOld , nRails + 1 , nLutSize - 1 , nJRatio , nZParam , fVerbose , vCas , NULL );
743+ int iEntry = fUseRand ? Abc_Random (0 ) % Vec_WrdSize (vGuides ) : 0 ;
744+ nRVars = Abc_LutCascadeDecStage ( Vec_WrdEntry (vGuides , iEntry ), pGuide , i , vFuncs , vVarIDs , nRVarsOld , nRails + 1 , nLutSize - 1 , nZParam , fVerbose , vCas , NULL );
740745 Vec_WrdFree ( vGuides );
741746 }
742747 else
@@ -867,7 +872,8 @@ Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nStages, i
867872 Abc_Random (1 );
868873 for ( i = 0 ; i < Seed ; i ++ )
869874 Abc_Random (0 );
870- for ( int Iter = 0 ; Iter < nIters + nJRatio ; Iter ++ ) {
875+ Abc_BSEval_t * p = Abc_BSEvalAlloc ();
876+ for ( int Iter = 0 ; Iter < nIters ; Iter ++ ) {
871877 word * pTruth1 = Gia_ObjComputeTruthTable ( pGia , Gia_ManCo (pGia , 0 ) );
872878 Abc_TtCopy ( pCopy , pTruth1 , nWords , 0 );
873879
@@ -885,7 +891,7 @@ Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nStages, i
885891 printf ( ".\n" );
886892 }
887893
888- word * pLuts = Abc_LutCascadeDec ( pGuide , pTruth1 , Abc_NtkCiNum (pNtk ), vVarIDs , nRails , nLutSize , nStages , Iter >= nIters ? 1 : 0 , nZParam , fXRail , fVeryVerbose , NULL , NULL );
894+ word * pLuts = Abc_LutCascadeDec ( p , pGuide , pTruth1 , Abc_NtkCiNum (pNtk ), vVarIDs , nRails , nLutSize , nStages , ( int )( Iter > 0 ) , nZParam , fXRail , fVeryVerbose , NULL , NULL );
889895 pNew = pLuts ? Abc_NtkLutCascadeFromLuts ( pLuts , Abc_NtkCiNum (pNtk ), pNtk , nLutSize , fVerbose ) : NULL ;
890896 Vec_IntFree ( vVarIDs );
891897
@@ -906,6 +912,7 @@ Abc_Ntk_t * Abc_NtkLutCascadeOne( Abc_Ntk_t * pNtk, int nLutSize, int nStages, i
906912 }
907913 //ABC_FREE( pTruth1 );
908914 }
915+ Abc_BSEvalFree ( p );
909916 ABC_FREE ( pCopy );
910917 Gia_ManStop ( pGia );
911918 return pNew ;
@@ -1423,6 +1430,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
14231430 printf ( "Considering %d functions having %d variables from file \"%s\".\n" , nFuncs , nVarsOrig , pFileName );
14241431 word * pCopy = ABC_ALLOC ( word , nWords );
14251432 int Iter = 0 , IterReal = 0 , LutStats [50 ] = {0 }, StageStats [50 ] = {0 }, MyuStats [50 ] = {0 };
1433+ Abc_BSEval_t * p = Abc_BSEvalAlloc ();
14261434 for ( i = 0 ; i < nFuncs ; i ++ )
14271435 {
14281436 word * pTruth = Vec_WrdEntryP ( vTruths , i * nWords );
@@ -1446,11 +1454,11 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
14461454 printf ( "Decomposing %d-var function into %d-rail cascade of %d-LUTs.\n" , nVars , nRails , nLutSize );
14471455 }
14481456
1449- word * pLuts = Abc_LutCascadeDec ( NULL , pTruth , nVarsOrig , vVarIDs , nRails , nLutSize , nStages , (int )(Iter >= nIters ), nZParam , fXRail , fVeryVerbose , & nStageCount , & MyuMin );
1457+ word * pLuts = Abc_LutCascadeDec ( p , NULL , pTruth , nVarsOrig , vVarIDs , nRails , nLutSize , nStages , (int )(Iter > 0 ), nZParam , fXRail , fVeryVerbose , & nStageCount , & MyuMin );
14501458 Vec_IntFree ( vVarIDs );
14511459 if ( MyuMin < 50 ) MyuStats [MyuMin ]++ , IterReal ++ ;
14521460 if ( pLuts == NULL ) {
1453- if ( ++ Iter < nIters + nJRatio ) {
1461+ if ( ++ Iter < nIters ) {
14541462 i -- ;
14551463 continue ;
14561464 }
@@ -1480,6 +1488,7 @@ void Abc_NtkLutCascadeFile( char * pFileName, int nVarsOrig, int nLutSize, int n
14801488 ABC_FREE ( pTruth2 );
14811489 ABC_FREE ( pLuts );
14821490 }
1491+ Abc_BSEvalFree ( p );
14831492 ABC_FREE ( pCopy );
14841493 Vec_WrdFree ( vTruths );
14851494 if ( fPrintMyu ) {
0 commit comments