Commit ee789ba9 by Alan Mishchenko

Improved DSD.

parent e0f27f5a
...@@ -14541,7 +14541,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -14541,7 +14541,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, "KCFAGDEWSqaflepmrsdbugyojikcvh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KCFAGDEWSqaflepmrsdbugyojikcnvh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -14706,6 +14706,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -14706,6 +14706,9 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'c': case 'c':
pPars->fEnableRealPos ^= 1; pPars->fEnableRealPos ^= 1;
break; break;
case 'n':
pPars->fUseDsd ^= 1;
break;
case 'v': case 'v':
pPars->fVerbose ^= 1; pPars->fVerbose ^= 1;
break; break;
...@@ -14958,7 +14961,7 @@ usage: ...@@ -14958,7 +14961,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 [-KCFAG num] [-DEW float] [-S str] [-qarlepmsdbugyojikcvh]\n" ); Abc_Print( -2, "usage: if [-KCFAG num] [-DEW float] [-S str] [-qarlepmsdbugyojikcnvh]\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 );
...@@ -14988,6 +14991,7 @@ usage: ...@@ -14988,6 +14991,7 @@ usage:
Abc_Print( -2, "\t-i : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck08? "yes": "no" ); Abc_Print( -2, "\t-i : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck08? "yes": "no" );
Abc_Print( -2, "\t-k : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck10? "yes": "no" ); Abc_Print( -2, "\t-k : toggles enabling additional check [default = %s]\n", pPars->fEnableCheck10? "yes": "no" );
Abc_Print( -2, "\t-c : toggles enabling additional feature [default = %s]\n", pPars->fEnableRealPos? "yes": "no" ); Abc_Print( -2, "\t-c : toggles enabling additional feature [default = %s]\n", pPars->fEnableRealPos? "yes": "no" );
Abc_Print( -2, "\t-n : toggles computing DSDs of the cut functions [default = %s]\n", pPars->fUseDsd? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t-h : prints the command usage\n");
return 1; return 1;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "misc/vec/vec.h" #include "misc/vec/vec.h"
#include "misc/mem/mem.h" #include "misc/mem/mem.h"
#include "misc/tim/tim.h" #include "misc/tim/tim.h"
#include "misc/util/utilNam.h"
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
...@@ -116,6 +116,7 @@ struct If_Par_t_ ...@@ -116,6 +116,7 @@ struct If_Par_t_
int fEnableCheck08;// enable additional checking int fEnableCheck08;// enable additional checking
int fEnableCheck10;// enable additional checking int fEnableCheck10;// enable additional checking
int fEnableRealPos;// enable additional feature int fEnableRealPos;// enable additional feature
int fUseDsd; // compute DSD of the cut functions
int fVerbose; // the verbosity flag int fVerbose; // the verbosity flag
char * pLutStruct; // LUT structure char * pLutStruct; // LUT structure
float WireDelay; // wire delay float WireDelay; // wire delay
...@@ -215,6 +216,9 @@ struct If_Man_t_ ...@@ -215,6 +216,9 @@ struct If_Man_t_
int nCutsCount[32]; int nCutsCount[32];
int nCutsCountAll; int nCutsCountAll;
int nCutsUselessAll; int nCutsUselessAll;
Abc_Nam_t * pNamDsd;
int iNamVar;
// timing manager // timing manager
Tim_Man_t * pManTim; Tim_Man_t * pManTim;
Vec_Int_t * vCoAttrs; // CO attributes 0=optimize; 1=keep; 2=relax Vec_Int_t * vCoAttrs; // CO attributes 0=optimize; 1=keep; 2=relax
...@@ -235,6 +239,7 @@ struct If_Cut_t_ ...@@ -235,6 +239,7 @@ struct If_Cut_t_
float Edge; // the edge flow float Edge; // the edge flow
float Power; // the power flow float Power; // the power flow
float Delay; // delay of the cut float Delay; // delay of the cut
int iDsd; // DSD ID of the cut
unsigned uSign; // cut signature unsigned uSign; // cut signature
unsigned Cost : 13; // the user's cost of the cut (related to IF_COST_MAX) unsigned Cost : 13; // the user's cost of the cut (related to IF_COST_MAX)
unsigned fCompl : 1; // the complemented attribute unsigned fCompl : 1; // the complemented attribute
......
...@@ -32,6 +32,8 @@ static If_Obj_t * If_ManSetupObj( If_Man_t * p ); ...@@ -32,6 +32,8 @@ static If_Obj_t * If_ManSetupObj( If_Man_t * p );
static void If_ManCutSetRecycle( If_Man_t * p, If_Set_t * pSet ) { pSet->pNext = p->pFreeList; p->pFreeList = pSet; } static void If_ManCutSetRecycle( If_Man_t * p, If_Set_t * pSet ) { pSet->pNext = p->pFreeList; p->pFreeList = pSet; }
static If_Set_t * If_ManCutSetFetch( If_Man_t * p ) { If_Set_t * pTemp = p->pFreeList; p->pFreeList = p->pFreeList->pNext; return pTemp; } static If_Set_t * If_ManCutSetFetch( If_Man_t * p ) { If_Set_t * pTemp = p->pFreeList; p->pFreeList = p->pFreeList->pNext; return pTemp; }
extern clock_t s_TimeComp[3];
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -79,6 +81,11 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -79,6 +81,11 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->puTemp[2] = p->puTemp[1] + p->nTruthWords; p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
p->puTemp[3] = p->puTemp[2] + p->nTruthWords; p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
p->pCutTemp = (If_Cut_t *)ABC_ALLOC( char, p->nCutBytes ); p->pCutTemp = (If_Cut_t *)ABC_ALLOC( char, p->nCutBytes );
if ( pPars->fUseDsd )
{
p->pNamDsd = Abc_NamStart( 1000, 20 );
p->iNamVar = Abc_NamStrFindOrAdd( p->pNamDsd, "a", NULL );
}
// create the constant node // create the constant node
p->pConst1 = If_ManSetupObj( p ); p->pConst1 = If_ManSetupObj( p );
...@@ -143,6 +150,17 @@ void If_ManStop( If_Man_t * p ) ...@@ -143,6 +150,17 @@ 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->pNamDsd )
{
if ( p->pPars->fVerbose )
Abc_Print( 1, "Number of unique entries in the DSD table = %d. Memory = %.1f MB.\n",
Abc_NamObjNumMax(p->pNamDsd), 1.0*Abc_NamMemAlloc(p->pNamDsd)/(1<<20) );
Abc_PrintTime( 1, "Time0", s_TimeComp[0] );
Abc_PrintTime( 1, "Time1", s_TimeComp[1] );
Abc_PrintTime( 1, "Time2", s_TimeComp[2] );
// Abc_NamPrint( p->pNamDsd );
Abc_NamStop( p->pNamDsd );
}
// 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 );
Vec_IntFreeP( &p->vCoAttrs ); Vec_IntFreeP( &p->vCoAttrs );
...@@ -408,6 +426,7 @@ void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId ) ...@@ -408,6 +426,7 @@ void If_ManSetupCutTriv( If_Man_t * p, If_Cut_t * pCut, int ObjId )
pCut->nLeaves = 1; pCut->nLeaves = 1;
pCut->pLeaves[0] = p->pPars->fLiftLeaves? (ObjId << 8) : ObjId; pCut->pLeaves[0] = p->pPars->fLiftLeaves? (ObjId << 8) : ObjId;
pCut->uSign = If_ObjCutSign( pCut->pLeaves[0] ); pCut->uSign = If_ObjCutSign( pCut->pLeaves[0] );
pCut->iDsd = p->iNamVar;
// set up elementary truth table of the unit cut // set up elementary truth table of the unit cut
if ( p->pPars->fTruth ) if ( p->pPars->fTruth )
{ {
......
...@@ -27,6 +27,8 @@ ABC_NAMESPACE_IMPL_START ...@@ -27,6 +27,8 @@ ABC_NAMESPACE_IMPL_START
/// DECLARATIONS /// /// DECLARATIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
extern char * Dau_DsdMerge( char * pDsd0i, int * pPerm0, char * pDsd1i, int * pPerm1, int fCompl0, int fCompl1 );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS /// /// FUNCTION DEFINITIONS ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -80,6 +82,50 @@ float If_CutDelaySpecial( If_Man_t * p, If_Cut_t * pCut, int fCarry ) ...@@ -80,6 +82,50 @@ float If_CutDelaySpecial( If_Man_t * p, If_Cut_t * pCut, int fCarry )
/**Function************************************************************* /**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int * If_CutPerm0( If_Cut_t * pCut, If_Cut_t * pCut0 )
{
static int pPerm[IF_MAX_LUTSIZE];
int i, k;
for ( i = k = 0; i < (int)pCut->nLeaves; i++ )
{
if ( k == (int)pCut0->nLeaves )
break;
if ( pCut->pLeaves[i] < pCut0->pLeaves[k] )
continue;
assert( pCut->pLeaves[i] == pCut0->pLeaves[k] );
pPerm[k++] = i;
}
return pPerm;
}
static inline int * If_CutPerm1( If_Cut_t * pCut, If_Cut_t * pCut1 )
{
static int pPerm[IF_MAX_LUTSIZE];
int i, k;
for ( i = k = 0; i < (int)pCut->nLeaves; i++ )
{
if ( k == (int)pCut1->nLeaves )
break;
if ( pCut->pLeaves[i] < pCut1->pLeaves[k] )
continue;
assert( pCut->pLeaves[i] == pCut1->pLeaves[k] );
pPerm[k++] = i;
}
return pPerm;
}
/**Function*************************************************************
Synopsis [Finds the best cut for the given node.] Synopsis [Finds the best cut for the given node.]
Description [Mapping modes: delay (0), area flow (1), area (2).] Description [Mapping modes: delay (0), area flow (1), area (2).]
...@@ -227,7 +273,16 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -227,7 +273,16 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
p->nCutsCountAll++; p->nCutsCountAll++;
p->nCutsCount[pCut->nLeaves]++; p->nCutsCount[pCut->nLeaves]++;
} }
}
if ( p->pPars->fUseDsd )
{
char * pName = Dau_DsdMerge(
Abc_NamStr(p->pNamDsd, pCut0->iDsd),
If_CutPerm0(pCut, pCut0),
Abc_NamStr(p->pNamDsd, pCut1->iDsd),
If_CutPerm1(pCut, pCut1),
pObj->fCompl0, pObj->fCompl1 );
pCut->iDsd = Abc_NamStrFindOrAdd( p->pNamDsd, pName, NULL );
} }
// compute the application-specific cost and depth // compute the application-specific cost and depth
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
ABC_NAMESPACE_HEADER_START ABC_NAMESPACE_HEADER_START
#define DAU_MAX_VAR 16 // should be 6 or more #define DAU_MAX_VAR 8 // should be 6 or more
#define DAU_MAX_STR 256 #define DAU_MAX_STR 64
#define DAU_MAX_WORD (1<<(DAU_MAX_VAR-6)) #define DAU_MAX_WORD (1<<(DAU_MAX_VAR-6))
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -184,6 +184,14 @@ void Dau_DsdNormalize_rec( char * pStr, char ** p, int * pMatches ) ...@@ -184,6 +184,14 @@ void Dau_DsdNormalize_rec( char * pStr, char ** p, int * pMatches )
static char pBuffer[DAU_MAX_STR]; static char pBuffer[DAU_MAX_STR];
if ( **p == '!' ) if ( **p == '!' )
(*p)++; (*p)++;
while ( (**p >= 'A' && **p <= 'F') || (**p >= '0' && **p <= '9') )
(*p)++;
if ( **p == '<' )
{
char * q = pStr + pMatches[*p - pStr];
if ( *(q+1) == '{' )
*p = q+1;
}
if ( **p >= 'a' && **p <= 'f' ) // var if ( **p >= 'a' && **p <= 'f' ) // var
return; return;
if ( **p == '(' || **p == '[' ) // and/or/xor if ( **p == '(' || **p == '[' ) // and/or/xor
......
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