@@ -658,18 +658,9 @@ void Abc_LutCascadeDerive( word * p, int nVars, int nBVars, int Myu, word * pRem
658658// performs decomposition of one stage
659659static 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 )
660660{
661- //extern word Abc_TtFindBVarsSVars( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
662- //extern word Abc_TtFindBVarsSVars2( word * p, int nVars, int nRVars, int nRails, int nLutSize, int fVerbose, int * pMyu, int nJRatio );
663661 assert ( Vec_IntSize (vVarIDs ) > nLutSize );
664662 assert ( Vec_IntSize (vVarIDs ) <= 24 );
665- //word Guide = pGuide ? 0 : Abc_TtFindBVarsSVars2( Vec_WrdArray(vFuncs[0]), Vec_IntSize(vVarIDs), nRVars, nRails, nLutSize, fVerbose, pMyu, nZParam );
666663 word Guide = pGuide ? 0 : Guide0 ;
667- if ( !pGuide && !Guide ) {
668- if ( fVerbose )
669- printf ( "The function is not decomposable with %d rails.\n" , nRails );
670- //Vec_IntClear( vVarIDs );
671- return -1 ;
672- }
673664 int m , Myu = pGuide ? 1 << nRails : (Guide >> 48 ) & 0xFF ;
674665 int nEVars = Abc_Base2Log (Myu );
675666 int nVars = Vec_IntSize (vVarIDs );
@@ -730,9 +721,9 @@ word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t
730721 int nRVarsOld = nRVars ;
731722 Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVars , nRails , nLutSize , fVerbose , pMyu , nZParam );
732723 if ( vGuides ) {
733- word Guide0 = Vec_WrdEntry (vGuides , 0 );
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 );
734726 Vec_WrdFree ( vGuides );
735- nRVars = Abc_LutCascadeDecStage ( Guide0 , pGuide , i , vFuncs , vVarIDs , nRVars , nRails , nLutSize , nJRatio , nZParam , fVerbose , vCas , i ? NULL : pMyu );
736727 }
737728 else
738729 nRVars = -1 ;
@@ -741,12 +732,12 @@ word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t
741732 printf ( "The length of the cascade (%d) exceeds the max allowed number of stages (%d).\n" , i + 2 , nStages );
742733 nRVars = -1 ;
743734 }
744- if ( nRVars == -1 && Vec_IntSize (vVarIDs ) > nLutSize - 1 && fXRail ) {
735+ if ( fXRail && nRVars == -1 && Vec_IntSize (vVarIDs ) > nLutSize - 1 ) {
745736 Vec_Wrd_t * vGuides = Abc_TtFindBVarsSVars2 ( Vec_WrdArray (vFuncs [0 ]), Vec_IntSize (vVarIDs ), nRVarsOld , nRails + 1 , nLutSize - 1 , fVerbose , pMyu , nZParam );
746737 if ( vGuides ) {
747- word Guide0 = Vec_WrdEntry (vGuides , 0 );
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 );
748740 Vec_WrdFree ( vGuides );
749- nRVars = Abc_LutCascadeDecStage ( Guide0 , pGuide , i , vFuncs , vVarIDs , nRVarsOld , nRails + 1 , nLutSize - 1 , nJRatio , nZParam , fVerbose , vCas , NULL );
750741 }
751742 else
752743 nRVars = -1 ;
@@ -758,6 +749,8 @@ word * Abc_LutCascadeDec( char * pGuide, word * pTruth, int nVarsOrig, Vec_Int_t
758749 }
759750 if ( nRVars == -1 ) {
760751 Vec_IntClear ( vVarIDs );
752+ if ( fVerbose )
753+ printf ( "The function is not decomposable with %d rails.\n" , nRails );
761754 break ;
762755 }
763756 }
0 commit comments