Commit 2a399042 by Alan Mishchenko

Improvement in SOP balancing.

parent faf3bf34
......@@ -344,111 +344,6 @@ Abc_Ntk_t * Abc_NtkFromIf( If_Man_t * pIfMan, Abc_Ntk_t * pNtk )
return pNtkNew;
}
/**Function*************************************************************
Synopsis [Inserts the entry while sorting them by delay.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Hop_Obj_t * Abc_NodeFromSopBalanceInt( Hop_Man_t * pMan, Vec_Wrd_t * vAnds, int nVars )
{
Vec_Ptr_t * vResults;
Hop_Obj_t * pRes0, * pRes1, * pRes = NULL;
If_And_t This;
word Entry;
int i;
if ( Vec_WrdSize(vAnds) == 0 )
return Hop_ManConst0(pMan);
if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
return Hop_ManConst1(pMan);
vResults = Vec_PtrAlloc( Vec_WrdSize(vAnds) );
for ( i = 0; i < nVars; i++ )
Vec_PtrPush( vResults, Hop_IthVar(pMan, i) );
Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
{
This = If_WrdToAnd( Entry );
pRes0 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan0), This.fCompl0 );
pRes1 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan1), This.fCompl1 );
pRes = Hop_And( pMan, pRes0, pRes1 );
Vec_PtrPush( vResults, pRes );
/*
printf( "fan0 = %c%d fan1 = %c%d Del = %d\n",
This.fCompl0? '-':'+', This.iFan0,
This.fCompl1? '-':'+', This.iFan1,
This.Delay );
*/
}
Vec_PtrFree( vResults );
return Hop_NotCond( pRes, This.fCompl );
}
Hop_Obj_t * Abc_NodeFromSopBalance( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut )
{
Hop_Obj_t * pResult;
Vec_Wrd_t * vArray;
vArray = If_CutDelaySopArray( p, pCut );
pResult = Abc_NodeFromSopBalanceInt( pMan, vArray, If_CutLeaveNum(pCut) );
// Vec_WrdFree( vArray );
return pResult;
}
/**Function*************************************************************
Synopsis [Inserts the entry while sorting them by delay.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Hop_Obj_t * Abc_NodeFromDsdBalanceInt( Hop_Man_t * pMan, Vec_Wrd_t * vAnds, int nVars )
{
Vec_Ptr_t * vResults;
Hop_Obj_t * pRes0, * pRes1, * pRes = NULL;
If_And_t This;
word Entry;
int i;
if ( Vec_WrdSize(vAnds) == 0 )
return Hop_ManConst0(pMan);
if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
return Hop_ManConst1(pMan);
vResults = Vec_PtrAlloc( Vec_WrdSize(vAnds) );
for ( i = 0; i < nVars; i++ )
Vec_PtrPush( vResults, Hop_IthVar(pMan, i) );
Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
{
This = If_WrdToAnd( Entry );
pRes0 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan0), This.fCompl0 );
pRes1 = Hop_NotCond( (Hop_Obj_t *)Vec_PtrEntry(vResults, This.iFan1), This.fCompl1 );
pRes = Hop_And( pMan, pRes0, pRes1 );
Vec_PtrPush( vResults, pRes );
/*
printf( "fan0 = %c%d fan1 = %c%d Del = %d\n",
This.fCompl0? '-':'+', This.iFan0,
This.fCompl1? '-':'+', This.iFan1,
This.Delay );
*/
}
Vec_PtrFree( vResults );
return Hop_NotCond( pRes, This.fCompl );
}
Hop_Obj_t * Abc_NodeFromDsdBalance( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut )
{
Hop_Obj_t * pResult;
Vec_Wrd_t * vArray;
vArray = If_CutDelaySopArray( p, pCut );
pResult = Abc_NodeFromDsdBalanceInt( pMan, vArray, If_CutLeaveNum(pCut) );
// Vec_WrdFree( vArray );
return pResult;
}
/**Function*************************************************************
Synopsis [Rebuilds GIA from mini AIG.]
......@@ -467,7 +362,7 @@ Hop_Obj_t * Abc_NodeBuildFromMiniInt( Hop_Man_t * pMan, Vec_Int_t * vAig, int nL
if ( Vec_IntSize(vAig) == 1 ) // const
{
assert( nLeaves == 0 );
return Hop_NotCond( Hop_ManConst1(pMan), Vec_IntEntry(vAig, 0) );
return Hop_NotCond( Hop_ManConst0(pMan), Vec_IntEntry(vAig, 0) );
}
if ( Vec_IntSize(vAig) == 2 ) // variable
{
......@@ -500,7 +395,7 @@ Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pC
{
Hop_Obj_t * pResult;
if ( p->vArray == NULL )
p->vArray = Vec_IntAlloc(100);
p->vArray = Vec_IntAlloc(1000);
If_CutDelaySopArray3( p, pCut, p->vArray );
pResult = Abc_NodeBuildFromMiniInt( pMan, p->vArray, If_CutLeaveNum(pCut) );
return pResult;
......@@ -582,15 +477,9 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
}
}
else if ( pIfMan->pPars->fDelayOpt )
{
extern Hop_Obj_t * Abc_NodeFromSopBalance( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut );
pNodeNew->pData = Abc_NodeFromSopBalance( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
}
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
else if ( pIfMan->pPars->fDsdBalance )
{
extern Hop_Obj_t * Abc_NodeFromDsdBalance( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut );
pNodeNew->pData = Abc_NodeFromDsdBalance( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
}
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
else if ( pIfMan->pPars->fUserRecLib )
{
extern Hop_Obj_t * Abc_RecToHop3( Hop_Man_t * pMan, If_Man_t * pIfMan, If_Cut_t * pCut, If_Obj_t * pIfObj );
......
......@@ -124,8 +124,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
{
// recompute the parameters of the best cut
if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut );
// pCut->Delay = If_CutDelaySopArray3( p, pCut, NULL );
// pCut->Delay = If_CutDelaySopCost( p, pCut );
pCut->Delay = If_CutDelaySopArray3( p, pCut, NULL );
else if ( p->pPars->fDsdBalance )
pCut->Delay = If_DsdCutBalanceCost( p, pCut );
else if ( p->pPars->fUserRecLib )
......@@ -281,8 +281,8 @@ void If_ObjPerformMappingAnd( If_Man_t * p, If_Obj_t * pObj, int Mode, int fPrep
continue;
// check if the cut satisfies the required times
if ( p->pPars->fDelayOpt )
pCut->Delay = If_CutDelaySopCost( p, pCut );
// pCut->Delay = If_CutDelaySopArray3( p, pCut, NULL );
// pCut->Delay = If_CutDelaySopCost( p, pCut );
pCut->Delay = If_CutDelaySopArray3( p, pCut, NULL );
else if ( p->pPars->fDsdBalance )
pCut->Delay = If_DsdCutBalanceCost( p, pCut );
else if ( p->pPars->fUserRecLib )
......
......@@ -253,6 +253,7 @@ Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut )
abctime clk;
Vec_Wrd_t * vAnds;
int RetValue;
printf( "Running old code!!!\n" );
if ( p->vCover == NULL )
p->vCover = Vec_IntAlloc(0);
if ( p->vAnds == NULL )
......@@ -742,13 +743,11 @@ void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, fl
{
if ( pCut->fUser )
{
/*
if ( p->pPars->fDelayOpt )
{
int Del = If_CutPinDelaysSopArray3( p, pCut, pCut->pPerm );
assert( Del == pCut->Delay );
}
*/
If_CutForEachLeaf( p, pCut, pLeaf, i )
{
Pin2PinDelay = pCut->pPerm ? (pCut->pPerm[i] == IF_BIG_CHAR ? -IF_BIG_CHAR : pCut->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