diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index a0b722bf1..87f2bb74c 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -6071,7 +6071,7 @@ Vec_Int_t * Gia_ManCofClassPattern( Gia_Man_t * p, Vec_Int_t * vVarNums, int fVe if ( fVerbose ) { int i, Class, nClasses = Vec_IntFindMax(vRes)+1; - printf( "Pattern %d -> %d: ", Vec_IntSize(vVarNums), nClasses ); + printf( "%d -> %d: ", Vec_IntSize(vVarNums), nClasses ); if ( nClasses <= 36 ) Vec_IntForEachEntry( vRes, Class, i ) printf( "%c", (Class < 10 ? (int)'0' : (int)'A'-10) + Class ); @@ -6123,18 +6123,48 @@ Gia_Man_t * Gia_ManDupEncode( Gia_Man_t * p, Vec_Int_t * vVarNums, int fVerbose ***********************************************************************/ void Gia_ManCofClassRand( Gia_Man_t * p, int nVars, int nRands ) -{ +{ for ( int n = 0; n < nRands; n++ ) { + Abc_Random(1); + for ( int i = 0; i < n; i++ ) + Abc_Random(0); Vec_Int_t * vIns = Vec_IntStartNatural( Gia_ManPiNum(p) ); Vec_IntRandomizeOrder( vIns ); Vec_IntShrink( vIns, nVars ); - Vec_IntPrint( vIns ); + int k, Entry; + printf( "Vars: " ); + Vec_IntForEachEntry( vIns, Entry, k ) + printf( "%d ", Entry ); + printf( " " ); Vec_Int_t * vTemp = Gia_ManCofClassPattern( p, vIns, 1 ); Vec_IntFree( vTemp ); Vec_IntFree( vIns ); } } +void Gia_ManCofClassEnum( Gia_Man_t * p, int nVars ) +{ + Vec_Int_t * vIns = Vec_IntAlloc( nVars ); + int m, k, Entry, Count, nMints = 1 << Gia_ManPiNum(p); + for ( m = 0; m < nMints; m++ ) { + for ( Count = k = 0; k < Gia_ManPiNum(p); k++ ) + Count += (m >> k) & 1; + if ( Count != nVars ) + continue; + Vec_IntClear( vIns ); + for ( k = 0; k < Gia_ManPiNum(p); k++ ) + if ( (m >> k) & 1 ) + Vec_IntPush( vIns, k ); + assert( Vec_IntSize(vIns) == Count ); + printf( "Vars: " ); + Vec_IntForEachEntry( vIns, Entry, k ) + printf( "%d ", Entry ); + printf( " " ); + Vec_Int_t * vTemp = Gia_ManCofClassPattern( p, vIns, 1 ); + Vec_IntFree( vTemp ); + } + Vec_IntFree( vIns ); +} //////////////////////////////////////////////////////////////////////// /// END OF FILE /// diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index ccc890395..acb9c3f4e 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -5207,18 +5207,14 @@ usage: ***********************************************************************/ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv ) { - Abc_Ntk_t * pNtk, * pNtkRes; + extern Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtk, int nLutSize, int fReorder, int fVerbose ); + Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pNtkRes; int c; - int nLutSize; - int fVerbose; - extern Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose ); - - pNtk = Abc_FrameReadNtk(pAbc); - // set defaults - nLutSize = 4; - fVerbose = 0; + int nLutSize = 4; + int fReorder = 1; + int fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "Kvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "Krvh" ) ) != EOF ) { switch ( c ) { @@ -5231,6 +5227,9 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv ) nLutSize = atoi(argv[globalUtilOptind]); globalUtilOptind++; break; + case 'r': + fReorder ^= 1; + break; case 'v': fVerbose ^= 1; break; @@ -5246,7 +5245,7 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv ) return 1; } // modify the current network - pNtkRes = Abc_NtkLutmin( pNtk, nLutSize, fVerbose ); + pNtkRes = Abc_NtkLutmin( pNtk, nLutSize, fReorder, fVerbose ); if ( pNtkRes == NULL ) { Abc_Print( -1, "The command has failed.\n" ); @@ -5257,11 +5256,12 @@ int Abc_CommandLutmin( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: lutmin [-K ] [-vh]\n" ); + Abc_Print( -2, "usage: lutmin [-K ] [-rvh]\n" ); Abc_Print( -2, "\t perform FPGA mapping while minimizing the LUT count\n" ); Abc_Print( -2, "\t as described in the paper T. Sasao and A. Mishchenko:\n" ); Abc_Print( -2, "\t \"On the number of LUTs to implement logic functions\".\n" ); Abc_Print( -2, "\t-K : the LUT size to use for the mapping (2 <= num) [default = %d]\n", nLutSize ); + Abc_Print( -2, "\t-r : toggle using BDD variable reordering [default = %s]\n", fReorder? "yes": "no" ); Abc_Print( -2, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; @@ -53544,11 +53544,12 @@ int Abc_CommandAbc9FunAbs( Abc_Frame_t * pAbc, int argc, char ** argv ) extern Gia_Man_t * Gia_ManDupEncode( Gia_Man_t * p, Vec_Int_t * vVarNums, int fVerbose ); extern Vec_Int_t * Gia_ManCofClassPattern( Gia_Man_t * p, Vec_Int_t * vVarNums, int fVerbose ); extern void Gia_ManCofClassRand( Gia_Man_t * p, int nVars, int nRands ); + extern void Gia_ManCofClassEnum( Gia_Man_t * p, int nVars ); Gia_Man_t * pNew = NULL; Vec_Int_t * vVars = NULL; - int c, nVars = 6, nRands = 0, fPrint = 0, fVerbose = 0; + int c, nVars = 6, nRands = 0, fEnum = 0, fPrint = 0, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KRpvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KRepvh" ) ) != EOF ) { switch ( c ) { @@ -53574,6 +53575,9 @@ int Abc_CommandAbc9FunAbs( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( nRands < 0 ) goto usage; break; + case 'e': + fEnum ^= 1; + break; case 'p': fPrint ^= 1; break; @@ -53603,6 +53607,10 @@ int Abc_CommandAbc9FunAbs( Abc_Frame_t * pAbc, int argc, char ** argv ) Gia_ManCofClassRand( pAbc->pGia, nVars, nRands ); return 0; } + if ( fEnum ) { + Gia_ManCofClassEnum( pAbc->pGia, nVars ); + return 0; + } if ( argc == globalUtilOptind ) { vVars = Vec_IntStartNatural( nVars ); printf( "Abstracting the first %d variables of the AIG.\n", nVars ); @@ -53626,10 +53634,11 @@ int Abc_CommandAbc9FunAbs( Abc_Frame_t * pAbc, int argc, char ** argv ) return 0; usage: - Abc_Print( -2, "usage: &funabs [-KR num] [-pvh] ... \n" ); + Abc_Print( -2, "usage: &funabs [-KR num] [-epvh] ... \n" ); Abc_Print( -2, "\t generates an abstraction of the function\n" ); Abc_Print( -2, "\t-K num : the number of primary inputs [default = %d]\n", nVars ); Abc_Print( -2, "\t-R num : the number of random K-set to try [default = %d]\n", nRands ); + Abc_Print( -2, "\t-e : toggles enumerating bound sets of the given size [default = %s]\n", fEnum ? "yes": "no" ); Abc_Print( -2, "\t-p : toggles printing statistics only [default = %s]\n", fPrint ? "yes": "no" ); Abc_Print( -2, "\t-v : toggles printing verbose information [default = %s]\n", fVerbose ? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); @@ -53652,7 +53661,7 @@ int Abc_CommandAbc9DsdInfo( Abc_Frame_t * pAbc, int argc, char ** argv ) { extern void Gia_ManPrintDsdMatrix( Gia_Man_t * p, int iIn ); extern void Gia_ManCheckDsd( Gia_Man_t * p, int fVerbose ); - int c, iIn = 0, fDsd = 0, fVerbose = 0; + int c, iIn = -1, fDsd = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Vdvh" ) ) != EOF ) { @@ -53686,15 +53695,26 @@ int Abc_CommandAbc9DsdInfo( Abc_Frame_t * pAbc, int argc, char ** argv ) Abc_Print( -1, "Abc_CommandAbc9DsdInfo(): There is no AIG.\n" ); return 0; } - if ( iIn < 0 || iIn >= Gia_ManPiNum(pAbc->pGia) ) + if ( fDsd ) { - Abc_Print( -1, "Abc_CommandAbc9DsdInfo(): There is no AIG.\n" ); + if ( iIn == -1 ) { + Gia_ManCheckDsd( pAbc->pGia, 1 ); + return 0; + } + for ( c = 0; c < 2; c++ ) { + Gia_Man_t * pTemp = Gia_ManDupCofactorVar( pAbc->pGia, iIn, c ); + printf( "Var %2d Cof %d:\n", iIn, c ); + Gia_ManCheckDsd( pTemp, 1 ); + Gia_ManStop( pTemp ); + } return 0; } - if ( fDsd ) - Gia_ManCheckDsd( pAbc->pGia, fVerbose ); - else - Gia_ManPrintDsdMatrix( pAbc->pGia, iIn ); + if ( iIn < 0 || iIn >= Gia_ManPiNum(pAbc->pGia) ) + { + Abc_Print( -1, "Abc_CommandAbc9DsdInfo(): The input variable is not specified.\n" ); + return 0; + } + Gia_ManPrintDsdMatrix( pAbc->pGia, iIn ); return 0; usage: diff --git a/src/base/abci/abcLutmin.c b/src/base/abci/abcLutmin.c index d53f57977..49681ae90 100644 --- a/src/base/abci/abcLutmin.c +++ b/src/base/abci/abcLutmin.c @@ -727,13 +727,13 @@ void Abc_NtkLutminConstruct( Abc_Ntk_t * pNtkClp, Abc_Ntk_t * pNtkDec, int nLutS SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkLutminInt( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose ) +Abc_Ntk_t * Abc_NtkLutminInt( Abc_Ntk_t * pNtk, int nLutSize, int fReorder, int fVerbose ) { extern void Abc_NtkBddReorder( Abc_Ntk_t * pNtk, int fVerbose ); Abc_Ntk_t * pNtkDec; // minimize BDDs -// Abc_NtkBddReorder( pNtk, fVerbose ); - Abc_NtkBddReorder( pNtk, 0 ); + if ( fReorder ) + Abc_NtkBddReorder( pNtk, 0 ); // decompose one output at a time pNtkDec = Abc_NtkStartFrom( pNtk, ABC_NTK_LOGIC, ABC_FUNC_BDD ); // make sure the new manager has enough inputs @@ -758,7 +758,7 @@ Abc_Ntk_t * Abc_NtkLutminInt( Abc_Ntk_t * pNtk, int nLutSize, int fVerbose ) SeeAlso [] ***********************************************************************/ -Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) +Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fReorder, int fVerbose ) { extern int Abc_NtkFraigSweep( Abc_Ntk_t * pNtk, int fUseInv, int fExdc, int fVerbose, int fVeryVerbose ); Abc_Ntk_t * pNtkNew, * pTemp; @@ -779,7 +779,7 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) else pNtkNew = Abc_NtkStrash( pNtkInit, 0, 1, 0 ); // collapse the network - pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, 1, 0, 0, 0 ); + pNtkNew = Abc_NtkCollapse( pTemp = pNtkNew, 10000, 0, fReorder, 0, 0, 0 ); Abc_NtkDelete( pTemp ); if ( pNtkNew == NULL ) return NULL; @@ -794,7 +794,7 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) if ( fVerbose ) printf( "Decomposing network with %d nodes and %d max fanin count for K = %d.\n", Abc_NtkNodeNum(pNtkNew), Abc_NtkGetFaninMax(pNtkNew), nLutSize ); - pNtkNew = Abc_NtkLutminInt( pTemp = pNtkNew, nLutSize, fVerbose ); + pNtkNew = Abc_NtkLutminInt( pTemp = pNtkNew, nLutSize, fReorder, fVerbose ); Abc_NtkDelete( pTemp ); } // fix the problem with complemented and duplicated CO edges @@ -812,7 +812,7 @@ Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) #else -Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fVerbose ) { return NULL; } +Abc_Ntk_t * Abc_NtkLutmin( Abc_Ntk_t * pNtkInit, int nLutSize, int fReorder, int fVerbose ) { return NULL; } #endif