76 if ( pManRwt == NULL )
79 if ( p->fFanout == 0 )
97 if ( nGain > 0 || (nGain == 0 && fUseZeroCost) )
122 printf(
"Ivy_ManRewritePre(): The check has failed.\n" );
147 int fVeryVerbose = 0;
154 unsigned uTruthBest = 0;
158 int nNodesSaveCur = -1;
159 int i, c, GainCur = -1, GainBest = -1;
171 for ( c = 1; c < pStore->
nCuts; c++ )
173 pCut = pStore->
pCuts + c;
175 if ( pCut->
nSize != 4 )
178 for ( i = 0; i < (int)pCut->
nSize; i++ )
181 if ( i != pCut->
nSize )
196 for ( i = 0; i < (int)pCut->
nSize; i++ )
200 pFanin =
Ivy_NotCond(pFanin, ((uPhase & (1<<i)) > 0) );
225 if ( pGraph != NULL && GainBest < GainCur )
228 nNodesSaveCur = nNodesSaved;
233 p->
fCompl = ((uPhase & (1<<4)) > 0);
244 if ( GainBest == -1 )
270 if ( fUseZeroCost || GainBest > 0 )
285 if ( fVeryVerbose && GainBest > 0 )
287 printf(
"Node %6d : ",
Ivy_ObjId(pNode) );
288 printf(
"Fanins = %d. ", p->
vFanins->nSize );
289 printf(
"Save = %d. ", nNodesSaveCur );
290 printf(
"Add = %d. ", nNodesSaveCur-GainBest );
291 printf(
"GAIN = %d. ", GainBest );
293 printf(
"Class = %d. ", p->
pMap[uTruthBest] );
317 int nNodesAdded, GainBest, i;
337 if ( nNodesAdded == -1 )
339 assert( nNodesSaved >= nNodesAdded );
341 if ( GainBest < nNodesSaved - nNodesAdded )
343 GainBest = nNodesSaved - nNodesAdded;
344 pGraphBest = pGraphCur;
347 if ( GainBest == -1 )
349 *pGainBest = GainBest;
422 for ( k = 0; pAnd0 && k < (int)pNode->
nLat0; k++ )
429 for ( k = 0; pAnd1 && k < (int)pNode->
nLat1; k++ )
437 if ( pAnd0 && pAnd1 )
444 pAnd =
Ivy_And( p, pAnd0, pAnd1 );
456 if ( ++Counter > NodeMax )
491 for ( k = 0; k < (int)pNode->
nLat2; k++ )
501 for ( k = 0; k < (int)pNode->
nLat0; k++ )
503 for ( k = 0; k < (int)pNode->
nLat1; k++ )
509 for ( k = 0; k < (int)pNode->
nLat2; k++ )
529 int nNodesNew, nNodesOld;
536 assert( nGain <= nNodesOld - nNodesNew );
562 static unsigned uMasks[5] = { 0xAAAAAAAA, 0xCCCCCCCC, 0xF0F0F0F0, 0xFF00FF00, 0xFFFF0000 };
563 unsigned uTruth0, uTruth1;
566 for ( i = 0; i < nNums; i++ )
567 if ( Leaf == pNums[i] )
587 return uTruth0 & uTruth1;
629 for ( i = 0; i < pCut->
nSize; i++ )
651 assert( IdNew0 < IdNew1 );
652 for ( i = k = 0; i < pCut->
nSize; i++ )
654 if ( pCut->
pArray[i] == IdOld )
658 if ( IdNew0 <= pCut->pArray[i] )
660 if ( IdNew0 < pCut->pArray[i] )
664 pCutNew->
pArray[ k++ ] = IdNew0;
672 if ( IdNew1 <= pCut->pArray[i] )
674 if ( IdNew1 < pCut->pArray[i] )
678 pCutNew->
pArray[ k++ ] = IdNew1;
693 pCutNew->
pArray[ k++ ] = IdNew0;
700 pCutNew->
pArray[ k++ ] = IdNew1;
704 pCutNew->
uHash = uHash;
706 for ( i = 1; i < pCutNew->
nSize; i++ )
727 assert( IdNew0 < IdNew1 );
728 for ( i = k = 0; i < pCut->
nSize; i++ )
730 if ( pCut->
pArray[i] == IdOld )
732 if ( IdNew0 <= pCut->pArray[i] )
734 if ( IdNew0 < pCut->pArray[i] )
736 pCutNew->
pArray[ k++ ] = IdNew0;
741 if ( IdNew1 <= pCut->pArray[i] )
743 if ( IdNew1 < pCut->pArray[i] )
745 pCutNew->
pArray[ k++ ] = IdNew1;
753 if ( IdNew0 < 0x7FFFFFFF )
755 pCutNew->
pArray[ k++ ] = IdNew0;
758 if ( IdNew1 < 0x7FFFFFFF )
760 pCutNew->
pArray[ k++ ] = IdNew1;
764 pCutNew->
uHash = uHash;
786 for ( i = 0; i < pCut->
nSize; i++ )
806 assert( IdNew0 < IdNew1 );
807 for ( i = k = 0; i < pCut->
nSize; i++ )
809 if ( pCut->
pArray[i] == IdOld )
811 if ( IdNew0 <= pCut->pArray[i] )
813 if ( IdNew0 < pCut->pArray[i] )
814 pCutNew->
pArray[ k++ ] = IdNew0;
817 if ( IdNew1 <= pCut->pArray[i] )
819 if ( IdNew1 < pCut->pArray[i] )
820 pCutNew->
pArray[ k++ ] = IdNew1;
825 if ( IdNew0 < 0x7FFFFFFF )
826 pCutNew->
pArray[ k++ ] = IdNew0;
827 if ( IdNew1 < 0x7FFFFFFF )
828 pCutNew->
pArray[ k++ ] = IdNew1;
849 for ( i = 0; i < pDom->
nSize; i++ )
852 for ( k = 0; k < pCut->
nSize; k++ )
855 if ( k == pCut->
nSize )
879 for ( i = 0; i < pCutStore->
nCuts; i++ )
881 pCut = pCutStore->
pCuts + i;
882 if ( pCut->
nSize == 0 )
888 for ( k = 0; k < pCutNew->
nSize; k++ )
891 if ( k == pCutNew->
nSize )
941 for ( i = k = 0; i < pCutStore->
nCuts; i++ )
943 pCut = pCutStore->
pCuts + i;
944 if ( pCut->
nSize == 0 )
948 pCutStore->
pCuts[k++] = *pCut;
950 pCutStore->
nCuts = k;
968 printf(
"%d : {", pCut->
nSize );
969 for ( i = 0; i < pCut->
nSize; i++ )
970 printf(
" %d", pCut->
pArray[i] );
988 printf(
"Node %d\n", pCutStore->
pCuts[0].
pArray[0] );
989 for ( i = 0; i < pCutStore->
nCuts; i++ )
1029 static Ivy_Store_t CutStore, * pCutStore = &CutStore;
1030 Ivy_Cut_t CutNew, * pCutNew = &CutNew, * pCut;
1032 int i, k, Temp, nLats, iLeaf0, iLeaf1;
1037 pCutStore->
nCuts = 0;
1046 pCutStore->
pCuts[pCutStore->
nCuts++] = *pCutNew;
1050 for ( i = 0; i < pCutStore->
nCuts; i++ )
1053 pCut = pCutStore->
pCuts + i;
1054 if ( pCut->nSize == 0 )
1056 for ( k = 0; k < pCut->nSize; k++ )
1068 iLeaf0 = nLats + iLeaf0;
1069 iLeaf1 = nLats + iLeaf1;
1073 if ( iLeaf0 > iLeaf1 )
1074 Temp = iLeaf0, iLeaf0 = iLeaf1, iLeaf1 = Temp;
1112 int i, nCutsTotal, nCutsTotalM, nNodeTotal, nNodeOver;
1116 printf(
"Cannot compute cuts for more than %d inputs.\n",
IVY_CUT_INPUT );
1119 nNodeTotal = nNodeOver = 0;
1126 nCutsTotal += pStore->
nCuts;
1127 nCutsTotalM += pStore->
nCutsM;
1128 nNodeOver += pStore->
fSatur;
1131 printf(
"All = %6d. Minus = %6d. Triv = %6d. Node = %6d. Satur = %6d. ",
void Rwt_ManStop(Rwt_Man_t *p)
Ivy_Obj_t * Ivy_Latch(Ivy_Man_t *p, Ivy_Obj_t *pObj, Ivy_Init_t Init)
static int Ivy_IsComplement(Ivy_Obj_t *p)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
void Rwt_ManAddTimeTotal(Rwt_Man_t *p, abctime Time)
static void Ivy_GraphUpdateNetworkSeq(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Dec_Graph_t *pGraph, int nGain)
void Ivy_ObjReplace(Ivy_Man_t *p, Ivy_Obj_t *pObjOld, Ivy_Obj_t *pObjNew, int fDeleteOld, int fFreeTop, int fUpdateLevel)
static Ivy_Obj_t * Ivy_ManConst1(Ivy_Man_t *p)
static int Dec_GraphNodeNum(Dec_Graph_t *pGraph)
static unsigned Ivy_NodeCutHash(Ivy_Cut_t *pCut)
static void Vec_PtrFill(Vec_Ptr_t *p, int nSize, void *Entry)
static Ivy_Store_t * Ivy_CutComputeForNode(Ivy_Man_t *p, Ivy_Obj_t *pObj, int nLeaves)
static int Ivy_ObjFaninId1(Ivy_Obj_t *pObj)
Ivy_Cut_t pCuts[IVY_CUT_LIMIT]
static int Ivy_CutDeriveNew3(Ivy_Cut_t *pCut, Ivy_Cut_t *pCutNew, int IdOld, int IdNew0, int IdNew1)
#define Ivy_ManForEachLatch(p, pObj, i)
int Ivy_ObjMffcLabel(Ivy_Man_t *p, Ivy_Obj_t *pObj)
static int Ivy_LeafId(int Leaf)
static int Dec_GraphIsConst(Dec_Graph_t *pGraph)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
void Ivy_CutPrintForNode(Ivy_Cut_t *pCut)
void Ivy_CutPrintForNodes(Ivy_Store_t *pCutStore)
Rwt_Man_t * Rwt_ManStart(int fPrecompute)
#define Ivy_ManForEachNode(p, pObj, i)
static abctime Abc_Clock()
static void Ivy_ObjRefsInc(Ivy_Obj_t *pObj)
void Ivy_CutComputeAll(Ivy_Man_t *p, int nInputs)
static int Vec_PtrSize(Vec_Ptr_t *p)
static int Ivy_CutReadLeaf(Ivy_Obj_t *pFanin)
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
void Rwt_ManPrintStats(Rwt_Man_t *p)
static int Ivy_CutHashValue(int NodeId)
static unsigned Ivy_CutGetTruth(Ivy_Man_t *p, Ivy_Obj_t *pObj, int *pNums, int nNums)
static int Ivy_LeafCreate(int Id, int Lat)
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
static int Ivy_CutCheckDominance(Ivy_Cut_t *pDom, Ivy_Cut_t *pCut)
int Ivy_ManPropagateBuffers(Ivy_Man_t *p, int fUpdateLevel)
static int Ivy_CutPrescreen(Ivy_Cut_t *pCut, int Id0, int Id1)
void Ivy_ManResetLevels(Ivy_Man_t *p)
#define IVY_MIN(a, b)
MACRO DEFINITIONS ///.
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
int Rwt_ManReadCompl(Rwt_Man_t *p)
static int Dec_GraphIsComplement(Dec_Graph_t *pGraph)
static int Ivy_ManObjIdMax(Ivy_Man_t *p)
static int Ivy_ObjFaninId0(Ivy_Obj_t *pObj)
Ivy_Obj_t * Ivy_TableLookup(Ivy_Man_t *p, Ivy_Obj_t *pObj)
FUNCTION DEFINITIONS ///.
void Ivy_ManIncrementTravId(Ivy_Man_t *p)
DECLARATIONS ///.
static Dec_Node_t * Dec_GraphVar(Dec_Graph_t *pGraph)
void * Rwt_ManReadDecs(Rwt_Man_t *p)
static int Ivy_ObjFaninC1(Ivy_Obj_t *pObj)
static Ivy_Obj_t * Ivy_ManObj(Ivy_Man_t *p, int i)
static Dec_Graph_t * Rwt_CutEvaluateSeq(Ivy_Man_t *pMan, Rwt_Man_t *p, Ivy_Obj_t *pRoot, Ivy_Cut_t *pCut, char *pPerm, Vec_Ptr_t *vFaninsCur, int nNodesSaved, int *pGainBest, unsigned uTruth)
static void Ivy_ObjRefsDec(Ivy_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static void Ivy_GraphPrepare(Dec_Graph_t *pGraph, Ivy_Cut_t *pCut, Vec_Ptr_t *vFanins, char *pPerm)
int pArray[IVY_CUT_INPUT]
static Ivy_Obj_t * Ivy_Regular(Ivy_Obj_t *p)
static int Ivy_CutDeriveNew2(Ivy_Cut_t *pCut, Ivy_Cut_t *pCutNew, int IdOld, int IdNew0, int IdNew1)
static int Ivy_ObjIsTravIdCurrent(Ivy_Man_t *p, Ivy_Obj_t *pObj)
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
void Ivy_ManStartFanout(Ivy_Man_t *p)
FUNCTION DEFINITIONS ///.
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
typedefABC_NAMESPACE_HEADER_START struct Ivy_Man_t_ Ivy_Man_t
INCLUDES ///.
static int Ivy_ManPiNum(Ivy_Man_t *p)
#define ABC_NAMESPACE_IMPL_START
#define Dec_GraphForEachNode(pGraph, pAnd, i)
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static Ivy_Obj_t * Ivy_ObjCreateGhost(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1, Ivy_Type_t Type, Ivy_Init_t Init)
static ABC_NAMESPACE_IMPL_START int Ivy_NodeRewriteSeq(Ivy_Man_t *pMan, Rwt_Man_t *p, Ivy_Obj_t *pNode, int fUseZeroCost)
DECLARATIONS ///.
static int Ivy_CutDeriveNew(Ivy_Cut_t *pCut, Ivy_Cut_t *pCutNew, int IdOld, int IdNew0, int IdNew1)
static int Ivy_ObjIsConst1(Ivy_Obj_t *pObj)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
int Ivy_CutFindOrAddFilter(Ivy_Store_t *pCutStore, Ivy_Cut_t *pCutNew)
#define Dec_GraphForEachLeaf(pGraph, pLeaf, i)
ITERATORS ///.
static Ivy_Obj_t * Ivy_GraphToNetworkSeq(Ivy_Man_t *p, Dec_Graph_t *pGraph)
static Ivy_Obj_t * Ivy_NotCond(Ivy_Obj_t *p, int c)
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
static int Dec_GraphLeaveNum(Dec_Graph_t *pGraph)
int Ivy_ManRewriteSeq(Ivy_Man_t *p, int fUseZeroCost, int fVerbose)
FUNCTION DEFINITIONS ///.
static int Ivy_GraphToNetworkSeqCountSeq(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Dec_Graph_t *pGraph, int NodeMax)
void Rwt_ManAddTimeUpdate(Rwt_Man_t *p, abctime Time)
static int Dec_GraphIsVar(Dec_Graph_t *pGraph)
static void Vec_PtrClear(Vec_Ptr_t *p)
void Ivy_CutCompactAll(Ivy_Store_t *pCutStore)
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
static int Ivy_ObjIsCi(Ivy_Obj_t *pObj)
static int Ivy_ManNodeNum(Ivy_Man_t *p)
static Vec_Ptr_t * Vec_VecEntry(Vec_Vec_t *p, int i)
#define Ivy_ManForEachObj(p, pObj, i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Ivy_LeafLat(int Leaf)
static int Ivy_ObjFaninC0(Ivy_Obj_t *pObj)
Ivy_Obj_t * Ivy_And(Ivy_Man_t *p, Ivy_Obj_t *p0, Ivy_Obj_t *p1)
int Ivy_ManCheck(Ivy_Man_t *p)
DECLARATIONS ///.
static int Ivy_ObjId(Ivy_Obj_t *pObj)
static void Vec_PtrFree(Vec_Ptr_t *p)
static void Dec_GraphComplement(Dec_Graph_t *pGraph)
unsigned Ivy_CutGetTruth_rec(Ivy_Man_t *p, int Leaf, int *pNums, int nNums)