summaryrefslogtreecommitdiffstats
path: root/src/base/abci
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2014-02-28 21:06:21 -0800
committerAlan Mishchenko <alanmi@berkeley.edu>2014-02-28 21:06:21 -0800
commit3d6eac52abb1fd05a0c954f00dd5b8b855765f6e (patch)
tree87ffc62a7e9ea895d4e2915ef5c7a79117f31502 /src/base/abci
parentde48fd79992a5218c18da8dca62869b865a62f0e (diff)
downloadabc-3d6eac52abb1fd05a0c954f00dd5b8b855765f6e.tar.gz
abc-3d6eac52abb1fd05a0c954f00dd5b8b855765f6e.tar.bz2
abc-3d6eac52abb1fd05a0c954f00dd5b8b855765f6e.zip
Changes to LUT mappers.
Diffstat (limited to 'src/base/abci')
-rw-r--r--src/base/abci/abc.c235
-rw-r--r--src/base/abci/abcIf.c9
2 files changed, 244 insertions, 0 deletions
diff --git a/src/base/abci/abc.c b/src/base/abci/abc.c
index b8e41dc0..5361e1b2 100644
--- a/src/base/abci/abc.c
+++ b/src/base/abci/abc.c
@@ -231,6 +231,10 @@ static int Abc_CommandSuperChoiceLut ( Abc_Frame_t * pAbc, int argc, cha
//static int Abc_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIf ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIfif ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdSave ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdLoad ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdFree ( Abc_Frame_t * pAbc, int argc, char ** argv );
+static int Abc_CommandDsdPs ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInit ( Abc_Frame_t * pAbc, int argc, char ** argv );
@@ -784,6 +788,10 @@ void Abc_Init( Abc_Frame_t * pAbc )
// Cmd_CommandAdd( pAbc, "FPGA mapping", "ffpga", Abc_CommandFpgaFast, 1 );
Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 );
Cmd_CommandAdd( pAbc, "FPGA mapping", "ifif", Abc_CommandIfif, 1 );
+ Cmd_CommandAdd( pAbc, "FPGA mapping", "dsd_save", Abc_CommandDsdSave, 0 );
+ Cmd_CommandAdd( pAbc, "FPGA mapping", "dsd_load", Abc_CommandDsdLoad, 0 );
+ Cmd_CommandAdd( pAbc, "FPGA mapping", "dsd_free", Abc_CommandDsdFree, 0 );
+ Cmd_CommandAdd( pAbc, "FPGA mapping", "dsd_ps", Abc_CommandDsdPs, 0 );
// Cmd_CommandAdd( pAbc, "Sequential", "scut", Abc_CommandScut, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
@@ -15088,6 +15096,29 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fUsePerm = 1;
}
+ if ( pPars->fUseDsd )
+ {
+ int LutSize = (pPars->pLutStruct && pPars->pLutStruct[2] == 0)? pPars->pLutStruct[0] - '0' : 0;
+ If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
+ if ( pPars->pLutStruct && pPars->pLutStruct[2] != 0 )
+ {
+ printf( "DSD only works for LUT structures XY.\n" );
+ return 0;
+ }
+ if ( p && pPars->nLutSize > If_DsdManVarNum(p) )
+ {
+ printf( "DSD manager has incompatible number of variables.\n" );
+ return 0;
+ }
+ if ( p && LutSize != If_DsdManLutSize(p) )
+ {
+ printf( "DSD manager has different LUT size.\n" );
+ return 0;
+ }
+ if ( p == NULL )
+ Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, LutSize) );
+ }
+
if ( pPars->fUserRecLib )
{
assert( Abc_NtkRecIsRunning3() );
@@ -15322,6 +15353,210 @@ usage:
return 1;
}
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandDsdSave( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * FileName;
+ char ** pArgvNew;
+ int nArgcNew;
+ int c;
+
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+
+ if ( !Abc_FrameReadManDsd() )
+ {
+ Abc_Print( -1, "The DSD manager is not started.\n" );
+ return 1;
+ }
+
+ pArgvNew = argv + globalUtilOptind;
+ nArgcNew = argc - globalUtilOptind;
+ if ( nArgcNew != 1 )
+ {
+ Abc_Print( -1, "File name is not given on the command line.\n" );
+ return 1;
+ }
+ // get the input file name
+ FileName = (nArgcNew == 1) ? pArgvNew[0] : NULL;
+ If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd(), FileName );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: dsd_save [-h] <file>\n" );
+ Abc_Print( -2, "\t saves DSD manager into a file\n");
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : (optional) file name to write\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandDsdLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ char * FileName, * pTemp;
+ char ** pArgvNew;
+ int c, nArgcNew;
+ FILE * pFile;
+ If_DsdMan_t * pDsdMan;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ pArgvNew = argv + globalUtilOptind;
+ nArgcNew = argc - globalUtilOptind;
+ if ( nArgcNew != 1 )
+ {
+ Abc_Print( -1, "File name is not given on the command line.\n" );
+ return 1;
+ }
+ // get the input file name
+ FileName = pArgvNew[0];
+ // fix the wrong symbol
+ for ( pTemp = FileName; *pTemp; pTemp++ )
+ if ( *pTemp == '>' )
+ *pTemp = '\\';
+ if ( (pFile = fopen( FileName, "r" )) == NULL )
+ {
+ Abc_Print( -1, "Cannot open input file \"%s\". ", FileName );
+ if ( (FileName = Extra_FileGetSimilarName( FileName, ".aig", NULL, NULL, NULL, NULL )) )
+ Abc_Print( 1, "Did you mean \"%s\"?", FileName );
+ Abc_Print( 1, "\n" );
+ return 1;
+ }
+ fclose( pFile );
+ pDsdMan = If_DsdManLoad(FileName);
+ if ( pDsdMan == NULL )
+ return 1;
+ Abc_FrameSetManDsd( pDsdMan );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: dsd_load [-h] <file>\n" );
+ Abc_Print( -2, "\t loads DSD manager from file\n");
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ Abc_Print( -2, "\t<file> : file name to read\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandDsdFree( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ int c;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( !Abc_FrameReadManDsd() )
+ {
+ Abc_Print( 1, "The DSD manager is not started.\n" );
+ return 0;
+ }
+ Abc_FrameSetManDsd( NULL );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: dsd_ps [-h]\n" );
+ Abc_Print( -2, "\t deletes DSD manager\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
+/**Function*************************************************************
+
+ Synopsis []
+
+ Description []
+
+ SideEffects []
+
+ SeeAlso []
+
+***********************************************************************/
+int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
+{
+ int c, fPrintLib = 0;
+ Extra_UtilGetoptReset();
+ while ( ( c = Extra_UtilGetopt( argc, argv, "ph" ) ) != EOF )
+ {
+ switch ( c )
+ {
+ case 'p':
+ fPrintLib ^= 1;
+ break;
+ case 'h':
+ goto usage;
+ default:
+ goto usage;
+ }
+ }
+ if ( !Abc_FrameReadManDsd() )
+ {
+ Abc_Print( 1, "The DSD manager is not started.\n" );
+ return 0;
+ }
+ If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd(), NULL, 0 );
+ return 0;
+
+usage:
+ Abc_Print( -2, "usage: dsd_ps [-h]\n" );
+ Abc_Print( -2, "\t prints statistics of DSD manager\n" );
+ Abc_Print( -2, "\t-h : print the command usage\n");
+ return 1;
+}
+
/**Function*************************************************************
diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c
index 63fdfb15..64dc11e6 100644
--- a/src/base/abci/abcIf.c
+++ b/src/base/abci/abcIf.c
@@ -137,6 +137,15 @@ Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
if ( pPars->fPower )
Abc_NtkIfComputeSwitching( pNtk, pIfMan );
+ // create DSD manager
+ if ( pPars->fUseDsd )
+ {
+ If_DsdMan_t * p = (If_DsdMan_t *)Abc_FrameReadManDsd();
+ assert( pPars->nLutSize <= If_DsdManVarNum(p) );
+ assert( (pPars->pLutStruct == NULL && If_DsdManLutSize(p) == 0) || (pPars->pLutStruct && pPars->pLutStruct[0] - '0' == If_DsdManLutSize(p)) );
+ pIfMan->pIfDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
+ }
+
// perform FPGA mapping
if ( !If_ManPerformMapping( pIfMan ) )
{