Commit ce74153c by Alan Mishchenko

Tuning LUT mapping flow.

parent 6db66071
......@@ -19,6 +19,8 @@
***********************************************************************/
#include "gia.h"
#include "base/main/main.h"
#include "base/cmd/cmd.h"
ABC_NAMESPACE_IMPL_START
......@@ -317,6 +319,123 @@ Gia_Man_t * Gia_ManPerformDsdBalanceWin( Gia_Man_t * p, int LevelMax, int nTimeW
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 ( nAnds < 100000 )
{
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; &st", 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" );
}
}
// perform AIG-based synthesis
if ( nAnds < 20000 )
{
Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "" );
sprintf( Command, "&dsdb; &dch -f; &if -K %d -C %d; &save; &st", 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" );
}
}
// 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" );
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 );
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
......
......@@ -383,6 +383,7 @@ static int Abc_CommandAbc9Force ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Embed ( Abc_Frame_t * pAbc, int argc, char ** argv );
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_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 );
......@@ -391,6 +392,7 @@ static int Abc_CommandAbc9Kf ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAbc9Lf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Mf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Nf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Unmap ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Struct ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Trace ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandAbc9Speedup ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -970,6 +972,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&embed", Abc_CommandAbc9Embed, 0 );
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", "&if", Abc_CommandAbc9If, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&iff", Abc_CommandAbc9Iff, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&if2", Abc_CommandAbc9If2, 0 );
......@@ -978,6 +981,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "ABC9", "&lf", Abc_CommandAbc9Lf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&mf", Abc_CommandAbc9Mf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&nf", Abc_CommandAbc9Nf, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&unmap", Abc_CommandAbc9Unmap, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&struct", Abc_CommandAbc9Struct, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&trace", Abc_CommandAbc9Trace, 0 );
Cmd_CommandAdd( pAbc, "ABC9", "&speedup", Abc_CommandAbc9Speedup, 0 );
......@@ -30622,6 +30626,91 @@ usage:
SeeAlso []
***********************************************************************/
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;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCRvh" ) ) != EOF )
{
switch ( c )
{
case 'K':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nLutSize = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
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 'R':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-R\" should be followed by an integer.\n" );
goto usage;
}
nRelaxRatio = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nRelaxRatio < 0 )
goto usage;
break;
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, nRelaxRatio, fVerbose );
return 0;
usage:
Abc_Print( -2, "usage: &flow [-KCR 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;
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char Buffer[200];
......@@ -32310,6 +32399,52 @@ usage:
SeeAlso []
***********************************************************************/
int Abc_CommandAbc9Unmap( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Gia_ManTestStruct( Gia_Man_t * p );
int c, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF )
{
switch ( c )
{
case 'v':
fVerbose ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( pAbc->pGia == NULL )
{
Abc_Print( -1, "Abc_CommandAbc9Struct(): There is no AIG to map.\n" );
return 1;
}
Vec_IntFreeP( &pAbc->pGia->vMapping );
Vec_IntFreeP( &pAbc->pGia->vPacking );
return 0;
usage:
Abc_Print( -2, "usage: &unmap [-vh]\n" );
Abc_Print( -2, "\t removes mapping from the current network\n" );
Abc_Print( -2, "\t-v : toggle printing optimization summary [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_CommandAbc9Struct( Abc_Frame_t * pAbc, int argc, char ** argv )
{
extern void Gia_ManTestStruct( Gia_Man_t * p );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment