Commit af6705a8 by Alan Mishchenko

Implementation of DSD balancing.

parent f1f1cf3e
...@@ -2323,6 +2323,10 @@ SOURCE=.\src\map\if\ifCore.c ...@@ -2323,6 +2323,10 @@ SOURCE=.\src\map\if\ifCore.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\map\if\ifCount.h
# End Source File
# Begin Source File
SOURCE=.\src\map\if\ifCut.c SOURCE=.\src\map\if\ifCut.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -15102,7 +15102,8 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -15102,7 +15102,8 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fTruth = 1; pPars->fTruth = 1;
pPars->fCutMin = 1; pPars->fCutMin = 1;
pPars->fExpRed = 0; pPars->fExpRed = 0;
pPars->fUsePerm = 0; pPars->fUsePerm = pPars->fDsdBalance;
pPars->fUseDsd = pPars->fDsdBalance;
pPars->pLutLib = NULL; pPars->pLutLib = NULL;
} }
// modify for delay optimization // modify for delay optimization
...@@ -29855,7 +29856,8 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29855,7 +29856,8 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fTruth = 1; pPars->fTruth = 1;
pPars->fCutMin = 1; pPars->fCutMin = 1;
pPars->fExpRed = 0; pPars->fExpRed = 0;
pPars->fUsePerm = 0; pPars->fUsePerm = pPars->fDsdBalance;
pPars->fUseDsd = pPars->fDsdBalance;
pPars->pLutLib = NULL; pPars->pLutLib = NULL;
} }
// modify for delay optimization // modify for delay optimization
...@@ -540,7 +540,7 @@ extern int If_DsdManLutSize( If_DsdMan_t * p ); ...@@ -540,7 +540,7 @@ extern int If_DsdManLutSize( If_DsdMan_t * p );
extern int If_DsdManSuppSize( If_DsdMan_t * p, int iDsd ); extern int If_DsdManSuppSize( If_DsdMan_t * p, int iDsd );
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 fHighEffort, int fVerbose ); extern unsigned If_DsdManCheckXY( If_DsdMan_t * p, int iDsd, int LutSize, int fDerive, int fHighEffort, int fVerbose );
extern int If_CutDsdBalanceEval( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig ); extern int If_CutDsdBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
extern int If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm ); extern int If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
/*=== ifLib.c =============================================================*/ /*=== ifLib.c =============================================================*/
extern If_LibLut_t * If_LibLutRead( char * FileName ); extern If_LibLut_t * If_LibLutRead( char * FileName );
......
...@@ -72,8 +72,6 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -72,8 +72,6 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->vTtMem[v] = p->vTtMem[6]; p->vTtMem[v] = p->vTtMem[6];
if ( p->pPars->fDelayOpt ) if ( p->pPars->fDelayOpt )
{ {
p->vCover = Vec_IntAlloc( 0 );
p->vArray = Vec_IntAlloc( 1000 );
for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
p->vTtIsops[v] = Vec_WecAlloc( 1000 ); p->vTtIsops[v] = Vec_WecAlloc( 1000 );
for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ )
...@@ -81,6 +79,11 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) ...@@ -81,6 +79,11 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
for ( v = 0; v < 6; v++ ) for ( v = 0; v < 6; v++ )
p->vTtIsops[v] = p->vTtIsops[6]; p->vTtIsops[v] = p->vTtIsops[6];
} }
if ( p->pPars->fDelayOpt || p->pPars->fDsdBalance );
{
p->vCover = Vec_IntAlloc( 0 );
p->vArray = Vec_IntAlloc( 1000 );
}
} }
p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0; p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0;
p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords); p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords);
......
...@@ -133,6 +133,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -133,6 +133,7 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
pCut->Delay = If_CutDelaySop( p, pCut ); pCut->Delay = If_CutDelaySop( p, pCut );
else else
pCut->Delay = If_CutDelay( p, pObj, pCut ); pCut->Delay = If_CutDelay( p, pObj, pCut );
assert( pCut->Delay != -1 );
// assert( pCut->Delay <= pObj->Required + p->fEpsilon ); // assert( pCut->Delay <= pObj->Required + p->fEpsilon );
if ( pCut->Delay > pObj->Required + 2*p->fEpsilon ) if ( pCut->Delay > pObj->Required + 2*p->fEpsilon )
Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n", Abc_Print( 1, "If_ObjPerformMappingAnd(): Warning! Delay of node %d (%f) exceeds the required times (%f).\n",
...@@ -213,25 +214,26 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -213,25 +214,26 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
int truthId = Abc_Lit2Var(pCut->iCutFunc); int truthId = Abc_Lit2Var(pCut->iCutFunc);
if ( Vec_IntSize(p->vTtDsds[pCut->nLeaves]) <= truthId || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 ) if ( Vec_IntSize(p->vTtDsds[pCut->nLeaves]) <= truthId || Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId) == -1 )
{ {
pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthW(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm, p->pPars->pLutStruct ); pCut->iCutDsd = If_DsdManCompute( p->pIfDsdMan, If_CutTruthWR(p, pCut), pCut->nLeaves, (unsigned char *)pCut->pPerm, p->pPars->pLutStruct );
while ( Vec_IntSize(p->vTtDsds[pCut->nLeaves]) <= truthId ) while ( Vec_IntSize(p->vTtDsds[pCut->nLeaves]) <= truthId )
{ {
Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 ); Vec_IntPush( p->vTtDsds[pCut->nLeaves], -1 );
for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ ) for ( v = 0; v < Abc_MaxInt(6, pCut->nLeaves); v++ )
Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR ); Vec_StrPush( p->vTtPerms[pCut->nLeaves], IF_BIG_CHAR );
} }
Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, Abc_LitNotCond(pCut->iCutDsd, Abc_LitIsCompl(pCut->iCutFunc)) ); Vec_IntWriteEntry( p->vTtDsds[pCut->nLeaves], truthId, pCut->iCutDsd );
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
Vec_StrWriteEntry( p->vTtPerms[pCut->nLeaves], truthId * Abc_MaxInt(6, pCut->nLeaves) + v, (char)pCut->pPerm[v] ); Vec_StrWriteEntry( p->vTtPerms[pCut->nLeaves], truthId * Abc_MaxInt(6, pCut->nLeaves) + v, (char)pCut->pPerm[v] );
} }
else else
{ {
pCut->iCutDsd = Abc_LitNotCond( Vec_IntEntry(p->vTtDsds[pCut->nLeaves], truthId), Abc_LitIsCompl(pCut->iCutFunc) ); pCut->iCutDsd = Vec_IntEntry( p->vTtDsds[pCut->nLeaves], truthId );
for ( v = 0; v < (int)pCut->nLeaves; v++ ) for ( v = 0; v < (int)pCut->nLeaves; v++ )
pCut->pPerm[v] = (unsigned char)Vec_StrEntry( p->vTtPerms[pCut->nLeaves], truthId * Abc_MaxInt(6, pCut->nLeaves) + v ); pCut->pPerm[v] = (unsigned char)Vec_StrEntry( p->vTtPerms[pCut->nLeaves], truthId * Abc_MaxInt(6, pCut->nLeaves) + v );
// assert( If_DsdManSuppSize(p->pIfDsdMan, pCut->iCutDsd) == (int)pCut->nLeaves ); // assert( If_DsdManSuppSize(p->pIfDsdMan, pCut->iCutDsd) == (int)pCut->nLeaves );
} }
// If_ManCacheRecord( p, pCut0->iCutDsd, pCut1->iCutDsd, nShared, pCut->iCutDsd ); // If_ManCacheRecord( p, pCut0->iCutDsd, pCut1->iCutDsd, nShared, pCut->iCutDsd );
pCut->iCutDsd = Abc_LitNotCond( pCut->iCutDsd, Abc_LitIsCompl(pCut->iCutFunc) );
} }
// run user functions // run user functions
pCut->fUseless = 0; pCut->fUseless = 0;
...@@ -289,6 +291,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep ...@@ -289,6 +291,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
pCut->Delay = If_CutDelaySop( p, pCut ); pCut->Delay = If_CutDelaySop( p, pCut );
else else
pCut->Delay = If_CutDelay( p, pObj, pCut ); pCut->Delay = If_CutDelay( p, pObj, pCut );
if ( pCut->Delay == -1 )
continue;
if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon ) if ( Mode && pCut->Delay > pObj->Required + p->fEpsilon )
continue; continue;
// compute area of the cut (this area may depend on the application specific cost) // compute area of the cut (this area may depend on the application specific cost)
......
...@@ -202,10 +202,19 @@ void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, fl ...@@ -202,10 +202,19 @@ void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, fl
{ {
if ( pCut->fUser ) if ( pCut->fUser )
{ {
char Perm[IF_MAX_FUNC_LUTSIZE]; char Perm[IF_MAX_FUNC_LUTSIZE], * pPerm = Perm;
char * pPerm = p->pPars->fDelayOpt ? Perm : pCut->pPerm;
if ( p->pPars->fDelayOpt ) if ( p->pPars->fDelayOpt )
If_CutSopBalancePinDelays( p, pCut, pPerm ); {
int Delay = If_CutSopBalancePinDelays( p, pCut, pPerm );
assert( Delay == pCut->Delay );
}
else if ( p->pPars->fDsdBalance )
{
int Delay = If_CutDsdBalancePinDelays( p, pCut, pPerm );
assert( Delay == pCut->Delay );
}
else
pPerm = pCut->pPerm;
If_CutForEachLeaf( p, pCut, pLeaf, i ) If_CutForEachLeaf( p, pCut, pLeaf, i )
{ {
Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1; Pin2PinDelay = pPerm ? (pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pPerm[i]) : 1;
......
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