42 #define FPGA_CUTS_MAX_COMPUTE 2000
45 #define FPGA_CUTS_MAX_USE 1000
48 static int s_HashPrimes[10] = { 109, 499, 557, 619, 631, 709, 797, 881, 907, 991 };
51 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
52 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
53 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
54 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
55 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
56 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
57 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
58 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8
61 #define FPGA_COUNT_ONES(u) (bit_count[(u)&255]+bit_count[((u)>>8)&255]+bit_count[((u)>>16)&255]+bit_count[(u)>>24])
90 #define Fpga_ListForEachCut( pList, pCut ) \
94 #define Fpga_ListForEachCutSafe( pList, pCut, pCut2 ) \
96 pCut2 = pCut? pCut->pNext: NULL; \
99 pCut2 = pCut? pCut->pNext: NULL )
135 int nCuts, nNodes, i;
136 clock_t clk = clock();
146 for ( i = 0; i < nNodes; i++ )
161 printf(
"Nodes = %6d. Total %d-cuts = %d. Cuts per node = %.1f. ",
163 ABC_PRT(
"Time", clock() - clk );
187 for ( i = 0; i < p->
nInputs; i++ )
192 pCut->
uSign = (1 << (i%31));
234 if ( pNode->
pRepr == NULL )
236 for ( pTemp = pNode->
pNextE; pTemp; pTemp = pTemp->
pNextE )
248 pCut->
uSign = (1 << (pNode->
Num%31));
309 pPrev = pNode->
pCuts;
313 for ( pTemp = pNode->
pCuts->
pNext; pTemp != pCut; pTemp = pTemp->
pNext )
316 for ( i = 0; i < pTemp->
nLeaves; i++ )
318 for ( k = 0; k < pCut->
nLeaves; k++ )
359 Fpga_Cut_t * pCut, * pPrev, * pTemp1, * pTemp2;
361 Fpga_Cut_t ** ppArray1, ** ppArray2, ** ppArray3;
362 int nCuts1, nCuts2, nCuts3, k, fComp3;
364 ppArray1 = pTable->pCuts1;
365 ppArray2 = pTable->pCuts2;
373 if ( nCuts1 > nCuts2 )
395 for ( i = 0; i < nCuts1; i++ )
397 for ( k = 0; k <= i; k++ )
399 pTemp1 = ppArray1[i];
400 pTemp2 = ppArray2[k];
425 pLists[(
int)pCut->
nLeaves] = pCut;
431 for ( k = 0; k < i; k++ )
433 pTemp1 = ppArray1[k];
434 pTemp2 = ppArray2[i];
460 pLists[(
int)pCut->
nLeaves] = pCut;
468 for ( i = nCuts1; i < nCuts2; i++ )
469 for ( k = 0; k < nCuts1; k++ )
471 pTemp1 = ppArray1[k];
472 pTemp2 = ppArray2[i];
500 pLists[(
int)pCut->
nLeaves] = pCut;
509 ppListNew = &pListNew;
510 for ( i = 1; i <= p->
nVarsMax; i++ )
512 if ( pLists[i] == NULL )
515 for ( pPrev = pLists[i], pCut = pPrev->
pNext; pCut;
516 pPrev = pCut, pCut = pCut->
pNext );
518 *ppListNew = pLists[i];
519 ppListNew = &pPrev->
pNext;
544 Fpga_Cut_t * pCut, * pPrev, * pTemp1, * pTemp2;
551 for ( pTemp1 = pList1; pTemp1; pTemp1 = fPivot1? NULL: pTemp1->
pNext )
552 for ( pTemp2 = pList2; pTemp2; pTemp2 = fPivot2? NULL: pTemp2->
pNext )
567 pLists[(
int)pCut->
nLeaves] = pCut;
576 ppListNew = &pListNew;
577 for ( i = 1; i <= p->
nVarsMax; i++ )
579 if ( pLists[i] == NULL )
582 for ( pPrev = pLists[i], pCut = pPrev->
pNext; pCut;
583 pPrev = pCut, pCut = pCut->
pNext );
585 *ppListNew = pLists[i];
586 ppListNew = &pPrev->
pNext;
615 if ( Counter > nNodesMax )
668 for ( i = 0; i < pCut2->
nLeaves; i++ )
671 for ( k = 0; k < pCut1->
nLeaves; k++ )
674 if ( k < pCut1->nLeaves )
677 if ( nTotal == nNodesMax )
679 ppNodes[nTotal++] = pCut2->
ppLeaves[i];
684 for ( k = 0; k < pCut1->
nLeaves; k++ )
688 for ( i = 0; i < nTotal - 1; i++ )
691 for ( k = i+1; k <
nTotal; k++ )
693 if ( ppNodes[k]->Num < ppNodes[min]->Num )
695 pNodeTemp = ppNodes[i];
696 ppNodes[i] = ppNodes[min];
697 ppNodes[min] = pNodeTemp;
724 pList2->
pNext = NULL;
745 for ( pTemp = pList; pTemp; pTemp = pTemp->
pNext )
747 for ( i = 0; i < nNodes; i++ )
748 if ( pTemp->
ppLeaves[i] != ppNodes[i] )
774 for ( i = 0; i < pMan->
nBins; i++ )
775 for ( pNode = pMan->
pBins[i]; pNode; pNode = pNode->
pNext )
776 for ( pCut = pNode->
pCuts; pCut; pCut = pCut->
pNext )
802 for ( i = 0; i < pMan->
nBins; i++ )
803 for ( pNode = pMan->
pBins[i]; pNode; pNode = pNode->
pNext )
804 for ( pCut = pNode->
pCuts; pCut; pCut = pCut->
pNext )
824 for ( i = 0; i < pMan->
nBins; i++ )
825 for ( pNode = pMan->
pBins[i]; pNode; pNode = pNode->
pNext )
826 for ( pCut = pNode->
pCuts; pCut; pCut = pCut->
pNext )
847 for ( Counter = 0, pTemp = pRoot->
pCuts; pTemp; pTemp = pTemp->
pNext, Counter++ )
849 printf(
"%2d : ", Counter + 1 );
869 for ( Counter = 0, pTemp = pRoot->
pCuts; pTemp; pTemp = pTemp->
pNext, Counter++ )
871 printf(
"%2d : ", Counter + 1 );
890 printf(
"(%3d) {", pRoot->
Num );
891 for ( i = 0; i < pMan->
nVarsMax; i++ )
968 for ( i = 0; i < nNodes; i++ )
992 for ( b = Key; p->pBins[b]; b = (b+1) % p->nBins )
997 for ( i = 0; i < nNodes; i++ )
998 if ( pCut->
ppLeaves[i] != ppNodes[i] )
1031 for ( i = 0; i < nNodes; i++ )
1038 assert( p->pBins[Place] == NULL );
1039 p->pBins[Place] = pCut;
1041 p->pCuts[ p->nCuts++ ] = Place;
1060 for ( i = 0; i < p->nCuts; i++ )
1062 assert( p->pBins[ p->pCuts[i] ] );
1063 p->pBins[ p->pCuts[i] ] = NULL;
1083 if ( (*pC1)->nLeaves < (*pC2)->nLeaves )
1085 if ( (*pC1)->nLeaves > (*pC2)->nLeaves )
1115 qsort( (
void *)p->pCuts1, nCuts,
sizeof(
void *),
1145 for ( i = 0; pList; pList = pList->
pNext, i++ )
1166 ppListNew = &pListNew;
1167 for ( i = 0; i < nCuts; i++ )
1170 *ppListNew = pArray[i];
1171 ppListNew = &pArray[i]->
pNext;
static void Fpga_CutFilter(Fpga_Man_t *p, Fpga_Node_t *pNode)
static Fpga_Cut_t * Fpga_CutCompute(Fpga_Man_t *p, Fpga_CutTable_t *pTable, Fpga_Node_t *pNode)
static void Fpga_CutTableRestart(Fpga_CutTable_t *p)
#define FPGA_CUTS_MAX_COMPUTE
static int Abc_PrimeCudd(unsigned int p)
#define Fpga_CutNotCond(p, c)
static int Fpga_CutTableLookup(Fpga_CutTable_t *p, Fpga_Node_t *ppNodes[], int nNodes)
Fpga_Cut_t * Fpga_CutMergeLists2(Fpga_Man_t *p, Fpga_CutTable_t *pTable, Fpga_Cut_t *pList1, Fpga_Cut_t *pList2, int fComp1, int fComp2, int fPivot1, int fPivot2)
void Fpga_CutFree(Fpga_Man_t *p, Fpga_Cut_t *pCut)
#define FPGA_MAX_LEAVES
INCLUDES ///.
#define FPGA_COUNT_ONES(u)
static void Fpga_CutPrint_(Fpga_Man_t *pMan, Fpga_Cut_t *pCut, Fpga_Node_t *pRoot)
int Fpga_NodeComparePhase(Fpga_Node_t *p1, Fpga_Node_t *p2)
#define ABC_ALLOC(type, num)
Fpga_Cut_t * Fpga_CutAlloc(Fpga_Man_t *p)
DECLARATIONS ///.
static int Fpga_CutBelongsToList(Fpga_Cut_t *pList, Fpga_Node_t *ppNodes[], int nNodes)
static void Fpga_CutListPrint(Fpga_Man_t *pMan, Fpga_Node_t *pRoot)
static int Fpga_CutMergeTwo(Fpga_Cut_t *pCut1, Fpga_Cut_t *pCut2, Fpga_Node_t *ppNodes[], int nNodesMax)
static int bit_count[256]
for(p=first;p->value< newval;p=p->next)
int Fpga_CutCountAll(Fpga_Man_t *pMan)
Fpga_Node_t * ppLeaves[FPGA_MAX_LEAVES+1]
static Fpga_Cut_t * Fpga_CutArray2List(Fpga_Cut_t **pArray, int nCuts)
typedefABC_NAMESPACE_IMPL_START struct Fpga_CutTableStrutct_t Fpga_CutTable_t
DECLARATIONS ///.
void Fpga_CutsCleanSign(Fpga_Man_t *pMan)
void Fpga_MappingCreatePiCuts(Fpga_Man_t *p)
#define ABC_NAMESPACE_IMPL_END
static Fpga_CutTable_t * Fpga_CutTableStart(Fpga_Man_t *pMan)
static unsigned Fpga_CutTableHash(Fpga_Node_t *ppNodes[], int nNodes)
#define ABC_NAMESPACE_IMPL_START
static int Fpga_CutSortCutsCompare(Fpga_Cut_t **pC1, Fpga_Cut_t **pC2)
#define Fpga_ListForEachCutSafe(pList, pCut, pCut2)
int Fpga_NodeIsAnd(Fpga_Node_t *p)
#define FPGA_CUTS_MAX_USE
void Fpga_CutsCleanRoot(Fpga_Man_t *pMan)
static int Fpga_CutList2Array(Fpga_Cut_t **pArray, Fpga_Cut_t *pList)
#define Fpga_NodeReadRef(p)
STRUCTURE DEFINITIONS ///.
static Fpga_Cut_t * Fpga_CutUnionLists(Fpga_Cut_t *pList1, Fpga_Cut_t *pList2)
#define Fpga_ListForEachCut(pList, pCut)
static Fpga_Cut_t * Fpga_CutSortCuts(Fpga_Man_t *pMan, Fpga_CutTable_t *p, Fpga_Cut_t *pList)
static Fpga_Cut_t * Fpga_CutMergeLists(Fpga_Man_t *p, Fpga_CutTable_t *pTable, Fpga_Cut_t *pList1, Fpga_Cut_t *pList2, int fComp1, int fComp2, int fPivot1, int fPivot2)
static Fpga_Cut_t * Fpga_CutTableConsider(Fpga_Man_t *pMan, Fpga_CutTable_t *p, Fpga_Node_t *ppNodes[], int nNodes)
static void Fpga_CutListPrint2(Fpga_Man_t *pMan, Fpga_Node_t *pRoot)
static void Fpga_CutTableStop(Fpga_CutTable_t *p)
#define Fpga_IsComplement(p)
GLOBAL VARIABLES ///.
static int s_HashPrimes[10]
int nTotal
DECLARATIONS ///.
void Fpga_MappingCuts(Fpga_Man_t *p)
FUNCTION DEFINITIONS ///.