diff options
-rw-r--r-- | src/aig/gia/giaScript.c | 297 | ||||
-rw-r--r-- | src/base/abci/abc.c | 92 |
2 files changed, 248 insertions, 141 deletions
diff --git a/src/aig/gia/giaScript.c b/src/aig/gia/giaScript.c index 475dfea7..5af50b4f 100644 --- a/src/aig/gia/giaScript.c +++ b/src/aig/gia/giaScript.c @@ -226,128 +226,6 @@ Gia_Man_t * Gia_ManAigSyn4( Gia_Man_t * p, int fVerbose, int fVeryVerbose ) /**Function************************************************************* - Synopsis [] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Gia_ManPerformMap( int nAnds, int nLutSize, int nCutNum, int fVerbose ) -{ - char Command[200]; - sprintf( Command, "&unmap; &lf -K %d -C %d -k; &save", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - if ( fVerbose ) - { - printf( "MAPPING:\n" ); - printf( "Mapping with &lf -k:\n" ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } - sprintf( Command, "&unmap; &lf -K %d -C %d; &save", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - if ( fVerbose ) - { - printf( "Mapping with &lf:\n" ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } - if ( (nLutSize == 4 && nAnds < 100000) || (nLutSize == 6 && nAnds < 2000) ) - { - sprintf( Command, "&unmap; &if -sz -S %d%d -K %d -C %d", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - Vec_IntFreeP( &Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->vPacking ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&save" ); - if ( fVerbose ) - { - printf( "Mapping with &if -sz -S %d%d -K %d -C %d:\n", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } - } - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" ); - if ( fVerbose ) - { - printf( "Mapping final:\n" ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } -} -void Gia_ManPerformRound( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose ) -{ - char Command[200]; - - // perform AIG-based synthesis - if ( nAnds < 50000 ) - { - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" ); - sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - if ( fVerbose ) - { - printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); - } - - // perform AIG-based synthesis - if ( nAnds < 20000 ) - { - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" ); - sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - if ( fVerbose ) - { - printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); - } - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); - } - - // perform first round of mapping - Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); - - // perform synthesis - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&dsdb" ); - - // perform second round of mapping - Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); - - // perform synthesis - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&syn2 -m -R 10; &dsdb" ); - - // prepare for final mapping - sprintf( Command, "&blut -a -K %d", nLutSize ); - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); - - // perform third round of mapping - Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); -} -void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose ) -{ - // remove comb equivs - if ( fIsMapped ) - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); - if ( Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->pManTime ) - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&sweep" ); - else - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&fraig -c" ); - - // perform first round - Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, nRelaxRatio, fVerbose ); - - // perform synthesis - Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb" ); - - // perform first round - Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, nRelaxRatio, fVerbose ); -} - - -/**Function************************************************************* - Synopsis [Duplicates the AIG manager.] Description [This duplicator works for AIGs with choices.] @@ -424,8 +302,8 @@ Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * pInit, void * pPars0, int nLutSize ) pPars->fCutMin = 1; pPars->fCoarsen = 1; pPars->nRelaxRatio = 20; - pPars->nAreaTuner = 1; - pPars->nCutNum = 4; + pPars->nAreaTuner = 5; + pPars->nCutNum = 12; pPars->fVerbose = fVerbose; if ( fVerbose ) Gia_ManPrintStats( pInit, NULL ); pGia1 = Gia_ManDup( pInit ); @@ -480,6 +358,177 @@ Gia_Man_t * Gia_ManAigSynch2( Gia_Man_t * pInit, void * pPars0, int nLutSize ) return pNew; } +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPerformMap( int nAnds, int nLutSize, int nCutNum, int fVerbose ) +{ + char Command[200]; + sprintf( Command, "&unmap; &lf -K %d -C %d -k; &save", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + if ( fVerbose ) + { + printf( "MAPPING:\n" ); + printf( "Mapping with &lf -k:\n" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + sprintf( Command, "&unmap; &lf -K %d -C %d; &save", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + if ( fVerbose ) + { + printf( "Mapping with &lf:\n" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + if ( (nLutSize == 4 && nAnds < 100000) || (nLutSize == 6 && nAnds < 2000) ) + { + sprintf( Command, "&unmap; &if -sz -S %d%d -K %d -C %d", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + Vec_IntFreeP( &Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->vPacking ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&save" ); + if ( fVerbose ) + { + printf( "Mapping with &if -sz -S %d%d -K %d -C %d:\n", nLutSize, nLutSize, 2*nLutSize-1, 2*nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + } + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" ); + if ( fVerbose ) + { + printf( "Mapping final:\n" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } +} +void Gia_ManPerformRound( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fVerbose ) +{ + char Command[200]; + + // perform AIG-based synthesis + if ( nAnds < 50000 ) + { + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" ); + sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + if ( fVerbose ) + { + printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + } + + // perform AIG-based synthesis + if ( nAnds < 20000 ) + { + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" ); + sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + if ( fVerbose ) + { + printf( "Mapping with &dch -f; &if -K %d -C %d:\n", nLutSize, nCutNum ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + } + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + } + + // perform first round of mapping + Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&dsdb" ); + + // perform second round of mapping + Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&syn2 -m -R 10; &dsdb" ); + + // prepare for final mapping + sprintf( Command, "&blut -a -K %d", nLutSize ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Command ); + + // perform third round of mapping + Gia_ManPerformMap( nAnds, nLutSize, nCutNum, fVerbose ); +} +void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fVerbose ) +{ + // remove comb equivs + if ( fIsMapped ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); +// if ( Abc_FrameReadGia(Abc_FrameGetGlobalFrame())->pManTime ) +// Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&sweep" ); +// else +// Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&fraig -c" ); + + // perform first round + Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, fVerbose ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st; &sopb" ); + + // perform first round + Gia_ManPerformRound( fIsMapped, nAnds, nLevels, nLutSize, nCutNum, fVerbose ); +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPerformFlow2( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fVerbose ) +{ + char Comm1[100], Comm2[100]; + sprintf( Comm1, "&synch2 -K %d; &lf -mk -E 5 -K %d -C %d; &save", nLutSize, nLutSize, nCutNum ); + sprintf( Comm2, "&dch -f; &lf -mk -E 5 -K %d -C %d; &save", nLutSize, nCutNum+4 ); + + // perform synthesis + if ( fIsMapped ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm1 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm1 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&st" ); + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), Comm2 ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); + + // perform synthesis + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&load" ); + if ( fVerbose ) + Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "&ps" ); +} + + + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c index db15c678..78185dd2 100644 --- a/src/base/abci/abc.c +++ b/src/base/abci/abc.c @@ -386,6 +386,7 @@ static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, cha static int Abc_CommandAbc9Sopb ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Dsdb ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Flow ( Abc_Frame_t * pAbc, int argc, char ** argv ); +static int Abc_CommandAbc9Flow2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9If ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9Iff ( Abc_Frame_t * pAbc, int argc, char ** argv ); static int Abc_CommandAbc9If2 ( Abc_Frame_t * pAbc, int argc, char ** argv ); @@ -977,6 +978,7 @@ void Abc_Init( Abc_Frame_t * pAbc ) Cmd_CommandAdd( pAbc, "ABC9", "&sopb", Abc_CommandAbc9Sopb, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&dsdb", Abc_CommandAbc9Dsdb, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&flow", Abc_CommandAbc9Flow, 0 ); + Cmd_CommandAdd( pAbc, "ABC9", "&flow2", Abc_CommandAbc9Flow2, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&if", Abc_CommandAbc9If, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&iff", Abc_CommandAbc9Iff, 0 ); Cmd_CommandAdd( pAbc, "ABC9", "&if2", Abc_CommandAbc9If2, 0 ); @@ -25652,8 +25654,7 @@ static inline int Gia_ManCompareWithBest( Gia_Man_t * pBest, Gia_Man_t * p, int Gia_ManRegNum(pBest) != Gia_ManRegNum(p) || strcmp(Gia_ManName(pBest), Gia_ManName(p)) || (*pnBestLevels > nCurLevels) || - (*pnBestLevels == nCurLevels && *pnBestLuts > nCurLuts) || - (*pnBestLevels == nCurLevels && *pnBestLuts == nCurLuts && *pnBestEdges > nCurEdges) ) + (*pnBestLevels == nCurLevels && 2*(*pnBestLuts) + *pnBestEdges > 2*nCurLuts + nCurEdges) ) { *pnBestLuts = nCurLuts; *pnBestEdges = nCurEdges; @@ -30884,14 +30885,12 @@ usage: ***********************************************************************/ int Abc_CommandAbc9Flow( Abc_Frame_t * pAbc, int argc, char ** argv ) { - extern void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int nRelaxRatio, int fVerbose ); -// Gia_Man_t * pTemp; - int nLutSize = 4; - int nCutNum = 8; - int nRelaxRatio = 0; - int c, fVerbose = 0; + extern void Gia_ManPerformFlow( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fVerbose ); + int nLutSize = 6; + int nCutNum = 8; + int c, fVerbose = 0; Extra_UtilGetoptReset(); - while ( ( c = Extra_UtilGetopt( argc, argv, "KCRvh" ) ) != EOF ) + while ( ( c = Extra_UtilGetopt( argc, argv, "KCvh" ) ) != EOF ) { switch ( c ) { @@ -30917,15 +30916,75 @@ int Abc_CommandAbc9Flow( Abc_Frame_t * pAbc, int argc, char ** argv ) if ( nCutNum < 0 ) goto usage; break; - case 'R': + case 'v': + fVerbose ^= 1; + break; + case 'h': + goto usage; + default: + goto usage; + } + } + if ( pAbc->pGia == NULL ) + { + Abc_Print( -1, "Abc_CommandAbc9Flow(): There is no AIG.\n" ); + return 1; + } + Gia_ManPerformFlow( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, fVerbose ); + return 0; + +usage: + Abc_Print( -2, "usage: &flow [-KC num] [-vh]\n" ); + Abc_Print( -2, "\t integration optimization and mapping flow\n" ); + Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize ); + Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum ); + Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); + Abc_Print( -2, "\t-h : print the command usage\n"); + return 1; +} + +/**Function************************************************************* + + Synopsis [] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Abc_CommandAbc9Flow2( Abc_Frame_t * pAbc, int argc, char ** argv ) +{ + extern void Gia_ManPerformFlow2( int fIsMapped, int nAnds, int nLevels, int nLutSize, int nCutNum, int fVerbose ); + int nLutSize = 6; + int nCutNum = 8; + int c, fVerbose = 0; + Extra_UtilGetoptReset(); + while ( ( c = Extra_UtilGetopt( argc, argv, "KCvh" ) ) != EOF ) + { + switch ( c ) + { + case 'K': if ( globalUtilOptind >= argc ) { - Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" ); + Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" ); goto usage; } - nRelaxRatio = atoi(argv[globalUtilOptind]); + nLutSize = atoi(argv[globalUtilOptind]); globalUtilOptind++; - if ( nRelaxRatio < 0 ) + if ( nLutSize < 0 ) + goto usage; + break; + case 'C': + if ( globalUtilOptind >= argc ) + { + Abc_Print( -1, "Command line switch \"-C\" should be followed by an integer.\n" ); + goto usage; + } + nCutNum = atoi(argv[globalUtilOptind]); + globalUtilOptind++; + if ( nCutNum < 0 ) goto usage; break; case 'v': @@ -30939,18 +30998,17 @@ int Abc_CommandAbc9Flow( Abc_Frame_t * pAbc, int argc, char ** argv ) } if ( pAbc->pGia == NULL ) { - Abc_Print( -1, "Abc_CommandAbc9Flow(): There is no AIG.\n" ); + Abc_Print( -1, "Abc_CommandAbc9Flow2(): There is no AIG.\n" ); return 1; } - Gia_ManPerformFlow( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, nRelaxRatio, fVerbose ); + Gia_ManPerformFlow2( Gia_ManHasMapping(pAbc->pGia), Gia_ManAndNum(pAbc->pGia), Gia_ManLevelNum(pAbc->pGia), nLutSize, nCutNum, fVerbose ); return 0; usage: - Abc_Print( -2, "usage: &flow [-KCR num] [-vh]\n" ); + Abc_Print( -2, "usage: &flow2 [-KC num] [-vh]\n" ); Abc_Print( -2, "\t integration optimization and mapping flow\n" ); Abc_Print( -2, "\t-K num : the number of LUT inputs (LUT size) [default = %d]\n", nLutSize ); Abc_Print( -2, "\t-C num : the number of cuts at a node [default = %d]\n", nCutNum ); - Abc_Print( -2, "\t-R num : the delay relaxation ratio (num >= 0) [default = %d]\n", nRelaxRatio ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; |