Commit a26d61f4 by Alan Mishchenko

Improvement in SOP balancing.

parent d05f83b2
......@@ -618,58 +618,6 @@ If_Man_t * Gia_ManToIf( Gia_Man_t * p, If_Par_t * pPars )
return pIfMan;
}
/**Function*************************************************************
Synopsis [Derives node's AIG after SOP balancing]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Gia_ManNodeIfSopToGiaInt( Gia_Man_t * pNew, Vec_Wrd_t * vAnds, int nVars, Vec_Int_t * vLeaves, int fHash )
{
Vec_Int_t * vResults;
int iRes0, iRes1, iRes = -1;
If_And_t This;
word Entry;
int i;
if ( Vec_WrdSize(vAnds) == 0 )
return 0;
if ( Vec_WrdSize(vAnds) == 1 && Vec_WrdEntry(vAnds,0) == 0 )
return 1;
vResults = Vec_IntAlloc( Vec_WrdSize(vAnds) );
for ( i = 0; i < nVars; i++ )
Vec_IntPush( vResults, Vec_IntEntry(vLeaves, i) );
Vec_WrdForEachEntryStart( vAnds, Entry, i, nVars )
{
This = If_WrdToAnd( Entry );
iRes0 = Abc_LitNotCond( Vec_IntEntry(vResults, This.iFan0), This.fCompl0 );
iRes1 = Abc_LitNotCond( Vec_IntEntry(vResults, This.iFan1), This.fCompl1 );
if ( fHash )
iRes = Gia_ManHashAnd( pNew, iRes0, iRes1 );
else if ( iRes0 == iRes1 )
iRes = iRes0;
else
iRes = Gia_ManAppendAnd( pNew, iRes0, iRes1 );
Vec_IntPush( vResults, iRes );
}
Vec_IntFree( vResults );
return Abc_LitNotCond( iRes, This.fCompl );
}
int Gia_ManNodeIfSopToGia( Gia_Man_t * pNew, If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vLeaves, int fHash )
{
int iResult;
Vec_Wrd_t * vArray;
vArray = If_CutDelaySopArray( p, pCut );
iResult = Gia_ManNodeIfSopToGiaInt( pNew, vArray, If_CutLeaveNum(pCut), vLeaves, fHash );
// Vec_WrdFree( vArray );
return iResult;
}
/**Function*************************************************************
Synopsis [Rebuilds GIA from mini AIG.]
......@@ -722,9 +670,9 @@ int Gia_ManBuildFromMiniInt( Gia_Man_t * pNew, Vec_Int_t * vLeaves, Vec_Int_t *
int Gia_ManBuildFromMini( Gia_Man_t * pNew, If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vLeaves, Vec_Int_t * vAig, int fHash, int fUseDsd )
{
if ( fUseDsd )
If_DsdCutBalanceAig( pIfMan, pCut, vAig );
If_CutDsdBalanceEval( pIfMan, pCut, vAig );
else
If_CutDelaySopArray3( pIfMan, pCut, vAig );
If_CutSopBalanceEval( pIfMan, pCut, vAig );
return Gia_ManBuildFromMiniInt( pNew, vLeaves, vAig, fHash );
}
......
......@@ -15102,7 +15102,7 @@ int Abc_CommandIf( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fTruth = 1;
pPars->fCutMin = 1;
pPars->fExpRed = 0;
pPars->fUsePerm = 1;
pPars->fUsePerm = 0;
pPars->pLutLib = NULL;
}
// modify for delay optimization
......@@ -29855,7 +29855,7 @@ int Abc_CommandAbc9If( Abc_Frame_t * pAbc, int argc, char ** argv )
pPars->fTruth = 1;
pPars->fCutMin = 1;
pPars->fExpRed = 0;
pPars->fUsePerm = 1;
pPars->fUsePerm = 0;
pPars->pLutLib = NULL;
}
// modify for delay optimization
......@@ -391,14 +391,13 @@ Hop_Obj_t * Abc_NodeBuildFromMiniInt( Hop_Man_t * pMan, Vec_Int_t * vAig, int nL
return piLit;
}
}
Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut )
Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut, int fUseDsd )
{
Hop_Obj_t * pResult;
if ( p->vArray == NULL )
p->vArray = Vec_IntAlloc(1000);
If_CutDelaySopArray3( p, pCut, p->vArray );
pResult = Abc_NodeBuildFromMiniInt( pMan, p->vArray, If_CutLeaveNum(pCut) );
return pResult;
if ( fUseDsd )
If_CutDsdBalanceEval( p, pCut, p->vArray );
else
If_CutSopBalanceEval( p, pCut, p->vArray );
return Abc_NodeBuildFromMiniInt( pMan, p->vArray, If_CutLeaveNum(pCut) );
}
/**Function*************************************************************
......@@ -477,9 +476,9 @@ Abc_Obj_t * Abc_NodeFromIf_rec( Abc_Ntk_t * pNtkNew, If_Man_t * pIfMan, If_Obj_t
}
}
else if ( pIfMan->pPars->fDelayOpt )
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest, 0 );
else if ( pIfMan->pPars->fDsdBalance )
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest );
pNodeNew->pData = Abc_NodeBuildFromMini( (Hop_Man_t *)pNtkNew->pManFunc, pIfMan, pCutBest, 1 );
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 );
......
......@@ -39,6 +39,7 @@
#include "misc/util/utilTruth.h"
#include "opt/dau/dau.h"
#include "misc/vec/vecHash.h"
#include "misc/vec/vecWec.h"
ABC_NAMESPACE_HEADER_START
......@@ -237,6 +238,7 @@ struct If_Man_t_
int nCuts5, nCuts5a;
If_DsdMan_t * pIfDsdMan; // DSD manager
Vec_Mem_t * vTtMem[IF_MAX_FUNC_LUTSIZE+1]; // truth table memory and hash table
Vec_Wec_t * vTtIsops[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into DSD
Vec_Int_t * vTtDsds[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into DSD
Vec_Str_t * vTtPerms[IF_MAX_FUNC_LUTSIZE+1]; // mapping of truth table into permutations
Hash_IntMan_t * vPairHash; // hashing pairs of truth tables
......@@ -327,18 +329,6 @@ struct If_Obj_t_
If_Cut_t CutBest; // the best cut selected
};
typedef struct If_And_t_ If_And_t;
struct If_And_t_
{
unsigned iFan0 : 15; // fanin0
unsigned fCompl0 : 1; // compl fanin0
unsigned iFan1 : 15; // fanin1
unsigned fCompl1 : 1; // compl fanin1
unsigned Id : 15; // Id
unsigned fCompl : 1; // compl output
unsigned Delay : 16; // delay
};
typedef struct If_Box_t_ If_Box_t;
struct If_Box_t_
{
......@@ -428,11 +418,6 @@ static inline If_Obj_t * If_CutLeaf( If_Man_t * p, If_Cut_t * pCut, int i ) { a
static inline float If_CutLutArea( If_Man_t * p, If_Cut_t * pCut ) { return pCut->fUser? (float)pCut->Cost : (p->pPars->pLutLib? p->pPars->pLutLib->pLutAreas[pCut->nLeaves] : (float)1.0); }
static inline float If_CutLutDelay( If_LibLut_t * p, int Size, int iPin ) { return p ? (p->fVarPinDelays ? p->pLutDelays[Size][iPin] : p->pLutDelays[Size][0]) : 1.0; }
static inline word If_AndToWrd( If_And_t m ) { union { If_And_t x; word y; } v; v.x = m; return v.y; }
static inline If_And_t If_WrdToAnd( word m ) { union { If_And_t x; word y; } v; v.y = m; return v.x; }
static inline void If_AndClear( If_And_t * pNode ) { *pNode = If_WrdToAnd(0); }
////////////////////////////////////////////////////////////////////////
/// MACRO DEFINITIONS ///
......@@ -536,8 +521,9 @@ 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,
char * pLut0, char * pLut1, char * pLut2, word * pFunc0, word * pFunc1, word * pFunc2 );
/*=== ifDelay.c =============================================================*/
extern int If_CutDelaySopArray3( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
extern int If_CutPinDelaysSopArray3( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
extern int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutSopBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig );
extern int If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
/*=== ifDsd.c =============================================================*/
extern If_DsdMan_t * If_DsdManAlloc( int nVars, int nLutSize );
extern void If_DsdManPrint( If_DsdMan_t * p, char * pFileName, int Number, int Support, int fOccurs, int fTtDump, int fVerbose );
......@@ -554,8 +540,8 @@ extern int If_DsdManLutSize( If_DsdMan_t * p );
extern int If_DsdManSuppSize( 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 int If_DsdCutBalanceCost( If_Man_t * pIfMan, If_Cut_t * pCut );
extern int If_DsdCutBalanceAig( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig );
extern int If_CutDsdBalanceEval( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig );
extern int If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm );
/*=== ifLib.c =============================================================*/
extern If_LibLut_t * If_LibLutRead( char * FileName );
extern If_LibLut_t * If_LibLutDup( If_LibLut_t * p );
......@@ -608,10 +594,6 @@ extern unsigned If_ManSatCheckXYall( void * pSat, int nLutSize, word * pT
/*=== ifSeq.c =============================================================*/
extern int If_ManPerformMappingSeq( If_Man_t * p );
/*=== ifTime.c ============================================================*/
extern int If_CutDelaySopCost( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutDelaySopCost2( If_Man_t * p, If_Cut_t * pCut );
extern int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut );
extern Vec_Wrd_t * If_CutDelaySopArray( If_Man_t * p, If_Cut_t * pCut );
extern float If_CutDelay( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut );
extern void If_CutPropagateRequired( If_Man_t * p, If_Obj_t * pObj, If_Cut_t * pCut, float Required );
/*=== ifTruth.c ===========================================================*/
......
......@@ -19,7 +19,6 @@
***********************************************************************/
#include "if.h"
#include "bool/kit/kit.h"
ABC_NAMESPACE_IMPL_START
......@@ -33,6 +32,77 @@ ABC_NAMESPACE_IMPL_START
/**Function*************************************************************
Synopsis [Computes the SOP delay using balanced AND decomposition.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
static inline int If_CutMaxCubeSize( Vec_Int_t * vCover, int nVars )
{
int i, k, Entry, Literal, Count, CountMax = 0;
Vec_IntForEachEntry( vCover, Entry, i )
{
Count = 0;
for ( k = 0; k < nVars; k++ )
{
Literal = (3 & (Entry >> (k << 1)));
if ( Literal == 1 || Literal == 2 )
Count++;
}
CountMax = Abc_MaxInt( CountMax, Count );
}
return CountMax;
}
int If_CutDelaySop( If_Man_t * p, If_Cut_t * pCut )
{
// delay is calculated using 1+log2(NumFanins)
static double GateDelays[20] = { 1.00, 1.00, 2.00, 2.58, 3.00, 3.32, 3.58, 3.81, 4.00, 4.17, 4.32, 4.46, 4.58, 4.70, 4.81, 4.91, 5.00, 5.09, 5.17, 5.25 };
Vec_Int_t * vCover;
If_Obj_t * pLeaf;
int i, nLitMax, Delay, DelayMax;
// mark cut as a user cut
pCut->fUser = 1;
if ( pCut->nLeaves == 0 )
return 0;
if ( pCut->nLeaves == 1 )
return (int)If_ObjCutBest(If_CutLeaf(p, pCut, 0))->Delay;
vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
if ( Vec_IntSize(vCover) == 0 )
return -1;
// mark the output as complemented
// vAnds = If_CutDelaySopAnds( p, pCut, p->vCover, RetValue ^ pCut->fCompl );
if ( Vec_IntSize(p->vCover) > p->pPars->nGateSize )
return ABC_INFINITY;
// set the area cost
assert( If_CutLeaveNum(pCut) >= 0 && If_CutLeaveNum(pCut) <= 16 );
// compute the gate delay
nLitMax = If_CutMaxCubeSize( p->vCover, If_CutLeaveNum(pCut) );
if ( Vec_IntSize(p->vCover) < 2 )
{
pCut->Cost = Vec_IntSize(p->vCover);
Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + 0.5);
DelayMax = 0;
If_CutForEachLeaf( p, pCut, pLeaf, i )
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
}
else
{
pCut->Cost = Vec_IntSize(p->vCover) + 1;
Delay = (int)(GateDelays[If_CutLeaveNum(pCut)] + GateDelays[nLitMax] + 0.5);
DelayMax = 0;
If_CutForEachLeaf( p, pCut, pLeaf, i )
DelayMax = Abc_MaxInt( DelayMax, If_ObjCutBest(pLeaf)->Delay + (pCut->pPerm[i] = (char)Delay) );
}
return DelayMax;
}
/**Function*************************************************************
Synopsis [Naive implementation of log-counter.]
Description [Incrementally computes [log2(SUMi(2^di)).]
......@@ -453,7 +523,7 @@ static inline word If_LogPinDelaysMulti( word * pPinDels, int nFanins, int nSupp
pPinDels[i-1] = If_CutPinDelayMax( pPinDels[i], pPinDels[i-1], nSuppAll, 1 + fXor );
return pPinDels[0];
}
int If_CutPinDelaysSopArray3IntInt( Vec_Int_t * vCover, int * pTimes, int nSuppAll, char * pPerm )
int If_CutSopBalancePinDelaysInt( Vec_Int_t * vCover, int * pTimes, int nSuppAll, char * pPerm )
{
word pPinDelsAnd[IF_MAX_FUNC_LUTSIZE], pPinDelsOr[32];
int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE];
......@@ -483,18 +553,8 @@ int If_CutPinDelaysSopArray3IntInt( Vec_Int_t * vCover, int * pTimes, int nSuppA
If_CutPinDelayTranslate( ResOr, nSuppAll, pPerm );
return Delay;
}
int If_CutPinDelaysSopArray3Int( unsigned * pTruth, int nLeaves, int * pTimes, Vec_Int_t * vCover, char * pPerm )
{
int RetValue = Kit_TruthIsop( pTruth, nLeaves, vCover, 1 );
if ( RetValue == -1 )
return -1;
// Kit_TruthIsopPrint( pTruth, nLeaves, vCover, 1 );
return If_CutPinDelaysSopArray3IntInt( vCover, pTimes, nLeaves, pPerm );
}
int If_CutPinDelaysSopArray3( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
int If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
{
if ( p->vCover == NULL )
p->vCover = Vec_IntAlloc(0);
if ( pCut->nLeaves == 0 ) // const
return 0;
if ( pCut->nLeaves == 1 ) // variable
......@@ -504,10 +564,14 @@ int If_CutPinDelaysSopArray3( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
}
else
{
Vec_Int_t * vCover;
int i, pTimes[IF_MAX_FUNC_LUTSIZE];
vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
if ( Vec_IntSize(vCover) == 0 )
return -1;
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
return If_CutPinDelaysSopArray3Int( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), pTimes, p->vCover, pPerm );
return If_CutSopBalancePinDelaysInt( vCover, pTimes, If_CutLeaveNum(pCut), pPerm );
}
}
......@@ -522,7 +586,7 @@ int If_CutPinDelaysSopArray3( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
SeeAlso []
***********************************************************************/
int If_CutDelaySopArray3IntInt( Vec_Int_t * vCover, int * pTimes, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea )
int If_CutSopBalanceEvalIntInt( Vec_Int_t * vCover, int * pTimes, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea )
{
int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE], pFaninLitsAnd[IF_MAX_FUNC_LUTSIZE];
int nCounterOr, pCounterOr[32], pFaninLitsOr[32];
......@@ -558,24 +622,21 @@ int If_CutDelaySopArray3IntInt( Vec_Int_t * vCover, int * pTimes, Vec_Int_t * vA
*pArea += Vec_IntSize(vCover) == 1 ? 0 : Vec_IntSize(vCover) - 1;
return Delay;
}
int If_CutDelaySopArray3Int( unsigned * pTruth, int nLeaves, int * pTimes, Vec_Int_t * vCover, Vec_Int_t * vAig, int fCompl, int * pArea )
int If_CutSopBalanceEvalInt( Vec_Int_t * vCover, int nLeaves, int * pTimes, Vec_Int_t * vAig, int fCompl, int * pArea )
{
int iRes = 0, Res;
int RetValue = Kit_TruthIsop( pTruth, nLeaves, vCover, 1 );
if ( RetValue == -1 )
if ( Vec_IntSize(vCover) == 0 )
return -1;
Res = If_CutDelaySopArray3IntInt( vCover, pTimes, vAig, &iRes, nLeaves, pArea );
Res = If_CutSopBalanceEvalIntInt( vCover, pTimes, vAig, &iRes, nLeaves, pArea );
assert( vAig == NULL || Abc_Lit2Var(iRes) == nLeaves + Abc_Lit2Var(Vec_IntSize(vAig)) - 1 );
if ( vAig )
Vec_IntPush( vAig, RetValue ^ Abc_LitIsCompl(iRes) ^ fCompl );
Vec_IntPush( vAig, Abc_LitIsCompl(iRes) ^ fCompl );
assert( vAig == NULL || (Vec_IntSize(vAig) & 1) );
return Res;
}
int If_CutDelaySopArray3( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig )
int If_CutSopBalanceEval( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig )
{
pCut->fUser = 1;
if ( p->vCover == NULL )
p->vCover = Vec_IntAlloc(0);
if ( vAig )
Vec_IntClear( vAig );
if ( pCut->nLeaves == 0 ) // const
......@@ -596,11 +657,13 @@ int If_CutDelaySopArray3( If_Man_t * p, If_Cut_t * pCut, Vec_Int_t * vAig )
}
else
{
Vec_Int_t * vCover = Vec_WecEntry( p->vTtIsops[pCut->nLeaves], Abc_Lit2Var(If_CutTruthLit(pCut)) );
int fCompl = Abc_LitIsCompl(If_CutTruthLit(pCut)) ^ ((vCover->nCap >> 16) & 1); // hack to remember complemented attribute
int Delay, Area = 0;
int i, pTimes[IF_MAX_FUNC_LUTSIZE];
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
pTimes[i] = (int)If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;
Delay = If_CutDelaySopArray3Int( If_CutTruth(p, pCut), If_CutLeaveNum(pCut), pTimes, p->vCover, vAig, 0, &Area );
Delay = If_CutSopBalanceEvalInt( vCover, If_CutLeaveNum(pCut), pTimes, vAig, fCompl, &Area );
pCut->Cost = Area;
return Delay;
}
......
......@@ -2025,7 +2025,7 @@ static inline int If_LogCounterAddAig( int * pTimes, int * pnTimes, int * pFanin
SeeAlso []
***********************************************************************/
int If_DsdCutBalanceAig_rec( If_DsdMan_t * p, int Id, int * pTimes, int * pnSupp, Vec_Int_t * vAig, int * piLit, int nSuppAll, int * pArea )
int If_CutDsdBalanceEval_rec( If_DsdMan_t * p, int Id, int * pTimes, int * pnSupp, Vec_Int_t * vAig, int * piLit, int nSuppAll, int * pArea )
{
If_DsdObj_t * pObj = If_DsdVecObj( &p->vObjs, Id );
if ( If_DsdObjType(pObj) == IF_DSD_PRIME )
......@@ -2041,7 +2041,7 @@ int If_DsdCutBalanceAig_rec( If_DsdMan_t * p, int Id, int * pTimes, int * pnSupp
int i, iFanin, Delay[3], pFaninLits[3];
If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, i )
{
Delay[i] = If_DsdCutBalanceAig_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea );
Delay[i] = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea );
if ( Delay[i] == -1 )
return -1;
}
......@@ -2058,7 +2058,7 @@ int If_DsdCutBalanceAig_rec( If_DsdMan_t * p, int Id, int * pTimes, int * pnSupp
int nCounter = 0, pCounter[IF_MAX_FUNC_LUTSIZE], pFaninLits[IF_MAX_FUNC_LUTSIZE];
If_DsdObjForEachFaninLit( &p->vObjs, pObj, iFanin, i )
{
Delay = If_DsdCutBalanceAig_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea );
Delay = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iFanin), pTimes, pnSupp, vAig, pFaninLits+i, nSuppAll, pArea );
if ( Delay == -1 )
return -1;
Result = If_LogCounterAddAig( pCounter, &nCounter, pFaninLits, Delay, pFaninLits[i], vAig, nSuppAll, fXor );
......@@ -2070,11 +2070,11 @@ int If_DsdCutBalanceAig_rec( If_DsdMan_t * p, int Id, int * pTimes, int * pnSupp
return Result;
}
}
int If_DsdCutBalanceAigInt( If_DsdMan_t * p, int iDsd, int * pTimes, Vec_Int_t * vAig, int * pArea )
int If_CutDsdBalanceEvalInt( If_DsdMan_t * p, int iDsd, int * pTimes, Vec_Int_t * vAig, int * pArea )
{
int nSupp = 0, iLit = 0;
int nSuppAll = If_DsdVecLitSuppSize( &p->vObjs, iDsd );
int Res = If_DsdCutBalanceAig_rec( p, Abc_Lit2Var(iDsd), pTimes, &nSupp, vAig, &iLit, nSuppAll, pArea );
int Res = If_CutDsdBalanceEval_rec( p, Abc_Lit2Var(iDsd), pTimes, &nSupp, vAig, &iLit, nSuppAll, pArea );
assert( nSupp == nSuppAll );
assert( vAig == NULL || Abc_Lit2Var(iLit) == nSupp + Abc_Lit2Var(Vec_IntSize(vAig)) - 1 );
if ( vAig )
......@@ -2082,7 +2082,7 @@ int If_DsdCutBalanceAigInt( If_DsdMan_t * p, int iDsd, int * pTimes, Vec_Int_t *
assert( vAig == NULL || (Vec_IntSize(vAig) & 1) );
return Res;
}
int If_DsdCutBalanceAig( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig )
int If_CutDsdBalanceEval( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig )
{
pCut->fUser = 1;
if ( vAig )
......@@ -2110,12 +2110,17 @@ int If_DsdCutBalanceAig( If_Man_t * pIfMan, If_Cut_t * pCut, Vec_Int_t * vAig )
int Delay, Area = 0;
If_CutForEachLeaf( pIfMan, pCut, pLeaf, i )
pTimes[i] = (int)If_ObjCutBest(pLeaf)->Delay;
Delay = If_DsdCutBalanceAigInt( pIfMan->pIfDsdMan, If_CutDsdLit(pCut), pTimes, vAig, &Area );
Delay = If_CutDsdBalanceEvalInt( pIfMan->pIfDsdMan, If_CutDsdLit(pCut), pTimes, vAig, &Area );
pCut->Cost = Area;
return Delay;
}
}
int If_CutDsdBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm )
{
return 0;
}
/**Function*************************************************************
......
......@@ -73,6 +73,17 @@ If_Man_t * If_ManStart( If_Par_t * pPars )
p->vTtMem[v] = Vec_MemAllocForTT( v, pPars->fUseTtPerm );
for ( v = 0; v < 6; v++ )
p->vTtMem[v] = p->vTtMem[6];
if ( p->pPars->fDelayOpt )
{
p->vCover = Vec_IntAlloc( 0 );
p->vArray = Vec_IntAlloc( 1000 );
for ( v = 6; v <= p->pPars->nLutSize; v++ )
p->vTtIsops[v] = Vec_WecAlloc( 1000 );
for ( v = 6; v <= p->pPars->nLutSize; v++ )
Vec_WecInit( p->vTtIsops[v], 2 );
for ( v = 0; v < 6; v++ )
p->vTtIsops[v] = p->vTtIsops[6];
}
}
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->nTruthWords*/);
......@@ -226,6 +237,8 @@ void If_ManStop( If_Man_t * p )
Vec_MemHashFree( p->vTtMem[i] );
for ( i = 6; i <= p->pPars->nLutSize; i++ )
Vec_MemFreeP( &p->vTtMem[i] );
for ( i = 6; i <= p->pPars->nLutSize; i++ )
Vec_WecFreeP( &p->vTtIsops[i] );
Mem_FixedStop( p->pMemObj, 0 );
ABC_FREE( p->pMemCi );
ABC_FREE( p->pMemAnd );
......
......@@ -124,10 +124,9 @@ 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_CutSopBalanceEval( p, pCut, NULL );
else if ( p->pPars->fDsdBalance )
pCut->Delay = If_DsdCutBalanceCost( p, pCut );
pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
else if ( p->pPars->fUserRecLib )
pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
else if( p->pPars->nGateSize > 0 )
......@@ -281,10 +280,9 @@ 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_CutSopBalanceEval( p, pCut, NULL );
else if ( p->pPars->fDsdBalance )
pCut->Delay = If_DsdCutBalanceCost( p, pCut );
pCut->Delay = If_CutDsdBalanceEval( p, pCut, NULL );
else if ( p->pPars->fUserRecLib )
pCut->Delay = If_CutDelayRecCost3( p, pCut, pObj );
else if( p->pPars->nGateSize > 0 )
......
......@@ -19,6 +19,7 @@
***********************************************************************/
#include "if.h"
#include "bool/kit/kit.h"
ABC_NAMESPACE_IMPL_START
......@@ -97,7 +98,7 @@ void If_CutRotatePins( If_Man_t * p, If_Cut_t * pCut )
int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_t * pCut1, int fCompl0, int fCompl1 )
{
int fCompl, truthId, nLeavesNew, RetValue = 0;
int nWords = Abc_TtWordNum( pCut->nLeaves );
int PrevSize, nWords = Abc_TtWordNum( pCut->nLeaves );
word * pTruth0s = Vec_MemReadEntry( p->vTtMem[pCut0->nLeaves], Abc_Lit2Var(pCut0->iCutFunc) );
word * pTruth1s = Vec_MemReadEntry( p->vTtMem[pCut1->nLeaves], Abc_Lit2Var(pCut1->iCutFunc) );
word * pTruth0 = (word *)p->puTemp[0];
......@@ -121,6 +122,7 @@ int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_
RetValue = 1;
}
}
PrevSize = Vec_MemEntryNum( p->vTtMem[pCut->nLeaves] );
truthId = Vec_MemHashInsert( p->vTtMem[pCut->nLeaves], pTruth );
pCut->iCutFunc = Abc_Var2Lit( truthId, fCompl );
assert( (pTruth[0] & 1) == 0 );
......@@ -132,6 +134,19 @@ int If_CutComputeTruth( If_Man_t * p, If_Cut_t * pCut, If_Cut_t * pCut0, If_Cut_
Abc_TtCanonicize( pCopy, pCut->nLeaves, pCanonPerm );
}
#endif
if ( p->vTtIsops[pCut->nLeaves] && PrevSize != Vec_MemEntryNum(p->vTtMem[pCut->nLeaves]) )
{
Vec_Int_t * vLevel = Vec_WecPushLevel( p->vTtIsops[pCut->nLeaves] );
fCompl = Kit_TruthIsop( (unsigned *)pTruth, pCut->nLeaves, p->vCover, 1 );
if ( fCompl >= 0 )
{
Vec_IntGrow( vLevel, Vec_IntSize(p->vCover) );
Vec_IntAppend( vLevel, p->vCover );
if ( fCompl )
vLevel->nCap ^= (1<<16); // hack to remember complemented attribute
}
assert( Vec_WecSize(p->vTtIsops[pCut->nLeaves]) == Vec_MemEntryNum(p->vTtMem[pCut->nLeaves]) );
}
return RetValue;
}
......
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