30 #define CUT_CELL_MVAR 9
125 "8s a'bc+ab'c+abc' ",
126 " (a'bc+ab'c+abc')' ",
135 static int s_NPNe3[10] = { 6, 8, 10, 11, 12, 14, 15, 17, 18, 20 };
145 static void Cut_CellTruthElem(
unsigned * InA,
unsigned * InB,
unsigned * InC,
unsigned * pOut,
int nVars,
int Type );
172 char * pFileName =
"cells22_daomap_iwls.txt";
177 pFile = fopen( pFileName,
"r" );
180 printf(
"Cannot open file \"%s\".\n", pFileName );
186 while ( fgets(pString, 1000, pFile) )
189 pString[Length--] = 0;
217 printf(
"Read %d cells from file \"%s\". Added %d cells to the table.\n", p->
nTotal, pFileName, p->
nGood );
237 int i1, i2, i3, i, j, k, c;
243 for ( i = 0; i < 22; i++ )
245 for ( i = 0; i < 22; i++ )
247 for ( i = 0; i < 22; i++ )
342 for ( k = 0; k < 10; k++ )
343 for ( i1 = 0; i1 < 22; i1++ )
344 for ( i2 = 0; i2 < 22; i2++ )
345 for ( i3 = 0; i3 < 22; i3++ )
356 for ( i = 0; i < (int)pCell->
nVars; i++ )
376 for ( i = 0; i < (int)pCell->
nVars-1; i++ )
378 if ( pCell->
Store[2*i] != pCell->
Store[2*(i+1)] )
382 for ( j = i+1; j < (int)pCell->
nVars; j++ )
386 if ( pCell->
Store[2*i] == pCell->
Store[2*i+1] )
404 printf(
"BASIC: Total = %d. Good = %d. Entry = %d. ", (
int)p->
nTotal, (
int)p->
nGood, (
int)
sizeof(
Cut_Cell_t) );
407 for ( i = 0; i <= 9; i++ )
409 printf(
"\nDiffs: " );
410 for ( i = 0; i <= 9; i++ )
412 printf(
"\nEquals: " );
413 for ( i = 0; i <= 9; i++ )
421 for ( i1 = 0; i1 < k; i1++ )
422 for ( i2 = i1+1; i2 < k; i2++ )
423 for ( c = 0; c < 3; c++ )
431 for ( i = 0; i < (int)pCell->
nVars; i++ )
459 for ( i = 0; i < (int)pCell->
nVars-1; i++ )
461 if ( pCell->
Store[2*i] != pCell->
Store[2*(i+1)] )
465 for ( j = i+1; j < (int)pCell->
nVars; j++ )
469 if ( pCell->
Store[2*i] == pCell->
Store[2*i+1] )
488 printf(
"VAR %d: Total = %d. Good = %d. Entry = %d. ", k, p->
nTotal, p->
nGood, (
int)
sizeof(
Cut_Cell_t) );
491 for ( i = 0; i <= 9; i++ )
493 printf(
"\nDiffs: " );
494 for ( i = 0; i <= 9; i++ )
496 printf(
"\nEquals: " );
497 for ( i = 0; i <= 9; i++ )
526 for ( pTemp = *pSlot; pTemp; pTemp = pTemp->
pNext )
534 pCell->
pNext = *pSlot;
556 unsigned * pIn, * pOut, * pTemp;
560 for ( k = pCell->
nVars - 1; k >= 0; k-- )
565 pIn = pCell->
uTruth; pOut = uTemp;
566 for ( i = k; i < (int)pCell->
nVars - 1; i++ )
569 pTemp = pIn; pIn = pOut; pOut = pTemp;
638 void Cut_CellTruthElem(
unsigned * InA,
unsigned * InB,
unsigned * InC,
unsigned * pOut,
int nVars,
int Type )
648 for ( i = 0; i <
nWords; i++ )
653 for ( i = 0; i <
nWords; i++ )
654 pOut[i] = 0xFFFFFFFF;
658 for ( i = 0; i <
nWords; i++ )
663 for ( i = 0; i <
nWords; i++ )
664 pOut[i] = InA[i] & InB[i];
668 for ( i = 0; i <
nWords; i++ )
669 pOut[i] = ~(InA[i] & InB[i]);
673 for ( i = 0; i <
nWords; i++ )
674 pOut[i] = InA[i] ^ InB[i];
678 for ( i = 0; i <
nWords; i++ )
679 pOut[i] = InA[i] & InB[i] & InC[i];
683 for ( i = 0; i <
nWords; i++ )
684 pOut[i] = ~(InA[i] & InB[i] & InC[i]);
688 for ( i = 0; i <
nWords; i++ )
689 pOut[i] = InA[i] & (InB[i] | InC[i]);
693 for ( i = 0; i <
nWords; i++ )
694 pOut[i] = ~(InA[i] & (InB[i] | InC[i]));
698 for ( i = 0; i <
nWords; i++ )
699 pOut[i] = InA[i] ^ InB[i] ^ InC[i];
703 for ( i = 0; i <
nWords; i++ )
704 pOut[i] = InA[i] ^ (InB[i] & InC[i]);
708 for ( i = 0; i <
nWords; i++ )
709 pOut[i] = InA[i] & (InB[i] ^ InC[i]);
713 for ( i = 0; i <
nWords; i++ )
714 pOut[i] = ~(InA[i] & (InB[i] ^ InC[i]));
718 for ( i = 0; i <
nWords; i++ )
719 pOut[i] = (InA[i] & InB[i]) | (InB[i] & InC[i]) | (InA[i] & InC[i]);
723 for ( i = 0; i <
nWords; i++ )
724 pOut[i] = (InA[i] & InB[i] & InC[i]) | (~InA[i] & ~InB[i] & ~InC[i]);
728 for ( i = 0; i <
nWords; i++ )
729 pOut[i] = ~((InA[i] & InB[i] & InC[i]) | (~InA[i] & ~InB[i] & ~InC[i]));
733 for ( i = 0; i <
nWords; i++ )
734 pOut[i] = (InA[i] & InB[i]) | (InB[i] & InC[i]) | (~InA[i] & InC[i]);
738 for ( i = 0; i <
nWords; i++ )
739 pOut[i] = (~InA[i] & InB[i] & InC[i]) | (InA[i] & ~InB[i] & InC[i]) | (InA[i] & InB[i] & ~InC[i]);
743 for ( i = 0; i <
nWords; i++ )
744 pOut[i] = ~((~InA[i] & InB[i] & InC[i]) | (InA[i] & ~InB[i] & InC[i]) | (InA[i] & InB[i] & ~InC[i]));
748 for ( i = 0; i <
nWords; i++ )
749 pOut[i] = (InA[i] & ~InB[i] & ~InC[i]) | (InB[i] & InC[i]);
753 for ( i = 0; i <
nWords; i++ )
754 pOut[i] = ~((InA[i] & ~InB[i] & ~InC[i]) | (InB[i] & InC[i]));
776 assert(
sizeof(
unsigned) == 4 );
786 p->
uInputs[k][i>>5] |= (1 << (i&31));
821 return s_pCMan != NULL;
840 char * pFileName =
"celllib22.txt";
841 int NumUsed[10][5] = {{0}};
842 int BoxUsed[22][5] = {{0}};
848 printf(
"Cut_CellDumpToFile: Cell manager is not defined.\n" );
857 if ( pTemp->
nUsed == 0 )
859 else if ( pTemp->
nUsed < 10 )
861 else if ( pTemp->
nUsed < 100 )
863 else if ( pTemp->
nUsed < 1000 )
868 for ( i = 0; i < 4; i++ )
869 if ( pTemp->
nUsed == 0 )
870 BoxUsed[ (int)pTemp->
Box[i] ][0]++;
872 BoxUsed[ (int)pTemp->
Box[i] ][1]++;
874 BoxUsed[ (int)pTemp->
Box[i] ][2]++;
875 else if ( pTemp->
nUsed < 1000 )
876 BoxUsed[ (int)pTemp->
Box[i] ][3]++;
878 BoxUsed[ (
int)pTemp->
Box[i] ][4]++;
885 printf(
"%3d : ", k );
886 for ( i = 0; i < 5; i++ )
887 printf(
"%8d ", NumUsed[k][i] );
890 printf(
"Box usage:\n" );
891 for ( k = 0; k < 22; k++ )
893 printf(
"%3d : ", k );
894 for ( i = 0; i < 5; i++ )
895 printf(
"%8d ", BoxUsed[k][i] );
900 pFile = fopen( pFileName,
"w" );
903 printf(
"Cut_CellDumpToFile: Cannout open output file.\n" );
911 if ( pTemp->
nUsed > 0 )
914 fprintf( pFile,
"\n" );
917 fprintf( pFile,
"\n" );
921 printf(
"Library composed of %d functions is written into file \"%s\". ", Counter, pFileName );
951 printf(
"Cut_CellTruthLookup: Cell manager is not defined.\n" );
957 pCell->
nVars = nVars;
961 for ( i = 0; i < (int)pCell->
nVars; i++ )
969 if (
st__lookup( p->
tTable, (
char *)(ABC_PTRUINT_T)Hash, (
char **)&pTemp ) )
971 for ( ; pTemp; pTemp = pTemp->
pNext )
static void Cut_CellTruthElem(unsigned *InA, unsigned *InB, unsigned *InC, unsigned *pOut, int nVars, int Type)
int Cut_CellTruthLookup(unsigned *pTruth, int nVars)
void st__free_table(st__table *table)
void Cut_CellLoad()
FUNCTION DEFINITIONS ///.
static void Cut_CellSuppMin(Cut_Cell_t *pCell)
int nSymGroupsE[CUT_CELL_MVAR+1]
int st__ptrcmp(const char *, const char *)
void Cut_CellPrecompute()
#define ABC_ALLOC(type, num)
unsigned puAux[1<<(CUT_CELL_MVAR-5)]
static abctime Abc_Clock()
static char * s_NP3Names[22]
static Cut_CMan_t * s_pCMan
void Cut_CellDumpToFile()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
unsigned uTemp3[22][1<<(CUT_CELL_MVAR-5)]
#define CUT_CELL_MVAR
DECLARATIONS ///.
static int Cut_CellTableLookup(Cut_CMan_t *p, Cut_Cell_t *pCell)
int st__find_or_add(st__table *table, char *key, char ***slot)
unsigned uTemp1[22][1<<(CUT_CELL_MVAR-5)]
int nVarCounts[CUT_CELL_MVAR+1]
static void Cut_CellCanonicize(Cut_CMan_t *p, Cut_Cell_t *pCell)
#define ABC_NAMESPACE_IMPL_END
unsigned uFinal[1<<(CUT_CELL_MVAR-5)]
static void Cut_CManStop(Cut_CMan_t *p)
static Cut_CMan_t * Cut_CManStart()
#define ABC_NAMESPACE_IMPL_START
int st__lookup(st__table *table, const char *key, char **value)
unsigned uTemp2[22][1<<(CUT_CELL_MVAR-5)]
static int Abc_Base2Log(unsigned n)
unsigned uInputs[CUT_CELL_MVAR][1<<(CUT_CELL_MVAR-5)]
short Store[2 *CUT_CELL_MVAR]
Cut_Cell_t * pSameVar[CUT_CELL_MVAR+1]
static void Cut_CellCrossBar(Cut_Cell_t *pCell)
unsigned uTruth[1<<(CUT_CELL_MVAR-5)]
int st__ptrhash(const char *, int)
char CanonPerm[CUT_CELL_MVAR+3]
int nSymGroups[CUT_CELL_MVAR+1]