31 #define ABC_RS_DIV1_MAX 150 // the max number of divisors to consider
32 #define ABC_RS_DIV2_MAX 500 // the max number of pair-wise divisors to consider
157 if ( nLevelsOdc > 0 )
211 pFForm =
Abc_ManResubEval( pManRes, pNode, vLeaves, nStepsMax, fUpdateLevel, fVerbose );
215 if ( pFForm == NULL )
266 printf(
"Abc_NtkRefactor: The network check has failed.\n" );
292 assert(
sizeof(
unsigned) == 4 );
312 pData = (
unsigned *)p->
vSims->pArray[k];
315 pData[i>>5] |= (1 << (i&31));
391 printf(
"Total divisors = %8d.\n", p->
nTotalDivs );
488 if ( ++Counter == Limit )
527 printf(
"%6d : %c\n", pNode->
Id,
'a'+i );
530 printf(
"%6d : %2d = ", pNode->
Id, i );
536 printf(
"%c",
'a' + k );
545 printf(
"%c",
'a' + k );
549 if ( pNode == pRoot )
571 unsigned * puData0, * puData1, * puData;
585 puData = (
unsigned *)pObj->
pData;
590 for ( k = 0; k <
nWords; k++ )
591 puData[k] = ~puData0[k] & ~puData1[k];
593 for ( k = 0; k <
nWords; k++ )
594 puData[k] = ~puData0[k] & puData1[k];
596 for ( k = 0; k <
nWords; k++ )
597 puData[k] = puData0[k] & ~puData1[k];
599 for ( k = 0; k <
nWords; k++ )
600 puData[k] = puData0[k] & puData1[k];
605 puData = (
unsigned *)pObj->
pData;
606 pObj->
fPhase = (puData[0] & 1);
608 for ( k = 0; k <
nWords; k++ )
609 puData[k] = ~puData[k];
727 Dec_Edge_t eRoot, ePrev, eNode0, eNode1, eNode2;
773 Dec_Edge_t eRoot, ePrev0, ePrev1, eNode0, eNode1, eNode2, eNode3;
844 unsigned * puData, * puDataR;
852 if ( (
int)pObj->
Level > Required - 1 )
855 puData = (
unsigned *)pObj->
pData;
859 if ( puData[w] & ~puDataR[w] & p->
pCareSet[w] )
867 for ( w = 0; w < p->
nWords; w++ )
869 if ( ~puData[w] & puDataR[w] & p->
pCareSet[w] )
895 unsigned * puData0, * puData1, * puDataR;
904 if ( (
int)pObj0->
Level > Required - 2 )
907 puData0 = (
unsigned *)pObj0->
pData;
910 if ( (
int)pObj1->
Level > Required - 2 )
913 puData1 = (
unsigned *)pObj1->
pData;
918 for ( w = 0; w < p->
nWords; w++ )
920 if ( (puData0[w] & puData1[w]) & ~puDataR[w] & p->
pCareSet[w] )
927 for ( w = 0; w < p->
nWords; w++ )
929 if ( (~puData0[w] & puData1[w]) & ~puDataR[w] & p->
pCareSet[w] )
936 for ( w = 0; w < p->
nWords; w++ )
938 if ( (puData0[w] & ~puData1[w]) & ~puDataR[w] & p->
pCareSet[w] )
945 for ( w = 0; w < p->
nWords; w++ )
947 if ( (puData0[w] | puData1[w]) & ~puDataR[w] & p->
pCareSet[w] )
959 for ( w = 0; w < p->
nWords; w++ )
961 if ( ~(puData0[w] & puData1[w]) & puDataR[w] & p->
pCareSet[w] )
968 for ( w = 0; w < p->
nWords; w++ )
970 if ( ~(~puData0[w] & puData1[w]) & puDataR[w] & p->
pCareSet[w] )
977 for ( w = 0; w < p->
nWords; w++ )
979 if ( ~(puData0[w] & ~puData1[w]) & puDataR[w] & p->
pCareSet[w] )
986 for ( w = 0; w < p->
nWords; w++ )
988 if ( ~(puData0[w] | puData1[w]) & puDataR[w] & p->
pCareSet[w] )
1048 unsigned * puData, * puDataR;
1053 puData = (
unsigned *)pObj->
pData;
1056 if ( (puData[w] ^ puDataR[w]) & p->
pCareSet[w] )
1078 unsigned * puData0, * puData1, * puDataR;
1084 puData0 = (
unsigned *)pObj0->
pData;
1087 puData1 = (
unsigned *)pObj1->
pData;
1090 if ( ((puData0[w] | puData1[w]) ^ puDataR[w]) & p->
pCareSet[w] )
1102 puData0 = (
unsigned *)pObj0->
pData;
1105 puData1 = (
unsigned *)pObj1->
pData;
1108 if ( ((puData0[w] & puData1[w]) ^ puDataR[w]) & p->
pCareSet[w] )
1133 Abc_Obj_t * pObj0, * pObj1, * pObj2, * pObjMax, * pObjMin0 = NULL, * pObjMin1 = NULL;
1134 unsigned * puData0, * puData1, * puData2, * puDataR;
1135 int i, k, j, w, LevelMax;
1140 puData0 = (
unsigned *)pObj0->
pData;
1143 puData1 = (
unsigned *)pObj1->
pData;
1146 puData2 = (
unsigned *)pObj2->
pData;
1149 if ( ((puData0[w] | puData1[w] | puData2[w]) ^ puDataR[w]) & p->
pCareSet[w] )
1154 assert( LevelMax <= Required - 1 );
1157 if ( (
int)pObj0->
Level == LevelMax )
1158 pObjMax = pObj0, pObjMin0 = pObj1, pObjMin1 = pObj2;
1159 if ( (
int)pObj1->
Level == LevelMax )
1161 if ( pObjMax )
continue;
1162 pObjMax = pObj1, pObjMin0 = pObj0, pObjMin1 = pObj2;
1164 if ( (
int)pObj2->
Level == LevelMax )
1166 if ( pObjMax )
continue;
1167 pObjMax = pObj2, pObjMin0 = pObj0, pObjMin1 = pObj1;
1181 puData0 = (
unsigned *)pObj0->
pData;
1184 puData1 = (
unsigned *)pObj1->
pData;
1187 puData2 = (
unsigned *)pObj2->
pData;
1190 if ( ((puData0[w] & puData1[w] & puData2[w]) ^ puDataR[w]) & p->
pCareSet[w] )
1195 assert( LevelMax <= Required - 1 );
1198 if ( (
int)pObj0->
Level == LevelMax )
1199 pObjMax = pObj0, pObjMin0 = pObj1, pObjMin1 = pObj2;
1200 if ( (
int)pObj1->
Level == LevelMax )
1202 if ( pObjMax )
continue;
1203 pObjMax = pObj1, pObjMin0 = pObj0, pObjMin1 = pObj2;
1205 if ( (
int)pObj2->
Level == LevelMax )
1207 if ( pObjMax )
continue;
1208 pObjMax = pObj2, pObjMin0 = pObj0, pObjMin1 = pObj1;
1236 unsigned * puData0, * puData1, * puData2, * puDataR;
1242 puData0 = (
unsigned *)pObj0->
pData;
1251 for ( w = 0; w < p->
nWords; w++ )
1253 if ( ((puData0[w] | (puData1[w] | puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1258 for ( w = 0; w < p->
nWords; w++ )
1260 if ( ((puData0[w] | (~puData1[w] & puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1265 for ( w = 0; w < p->
nWords; w++ )
1267 if ( ((puData0[w] | (puData1[w] & ~puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1272 for ( w = 0; w < p->
nWords; w++ )
1274 if ( ((puData0[w] | (puData1[w] & puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1287 puData0 = (
unsigned *)pObj0->
pData;
1296 for ( w = 0; w < p->
nWords; w++ )
1298 if ( ((puData0[w] & (puData1[w] | puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1303 for ( w = 0; w < p->
nWords; w++ )
1305 if ( ((puData0[w] & (~puData1[w] & puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1310 for ( w = 0; w < p->
nWords; w++ )
1312 if ( ((puData0[w] & (puData1[w] & ~puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1317 for ( w = 0; w < p->
nWords; w++ )
1319 if ( ((puData0[w] & (puData1[w] & puData2[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1345 Abc_Obj_t * pObj0, * pObj1, * pObj2, * pObj3;
1346 unsigned * puData0, * puData1, * puData2, * puData3, * puDataR;
1347 int i, k, w = 0, Flag;
1368 for ( w = 0; w < p->
nWords; w++ )
1370 if ( (((puData0[w] & puData1[w]) | (puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1374 for ( w = 0; w < p->
nWords; w++ )
1376 if ( (((puData0[w] & puData1[w]) | (puData2[w] & ~puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1380 for ( w = 0; w < p->
nWords; w++ )
1382 if ( (((puData0[w] & puData1[w]) | (~puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1386 for ( w = 0; w < p->
nWords; w++ )
1388 if ( (((puData0[w] & puData1[w]) | (puData2[w] | puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1393 for ( w = 0; w < p->
nWords; w++ )
1395 if ( (((puData0[w] & ~puData1[w]) | (puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1399 for ( w = 0; w < p->
nWords; w++ )
1401 if ( (((puData0[w] & ~puData1[w]) | (puData2[w] & ~puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1405 for ( w = 0; w < p->
nWords; w++ )
1407 if ( (((puData0[w] & ~puData1[w]) | (~puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1411 for ( w = 0; w < p->
nWords; w++ )
1413 if ( (((puData0[w] & ~puData1[w]) | (puData2[w] | puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1418 for ( w = 0; w < p->
nWords; w++ )
1420 if ( (((~puData0[w] & puData1[w]) | (puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1424 for ( w = 0; w < p->
nWords; w++ )
1426 if ( (((~puData0[w] & puData1[w]) | (puData2[w] & ~puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1430 for ( w = 0; w < p->
nWords; w++ )
1432 if ( (((~puData0[w] & puData1[w]) | (~puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1436 for ( w = 0; w < p->
nWords; w++ )
1438 if ( (((~puData0[w] & puData1[w]) | (puData2[w] | puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1443 for ( w = 0; w < p->
nWords; w++ )
1445 if ( (((puData0[w] | puData1[w]) | (puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1449 for ( w = 0; w < p->
nWords; w++ )
1451 if ( (((puData0[w] | puData1[w]) | (puData2[w] & ~puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1455 for ( w = 0; w < p->
nWords; w++ )
1457 if ( (((puData0[w] | puData1[w]) | (~puData2[w] & puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1461 for ( w = 0; w < p->
nWords; w++ )
1463 if ( (((puData0[w] | puData1[w]) | (puData2[w] | puData3[w])) ^ puDataR[w]) & p->
pCareSet[w] )
1674 if ( nSteps == 0 || p->
nMffc == 1 )
1691 if ( nSteps == 1 || p->
nMffc == 2 )
1718 if ( nSteps == 2 || p->
nMffc == 3 )
1757 printf(
"Abc_CutVolumeCheck() ERROR: The set of nodes is not a cut!\n" );
1856 Vec_Ptr_t * vLeaves, * vFactors, * vFact, * vNext;
1860 int BestCut, BestShare;
1886 BestCut = -1, BestShare = -1;
1891 if ( vFact == NULL )
1898 if ( Counter <= nLeavesMax -
Vec_PtrSize(vLeaves) + 1 )
1901 if ( BestCut == -1 || BestShare <
Vec_PtrSize(vFact) - Counter )
1918 for ( i = RandLeaf; i <
Vec_PtrSize(vLeaves)-1; i++ )
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Dec_Graph_t * Abc_ManResubQuit2(Abc_Obj_t *pRoot, Abc_Obj_t *pObj0, Abc_Obj_t *pObj1, Abc_Obj_t *pObj2, int fOrGate)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static void Abc_ManResubPrintDivs(Abc_ManRes_t *p, Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves)
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
ABC_DLL int Abc_NtkDontCareCompute(Odc_Man_t *p, Abc_Obj_t *pNode, Vec_Ptr_t *vLeaves, unsigned *puTruth)
int Abc_NodeMffcInside(Abc_Obj_t *pNode, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vInside)
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
int Abc_NtkResubstitute(Abc_Ntk_t *pNtk, int nCutMax, int nStepsMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose)
FUNCTION DEFINITIONS ///.
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
ABC_DLL Odc_Man_t * Abc_NtkDontCareAlloc(int nVarsMax, int nLevels, int fVerbose, int fVeryVerbose)
FUNCTION DEFINITIONS ///.
static Dec_Graph_t * Abc_ManResubEval(Abc_ManRes_t *p, Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, int nSteps, int fUpdateLevel, int fVerbose)
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
static Abc_ManRes_t * Abc_ManResubStart(int nLeavesMax, int nDivsMax)
static Dec_Graph_t * Abc_ManResubDivs3(Abc_ManRes_t *p, int Required)
static void Abc_NodeSetTravIdPrevious(Abc_Obj_t *p)
Dec_Graph_t * Abc_ManResubQuit0(Abc_Obj_t *pRoot, Abc_Obj_t *pObj)
static void Abc_InfoFill(unsigned *p, int nWords)
static Dec_Graph_t * Abc_ManResubDivs1(Abc_ManRes_t *p, int Required)
static Dec_Edge_t Dec_EdgeCreate(int Node, int fCompl)
FUNCTION DEFINITIONS ///.
void Dec_GraphUpdateNetwork(Abc_Obj_t *pRoot, Dec_Graph_t *pGraph, int fUpdateLevel, int nGain)
static int Abc_NtkLatchNum(Abc_Ntk_t *pNtk)
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
static void Abc_ManResubDivsD(Abc_ManRes_t *p, int Required)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Vec_Ptr_t * Abc_CutFactor(Abc_Obj_t *pNode)
#define ABC_RS_DIV1_MAX
DECLARATIONS ///.
#define ABC_ALLOC(type, num)
static Dec_Graph_t * Abc_ManResubDivs2(Abc_ManRes_t *p, int Required)
typedefABC_NAMESPACE_HEADER_START struct Dec_Edge_t_ Dec_Edge_t
INCLUDES ///.
static void Abc_ManResubCleanup(Abc_ManRes_t *p)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
static int Vec_PtrSize(Vec_Ptr_t *p)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
for(p=first;p->value< newval;p=p->next)
static Dec_Graph_t * Dec_GraphCreateConst1()
static Vec_Ptr_t * Abc_CutFactorLarge(Abc_Obj_t *pNode, int nLeavesMax)
ABC_DLL void Abc_NtkStopReverseLevels(Abc_Ntk_t *pNtk)
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
ABC_DLL int Abc_NodeIsMuxControlType(Abc_Obj_t *pNode)
static Dec_Edge_t Dec_GraphAddNodeAnd(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
ABC_DLL Vec_Ptr_t * Abc_NodeFindCut(Abc_ManCut_t *p, Abc_Obj_t *pRoot, int fContain)
ABC_DLL void Abc_NtkReassignIds(Abc_Ntk_t *pNtk)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
ABC_DLL int Abc_ObjRequiredLevel(Abc_Obj_t *pObj)
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
ABC_DLL int Abc_AigCleanup(Abc_Aig_t *pMan)
static void Abc_ManResubStop(Abc_ManRes_t *p)
static int Abc_CutVolumeCheck(Abc_Obj_t *pNode, Vec_Ptr_t *vLeaves)
static void Abc_ManResubDivsS(Abc_ManRes_t *p, int Required)
static Dec_Graph_t * Dec_GraphCreateConst0()
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void Abc_NtkDontCareFree(Odc_Man_t *p)
Dec_Graph_t * Abc_ManResubQuit3(Abc_Obj_t *pRoot, Abc_Obj_t *pObj0, Abc_Obj_t *pObj1, Abc_Obj_t *pObj2, Abc_Obj_t *pObj3, int fOrGate)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
ABC_DLL void Abc_NtkDontCareClear(Odc_Man_t *p)
#define Abc_NtkForEachLatch(pNtk, pObj, i)
ABC_DLL void Abc_NtkStartReverseLevels(Abc_Ntk_t *pNtk, int nMaxLevelIncrease)
void Abc_ManResubCollectDivs_rec(Abc_Obj_t *pNode, Vec_Ptr_t *vInternal)
static Dec_Graph_t * Abc_ManResubQuit(Abc_ManRes_t *p)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
#define Abc_NtkForEachNode(pNtk, pNode, i)
static int Abc_NodeIsPersistant(Abc_Obj_t *pNode)
static void Dec_GraphSetRoot(Dec_Graph_t *pGraph, Dec_Edge_t eRoot)
int Abc_CutVolumeCheck_rec(Abc_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Dec_Graph_t * Abc_ManResubQuit21(Abc_Obj_t *pRoot, Abc_Obj_t *pObj0, Abc_Obj_t *pObj1, Abc_Obj_t *pObj2, int fOrGate)
static Dec_Graph_t * Dec_GraphCreate(int nLeaves)
static Dec_Edge_t Dec_GraphAddNodeOr(Dec_Graph_t *pGraph, Dec_Edge_t eEdge0, Dec_Edge_t eEdge1)
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
static Abc_Obj_t * Abc_ObjRegular(Abc_Obj_t *p)
static int Vec_IntSize(Vec_Int_t *p)
#define Vec_PtrForEachEntryStop(Type, vVec, pEntry, i, Stop)
#define Abc_ObjForEachFanout(pObj, pFanout, i)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static Dec_Graph_t * Abc_ManResubDivs12(Abc_ManRes_t *p, int Required)
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
static int Abc_ManResubCollectDivs(Abc_ManRes_t *p, Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, int Required)
ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart(int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop)
static void Dec_GraphFree(Dec_Graph_t *pGraph)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
void Abc_CutFactor_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vLeaves)
static void Vec_PtrClear(Vec_Ptr_t *p)
ABC_DLL void Abc_NtkManCutStop(Abc_ManCut_t *p)
static Dec_Node_t * Dec_GraphNode(Dec_Graph_t *pGraph, int i)
static Abc_Obj_t * Abc_ObjNot(Abc_Obj_t *p)
static void Abc_ManResubPrint(Abc_ManRes_t *p)
static void Abc_ManResubSimulate(Vec_Ptr_t *vDivs, int nLeaves, Vec_Ptr_t *vSims, int nLeavesMax, int nWords)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static int Abc_ObjIsComplement(Abc_Obj_t *p)
static void Vec_IntClear(Vec_Int_t *p)
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
ABC_DLL int Abc_NtkLevel(Abc_Ntk_t *pNtk)
Dec_Graph_t * Abc_ManResubQuit1(Abc_Obj_t *pRoot, Abc_Obj_t *pObj0, Abc_Obj_t *pObj1, int fOrGate)
static Dec_Graph_t * Abc_ManResubDivs0(Abc_ManRes_t *p)
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
static void Vec_PtrFree(Vec_Ptr_t *p)
static void Dec_GraphComplement(Dec_Graph_t *pGraph)