Commit 3d6eac52 by Alan Mishchenko

Changes to LUT mappers.

parent de48fd79
...@@ -231,6 +231,10 @@ static int Abc_CommandSuperChoiceLut ( Abc_Frame_t * pAbc, int argc, cha ...@@ -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_CommandFpgaFast ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandIf ( 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_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_CommandScut ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandInit ( 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 ) ...@@ -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", "ffpga", Abc_CommandFpgaFast, 1 );
Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 ); Cmd_CommandAdd( pAbc, "FPGA mapping", "if", Abc_CommandIf, 1 );
Cmd_CommandAdd( pAbc, "FPGA mapping", "ifif", Abc_CommandIfif, 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", "scut", Abc_CommandScut, 0 );
Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 ); Cmd_CommandAdd( pAbc, "Sequential", "init", Abc_CommandInit, 1 );
...@@ -15088,6 +15096,29 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -15088,6 +15096,29 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fUsePerm = 1; 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 ) if ( pPars->fUserRecLib )
{ {
assert( Abc_NtkRecIsRunning3() ); assert( Abc_NtkRecIsRunning3() );
...@@ -15322,6 +15353,210 @@ usage: ...@@ -15322,6 +15353,210 @@ usage:
return 1; 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************************************************************* /**Function*************************************************************
...@@ -137,6 +137,15 @@ Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars ) ...@@ -137,6 +137,15 @@ Abc_Ntk_t * Abc_NtkIf( Abc_Ntk_t * pNtk, If_Par_t * pPars )
if ( pPars->fPower ) if ( pPars->fPower )
Abc_NtkIfComputeSwitching( pNtk, pIfMan ); 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 // perform FPGA mapping
if ( !If_ManPerformMapping( pIfMan ) ) if ( !If_ManPerformMapping( pIfMan ) )
{ {
......
...@@ -106,6 +106,8 @@ extern ABC_DLL void * Abc_FrameReadLibVer(); ...@@ -106,6 +106,8 @@ extern ABC_DLL void * Abc_FrameReadLibVer();
extern ABC_DLL void * Abc_FrameReadLibScl(); extern ABC_DLL void * Abc_FrameReadLibScl();
extern ABC_DLL void * Abc_FrameReadManDd(); extern ABC_DLL void * Abc_FrameReadManDd();
extern ABC_DLL void * Abc_FrameReadManDec(); extern ABC_DLL void * Abc_FrameReadManDec();
extern ABC_DLL void * Abc_FrameReadManDsd();
extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag ); extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag );
extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag ); extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag );
extern ABC_DLL int Abc_FrameIsBatchMode(); extern ABC_DLL int Abc_FrameIsBatchMode();
...@@ -138,6 +140,7 @@ extern ABC_DLL void Abc_FrameSetFlag( char * pFlag, char * pValue ); ...@@ -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_FrameSetCex( Abc_Cex_t * pCex );
extern ABC_DLL void Abc_FrameSetNFrames( int nFrames ); extern ABC_DLL void Abc_FrameSetNFrames( int nFrames );
extern ABC_DLL void Abc_FrameSetStatus( int Status ); 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 ); extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum );
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "mainInt.h" #include "mainInt.h"
#include "bool/dec/dec.h" #include "bool/dec/dec.h"
#include "misc/extra/extraBdd.h" #include "misc/extra/extraBdd.h"
#include "map/if/if.h"
ABC_NAMESPACE_IMPL_START ABC_NAMESPACE_IMPL_START
...@@ -59,6 +60,7 @@ void * Abc_FrameReadLibVer() { return s_GlobalFr ...@@ -59,6 +60,7 @@ void * Abc_FrameReadLibVer() { return s_GlobalFr
void * Abc_FrameReadLibScl() { return s_GlobalFrame->pLibScl; } 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_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_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 ); } char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; } int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; }
...@@ -85,6 +87,7 @@ void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateVal ...@@ -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_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_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_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; } int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; }
...@@ -194,6 +197,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p ) ...@@ -194,6 +197,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
if ( p->pSave2 ) Aig_ManStop( (Aig_Man_t *)p->pSave2 ); if ( p->pSave2 ) Aig_ManStop( (Aig_Man_t *)p->pSave2 );
if ( p->pSave3 ) Aig_ManStop( (Aig_Man_t *)p->pSave3 ); if ( p->pSave3 ) Aig_ManStop( (Aig_Man_t *)p->pSave3 );
if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 ); if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 );
if ( p->pManDsd ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd, 0 );
if ( p->vPlugInComBinPairs ) if ( p->vPlugInComBinPairs )
{ {
char * pTemp; char * pTemp;
......
...@@ -82,8 +82,9 @@ struct Abc_Frame_t_ ...@@ -82,8 +82,9 @@ struct Abc_Frame_t_
double TimeTotal; // the total runtime of all commands double TimeTotal; // the total runtime of all commands
// temporary storage for structural choices // temporary storage for structural choices
Vec_Ptr_t * vStore; // networks to be used by choice Vec_Ptr_t * vStore; // networks to be used by choice
// decomposition package // decomposition package
void * pManDec; // decomposition manager void * pManDec; // decomposition manager
void * pManDsd; // decomposition manager
DdManager * dd; // temporary BDD package DdManager * dd; // temporary BDD package
// libraries for mapping // libraries for mapping
void * pLibLut; // the current LUT library void * pLibLut; // the current LUT library
......
...@@ -517,12 +517,18 @@ extern int If_CluCheckExt( void * p, word * pTruth, int nVars, int n ...@@ -517,12 +517,18 @@ extern int If_CluCheckExt( void * p, word * pTruth, int nVars, int n
extern int If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot, extern int If_CluCheckExt3( void * p, word * pTruth, int nVars, int nLutLeaf, int nLutLeaf2, int nLutRoot,
char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 ); char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
/*=== ifDsd.c =============================================================*/ /*=== ifDsd.c =============================================================*/
extern If_DsdMan_t * If_DsdManAlloc( int nLutSize ); extern If_DsdMan_t * If_DsdManAlloc( int nVars, int nLutSize );
extern void If_DsdManDump( If_DsdMan_t * p ); extern void If_DsdManDump( If_DsdMan_t * p );
extern void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int fVerbose ); extern void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int fVerbose );
extern void If_DsdManFree( If_DsdMan_t * p, int fVerbose ); extern void If_DsdManFree( If_DsdMan_t * p, int fVerbose );
extern void If_DsdManSave( If_DsdMan_t * p, char * pFileName );
extern If_DsdMan_t * If_DsdManLoad( char * pFileName );
extern int If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct ); extern int If_DsdManCompute( If_DsdMan_t * p, word * pTruth, int nLeaves, unsigned char * pPerm, char * pLutStruct );
extern char * If_DsdManFileName( If_DsdMan_t * p );
extern int If_DsdManVarNum( If_DsdMan_t * p );
extern int If_DsdManLutSize( If_DsdMan_t * p );
extern int If_DsdManCheckDec( If_DsdMan_t * p, int iDsd ); extern int If_DsdManCheckDec( If_DsdMan_t * p, int iDsd );
extern unsigned If_DsdManCheckXY( If_DsdMan_t * p, int iDsd, int LutSize, int fDerive, int fVerbose );
/*=== ifLib.c =============================================================*/ /*=== ifLib.c =============================================================*/
extern If_LibLut_t * If_LibLutRead( char * FileName ); extern If_LibLut_t * If_LibLutRead( char * FileName );
extern If_LibLut_t * If_LibLutDup( If_LibLut_t * p ); extern If_LibLut_t * If_LibLutDup( If_LibLut_t * p );
......
...@@ -85,7 +85,6 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -85,7 +85,6 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words ) : NULL; p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words ) : NULL;
if ( pPars->fUseDsd ) if ( pPars->fUseDsd )
{ {
p->pIfDsdMan = If_DsdManAlloc( pPars->nLutSize );
p->vTtDsds = Vec_IntAlloc( 1000 ); p->vTtDsds = Vec_IntAlloc( 1000 );
Vec_IntPush( p->vTtDsds, 0 ); Vec_IntPush( p->vTtDsds, 0 );
Vec_IntPush( p->vTtDsds, 2 ); Vec_IntPush( p->vTtDsds, 2 );
...@@ -142,6 +141,15 @@ void If_ManRestart( If_Man_t * p ) ...@@ -142,6 +141,15 @@ void If_ManRestart( If_Man_t * p )
***********************************************************************/ ***********************************************************************/
void If_ManStop( If_Man_t * p ) void If_ManStop( If_Man_t * p )
{ {
/*
if ( p->pIfDsdMan )
{
If_DsdMan_t * pNew;
If_DsdManSave( p->pIfDsdMan, NULL );
pNew = If_DsdManLoad( If_DsdManFileName(p->pIfDsdMan) );
If_DsdManFree( pNew, 1 );
}
*/
{ {
// extern void If_CluHashFindMedian( If_Man_t * p ); // extern void If_CluHashFindMedian( If_Man_t * p );
// extern void If_CluHashTableCheck( If_Man_t * p ); // extern void If_CluHashTableCheck( If_Man_t * p );
...@@ -158,11 +166,13 @@ void If_ManStop( If_Man_t * p ) ...@@ -158,11 +166,13 @@ void If_ManStop( If_Man_t * p )
Abc_Print( 1, "Useless cuts %2d = %9d (out of %9d) (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/(p->nCutsCount[i]+1) ); Abc_Print( 1, "Useless cuts %2d = %9d (out of %9d) (%6.2f %%)\n", i, p->nCutsUseless[i], p->nCutsCount[i], 100.0*p->nCutsUseless[i]/(p->nCutsCount[i]+1) );
Abc_Print( 1, "Useless cuts all = %9d (out of %9d) (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/(p->nCutsCountAll+1) ); Abc_Print( 1, "Useless cuts all = %9d (out of %9d) (%6.2f %%)\n", p->nCutsUselessAll, p->nCutsCountAll, 100.0*p->nCutsUselessAll/(p->nCutsCountAll+1) );
} }
if ( p->pPars->fVerbose && p->nCuts5 ) // if ( p->pPars->fVerbose && p->nCuts5 )
Abc_Print( 1, "Statistics about 5-cuts: Total = %d Non-decomposable = %d (%.2f %%)\n", p->nCuts5, p->nCuts5-p->nCuts5a, 100.0*(p->nCuts5-p->nCuts5a)/p->nCuts5 ); // Abc_Print( 1, "Statistics about 5-cuts: Total = %d Non-decomposable = %d (%.2f %%)\n", p->nCuts5, p->nCuts5-p->nCuts5a, 100.0*(p->nCuts5-p->nCuts5a)/p->nCuts5 );
if ( p->pPars->fUseDsd ) // if ( p->pPars->fUseDsd )
If_DsdManFree( p->pIfDsdMan, p->pPars->fVerbose ); // If_DsdManFree( p->pIfDsdMan, p->pPars->fVerbose );
if ( p->pPars->fUseDsd ) if ( p->pIfDsdMan )
p->pIfDsdMan = NULL;
if ( p->pPars->fUseDsd && (p->nCountNonDec[0] || p->nCountNonDec[1]) )
printf( "NonDec0 = %d. NonDec1 = %d.\n", p->nCountNonDec[0], p->nCountNonDec[1] ); printf( "NonDec0 = %d. NonDec1 = %d.\n", p->nCountNonDec[0], p->nCountNonDec[1] );
// Abc_PrintTime( 1, "Truth", p->timeTruth ); // Abc_PrintTime( 1, "Truth", p->timeTruth );
// Abc_Print( 1, "Small support = %d.\n", p->nSmallSupp ); // Abc_Print( 1, "Small support = %d.\n", p->nSmallSupp );
......
...@@ -217,12 +217,39 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -217,12 +217,39 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
// abctime clk = Abc_Clock(); // abctime clk = Abc_Clock();
If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 ); If_CutComputeTruth( p, pCut, pCut0, pCut1, pObj->fCompl0, pObj->fCompl1 );
// p->timeTruth += Abc_Clock() - clk; // p->timeTruth += Abc_Clock() - clk;
if ( p->pPars->fUseDsd )
{
int truthId = Abc_Lit2Var(pCut->iCutFunc);
if ( Vec_IntSize(p->vTtDsds) <= truthId || Vec_IntEntry(p->vTtDsds, truthId) == -1 )
{
pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthW(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm, p->pPars->pLutStruct );
// printf( "%d(%d) ", pCut->iCutDsd, If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd ) );
while ( Vec_IntSize(p->vTtDsds) <= truthId )
{
Vec_IntPush( p->vTtDsds, -1 );
for ( v = 0; v < p->pPars->nLutSize; v++ )
Vec_StrPush( p->vTtPerms, IF_BIG_CHAR );
}
Vec_IntWriteEntry( p->vTtDsds, truthId, Abc_LitNotCond(pCut->iCutDsd, Abc_LitIsCompl(pCut->iCutFunc)) );
for ( v = 0; v < (int)pCut->nLeaves; v++ )
Vec_StrWriteEntry( p->vTtPerms, truthId * p->pPars->nLutSize + v, (char)pCut->pPerm[v] );
}
else
{
pCut->iCutDsd = Abc_LitNotCond( Vec_IntEntry(p->vTtDsds, truthId), Abc_LitIsCompl(pCut->iCutFunc) );
for ( v = 0; v < (int)pCut->nLeaves; v++ )
pCut->pPerm[v] = (unsigned char)Vec_StrEntry( p->vTtPerms, truthId * p->pPars->nLutSize + v );
}
}
// run user functions // run user functions
pCut->fUseless = 0; pCut->fUseless = 0;
if ( p->pPars->pFuncCell ) if ( p->pPars->pFuncCell )
{ {
assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 ); assert( pCut->nLimit >= 4 && pCut->nLimit <= 16 );
pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), pCut->nLimit, pCut->nLeaves, p->pPars->pLutStruct ); if ( p->pPars->fUseDsd )
pCut->fUseless = If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd );
else
pCut->fUseless = !p->pPars->pFuncCell( p, If_CutTruth(p, pCut), pCut->nLimit, pCut->nLeaves, p->pPars->pLutStruct );
p->nCutsUselessAll += pCut->fUseless; p->nCutsUselessAll += pCut->fUseless;
p->nCutsUseless[pCut->nLeaves] += pCut->fUseless; p->nCutsUseless[pCut->nLeaves] += pCut->fUseless;
p->nCutsCountAll++; p->nCutsCountAll++;
...@@ -251,29 +278,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -251,29 +278,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
p->nCuts5a++; p->nCuts5a++;
} }
} }
/*
if ( p->pPars->fUseDsd ) if ( p->pPars->fUseDsd )
{ {
int truthId = Abc_Lit2Var(pCut->iCutFunc);
if ( Vec_IntSize(p->vTtDsds) <= truthId || Vec_IntEntry(p->vTtDsds, truthId) == -1 )
{
pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthW(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm, p->pPars->pLutStruct );
// printf( "%d(%d) ", pCut->iCutDsd, If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd ) );
while ( Vec_IntSize(p->vTtDsds) <= truthId )
{
Vec_IntPush( p->vTtDsds, -1 );
for ( v = 0; v < p->pPars->nLutSize; v++ )
Vec_StrPush( p->vTtPerms, IF_BIG_CHAR );
}
Vec_IntWriteEntry( p->vTtDsds, truthId, Abc_LitNotCond(pCut->iCutDsd, Abc_LitIsCompl(pCut->iCutFunc)) );
for ( v = 0; v < (int)pCut->nLeaves; v++ )
Vec_StrWriteEntry( p->vTtPerms, truthId * p->pPars->nLutSize + v, (char)pCut->pPerm[v] );
}
else
{
pCut->iCutDsd = Abc_LitNotCond( Vec_IntEntry(p->vTtDsds, truthId), Abc_LitIsCompl(pCut->iCutFunc) );
for ( v = 0; v < (int)pCut->nLeaves; v++ )
pCut->pPerm[v] = (unsigned char)Vec_StrEntry( p->vTtPerms, truthId * p->pPars->nLutSize + v );
}
if ( p->pPars->pLutStruct ) if ( p->pPars->pLutStruct )
{ {
int Value = If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd ); int Value = If_DsdManCheckDec( p->pIfDsdMan, pCut->iCutDsd );
...@@ -283,7 +290,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -283,7 +290,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
p->nCountNonDec[0]++; p->nCountNonDec[0]++;
if ( !pCut->fUseless && Value ) if ( !pCut->fUseless && Value )
p->nCountNonDec[1]++; p->nCountNonDec[1]++;
/*
// if ( pCut->fUseless && !Value ) // if ( pCut->fUseless && !Value )
// printf( "Old does not work. New works.\n" ); // printf( "Old does not work. New works.\n" );
if ( !pCut->fUseless && Value ) if ( !pCut->fUseless && Value )
...@@ -307,14 +314,14 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -307,14 +314,14 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
z = If_Dec6Perform( t, 1 ); z = If_Dec6Perform( t, 1 );
If_DecPrintConfig( z ); If_DecPrintConfig( z );
s = If_DsdManCheckXY( p->pIfDsdMan, pCut->iCutDsd, 4, 1 ); s = If_DsdManCheckXY( p->pIfDsdMan, pCut->iCutDsd, 4, 0, 1 );
printf( "Confirm %d\n", s ); printf( "Confirm %d\n", s );
s = 0; s = 0;
} }
*/
} }
} }
} }
*/
} }
// compute the application-specific cost and depth // compute the application-specific cost and depth
......
...@@ -204,46 +204,46 @@ void If_ManSatTest() ...@@ -204,46 +204,46 @@ void If_ManSatTest()
uSet = (3 << 0) | (1 << 2) | (1 << 4); uSet = (3 << 0) | (1 << 2) | (1 << 4);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (3 << 2) | (1 << 4); uSet = (1 << 0) | (3 << 2) | (1 << 4);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (1 << 2) | (3 << 4); uSet = (1 << 0) | (1 << 2) | (3 << 4);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (3 << 0) | (1 << 2) | (1 << 6); uSet = (3 << 0) | (1 << 2) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (3 << 2) | (1 << 6); uSet = (1 << 0) | (3 << 2) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (1 << 2) | (3 << 6); uSet = (1 << 0) | (1 << 2) | (3 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (3 << 0) | (1 << 4) | (1 << 6); uSet = (3 << 0) | (1 << 4) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (3 << 4) | (1 << 6); uSet = (1 << 0) | (3 << 4) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 0) | (1 << 4) | (3 << 6); uSet = (1 << 0) | (1 << 4) | (3 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (3 << 2) | (1 << 4) | (1 << 6); uSet = (3 << 2) | (1 << 4) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 2) | (3 << 4) | (1 << 6); uSet = (1 << 2) | (3 << 4) | (1 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
uSet = (1 << 2) | (1 << 4) | (3 << 6); uSet = (1 << 2) | (1 << 4) | (3 << 6);
RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits ); RetValue = If_ManSatCheckXY( p, nLutSize, pTruth, nVars, uSet, &uBound, &uFree, vLits );
printf( "%d", RetValue ); printf( "%d (%d)", RetValue, sat_solver_nconflicts(p) );
printf( "\n" ); printf( "\n" );
......
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