58 unsigned i, iLitFanin, uSupport, uSuppCur;
66 unsigned uSupps[16], Limit, s;
71 uSupport |= uSupps[i];
74 Limit = (1 << pObj->
nFans) - 1;
75 for ( s = 1; s < Limit; s++ )
78 for ( i = 0; i < pObj->
nFans; i++ )
80 uSuppCur |= uSupps[i];
110 unsigned uSupport, Entry;
124 assert( (uSupport & 0xFFFF0000) == 0 );
149 for ( k = 0; k < 16; k++ )
150 if ( uSupport & (1<<k) )
151 printf(
"%c",
'a'+k );
190 Lpk_Set_t * pStore,
int * pSize,
int nSizeLimit )
192 static int nTravId = 0;
193 static int TravId[1<<16] = {0};
194 static char SRed[1<<16];
195 static char Over[1<<16];
196 static unsigned Parents[1<<16];
197 static unsigned short Used[1<<16];
198 int nSuppSize, nSuppOver, nSuppRed, nUsed, nMinOver, i, k, s;
199 unsigned Entry, Entry0, Entry1;
200 unsigned uSupp, uSupp0, uSupp1, uSuppTotal;
203 if ( nTravId == (1 << 30) )
204 memset( TravId, 0,
sizeof(
int) * (1 << 16) );
213 uSupp0 = (Entry0 & 0xFFFF);
214 uSupp1 = (Entry1 & 0xFFFF);
216 if ( uSupp0 == 0 || uSupp1 == 0 || (uSupp0 | uSupp1) == uSuppTotal )
221 Entry = Entry0 | Entry1;
222 uSupp = Entry & 0xFFFF;
228 nSuppRed = nSuppSize - 1 - nSuppOver;
233 if ( TravId[uSupp] < nTravId )
235 Used[nUsed++] = uSupp;
237 TravId[uSupp] = nTravId;
238 SRed[uSupp] = nSuppRed;
239 Over[uSupp] = nSuppOver;
240 Parents[uSupp] = (k << 16) | i;
242 else if ( TravId[uSupp] == nTravId && SRed[uSupp] < nSuppRed )
244 TravId[uSupp] = nTravId;
245 SRed[uSupp] = nSuppRed;
246 Over[uSupp] = nSuppOver;
247 Parents[uSupp] = (k << 16) | i;
253 for ( s = 0; s < nUsed; s++ )
254 if ( nMinOver > Over[Used[s]] )
255 nMinOver = Over[Used[s]];
259 for ( s = 0; s < nUsed; s++ )
260 if ( Over[Used[s]] == nMinOver )
263 if ( *pSize == nSizeLimit )
265 pEntry = pStore + (*pSize)++;
267 i = Parents[Used[s]] & 0xFFFF;
268 k = Parents[Used[s]] >> 16;
272 Entry = pEntry->uSubset0 | pEntry->uSubset1;
275 pEntry->iVar = iCofVar;
281 pEntry->SRed = pEntry->Size - 1 - pEntry->Over;
282 assert( pEntry->SRed > 0 );
300 Entry = pSet->uSubset0 | pSet->uSubset1;
301 printf(
"%2d : ", i );
302 printf(
"Var = %c ",
'a' + pSet->iVar );
303 printf(
"Size = %2d ", pSet->Size );
304 printf(
"Over = %2d ", pSet->Over );
305 printf(
"SRed = %2d ", pSet->SRed );
325 static int nStoreSize = 256;
326 static Lpk_Set_t pStore[256], * pSet, * pSetBest;
332 int nSets, i, SizeMax;
334 int fVerbose = p->
pPars->fVeryVerbose;
340 printf(
"\nExploring support-reducing bound-sets of function:\n" );
344 for ( i = 0; i < nVars; i++ )
347 printf(
"Evaluating variable %c:\n",
'a'+i );
372 Lpk_ComposeSets( vSets0, vSets1, nVars, i, pStore, &nSets, nStoreSize );
379 for ( i = 0; i < nSets; i++ )
385 for ( i = 0; i < nSets; i++ )
388 if ( pSet->Size > p->
pPars->nLutSize - 1 )
390 if ( SizeMax < pSet->Size )
393 SizeMax = pSet->Size;
412 if ( pSetBest == NULL )
415 printf(
"Could not select a subset.\n" );
421 printf(
"Selected the following subset:\n" );
428 Entry = ((pSetBest->uSubset0 >> 16) | (pSetBest->uSubset1 >> 16));
430 Entry =
Kit_BitMask(nVars) & ~(1<<pSetBest->iVar) & ~Entry;
435 *piVar = pSetBest->iVar;
436 return (pSetBest->uSubset1 << 16) | (pSetBest->uSubset0 & 0xFFFF);
void Lpk_ComposeSets(Vec_Int_t *vSets0, Vec_Int_t *vSets1, int nVars, int iCofVar, Lpk_Set_t *pStore, int *pSize, int nSizeLimit)
static Kit_DsdObj_t * Kit_DsdNtkRoot(Kit_DsdNtk_t *pNtk)
static void Lpk_PrintSets(Vec_Int_t *vSets)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Kit_WordHasOneBit(unsigned uWord)
static Kit_DsdObj_t * Kit_DsdNtkObj(Kit_DsdNtk_t *pNtk, int Id)
unsigned Lpk_ComputeSets_rec(Kit_DsdNtk_t *p, int iLit, Vec_Int_t *vSets)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Lpk_Set_t_ Lpk_Set_t
DECLARATIONS ///.
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
#define Kit_DsdObjForEachFanin(pNtk, pObj, iLit, i)
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
void Kit_TruthCofactor0New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
unsigned Lpk_MapSuppRedDecSelect(Lpk_Man_t *p, unsigned *pTruth, int nVars, int *piVar, int *piVarReused)
static void Lpk_PrintSetOne(int uSupport)
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
static int Vec_IntEntry(Vec_Int_t *p, int i)
#define ABC_NAMESPACE_IMPL_END
void Kit_TruthCofactor1New(unsigned *pOut, unsigned *pIn, int nVars, int iVar)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
void Lpk_MapSuppPrintSet(Lpk_Set_t *pSet, int i)
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
static int Vec_IntSize(Vec_Int_t *p)
static int Kit_WordFindFirstBit(unsigned uWord)
static int Abc_Lit2Var(int Lit)
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
static int Kit_WordCountOnes(unsigned uWord)
static void Vec_IntClear(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Kit_DsdNtk_t * Kit_DsdExpand(Kit_DsdNtk_t *p)
static unsigned Kit_BitMask(int nBits)
unsigned Lpk_ComputeSets(Kit_DsdNtk_t *p, Vec_Int_t *vSets)