51 int nLatches, FaninLeaf, Cost;
65 Cost = FaninLeaf && (
Vec_IntFind(vInside, FaninLeaf) == -1);
72 Cost += FaninLeaf && (
Vec_IntFind(vInside, FaninLeaf) == -1);
93 int CostBest, CostCur, Leaf, LeafBest, Next, nLatches, i;
108 if ( CostBest > CostCur )
112 LeavesBest[0] = Leaf;
115 else if ( CostBest == CostCur )
116 LeavesBest[Counter++] = Leaf;
121 if ( CostBest == 99 )
126 if (
Vec_IntSize(vFront) - 1 + CostBest > nSizeLimit )
131 printf(
"%d", Counter );
133 LeafBest = LeavesBest[rand() %
Counter];
223 int RetValue0, RetValue1;
224 if ( pObj == pPivot )
248 if ( !RetValue0 && !RetValue1 )
307 Ivy_Obj_t * pFaninC, * pFanin0, * pFanin1, * pPivot;
308 int RetValue, LevelLimit, Lev, k;
333 for ( Lev =
Ivy_ObjLevel(pRoot) - 1; Lev >= LevelLimit; Lev-- )
339 if ( (
int)pObj->
Level == Lev )
396 if ( pPivot != NULL )
399 if ( pPivot == NULL )
473 Vec_Ptr_t * vFront, * vVolume, * vLeaves;
527 for ( i = 0; i < pCut->
nSize; i++ )
546 for ( i = k = 0; i < pCut->
nSize; i++ )
547 if ( pCut->
pArray[i] != iOld )
567 for ( i = 0; i < pCut->
nSize; i++ )
568 if ( pCut->
pArray[i] == iNew )
574 for ( i = pCut->
nSize - 1; i >= 0; i-- )
575 if ( pCut->
pArray[i] > iNew )
603 for ( i = 0; i < pCut->
nSize; i++ )
625 assert( IdNew0 < IdNew1 );
626 for ( i = k = 0; i < pCut->
nSize; i++ )
628 if ( pCut->
pArray[i] == IdOld )
630 if ( IdNew0 <= pCut->pArray[i] )
632 if ( IdNew0 < pCut->pArray[i] )
634 pCutNew->
pArray[ k++ ] = IdNew0;
639 if ( IdNew1 <= pCut->pArray[i] )
641 if ( IdNew1 < pCut->pArray[i] )
643 pCutNew->
pArray[ k++ ] = IdNew1;
651 if ( IdNew0 < 0x7FFFFFFF )
653 pCutNew->
pArray[ k++ ] = IdNew0;
656 if ( IdNew1 < 0x7FFFFFFF )
658 pCutNew->
pArray[ k++ ] = IdNew1;
662 pCutNew->
uHash = uHash;
686 for ( i = 0; i < pCutStore->
nCuts; i++ )
688 pCut = pCutStore->
pCuts + i;
691 for ( k = 0; k < pCutNew->
nSize; k++ )
694 if ( k == pCutNew->
nSize )
719 for ( i = 0; i < pDom->
nSize; i++ )
721 for ( k = 0; k < pCut->
nSize; k++ )
724 if ( k == pCut->
nSize )
748 for ( i = 0; i < pCutStore->
nCuts; i++ )
750 pCut = pCutStore->
pCuts + i;
751 if ( pCut->
nSize == 0 )
757 for ( k = 0; k < pCutNew->
nSize; k++ )
760 if ( k == pCutNew->
nSize )
813 for ( i = k = 0; i < pCutStore->
nCuts; i++ )
815 pCut = pCutStore->
pCuts + i;
816 if ( pCut->
nSize == 0 )
818 pCutStore->
pCuts[k++] = *pCut;
820 pCutStore->
nCuts = k;
838 printf(
"%d : {", pCut->
nSize );
839 for ( i = 0; i < pCut->
nSize; i++ )
840 printf(
" %d", pCut->
pArray[i] );
858 printf(
"Node %d\n", pCutStore->
pCuts[0].
pArray[0] );
859 for ( i = 0; i < pCutStore->
nCuts; i++ )
894 static Ivy_Store_t CutStore, * pCutStore = &CutStore;
895 Ivy_Cut_t CutNew, * pCutNew = &CutNew, * pCut;
897 int i, k, iLeaf0, iLeaf1;
902 pCutStore->
nCuts = 0;
915 for ( i = 0; i < pCutStore->
nCuts; i++ )
918 pCut = pCutStore->
pCuts + i;
919 if ( pCut->nSize == 0 )
921 for ( k = 0; k < pCut->nSize; k++ )
941 if ( iLeaf0 > iLeaf1 )
971 int i, nCutsCut, nCutsTotal, nNodeTotal, nNodeOver;
973 nNodeTotal = nNodeOver = 0;
980 nCutsTotal += nCutsCut;
984 printf(
"Total cuts = %6d. Trivial = %6d. Nodes = %6d. Satur = %6d. ",
int Ivy_ManFindBoolCut_rec(Ivy_Man_t *p, Ivy_Obj_t *pObj, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume, Ivy_Obj_t *pPivot)
static int Ivy_IsComplement(Ivy_Obj_t *p)
void Ivy_ManSeqFindCut(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Vec_Int_t *vFront, Vec_Int_t *vInside, int nSize)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Ivy_Store_t * Ivy_NodeFindCutsAll(Ivy_Man_t *p, Ivy_Obj_t *pObj, int nLeaves)
static int Ivy_ObjLevelNew(Ivy_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Vec_PtrPushUnique(Vec_Ptr_t *p, void *Entry)
int Ivy_ObjIsMuxType(Ivy_Obj_t *pObj)
static int Ivy_ObjFaninId1(Ivy_Obj_t *pObj)
static ABC_NAMESPACE_IMPL_START int Ivy_NodeCutHashValue(int NodeId)
DECLARATIONS ///.
Ivy_Cut_t pCuts[IVY_CUT_LIMIT]
static int Ivy_ObjIsPi(Ivy_Obj_t *pObj)
static int Ivy_NodeCutPrescreen(Ivy_Cut_t *pCut, int Id0, int Id1)
void Ivy_NodeCompactCuts(Ivy_Store_t *pCutStore)
void Ivy_NodePrintCut(Ivy_Cut_t *pCut)
static int Ivy_LeafId(int Leaf)
static int Vec_IntFind(Vec_Int_t *p, int Entry)
static unsigned Ivy_NodeCutHash(Ivy_Cut_t *pCut)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
void Ivy_ManTestCutsBool(Ivy_Man_t *p)
static int Ivy_NodeGetLeafCostOne(Ivy_Man_t *p, int Leaf, Vec_Int_t *vInside)
FUNCTION DEFINITIONS ///.
static abctime Abc_Clock()
static int Vec_PtrSize(Vec_Ptr_t *p)
int Ivy_ManFindBoolCut(Ivy_Man_t *p, Ivy_Obj_t *pRoot, Vec_Ptr_t *vFront, Vec_Ptr_t *vVolume, Vec_Ptr_t *vLeaves)
static int Ivy_ObjIsLatch(Ivy_Obj_t *pObj)
static int Ivy_LeafCreate(int Id, int Lat)
Ivy_Obj_t * Ivy_ObjRecognizeMux(Ivy_Obj_t *pObj, Ivy_Obj_t **ppObjT, Ivy_Obj_t **ppObjE)
static Ivy_Obj_t * Ivy_ObjFanin1(Ivy_Obj_t *pObj)
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
static int Ivy_ObjLevel(Ivy_Obj_t *pObj)
void Ivy_NodePrintCuts(Ivy_Store_t *pCutStore)
static Ivy_Obj_t * Ivy_ObjFanin0(Ivy_Obj_t *pObj)
static int Ivy_ObjFaninId0(Ivy_Obj_t *pObj)
int Ivy_NodeCutFindOrAdd(Ivy_Store_t *pCutStore, Ivy_Cut_t *pCutNew)
int Ivy_ManSeqFindCut_int(Ivy_Man_t *p, Vec_Int_t *vFront, Vec_Int_t *vInside, int nSizeLimit)
static Ivy_Obj_t * Ivy_ManObj(Ivy_Man_t *p, int i)
int Ivy_ManFindBoolCutCost(Ivy_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static Ivy_Obj_t * Ivy_ObjRealFanin(Ivy_Obj_t *pObj)
int pArray[IVY_CUT_INPUT]
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static void Ivy_NodeCutShrink(Ivy_Cut_t *pCut, int iOld)
static int Ivy_ObjIsNode(Ivy_Obj_t *pObj)
static int Vec_IntRemove(Vec_Int_t *p, int Entry)
int Ivy_NodeCutFindOrAddFilter(Ivy_Store_t *pCutStore, Ivy_Cut_t *pCutNew)
static int Ivy_NodeCutDeriveNew(Ivy_Cut_t *pCut, Ivy_Cut_t *pCutNew, int IdOld, int IdNew0, int IdNew1)
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
static int Ivy_ObjIsExor(Ivy_Obj_t *pObj)
static int Vec_IntSize(Vec_Int_t *p)
static int Ivy_ObjIsConst1(Ivy_Obj_t *pObj)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static int Ivy_CutCheckDominance(Ivy_Cut_t *pDom, Ivy_Cut_t *pCut)
static int Ivy_ObjIsBuf(Ivy_Obj_t *pObj)
static int Ivy_NodeCutExtend(Ivy_Cut_t *pCut, int iNew)
static void Vec_PtrClear(Vec_Ptr_t *p)
static int Ivy_ObjIsCi(Ivy_Obj_t *pObj)
static int Ivy_ManNodeNum(Ivy_Man_t *p)
#define Ivy_ManForEachObj(p, pObj, i)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static void Vec_IntClear(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Ivy_LeafLat(int Leaf)
void Ivy_ManTestCutsAll(Ivy_Man_t *p)
static int Ivy_ObjId(Ivy_Obj_t *pObj)
static void Vec_PtrFree(Vec_Ptr_t *p)