29 #define SUPER_MASK(n) ((~((unsigned)0)) >> (32-n))
30 #define SUPER_FULL (~((unsigned)0))
67 #define Super2_IsComplement(p) (((int)((ABC_PTRUINT_T) (p) & 01)))
68 #define Super2_Regular(p) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) & ~01))
69 #define Super2_Not(p) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) ^ 01))
70 #define Super2_NotCond(p,c) ((Super2_Gate_t *)((ABC_PTRUINT_T)(p) ^ (c)))
73 #define Super2_LibForEachGate( Lib, Gate ) \
75 Lib->i < Lib->nGates && (Gate = Lib->pGates[Lib->i]); \
77 #define Super2_LibForEachGate2( Lib, Gate2 ) \
79 Lib->k < Lib->i && (Gate2 = Lib->pGates[Lib->k]); \
129 printf(
"Computing supergates for %d inputs and %d levels:\n", nInputs, nLevels );
130 for ( Level = 1; Level <= nLevels; Level++ )
137 printf(
"Level %d: Tried = %7d. Computed = %7d. ", Level, pMan->
nTried, pLibCur->
nGates );
142 printf(
"Writing the output file...\n" );
298 pLib->
nMints = (1 << nInputs);
300 pLib->
nGates = nInputs + 1;
308 for ( v = 0; v < nInputs; v++ )
316 for ( m = 0; m < pLib->
nMints; m++ )
317 for ( v = 0; v < nInputs; v++ )
340 unsigned uTruth, uTruthR, uTruth1, uTruth2, uTruth1c, uTruth2c;
353 if (
stmm_lookup( pMan->
tTable, (
char *)(ABC_PTRUINT_T)uTruthR, (
char **)&pGate2 ) )
355 printf(
"New gate:\n" );
357 printf(
"Gate in the table:\n" );
361 stmm_insert( pMan->
tTable, (
char *)(ABC_PTRUINT_T)uTruthR, (
char *)(ABC_PTRUINT_T)pGate1 );
371 if ( pLib->
i && pLib->
i % 300 == 0 )
373 printf(
"Tried %5d first gates...\n", pLib->
i );
381 uTruth1c = Mask & ~uTruth1;
382 uTruth2c = Mask & ~uTruth2;
385 uTruth = uTruth1 & uTruth2;
386 uTruthR = ((uTruth & pLibNew->
uMaskBit)? Mask & ~uTruth : uTruth);
391 pGateNew->
pOne = pGate1;
392 pGateNew->
pTwo = pGate2;
393 pGateNew->
uTruth = uTruth;
399 uTruth = uTruth1c & uTruth2;
400 uTruthR = ((uTruth & pLibNew->
uMaskBit)? Mask & ~uTruth : uTruth);
406 pGateNew->
pTwo = pGate2;
407 pGateNew->
uTruth = uTruth;
413 uTruth = uTruth1 & uTruth2c;
414 uTruthR = ((uTruth & pLibNew->
uMaskBit)? Mask & ~uTruth : uTruth);
419 pGateNew->
pOne = pGate1;
421 pGateNew->
uTruth = uTruth;
427 uTruth = uTruth1c & uTruth2c;
428 uTruthR = ((uTruth & pLibNew->
uMaskBit)? Mask & ~uTruth : uTruth);
435 pGateNew->
uTruth = uTruth;
470 printf(
"Cannot write file for %d levels.\n", pLib->
nLevels );
486 pFile = fopen( FileName,
"w" );
487 fprintf( pFile,
"# AND2/INV supergates derived on %s.\n",
Extra_TimeStamp() );
488 fprintf( pFile,
"# Command line: \"super2 -i %d -l %d\".\n", pLib->
nInputs, pLib->
nLevels );
489 fprintf( pFile,
"# The number of inputs = %6d.\n", pLib->
nInputs );
490 fprintf( pFile,
"# The number of levels = %6d.\n", pLib->
nLevels );
491 fprintf( pFile,
"# The number of supergates = %6d.\n", pLib->
nGates );
492 fprintf( pFile,
"# The total functions = %6d.\n", (1<<(pLib->
nMints-1)) );
493 fprintf( pFile,
"\n" );
494 fprintf( pFile,
"%6d\n", pLib->
nGates );
501 printf(
"The supergates are written into file \"%s\" ", FileName );
502 printf(
"(%0.2f MB).\n", ((
double)
Extra_FileSize(FileName))/(1<<20) );
520 unsigned uTruth1, uTruth2;
525 if ( uTruth1 < uTruth2 )
559 fprintf( pFile,
" " );
562 fprintf( pFile,
"\n" );
579 static char Buff01[ 3], Buff02[ 3];
580 static char Buff11[ 6], Buff12[ 6];
581 static char Buff21[ 12], Buff22[ 12];
582 static char Buff31[ 25], Buff32[ 25];
583 static char Buff41[ 50], Buff42[ 50];
584 static char Buff51[100], Buff52[100];
585 static char * pBuffs1[6] = { Buff01, Buff11, Buff21, Buff31, Buff41, Buff51 };
586 static char * pBuffs2[6] = { Buff02, Buff12, Buff22, Buff32, Buff42, Buff52 };
588 char * pBuffer1 = pBuffs1[Level];
589 char * pBuffer2 = pBuffs2[Level];
591 int fInvNext1, fInvNext2;
596 if ( pGate->
pOne == NULL )
600 pBuffer1[0] = (fInv?
'1':
'0');
606 pBuffer1[0] = (fInv?
'A' + ((int)(ABC_PTRUINT_T)pGate->
pTwo):
'a' + ((
int)(ABC_PTRUINT_T)pGate->
pTwo));
619 strcpy( pBuffer1, pBranch );
627 if ( fInvNext1 ^ fInvNext2 )
629 if ( fInvNext1 > fInvNext2 )
630 sprintf( pBuffer2,
"%c%s%s%c", (fInv?
'<':
'('), pBuffer1, pBranch, (fInv?
'>':
')') );
632 sprintf( pBuffer2,
"%c%s%s%c", (fInv?
'<':
'('), pBranch, pBuffer1, (fInv?
'>':
')') );
639 sprintf( pBuffer2,
"%c%s%s%c", (fInv?
'<':
'('), pBuffer1, pBranch, (fInv?
'>':
')') );
642 sprintf( pBuffer2,
"%c%s%s%c", (fInv?
'<':
'('), pBranch, pBuffer1, (fInv?
'>':
')') );
644 printf(
"Strange!\n" );
666 while ( *pStr1 && *pStr1 <
'A' )
668 while ( *pStr2 && *pStr2 <
'A' )
672 if ( *pStr1 == 0 || *pStr2 == 0 )
680 if ( *pStr1 == *pStr2 )
687 if ( *pStr1 < *pStr2 )
static unsigned s_uMaskAll
stmm_table * stmm_init_table(stmm_compare_func_type compare, stmm_hash_func_type hash)
#define ABC_REALLOC(type, obj, num)
#define SUPER_MASK(n)
DECLARATIONS ///.
int stmm_insert(stmm_table *table, char *key, char *value)
void Super2_Precompute(int nInputs, int nLevels, int fVerbose)
FUNCTION DEFINITIONS ///.
#define Super2_LibForEachGate2(Lib, Gate2)
static unsigned s_uMaskBit
int st__ptrcmp(const char *, const char *)
static Super2_Lib_t * Super2_LibDup(Super2_Lib_t *pLib)
#define ABC_ALLOC(type, num)
static abctime Abc_Clock()
static char * Super2_LibWriteGate_rec(Super2_Gate_t *pGate, int fInv, int Level)
static void Super2_LibWriteGate(FILE *pFile, Super2_Lib_t *pLib, Super2_Gate_t *pGate)
static void Super2_LibWrite(Super2_Lib_t *pLib)
int stmm_lookup(stmm_table *table, char *key, char **value)
static Super2_Lib_t * Super2_LibCompute(Super2_Man_t *pMan, Super2_Lib_t *pLib)
static Super2_Man_t * Super2_ManStart()
static int Super2_LibCompareGates(Super2_Gate_t **ppG1, Super2_Gate_t **ppG2)
static void Super2_LibAddGate(Super2_Lib_t *pLib, Super2_Gate_t *pGate)
#define ABC_NAMESPACE_IMPL_END
static void Super2_LibStop(Super2_Lib_t *pLib)
int stmm_find_or_add(stmm_table *table, char *key, char ***slot)
#define ABC_NAMESPACE_IMPL_START
void stmm_free_table(stmm_table *table)
#define Super2_LibForEachGate(Lib, Gate)
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
static Super2_Lib_t * Super2_LibFirst(Super2_Man_t *pMan, int nInputs)
#define Super2_IsComplement(p)
static void Super2_ManStop(Super2_Man_t *pMan)
#define Super2_Regular(p)
static Super2_Lib_t * Super2_LibStart()
static int Super2_LibWriteCompare(char *pStr1, char *pStr2)
int st__ptrhash(const char *, int)