Commit 976f5f5a by Alan Mishchenko

Changes to Boolean matching.

parent d080336b
...@@ -902,6 +902,10 @@ void Abc_Init( Abc_Frame_t * pAbc ) ...@@ -902,6 +902,10 @@ void Abc_Init( Abc_Frame_t * pAbc )
printf( "\n" ); printf( "\n" );
} }
*/ */
{
extern void If_CluTest();
If_CluTest();
}
} }
/**Function************************************************************* /**Function*************************************************************
...@@ -12992,6 +12996,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -12992,6 +12996,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fSeqMap = 0; pPars->fSeqMap = 0;
pPars->fBidec = 0; pPars->fBidec = 0;
pPars->fVerbose = 0; pPars->fVerbose = 0;
pPars->pLutStruct = NULL;
// internal parameters // internal parameters
pPars->fTruth = 0; pPars->fTruth = 0;
pPars->nLatches = pNtk? Abc_NtkLatchNum(pNtk) : 0; pPars->nLatches = pNtk? Abc_NtkLatchNum(pNtk) : 0;
...@@ -13003,7 +13008,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -13003,7 +13008,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
fLutMux = 0; fLutMux = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEqaflepmrsdbugojikcvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KCFADEWSqaflepmrsdbugojikcvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -13075,6 +13080,31 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -13075,6 +13080,31 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 ) if ( pPars->Epsilon < 0.0 || pPars->Epsilon > 1.0 )
goto usage; goto usage;
break; break;
case 'W':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" );
goto usage;
}
pPars->WireDelay = (float)atof(argv[globalUtilOptind]);
globalUtilOptind++;
if ( pPars->WireDelay < 0.0 )
goto usage;
break;
case 'S':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by string.\n" );
goto usage;
}
pPars->pLutStruct = argv[globalUtilOptind];
globalUtilOptind++;
if ( !strlen(pPars->pLutStruct) == 2 && !strlen(pPars->pLutStruct) == 3 )
{
Abc_Print( -1, "Command line switch \"-S\" should be followed by a 2- or 3-char string (e.g. \"44\" or \"555\").\n" );
goto usage;
}
break;
case 'q': case 'q':
pPars->fPreprocess ^= 1; pPars->fPreprocess ^= 1;
break; break;
...@@ -13261,6 +13291,20 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -13261,6 +13291,20 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->pLutLib = NULL; pPars->pLutLib = NULL;
} }
// modify for LUT structures
if ( pPars->pLutStruct )
{
if ( pPars->nLutSize == -1 )
{
Abc_Print( -1, "Please specify the maximum cut size (-K <num>) when LUT structure is used.\n" );
return 1;
}
pPars->fTruth = 1;
pPars->fExpRed = 0;
pPars->fUsePerm = 1;
pPars->pLutLib = NULL;
}
// complain if truth tables are requested but the cut size is too large // complain if truth tables are requested but the cut size is too large
if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE ) if ( pPars->fTruth && pPars->nLutSize > IF_MAX_FUNC_LUTSIZE )
{ {
...@@ -13323,7 +13367,7 @@ usage: ...@@ -13323,7 +13367,7 @@ usage:
sprintf( LutSize, "library" ); sprintf( LutSize, "library" );
else else
sprintf( LutSize, "%d", pPars->nLutSize ); sprintf( LutSize, "%d", pPars->nLutSize );
Abc_Print( -2, "usage: if [-KCFA num] [-DE float] [-qarlepmsdbugojikcvh]\n" ); Abc_Print( -2, "usage: if [-KCFA num] [-DEW float] [-S str] [-qarlepmsdbugojikcvh]\n" );
Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" ); Abc_Print( -2, "\t performs FPGA technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize ); Abc_Print( -2, "\t-K num : the number of LUT inputs (2 < num < %d) [default = %s]\n", IF_MAX_LUTSIZE+1, LutSize );
Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax ); Abc_Print( -2, "\t-C num : the max number of priority cuts (0 < num < 2^12) [default = %d]\n", pPars->nCutsMax );
...@@ -13331,6 +13375,8 @@ usage: ...@@ -13331,6 +13375,8 @@ usage:
Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters ); Abc_Print( -2, "\t-A num : the number of exact area recovery iterations (num >= 0) [default = %d]\n", pPars->nAreaIters );
Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer ); Abc_Print( -2, "\t-D float : sets the delay constraint for the mapping [default = %s]\n", Buffer );
Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon ); Abc_Print( -2, "\t-E float : sets epsilon used for tie-breaking [default = %f]\n", pPars->Epsilon );
Abc_Print( -2, "\t-W float : sets wire delay between adjects LUTs [default = %f]\n", pPars->WireDelay );
Abc_Print( -2, "\t-S str : string representing the LUT structure [default = %s]\n", pPars->pLutStruct ? pPars->pLutStruct : "not used" );
Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" ); Abc_Print( -2, "\t-q : toggles preprocessing using several starting points [default = %s]\n", pPars->fPreprocess? "yes": "no" );
Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" ); Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fArea? "yes": "no" );
// Abc_Print( -2, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" ); // Abc_Print( -2, "\t-f : toggles one fancy feature [default = %s]\n", pPars->fFancy? "yes": "no" );
......
...@@ -436,7 +436,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t ...@@ -436,7 +436,7 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
pCutBest = If_ObjCutBest( pIfObj ); pCutBest = If_ObjCutBest( pIfObj );
// printf( "%d 0x%02X %d\n", pCutBest->nLeaves, 0xff & *If_CutTruth(pCutBest), pIfMan->pPars->pFuncCost(pCutBest) ); // printf( "%d 0x%02X %d\n", pCutBest->nLeaves, 0xff & *If_CutTruth(pCutBest), pIfMan->pPars->pFuncCost(pCutBest) );
// if ( pIfMan->pPars->pLutLib && pIfMan->pPars->pLutLib->fVarPinDelays ) // if ( pIfMan->pPars->pLutLib && pIfMan->pPars->pLutLib->fVarPinDelays )
if ( !pIfMan->pPars->fDelayOpt ) if ( !pIfMan->pPars->fDelayOpt && !pIfMan->pPars->pLutStruct )
If_CutRotatePins( pIfMan, pCutBest ); If_CutRotatePins( pIfMan, pCutBest );
if ( pIfMan->pPars->fUseCnfs || pIfMan->pPars->fUseMv ) if ( pIfMan->pPars->fUseCnfs || pIfMan->pPars->fUseMv )
{ {
......
...@@ -101,6 +101,8 @@ struct If_Par_t_ ...@@ -101,6 +101,8 @@ struct If_Par_t_
int fEnableCheck10;// enable additional checking int fEnableCheck10;// enable additional checking
int fEnableRealPos;// enable additional feature int fEnableRealPos;// enable additional feature
int fVerbose; // the verbosity flag int fVerbose; // the verbosity flag
char * pLutStruct; // LUT structure
float WireDelay; // wire delay
// internal parameters // internal parameters
int fDelayOpt; // special delay optimization int fDelayOpt; // special delay optimization
int fAreaOnly; // area only mode int fAreaOnly; // area only mode
...@@ -414,6 +416,7 @@ extern float If_CutPowerRefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t ...@@ -414,6 +416,7 @@ extern float If_CutPowerRefed( If_Man_t * p, If_Cut_t * pCut, If_Obj_t
extern int If_CutPerformCheck07( unsigned * pTruth, int nVars, int nLeaves ); extern int If_CutPerformCheck07( unsigned * pTruth, int nVars, int nLeaves );
extern int If_CutPerformCheck08( unsigned * pTruth, int nVars, int nLeaves ); extern int If_CutPerformCheck08( unsigned * pTruth, int nVars, int nLeaves );
extern int If_CutPerformCheck10( unsigned * pTruth, int nVars, int nLeaves ); extern int If_CutPerformCheck10( unsigned * pTruth, int nVars, int nLeaves );
extern float If_CutDelayLutStruct( If_Man_t * p, If_Cut_t * pCut, char * pStr, float WireDelay );
/*=== ifLib.c =============================================================*/ /*=== ifLib.c =============================================================*/
extern If_Lib_t * If_LutLibRead( char * FileName ); extern If_Lib_t * If_LutLibRead( char * FileName );
extern If_Lib_t * If_LutLibDup( If_Lib_t * p ); extern If_Lib_t * If_LutLibDup( If_Lib_t * p );
......
...@@ -153,7 +153,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -153,7 +153,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->nLeaves > 0 ) if ( pCut->nLeaves > 0 )
{ {
// recompute the parameters of the best cut // recompute the parameters of the best cut
if ( p->pPars->fDelayOpt ) if ( p->pPars->pLutStruct )
pCut->Delay = If_CutDelayLutStruct( p, pCut, p->pPars->pLutStruct, p->pPars->WireDelay );
else if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut ); pCut->Delay = If_CutDelaySopCost( p, pCut );
else else
pCut->Delay = If_CutDelay( p, pObj, pCut ); pCut->Delay = If_CutDelay( p, pObj, pCut );
...@@ -215,7 +217,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -215,7 +217,9 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
if ( pCut->Cost == IF_COST_MAX ) if ( pCut->Cost == IF_COST_MAX )
continue; continue;
// check if the cut satisfies the required times // check if the cut satisfies the required times
if ( p->pPars->fDelayOpt ) if ( p->pPars->pLutStruct )
pCut->Delay = If_CutDelayLutStruct( p, pCut, p->pPars->pLutStruct, p->pPars->WireDelay );
else if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut ); pCut->Delay = If_CutDelaySopCost( p, pCut );
else else
pCut->Delay = If_CutDelay( p, pObj, pCut ); pCut->Delay = If_CutDelay( p, pObj, pCut );
......
...@@ -200,6 +200,7 @@ void Extra_PrintKMap( ...@@ -200,6 +200,7 @@ void Extra_PrintKMap(
int fSuppType, /* the flag which determines how support is computed */ int fSuppType, /* the flag which determines how support is computed */
char ** pVarNames ) char ** pVarNames )
{ {
int fPrintTruth = 1;
int d, p, n, s, v, h, w; int d, p, n, s, v, h, w;
int nVarsVer; int nVarsVer;
int nVarsHor; int nVarsHor;
...@@ -213,6 +214,40 @@ void Extra_PrintKMap( ...@@ -213,6 +214,40 @@ void Extra_PrintKMap(
fprintf( Output, "PrintKMap(): The on-set and the off-set overlap\n" ); fprintf( Output, "PrintKMap(): The on-set and the off-set overlap\n" );
return; return;
} }
// print truth table for debugging
if ( fPrintTruth )
{
DdNode * bCube, * bPart;
printf( "Truth table: " );
if ( nVars == 0 )
printf( "Constant" );
else if ( nVars == 1 )
printf( "1-var function" );
else
{
// printf( "0x" );
for ( d = (1<<(nVars-2)) - 1; d >= 0; d-- )
{
int Value = 0;
for ( s = 0; s < 4; s++ )
{
bCube = Extra_bddBitsToCube( dd, 4*d+s, nVars, dd->vars, 0 ); Cudd_Ref( bCube );
bPart = Cudd_Cofactor( dd, OnSet, bCube ); Cudd_Ref( bPart );
Value |= ((int)(bPart == b1) << s);
Cudd_RecursiveDeref( dd, bPart );
Cudd_RecursiveDeref( dd, bCube );
}
if ( Value < 10 )
fprintf( stdout, "%d", Value );
else
fprintf( stdout, "%c", 'a' + Value-10 );
}
}
printf( "\n" );
}
/* /*
if ( OnSet == b1 ) if ( OnSet == b1 )
{ {
......
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