From 3d6eac52abb1fd05a0c954f00dd5b8b855765f6e Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 28 Feb 2014 21:06:21 -0800 Subject: Changes to LUT mappers. --- src/base/abci/abc.c | 235 ++++++++++++++++++++++++++++++++++++++++++++++ src/base/abci/abcIf.c | 9 ++ src/base/main/main.h | 3 + src/base/main/mainFrame.c | 4 + src/base/main/mainInt.h | 3 +- 5 files changed, 253 insertions(+), 1 deletion(-) (limited to 'src/base') 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] \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 : (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] \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 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 ) ) { diff --git a/src/base/main/main.h b/src/base/main/main.h index a55ff06c..e58fa75b 100644 --- a/src/base/main/main.h +++ b/src/base/main/main.h @@ -106,6 +106,8 @@ extern ABC_DLL void * Abc_FrameReadLibVer(); extern ABC_DLL void * Abc_FrameReadLibScl(); extern ABC_DLL void * Abc_FrameReadManDd(); extern ABC_DLL void * Abc_FrameReadManDec(); +extern ABC_DLL void * Abc_FrameReadManDsd(); + extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag ); extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag ); extern ABC_DLL int Abc_FrameIsBatchMode(); @@ -138,6 +140,7 @@ extern ABC_DLL void Abc_FrameSetFlag( char * pFlag, char * pValue ); extern ABC_DLL void Abc_FrameSetCex( Abc_Cex_t * pCex ); extern ABC_DLL void Abc_FrameSetNFrames( int nFrames ); extern ABC_DLL void Abc_FrameSetStatus( int Status ); +extern ABC_DLL void Abc_FrameSetManDsd( void * pMan ); extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum ); diff --git a/src/base/main/mainFrame.c b/src/base/main/mainFrame.c index 20054228..bb9d19e4 100644 --- a/src/base/main/mainFrame.c +++ b/src/base/main/mainFrame.c @@ -22,6 +22,7 @@ #include "mainInt.h" #include "bool/dec/dec.h" #include "misc/extra/extraBdd.h" +#include "map/if/if.h" ABC_NAMESPACE_IMPL_START @@ -59,6 +60,7 @@ void * Abc_FrameReadLibVer() { return s_GlobalFr void * Abc_FrameReadLibScl() { return s_GlobalFrame->pLibScl; } void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; } void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; } +void * Abc_FrameReadManDsd() { return s_GlobalFrame->pManDsd; } char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); } int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; } @@ -85,6 +87,7 @@ void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateVal void Abc_FrameSetCex( Abc_Cex_t * pCex ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->pCex = pCex; } void Abc_FrameSetNFrames( int nFrames ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->nFrames = nFrames; } void Abc_FrameSetStatus( int Status ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->Status = Status; } +void Abc_FrameSetManDsd( void * pMan ) { if (s_GlobalFrame->pManDsd) If_DsdManFree((If_DsdMan_t *)s_GlobalFrame->pManDsd, 0); s_GlobalFrame->pManDsd = pMan; } int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; } @@ -194,6 +197,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) if ( p->pSave2 ) Aig_ManStop( (Aig_Man_t *)p->pSave2 ); if ( p->pSave3 ) Aig_ManStop( (Aig_Man_t *)p->pSave3 ); if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 ); + if ( p->pManDsd ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd, 0 ); if ( p->vPlugInComBinPairs ) { char * pTemp; diff --git a/src/base/main/mainInt.h b/src/base/main/mainInt.h index 07dc93e4..c5b7de58 100644 --- a/src/base/main/mainInt.h +++ b/src/base/main/mainInt.h @@ -82,8 +82,9 @@ struct Abc_Frame_t_ double TimeTotal; // the total runtime of all commands // temporary storage for structural choices Vec_Ptr_t * vStore; // networks to be used by choice - // decomposition package + // decomposition package void * pManDec; // decomposition manager + void * pManDsd; // decomposition manager DdManager * dd; // temporary BDD package // libraries for mapping void * pLibLut; // the current LUT library -- cgit v1.2.3