50 char * pSop, * pSopNew;
51 char * pCube, * pCubeNew;
52 int nVars, i, v, * pOrder;
58 pSop = (
char *)pNode->
pData;
62 for ( v = 0; v < nVars; v++ )
69 pSopNew = pCubeNew = pSop;
74 for ( v = 0; v < nVars; v++ )
76 for ( v = 0; v < nVars; v++ )
77 if ( pCube[pOrder[v]] ==
'0' )
79 else if ( pCube[pOrder[v]] ==
'1' )
81 pCubeNew += nVars + 3;
83 pNode->
pData = pSopNew;
97 char * pSop, * pSopNew;
98 char * pCube, * pCubeNew;
99 int nVars, i, v, * pOrder;
107 pSop = (
char *)pNode->
pData;
113 for ( v = 0; v < nVars; v++ )
114 if ( pCube[v] !=
'-' )
118 for ( v = 0; v < nVars; v++ )
125 pSopNew = pCubeNew = pSop;
130 for ( v = 0; v < nVars; v++ )
132 for ( v = 0; v < nVars; v++ )
133 if ( pCube[pOrder[v]] ==
'0' )
135 else if ( pCube[pOrder[v]] ==
'1' )
137 pCubeNew += nVars + 3;
139 pNode->
pData = pSopNew;
142 for ( v = 0; v < nVars; v++ )
162 char * pSop, * pSopNew;
163 char * pCube, * pCubeNew;
164 int nVars, i, v, iCube, * pOrder;
173 pSop = (
char *)pNode->
pData;
182 for ( v = 0; v < nVars; v++ )
183 if ( pCube[v] !=
'-' )
191 for ( v = 0; v < nVars; v++ )
198 for ( v = 0; v < nVars; v++ )
205 pSopNew = pCubeNew = pSop;
210 for ( v = 0; v < nVars; v++ )
212 for ( v = 0; v < nVars; v++ )
213 if ( pCube[pOrder[v]] ==
'0' )
215 else if ( pCube[pOrder[v]] ==
'1' )
217 pCubeNew += nVars + 3;
219 pNode->
pData = pSopNew;
222 for ( v = 0; v < nVars; v++ )
263 CutPoint = (nCubes / 2) * (nVars + 3);
264 ((
char *)pNode1->
pData)[CutPoint] = 0;
265 pNode2->
pData = (
char *)pNode2->
pData + CutPoint;
278 if ( (
Abc_ObjFaninNum(pNode) > nFaninsMax && nCubes > 1) || nCubes > nCubesMax )
296 return strcmp( *pp1, *pp2 );
300 char * pCube, * pPivot;
301 char * pSop = (
char *)pNode->
pData;
306 assert( pCube[nVars] ==
' ' );
315 assert( pCube[nVars] == 0 );
317 memcpy( pPivot, pCube, nVars + 3 );
369 int v, fCont12 = 1, fCont21 = 1;
370 for ( v = 0; v < nVars; v++ )
372 if ( pCube1[v] == pCube2[v] )
374 if ( pCube1[v] ==
'-' )
376 else if ( pCube2[v] ==
'-' )
380 if ( !fCont21 && !fCont21 )
383 assert( fCont21 || fCont12 );
384 return (fCont21 << 1) | fCont12;
388 char * pSop = (
char *)pNode->
pData;
389 char * pCube, * pCube2, * pSopNew;
391 int Status, nCount = 0;
394 if ( pCube[0] ==
'z' || pCube2[0] ==
'z' )
397 nCount += (int)(Status > 0);
400 else if ( Status & 2 )
406 pSopNew = (
char *)pNode->
pData;
409 if ( pCube[0] ==
'z' )
411 memcpy( pSopNew, pCube, nVars + 3 );
412 pSopNew += nVars + 3;
419 char * pSop = (
char *)pNode->
pData;
420 char * pCube, * pCube2;
426 for ( i = 0; i < nVars; i++ )
427 if ( pCube[i] != pCube2[i] )
428 Counter++, iDiff = i;
429 if ( Counter == 1 && ((pCube[iDiff] ==
'0' && pCube2[iDiff] ==
'1') || (pCube[iDiff] ==
'1' && pCube2[iDiff] ==
'0')) )
430 pCube[iDiff] = pCube2[iDiff] =
'-';
435 char * pSop = (
char *)pNode->
pData;
436 char * pCube, * pCube2;
442 if ( pCube == pCube2 )
444 for ( i = 0; i < nVars; i++ )
445 if ( pCube[i] != pCube2[i] )
453 for ( i = 0; fChanges; i++ )
469 Abc_Print( 0,
"%d nodes were made dist1-cube-free and/or single-cube-containment-free.\n", Counter );
static int * Vec_IntArray(Vec_Int_t *p)
void Abc_NtkSortCubes(Abc_Ntk_t *pNtk)
int Abc_NodeCompareCubes(char **pp1, char **pp2)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
void Abc_NtkOrderFaninsByLitCount(Abc_Ntk_t *pNtk)
void Abc_NodeMakeDist1Free(Abc_Obj_t *pNode)
static int Abc_NtkHasSop(Abc_Ntk_t *pNtk)
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static char * Vec_StrArray(Vec_Str_t *p)
#define Abc_SopForEachCube(pSop, nFanins, pCube)
ABC_DLL int Abc_SopGetCubeNum(char *pSop)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
void Abc_NodeSplitLarge(Abc_Obj_t *pNode)
ABC_DLL Abc_Obj_t * Abc_NtkDupObj(Abc_Ntk_t *pNtkNew, Abc_Obj_t *pObj, int fCopyName)
static void Vec_PtrSort(Vec_Ptr_t *p, int(*Vec_PtrSortCompare)()) ___unused
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
void Abc_NodeCheckDist1Free(Abc_Obj_t *pNode)
int Abc_NodeMakeSCCFree(Abc_Obj_t *pNode)
static Vec_Str_t * Vec_StrAlloc(int nCap)
static int Vec_PtrSize(Vec_Ptr_t *p)
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
static void Vec_StrGrow(Vec_Str_t *p, int nCapMin)
static int Abc_CubeContain(char *pCube1, char *pCube2, int nVars)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
static void Vec_StrFree(Vec_Str_t *p)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static void Vec_IntSelectSortCost(int *pArray, int nSize, Vec_Int_t *vCosts)
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
void Abc_NtkOrderFaninsByLitCountAndCubeCount(Abc_Ntk_t *pNtk)
void Abc_NodeSortCubes(Abc_Obj_t *pNode, Vec_Ptr_t *vCubes, Vec_Str_t *vStore)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static void Abc_Print(int level, const char *format,...)
ABC_NAMESPACE_IMPL_START void Abc_NtkOrderFaninsById(Abc_Ntk_t *pNtk)
DECLARATIONS ///.
void Abc_NtkSortSops(Abc_Ntk_t *pNtk)
ABC_DLL void Abc_ObjRemoveFanins(Abc_Obj_t *pObj)
#define Abc_NtkForEachNode(pNtk, pNode, i)
#define ABC_NAMESPACE_IMPL_START
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
#define Abc_ObjForEachFanin(pObj, pFanin, i)
int Abc_NodeMakeLegit(Abc_Obj_t *pNode)
ABC_DLL int Abc_SopGetVarNum(char *pSop)
void Abc_NtkSplitLarge(Abc_Ntk_t *pNtk, int nFaninsMax, int nCubesMax)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
int Abc_NtkMakeLegit(Abc_Ntk_t *pNtk)
static void Vec_PtrClear(Vec_Ptr_t *p)
static int Abc_ObjFaninId(Abc_Obj_t *pObj, int i)
static void Vec_IntFree(Vec_Int_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
static void Vec_IntClear(Vec_Int_t *p)
#define Abc_SopForEachCubePair(pSop, nFanins, pCube, pCube2)
ABC_DLL char * Abc_SopCreateOr(Mem_Flex_t *pMan, int nVars, int *pfCompl)
static void Vec_PtrFree(Vec_Ptr_t *p)