80 int i, k = 0, Prev = -1, This, fCompl = 0;
87 else if ( Prev != This )
100 int i, k = 0, Prev = -1, This;
109 else if ( Prev != This )
234 else if ( nLits == 2 )
240 else if ( nLits > 2 )
243 int i, * pArray, *
pPerm;
244 for ( i = 0; i < nLits; i++ )
249 pPerm = pArray + nLits;
252 for ( i = 0; i < nLits; i++ )
280 int i, iLit, iBeg, iEnd;
433 int i, iBeg, iEnd, iLit;
499 int Slack = p->nLevelMax - LevR -
Abc_MaxInt(Lev0, Lev1) - 1 - (int)(iLit0 > iLit1);
515 for ( k = 1; k <= pSet[0]; k++ )
521 for ( k = 1; k <= pSet[0]; k++ )
525 *pvRefsAnd = vRefsAnd;
526 *pvRefsXor = vRefsXor;
532 Vec_Int_t * vRefsAnd, * vRefsXor, * vSuper, * vDivs, * vRemap, * vLevRMax;
533 int i, j, k, Num, FanK, FanJ, nRefs, iNode, iDiv, * pSet;
534 int nPairsAll = 0, nPairsTried = 0, nPairsUsed = 0, nPairsXor = 0;
535 int nDivsAll = 0, nDivsUsed = 0, nDivsXor = 0;
537 vSuper = p->pGia->vSuper;
547 nPairsAll += pSet[0] * (pSet[0] - 1) / 2;
551 for ( k = 1; k <= pSet[0]; k++ )
557 for ( k = 1; k <= pSet[0]; k++ )
599 for ( i = 1; i <= nDivsAll; i++ )
637 pSet[++pSet[0]] = iNode;
650 printf(
" Total =%9d (%6.2f %%)", nPairsAll, 100.0 * nPairsAll /
Abc_MaxInt(nPairsAll, 1) );
651 printf(
" Tried =%9d (%6.2f %%)", nPairsTried, 100.0 * nPairsTried /
Abc_MaxInt(nPairsAll, 1) );
652 printf(
" Used =%9d (%6.2f %%)", nPairsUsed, 100.0 * nPairsUsed /
Abc_MaxInt(nPairsAll, 1) );
653 printf(
" Xor =%9d (%6.2f %%)", nPairsXor, 100.0 * nPairsXor /
Abc_MaxInt(nPairsAll, 1) );
656 printf(
" Total =%9d (%6.2f %%)", nDivsAll, 100.0 * nDivsAll /
Abc_MaxInt(nDivsAll, 1) );
657 printf(
" Tried =%9d (%6.2f %%)", nDivsAll, 100.0 * nDivsAll /
Abc_MaxInt(nDivsAll, 1) );
658 printf(
" Used =%9d (%6.2f %%)", nDivsUsed, 100.0 * nDivsUsed /
Abc_MaxInt(nDivsAll, 1) );
659 printf(
" Xor =%9d (%6.2f %%)", nDivsXor, 100.0 * nDivsXor /
Abc_MaxInt(nDivsAll, 1) );
699 for ( i = 1; i <= pSet[0]; i++ )
764 printf(
"Final statistics after extracting %6d divisors: ", p->nDivs );
770 printf(
"Div%5d : ", p->nDivs+1 );
771 printf(
"D%-8d = ", iDiv );
773 printf(
"%8s ", Buffer );
774 printf(
"%c ", (iData0 < iData1) ?
'*' :
'+' );
776 printf(
"%8s ", Buffer );
777 printf(
"Weight %9.2f ",
Vec_FltEntry(p->vCounts, iDiv) );
780 printf(
"Ands =%8d ", p->nAnds - p->nGain );
786 printf(
"Divisor queue: \n" );
791 printf(
"Div %7d : ", i );
802 int i, k, c, Num, iLit, iLit2, fPres;
804 for ( i = 1; i <= pSet[0]; i++ )
805 if ( pSet[i] == iLit0 )
810 for ( i = 1; i <= pSet[0]; i++ )
811 if ( pSet[i] == iLit1 )
817 for ( k = i = 1; i <= pSet[0]; i++ )
819 if ( iLit0 == pSet[i] || iLit1 == pSet[i] )
821 pSet[k++] = iLit = pSet[i];
824 for ( c = 0; c < 2; c++ )
826 iLit2 = c ? iLit1 : iLit0;
827 if ( (iLit > iLit2) ^ (iLit0 > iLit1) )
843 if ( (iLit > iLitNew) ^ (iLit0 > iLit1) )
863 int i, iLitNew, * pSet, * pNods =
Dam_DivSet( p, iDiv );
864 int nPresent = 0, nPairsStart, nPairsStop, pPairsNew, nRefs;
865 int fThisIsXor = (iLit0 > iLit1), iDivTemp, iNode;
877 for ( i = 1; i <= pNods[0]; i++ )
884 for ( i = nPairsStart; i < nPairsStop; i++ )
910 pSet[++pSet[0]] = iNode;
913 for ( i = nPairsStart; i < nPairsStop; i++ )
918 p->nGain += (1 + 2 * fThisIsXor) * (nPresent - 1);
919 p->nGainX += 3 * fThisIsXor * (nPresent - 1);
957 int nDivsUsed = p->nDivs;
959 printf(
" Total =%9d (%6.2f %%) ", nDivsAll, 100.0 * nDivsAll /
Abc_MaxInt(nDivsAll, 1) );
960 printf(
" Used =%9d (%6.2f %%)", nDivsUsed, 100.0 * nDivsUsed /
Abc_MaxInt(nDivsAll, 1) );
961 printf(
" Gain =%6d (%6.2f %%)", p->nGain, 100.0 * p->nGain /
Abc_MaxInt(p->nAnds, 1) );
962 printf(
" GainX = %d ", p->nGainX );
970 Gia_Man_t * pNew0, * pNew, * pNew1, * pNew2;
static int Gia_ObjFanin2Copy(Gia_Man_t *p, Gia_Obj_t *pObj)
static Hash_IntMan_t * Hash_IntManStart(int nSize)
FUNCTION DEFINITIONS ///.
static int Gia_ObjToLit(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Gia_ObjLevelId(Gia_Man_t *p, int Id)
static int Dam_DivHand(Dam_Man_t *p, int d)
static int * Vec_IntArray(Vec_Int_t *p)
static int Gia_ManAppendAnd(Gia_Man_t *p, int iLit0, int iLit1)
void Gia_ManCreateRefs(Gia_Man_t *p)
static Gia_Obj_t * Gia_ObjChild0(Gia_Obj_t *pObj)
static int * Dam_DivSet(Dam_Man_t *p, int d)
static int Hash_IntManEntryNum(Hash_IntMan_t *p)
Gia_Man_t * Dam_ManMultiAig(Dam_Man_t *pMan)
Vec_Int_t * Gia_ManGetCiLevels(Gia_Man_t *p)
static void Vec_FltFillExtra(Vec_Flt_t *p, int nSize, float Fill)
static int Hash_Int2ObjInc(Hash_IntMan_t *p, int i)
void Dam_ManMultiAig_rec(Dam_Man_t *pMan, Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
static int Gia_ObjIsAndReal(Gia_Man_t *p, Gia_Obj_t *pObj)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
static void Vec_FltWriteEntry(Vec_Flt_t *p, int i, float Entry)
#define Gia_ManForEachCo(p, pObj, i)
void Gia_ManSuperCollect(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManPrintStats(Gia_Man_t *p, Gps_Par_t *pPars)
void Gia_ManSimplifyXor(Vec_Int_t *vSuper)
FUNCTION DEFINITIONS ///.
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
static int Gia_ManAppendCo(Gia_Man_t *p, int iLit0)
int Gia_ManHashXor(Gia_Man_t *p, int iLit0, int iLit1)
static void Vec_IntFillExtra(Vec_Int_t *p, int nSize, int Fill)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Vec_FltCap(Vec_Flt_t *p)
void Gia_ManSuperCollectAnd_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManCreateGate(Gia_Man_t *pNew, Gia_Obj_t *pObj, Vec_Int_t *vSuper)
static void Gia_ObjSetGateLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
static float Vec_QueTopPriority(Vec_Que_t *p)
static int Gia_ManAppendCi(Gia_Man_t *p)
int Gia_ManLevelWithBoxes(Gia_Man_t *p)
static int Hash_IntObjData2(Hash_IntMan_t *p, int i)
Gia_Man_t * Dam_ManAreaBalanceInt(Gia_Man_t *pGia, Vec_Int_t *vCiLevels, int nNewNodesMax, int fVerbose, int fVeryVerbose)
typedefABC_NAMESPACE_HEADER_START struct Vec_Que_t_ Vec_Que_t
INCLUDES ///.
int Gia_ManSetLevels(Gia_Man_t *p, Vec_Int_t *vCiLevels)
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
void Abc_QuickSortCostData(int *pCosts, int nSize, int fDecrease, word *pData, int *pResult)
static Vec_Flt_t * Vec_FltAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Gia_ObjIsBuf(Gia_Obj_t *pObj)
Gia_Man_t * Gia_ManBalance(Gia_Man_t *p, int fSimpleAnd, int fVerbose)
void Dam_ManCollectSets_rec(Dam_Man_t *p, int Id)
void Gia_ManSetRegNum(Gia_Man_t *p, int nRegs)
static int Vec_QuePop(Vec_Que_t *p)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static int Dam_ObjHand(Dam_Man_t *p, int i)
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
static Vec_Int_t * Vec_IntStartFull(int nSize)
static void Vec_FltFreeP(Vec_Flt_t **p)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static int Abc_LitNotCond(int Lit, int c)
static void Vec_FltPush(Vec_Flt_t *p, float Entry)
void Gia_ManSimplifyAnd(Vec_Int_t *vSuper)
Gia_Man_t * Gia_ManDupNoMuxes(Gia_Man_t *p)
Gia_Man_t * Gia_ManBalanceInt(Gia_Man_t *p)
int Gia_ManBalanceGate(Gia_Man_t *pNew, Gia_Obj_t *pObj, Vec_Int_t *vSuper, int *pLits, int nLits)
static Gia_Obj_t * Gia_ObjChild1(Gia_Obj_t *pObj)
static void Vec_IntGrow(Vec_Int_t *p, int nCapMin)
#define Gia_ManForEachCi(p, pObj, i)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
void Dam_ManUpdate(Dam_Man_t *p, int iDiv)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static void Vec_QueFreeP(Vec_Que_t **p)
void Dam_ManCreateMultiRefs(Dam_Man_t *p, Vec_Int_t **pvRefsAnd, Vec_Int_t **pvRefsXor)
static int Abc_MinInt(int a, int b)
static int Gia_ObjLevel(Gia_Man_t *p, Gia_Obj_t *pObj)
static Vec_Int_t * Vec_IntStart(int nSize)
static int Abc_LitIsCompl(int Lit)
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Dam_PrintDiv(Dam_Man_t *p, int iDiv)
void Dam_ManFree(Dam_Man_t *p)
static int Gia_ObjFanin1Copy(Gia_Obj_t *pObj)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
Dam_Man_t * Dam_ManAlloc(Gia_Man_t *pGia)
Gia_Man_t * Gia_ManDupNormalize(Gia_Man_t *p)
static int Gia_ManAppendBuf(Gia_Man_t *p, int iLit)
int Dam_ManDivSlack(Dam_Man_t *p, int iLit0, int iLit1, int LevR)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
static void Hash_IntManStop(Hash_IntMan_t *p)
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
void Gia_ManHashStart(Gia_Man_t *p)
Gia_Man_t * Gia_ManStart(int nObjsMax)
DECLARATIONS ///.
Gia_Man_t * Gia_ManDupMuxes(Gia_Man_t *p, int Limit)
static void Vec_IntUpdateEntry(Vec_Int_t *p, int i, int Value)
static int Gia_ObjIsXor(Gia_Obj_t *pObj)
#define Gia_ManForEachAnd(p, pObj, i)
void Dam_ManCreatePairs(Dam_Man_t *p, int fVerbose)
int Gia_ManHashXorReal(Gia_Man_t *p, int iLit0, int iLit1)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Dam_Man_t_ Dam_Man_t
DECLARATIONS ///.
void Gia_ManFillValue(Gia_Man_t *p)
static int * Dam_ObjSet(Dam_Man_t *p, int i)
void Gia_ManTransferTiming(Gia_Man_t *p, Gia_Man_t *pGia)
Gia_Man_t * Gia_ManAreaBalance(Gia_Man_t *p, int fSimpleAnd, int nNewNodesMax, int fVerbose, int fVeryVerbose)
static int * Hash_Int2ManLookup(Hash_IntMan_t *p, int iData0, int iData1)
#define Vec_IntForEachEntryStart(vVec, Entry, i, Start)
static void Vec_IntFreeP(Vec_Int_t **p)
static int Hash_Int2ManInsert(Hash_IntMan_t *p, int iData0, int iData1, int iData2)
static int Gia_ObjFanin0Copy(Gia_Obj_t *pObj)
static Gia_Obj_t * Gia_ObjFanin2(Gia_Man_t *p, Gia_Obj_t *pObj)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
static int Abc_LitNot(int Lit)
static void Vec_FltAddToEntry(Vec_Flt_t *p, int i, float Addition)
int Dam_ManUpdateNode(Dam_Man_t *p, int iObj, int iLit0, int iLit1, int iLitNew, Vec_Int_t *vDivs)
void Gia_ManSuperCollectXor_rec(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Vec_IntSize(Vec_Int_t *p)
static int Gia_ManHasMapping(Gia_Man_t *p)
static int Gia_IsComplement(Gia_Obj_t *p)
void Dam_PrintQue(Dam_Man_t *p)
void Dam_ManCollectSets(Dam_Man_t *p)
void * Dsm_ManDeriveGia(void *p, int fUseMuxes)
static float ** Vec_FltArrayP(Vec_Flt_t *p)
static void Vec_IntShrink(Vec_Int_t *p, int nSizeNew)
int Gia_ManIsNormalized(Gia_Man_t *p)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
void Gia_ManBalance_rec(Gia_Man_t *pNew, Gia_Man_t *p, Gia_Obj_t *pObj)
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
static void Vec_QueUpdate(Vec_Que_t *p, int v)
#define ABC_CALLOC(type, num)
static int Abc_Lit2Var(int Lit)
static int Gia_ObjFaninId0p(Gia_Man_t *p, Gia_Obj_t *pObj)
typedefABC_NAMESPACE_HEADER_START struct Vec_Flt_t_ Vec_Flt_t
INCLUDES ///.
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
static int Vec_QueIsMember(Vec_Que_t *p, int v)
#define Gia_ManForEachBuf(p, pObj, i)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
static int * Vec_IntEntryP(Vec_Int_t *p, int i)
#define Vec_IntForEachEntryStartStop(vVec, Entry, i, Start, Stop)
static int Gia_ObjFaninId2(Gia_Man_t *p, int ObjId)
int Gia_ManHashMuxReal(Gia_Man_t *p, int iLitC, int iLit1, int iLit0)
static float Vec_FltEntry(Vec_Flt_t *p, int i)
static int Hash_IntObjData1(Hash_IntMan_t *p, int i)
static int Hash_IntObjData0(Hash_IntMan_t *p, int i)
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
static void Vec_IntClear(Vec_Int_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
static int Vec_FltSize(Vec_Flt_t *p)
Gia_Man_t * Gia_ManCleanup(Gia_Man_t *p)
char * Abc_UtilStrsav(char *s)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
static Vec_Que_t * Vec_QueAlloc(int nCap)
MACRO DEFINITIONS ///.
static int Gia_ObjIsMux(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Gia_ManAppendXorReal(Gia_Man_t *p, int iLit0, int iLit1)
int Gia_ManHashAnd(Gia_Man_t *p, int iLit0, int iLit1)
static void Vec_QuePush(Vec_Que_t *p, int v)
static int Gia_ManObjNum(Gia_Man_t *p)
static void Vec_QueSetPriority(Vec_Que_t *p, float **pCosts)
Vec_Int_t * Gia_ManReverseLevel(Gia_Man_t *p)
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)
void Gia_ManHashStop(Gia_Man_t *p)
static int Gia_ManRegNum(Gia_Man_t *p)