26 #define LARGE_LEVEL 1000000
32 #define SCL_LUT_MAX 6 // the maximum LUT size
33 #define SCL_VARS_MAX 15 // the maximum number of variables
34 #define SCL_NODE_MAX 1000 // the maximum number of nodes
88 int i, LevelMax, nNodes;
89 int nNodesTried, nNodesDec, nNodesExist, nNodesUsed;
94 printf(
"LUT size (%d) does not belong to the interval: 3 <= LUT size <= %d\n", nLutSize, SCL_LUT_MAX );
97 if ( nCutSizeMax <= nLutSize || nCutSizeMax >
SCL_VARS_MAX )
99 printf(
"Cut size (%d) does not belong to the interval: LUT size (%d) < Cut size <= %d\n", nCutSizeMax, nLutSize, SCL_VARS_MAX );
103 assert( nLutSize <= SCL_LUT_MAX );
104 assert( nCutSizeMax <= SCL_VARS_MAX );
105 nNodesTried = nNodesDec = nNodesExist = nNodesUsed = 0;
148 if ( pObjTop == NULL )
181 printf(
"Try = %d. Dec = %d. Exist = %d. Use = %d. SUPER = %d levels of %d-LUTs.\n",
182 nNodesTried, nNodesDec, nNodesExist, nNodesUsed, LevelMax, nLutSize );
193 printf(
"Abc_NtkSuperChoiceLut: The network check has failed.\n" );
220 for ( pCut = pCut->
pNext; pCut; pCut = pCut->
pNext )
223 for ( i = 0; i < (int)pCut->
nLeaves; i++ )
227 if ( DelayMax < (
int)pFanin->
Level )
228 DelayMax = pFanin->
Level;
230 if ( (
int)pObj->
Level > DelayMax )
231 pObj->
Level = DelayMax;
266 if ( pParams->
fDrop )
290 assert(
sizeof(
unsigned) == 4 );
304 for ( i = 0; i < p->
nWords * 32; i++ )
306 p->
uVars[k][i>>5] |= (1 << (i&31));
347 unsigned * puData0, * puData1, * puData = NULL;
359 puData = (
unsigned *)pObj->
pNext;
363 pSop = (
char *)pObj->
pData;
364 if ( pSop[0] ==
'0' && pSop[1] ==
'0' )
365 for ( k = 0; k < pManScl->
nWords; k++ )
366 puData[k] = ~puData0[k] & ~puData1[k];
367 else if ( pSop[0] ==
'0' )
368 for ( k = 0; k < pManScl->
nWords; k++ )
369 puData[k] = ~puData0[k] & puData1[k];
370 else if ( pSop[1] ==
'0' )
371 for ( k = 0; k < pManScl->
nWords; k++ )
372 puData[k] = puData0[k] & ~puData1[k];
374 for ( k = 0; k < pManScl->
nWords; k++ )
375 puData[k] = puData0[k] & puData1[k];
496 for ( i = nVars - 1; i >= 0; i-- )
497 if ( uPhase & (1 << i) )
536 int i, nVars, uSupport, nSuppVars;
546 assert( nSuppVars <= nVars );
547 if ( nSuppVars == 0 )
552 if ( nSuppVars == 1 )
555 for ( i = 0; i < nVars; i++ )
556 if ( uSupport & (1 << i) )
564 if ( nSuppVars != nVars )
627 int i, k, kBest, LevelMin;
628 assert( nLutSize < nVars );
632 for ( i = 0; i < nVars; i++ )
634 pTemp[i] = pLeaves[i];
639 for ( i = 0; i < nLutSize; i++ )
643 for ( k = 0; k < nVars; k++ )
644 if ( pTemp[k] && LevelMin > (
int)pTemp[k]->Level )
646 LevelMin = pTemp[k]->
Level;
671 unsigned * pTruthCof, * pTruthClass, * pTruth, uPhase;
672 int i, k, c, v, w, nVars, nVarsNew, nClasses, nCofs;
691 for ( k = 0; k < (1<<v); k++ )
703 for ( i = 0; i < nCofs; i++ )
705 pTruthCof = p->
uCofs[ nCofs + i ];
706 for ( k = 0; k < nClasses; k++ )
708 pTruthClass = p->
uCofs[ nCofs + pCofClasses[k][0] ];
711 pCofClasses[k][(int)nCofClasses[k]++ ] = i;
718 pCofClasses[nClasses][0] = i;
719 nCofClasses[nClasses] = 1;
721 if ( nClasses > nCofs/2 )
726 assert( nVarsNew < p->nLutSize );
730 for ( k = 0; k < nClasses; k++ )
732 pTruthClass = p->
uCofs[ nCofs + pCofClasses[k][0] ];
733 for ( v = 0; v < nVarsNew; v++ )
741 pTruth = p->
uCofs[0];
742 for ( v = 0; v < nVarsNew; v++ )
745 for ( k = 0; k < nClasses; k++ )
747 for ( i = 0; i < nCofClasses[k]; i++ )
749 pTruthCof = p->
uCofs[1];
752 if ( pCofClasses[k][i] & (1 << (p->
nLutSize-1-w)) )
768 pNodesNew[v] = pObjNew;
771 for ( v = 0; v < nVarsNew; v++ )
775 for ( v = nVarsNew; v < p->
nLutSize; v++ )
776 uPhase |= (1 << p->
pBSet[v]);
int Abc_NtkSuperChoiceLut(Abc_Ntk_t *pNtk, int nLutSize, int nCutSizeMax, int fVerbose)
FUNCTION DEFINITIONS ///.
static void Abc_ManSclStop(Abc_ManScl_t *p)
void Abc_NodeSuperChoiceCollect2(Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
void Abc_NodeDecomposeSort(Abc_Obj_t **pLeaves, int nVars, int *pBSet, int nLutSize)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
int Abc_NodeCompareLevelsInc(int *pp1, int *pp2)
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
static int Abc_NodeDecomposeStep(Abc_ManScl_t *pManScl)
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
ABC_DLL void Abc_NtkDeleteObj_rec(Abc_Obj_t *pObj, int fOnlyNodes)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadVisited(Abc_ManCut_t *p)
#define Abc_NtkForEachCo(pNtk, pCo, i)
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
static int Abc_NtkIsSopLogic(Abc_Ntk_t *pNtk)
void Cut_NodeSetTriv(Cut_Man_t *p, int Node)
static int Abc_MaxInt(int a, int b)
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
static int Vec_PtrSize(Vec_Ptr_t *p)
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
void Cut_ManSetFanoutCounts(Cut_Man_t *p, Vec_Int_t *vFanCounts)
static void Vec_PtrRemove(Vec_Ptr_t *p, void *Entry)
ABC_DLL Vec_Ptr_t * Abc_NodeFindCut(Abc_ManCut_t *p, Abc_Obj_t *pRoot, int fContain)
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
void Abc_NodeLeavesRemove(Vec_Ptr_t *vLeaves, unsigned uPhase, int nVars)
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
static Abc_ManScl_t * Abc_ManSclStart(int nLutSize, int nCutSizeMax, int nNodesMax)
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
ABC_DLL Vec_Ptr_t * Abc_NtkManCutReadCutSmall(Abc_ManCut_t *p)
void Cut_ManStop(Cut_Man_t *p)
Cut_Man_t * Cut_ManStart(Cut_Params_t *pParams)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_END
ABC_DLL void * Abc_NodeGetCutsRecursive(void *p, Abc_Obj_t *pObj, int fDag, int fTree)
void Abc_NodeSuperChoiceCollect(Abc_Obj_t *pRoot, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
void Abc_NodeSuperChoiceCollect_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vLeaves, Vec_Ptr_t *vVolume)
ABC_DLL char * Abc_SopCreateFromTruth(Mem_Flex_t *pMan, int nVars, unsigned *pTruth)
void Abc_NodeSuperChoiceCollect2_rec(Abc_Obj_t *pObj, Vec_Ptr_t *vVolume)
#define Abc_NtkForEachCi(pNtk, pCi, i)
static Cut_Man_t * Abc_NtkStartCutManForScl(Abc_Ntk_t *pNtk, int nLutSize)
static Abc_Obj_t * Abc_NodeSuperChoiceLut(Abc_ManScl_t *pManScl, Abc_Obj_t *pObj)
#define Abc_ObjForEachFanin(pObj, pFanin, i)
static int Abc_Base2Log(unsigned n)
int Abc_NodeGetLevel(Abc_Obj_t *pObj)
static Abc_Obj_t * Abc_NtkCreateNode(Abc_Ntk_t *pNtk)
unsigned * Abc_NodeSuperChoiceTruth(Abc_ManScl_t *pManScl)
ABC_DLL Abc_ManCut_t * Abc_NtkManCutStart(int nNodeSizeMax, int nConeSizeMax, int nNodeFanStop, int nConeFanStop)
static Vec_Ptr_t * s_pLeaves
static void Abc_NodeLutMap(Cut_Man_t *pManCuts, Abc_Obj_t *pObj)
ABC_DLL Vec_Int_t * Abc_NtkFanoutCounts(Abc_Ntk_t *pNtk)
static void Vec_PtrClear(Vec_Ptr_t *p)
ABC_DLL void Abc_NtkManCutStop(Abc_ManCut_t *p)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
static void ** Vec_PtrArray(Vec_Ptr_t *p)
#define SCL_LUT_MAX
DECLARATIONS ///.