Commit b90f1c73 by Alan Mishchenko

Adding switch -N to 'super' to set an upper bound on the number of supergates generated.

parent b30791ba
...@@ -94,17 +94,17 @@ int Super_CommandSupergatesAnd( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -94,17 +94,17 @@ int Super_CommandSupergatesAnd( Abc_Frame_t * pAbc, int argc, char **argv )
nLevels = 3; nLevels = 3;
fVerbose = 0; fVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "ilvh")) != EOF ) while ( (c = Extra_UtilGetopt(argc, argv, "ILvh")) != EOF )
{ {
switch (c) switch (c)
{ {
case 'i': case 'I':
nVarsMax = atoi(argv[globalUtilOptind]); nVarsMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nVarsMax < 0 ) if ( nVarsMax < 0 )
goto usage; goto usage;
break; break;
case 'l': case 'L':
nLevels = atoi(argv[globalUtilOptind]); nLevels = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nLevels < 0 ) if ( nLevels < 0 )
...@@ -126,10 +126,10 @@ int Super_CommandSupergatesAnd( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -126,10 +126,10 @@ int Super_CommandSupergatesAnd( Abc_Frame_t * pAbc, int argc, char **argv )
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: super2 [-i num] [-l num] [-vh]\n"); fprintf( pErr, "usage: super2 [-IL num] [-vh]\n");
fprintf( pErr, "\t precomputes the supergates composed of AND2s and INVs\n" ); fprintf( pErr, "\t precomputes the supergates composed of AND2s and INVs\n" );
fprintf( pErr, "\t-i num : the max number of inputs to the supergate [default = %d]\n", nVarsMax ); fprintf( pErr, "\t-I num : the max number of inputs to the supergate [default = %d]\n", nVarsMax );
fprintf( pErr, "\t-l num : the max number of logic levels of gates [default = %d]\n", nLevels ); fprintf( pErr, "\t-L num : the max number of logic levels of gates [default = %d]\n", nLevels );
fprintf( pErr, "\t-v : enable verbose output\n"); fprintf( pErr, "\t-v : enable verbose output\n");
fprintf( pErr, "\t-h : print the help message\n"); fprintf( pErr, "\t-h : print the help message\n");
return 1; /* error exit */ return 1; /* error exit */
...@@ -157,7 +157,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -157,7 +157,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
float AreaLimit; float AreaLimit;
int fSkipInvs; int fSkipInvs;
int fWriteOldFormat; int fWriteOldFormat;
int nVarsMax, nLevels, TimeLimit; int nVarsMax, nLevels, nGatesMax, TimeLimit;
int fVerbose; int fVerbose;
int c; int c;
...@@ -169,6 +169,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -169,6 +169,7 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
nLevels = 3; nLevels = 3;
DelayLimit = 3.5; DelayLimit = 3.5;
AreaLimit = 9; AreaLimit = 9;
nGatesMax = 10000;
TimeLimit = 10; TimeLimit = 10;
fSkipInvs = 1; fSkipInvs = 1;
fVerbose = 0; fVerbose = 0;
...@@ -176,46 +177,52 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -176,46 +177,52 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
ExcludeFile = 0; ExcludeFile = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( (c = Extra_UtilGetopt(argc, argv, "eiltdasovh")) != EOF ) while ( (c = Extra_UtilGetopt(argc, argv, "ILNTDAEsovh")) != EOF )
{ {
switch (c) switch (c)
{ {
case 'e': case 'I':
ExcludeFile = argv[globalUtilOptind];
if ( ExcludeFile == 0 )
goto usage;
globalUtilOptind++;
break;
case 'i':
nVarsMax = atoi(argv[globalUtilOptind]); nVarsMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nVarsMax < 0 ) if ( nVarsMax < 0 )
goto usage; goto usage;
break; break;
case 'l': case 'L':
nLevels = atoi(argv[globalUtilOptind]); nLevels = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( nLevels < 0 ) if ( nLevels < 0 )
goto usage; goto usage;
break; break;
case 't': case 'N':
nGatesMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nGatesMax < 0 )
goto usage;
break;
case 'T':
TimeLimit = atoi(argv[globalUtilOptind]); TimeLimit = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( TimeLimit < 0 ) if ( TimeLimit < 0 )
goto usage; goto usage;
break; break;
case 'd': case 'D':
DelayLimit = (float)atof(argv[globalUtilOptind]); DelayLimit = (float)atof(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( DelayLimit <= 0.0 ) if ( DelayLimit <= 0.0 )
goto usage; goto usage;
break; break;
case 'a': case 'A':
AreaLimit = (float)atof(argv[globalUtilOptind]); AreaLimit = (float)atof(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( AreaLimit <= 0.0 ) if ( AreaLimit <= 0.0 )
goto usage; goto usage;
break; break;
case 'E':
ExcludeFile = argv[globalUtilOptind];
if ( ExcludeFile == 0 )
goto usage;
globalUtilOptind++;
break;
case 's': case 's':
fSkipInvs ^= 1; fSkipInvs ^= 1;
break; break;
...@@ -268,41 +275,42 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv ) ...@@ -268,41 +275,42 @@ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv )
} }
// compute the gates // compute the gates
Super_Precompute( pLib, nVarsMax, nLevels, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fWriteOldFormat, fVerbose ); Super_Precompute( pLib, nVarsMax, nLevels, nGatesMax, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fWriteOldFormat, fVerbose );
// delete the library // delete the library
Mio_LibraryDelete( pLib ); Mio_LibraryDelete( pLib );
return 0; return 0;
usage: usage:
fprintf( pErr, "usage: super [-i num] [-l num] [-d float] [-a float] [-t num] [-sovh] <genlib_file>\n"); fprintf( pErr, "usage: super [-ILNT num] [-DA float] [-E file] [-sovh] <genlib_file>\n");
fprintf( pErr, "\t precomputes the supergates for the given GENLIB library\n" ); fprintf( pErr, "\t precomputes the supergates for the given GENLIB library\n" );
fprintf( pErr, "\t-i num : the max number of supergate inputs [default = %d]\n", nVarsMax ); fprintf( pErr, "\t-I num : the max number of supergate inputs [default = %d]\n", nVarsMax );
fprintf( pErr, "\t-l num : the max number of levels of gates [default = %d]\n", nLevels ); fprintf( pErr, "\t-L num : the max number of levels of gates [default = %d]\n", nLevels );
fprintf( pErr, "\t-d float : the max delay of the supergates [default = %.2f]\n", DelayLimit ); fprintf( pErr, "\t-N num : the limit on the number of considered supergates [default = %d]\n", nGatesMax );
fprintf( pErr, "\t-a float : the max area of the supergates [default = %.2f]\n", AreaLimit ); fprintf( pErr, "\t-T num : the approximate runtime limit in seconds [default = %d]\n", TimeLimit );
fprintf( pErr, "\t-t num : the approximate runtime limit in seconds [default = %d]\n", TimeLimit ); fprintf( pErr, "\t-D float : the max delay of the supergates [default = %.2f]\n", DelayLimit );
fprintf( pErr, "\t-A float : the max area of the supergates [default = %.2f]\n", AreaLimit );
fprintf( pErr, "\t-E file : file contains list of genlib gates to exclude\n" );
fprintf( pErr, "\t-s : toggle the use of inverters at the inputs [default = %s]\n", (fSkipInvs? "no": "yes") ); fprintf( pErr, "\t-s : toggle the use of inverters at the inputs [default = %s]\n", (fSkipInvs? "no": "yes") );
fprintf( pErr, "\t-o : toggle dumping the supergate library in old format [default = %s]\n", (fWriteOldFormat? "yes": "no") ); fprintf( pErr, "\t-o : toggle dumping the supergate library in old format [default = %s]\n", (fWriteOldFormat? "yes": "no") );
fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" );
fprintf( pErr, "\t-v : enable verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-v : enable verbose output [default = %s]\n", (fVerbose? "yes" : "no") );
fprintf( pErr, "\t-h : print the help message\n"); fprintf( pErr, "\t-h : print the help message\n");
fprintf( pErr, "\n"); fprintf( pErr, "\n");
fprintf( pErr, "\tHere is a piece of advice on precomputing supergate libraries:\n"); fprintf( pErr, "\tHere is a piece of advice on precomputing supergate libraries:\n");
fprintf( pErr, "\t\n"); fprintf( pErr, "\t\n");
fprintf( pErr, "\tStart with the number of inputs equal to 5 (-i 5), the number of \n"); fprintf( pErr, "\tStart with the number of inputs equal to 5 (-I 5), the number of \n");
fprintf( pErr, "\tlevels equal to 3 (-l 3), the delay equal to 2-3 delays of inverter, \n"); fprintf( pErr, "\tlevels equal to 2 (-L 2), the delay equal to 2-3 delays of inverter, \n");
fprintf( pErr, "\tthe area equal to 3-4 areas of two input NAND, and runtime limit equal \n"); fprintf( pErr, "\tthe area equal to 2-3 areas of two input NAND, and runtime limit equal \n");
fprintf( pErr, "\tto 10 seconds (-t 10). Run precomputation and learn from the result.\n"); fprintf( pErr, "\tto 10 seconds (-T 10). Run precomputation and learn from the result.\n");
fprintf( pErr, "\tDetermine what parameter is most constraining and try to increase \n"); fprintf( pErr, "\tDetermine what parameter is most constraining and try to increase \n");
fprintf( pErr, "\tthe value of that parameter. The goal is to have a well-balanced\n"); fprintf( pErr, "\tthe value of that parameter. The goal is to have a well-balanced\n");
fprintf( pErr, "\tset of constraints and the resulting supergate library containing\n"); fprintf( pErr, "\tset of constraints and the resulting supergate library containing\n");
fprintf( pErr, "\tapproximately 100K-200K supergates. Typically, it is better to increase\n"); fprintf( pErr, "\tapproximately 5K-20K supergates. Typically, it is better to increase\n");
fprintf( pErr, "\tdelay limit rather than area limit, because having large-area supergates\n"); fprintf( pErr, "\tdelay limit rather than area limit, because having large-area supergates\n");
fprintf( pErr, "\tmay result in a considerable increase in area.\n"); fprintf( pErr, "\tmay result in a considerable increase in area.\n");
fprintf( pErr, "\t\n"); fprintf( pErr, "\t\n");
fprintf( pErr, "\tNote that a good supergate library for experiments typically can be \n"); fprintf( pErr, "\tNote that a good supergate library for experiments typically can be \n");
fprintf( pErr, "\tprecomputed in 30 sec. Increasing the runtime limit makes sense when\n"); fprintf( pErr, "\tprecomputed in 30 sec or less. Increasing runtime limit makes sense when\n");
fprintf( pErr, "\tother parameters are well-balanced and it is needed to enumerate more\n"); fprintf( pErr, "\tother parameters are well-balanced and it is needed to enumerate more\n");
fprintf( pErr, "\tchoices to have a good result. In the end, to compute the final library\n"); fprintf( pErr, "\tchoices to have a good result. In the end, to compute the final library\n");
fprintf( pErr, "\tthe runtime can be set to 300 sec to ensure the ultimate quality.\n"); fprintf( pErr, "\tthe runtime can be set to 300 sec to ensure the ultimate quality.\n");
......
...@@ -43,6 +43,7 @@ struct Super_ManStruct_t_ ...@@ -43,6 +43,7 @@ struct Super_ManStruct_t_
int nVarsMax; // the number of inputs int nVarsMax; // the number of inputs
int nMints; // the number of minterms int nMints; // the number of minterms
int nLevels; // the number of logic levels int nLevels; // the number of logic levels
int nGatesMax; // the number of gates computed
float tDelayMax; // the max delay of the supergates in the library float tDelayMax; // the max delay of the supergates in the library
float tAreaMax; // the max area of the supergates in the library float tAreaMax; // the max area of the supergates in the library
int fSkipInv; // the flag says about skipping inverters int fSkipInv; // the flag says about skipping inverters
...@@ -63,6 +64,7 @@ struct Super_ManStruct_t_ ...@@ -63,6 +64,7 @@ struct Super_ManStruct_t_
int nTried; // the total number of tried int nTried; // the total number of tried
int nAdded; // the number of entries added int nAdded; // the number of entries added
int nRemoved; // the number of entries removed int nRemoved; // the number of entries removed
int nClasses; // the number of gate classes
int nUnique; // the number of unique gates int nUnique; // the number of unique gates
int nLookups; // the number of hash table lookups int nLookups; // the number of hash table lookups
int nAliases; // the number of hash table lookups thrown away due to aliasing int nAliases; // the number of hash table lookups thrown away due to aliasing
...@@ -103,9 +105,9 @@ static void Super_ManStop( Super_Man_t * pMan ); ...@@ -103,9 +105,9 @@ static void Super_ManStop( Super_Man_t * pMan );
static void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate ); static void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate );
static void Super_First( Super_Man_t * pMan, int nVarsMax ); static void Super_First( Super_Man_t * pMan, int nVarsMax );
static Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int fSkipInv ); static Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int nGatesMax, int fSkipInv );
static Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Super_Gate_t ** pSupers, int nSupers, unsigned uTruth[], float Area, float tPinDelaysRes[], float tDelayMax, int nPins ); static Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Super_Gate_t ** pSupers, int nSupers, unsigned uTruth[], float Area, float tPinDelaysRes[], float tDelayMax, int nPins );
static int Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins ); static int Super_CompareGates( Super_Man_t * pMan, unsigned uTruth[], float Area, float tPinDelaysRes[], int nPins );
static int Super_DelayCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 ); static int Super_DelayCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 );
static int Super_AreaCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 ); static int Super_AreaCompare( Super_Gate_t ** ppG1, Super_Gate_t ** ppG2 );
static void Super_TranferGatesToArray( Super_Man_t * pMan ); static void Super_TranferGatesToArray( Super_Man_t * pMan );
...@@ -138,27 +140,39 @@ static void Super_WriteLibraryTree_rec( FILE * pFile, Super_Man_t * pM ...@@ -138,27 +140,39 @@ static void Super_WriteLibraryTree_rec( FILE * pFile, Super_Man_t * pM
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose ) void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose )
{ {
Super_Man_t * pMan; Super_Man_t * pMan;
Mio_Gate_t ** ppGates; Mio_Gate_t ** ppGates;
int nGates, Level, clk, clockStart; int nGates, Level, clk, clockStart;
assert( nVarsMax < 7 ); assert( nVarsMax < 7 );
if ( nGatesMax < nVarsMax )
{
fprintf( stderr, "Erro! The number of supergates requested (%d) in less than the number of variables (%d).\n", nGatesMax, nVarsMax );
fprintf( stderr, "The library cannot be computed.\n" );
return;
}
// get the root gates // get the root gates
ppGates = Mio_CollectRoots( pLibGen, nVarsMax, tDelayMax, 0, &nGates ); ppGates = Mio_CollectRoots( pLibGen, nVarsMax, tDelayMax, 0, &nGates );
if ( nGates >= nGatesMax )
{
fprintf( stdout, "Warning! Genlib library contains more gates than can be computed.\n");
fprintf( stdout, "Only one-gate supergates are included in the supergate library.\n" );
}
// start the manager // start the manager
pMan = Super_ManStart(); pMan = Super_ManStart();
pMan->pName = Mio_LibraryReadName(pLibGen); pMan->pName = Mio_LibraryReadName(pLibGen);
pMan->nGatesMax = nGatesMax;
pMan->fSkipInv = fSkipInv; pMan->fSkipInv = fSkipInv;
pMan->tDelayMax = tDelayMax; pMan->tDelayMax = tDelayMax;
pMan->tAreaMax = tAreaMax; pMan->tAreaMax = tAreaMax;
pMan->TimeLimit = TimeLimit; // in seconds pMan->TimeLimit = TimeLimit; // in seconds
pMan->TimeStop = TimeLimit * CLOCKS_PER_SEC + clock(); // in CPU ticks pMan->TimeStop = TimeLimit * CLOCKS_PER_SEC + clock(); // in CPU ticks
pMan->fVerbose = fVerbose;
pMan->fWriteOldFormat = fWriteOldFormat; pMan->fWriteOldFormat = fWriteOldFormat;
pMan->fVerbose = fVerbose;
if ( nGates == 0 ) if ( nGates == 0 )
{ {
...@@ -180,8 +194,8 @@ void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float ...@@ -180,8 +194,8 @@ void Super_Precompute( Mio_Library_t * pLibGen, int nVarsMax, int nLevels, float
clockStart = clock(); clockStart = clock();
if ( fVerbose ) if ( fVerbose )
{ {
printf( "Computing supergates with %d inputs and %d levels.\n", printf( "Computing supergates with %d inputs, %d levels, and %d max gates.\n",
pMan->nVarsMax, nLevels ); pMan->nVarsMax, nLevels, nGatesMax );
printf( "Limits: max delay = %.2f, max area = %.2f, time limit = %d sec.\n", printf( "Limits: max delay = %.2f, max area = %.2f, time limit = %d sec.\n",
pMan->tDelayMax, pMan->tAreaMax, pMan->TimeLimit ); pMan->tDelayMax, pMan->tAreaMax, pMan->TimeLimit );
} }
...@@ -191,7 +205,7 @@ if ( fVerbose ) ...@@ -191,7 +205,7 @@ if ( fVerbose )
if ( clock() > pMan->TimeStop ) if ( clock() > pMan->TimeStop )
break; break;
clk = clock(); clk = clock();
Super_Compute( pMan, ppGates, nGates, fSkipInv ); Super_Compute( pMan, ppGates, nGates, nGatesMax, fSkipInv );
pMan->nLevels = Level; pMan->nLevels = Level;
if ( fVerbose ) if ( fVerbose )
{ {
...@@ -295,7 +309,7 @@ void Super_First( Super_Man_t * pMan, int nVarsMax ) ...@@ -295,7 +309,7 @@ void Super_First( Super_Man_t * pMan, int nVarsMax )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int fSkipInv ) Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGates, int nGatesMax, int fSkipInv )
{ {
Super_Gate_t * pSupers[6], * pGate0, * pGate1, * pGate2, * pGate3, * pGate4, * pGate5, * pGateNew; Super_Gate_t * pSupers[6], * pGate0, * pGate1, * pGate2, * pGate3, * pGate4, * pGate5, * pGateNew;
float tPinDelaysRes[6], * ptPinDelays[6], tPinDelayMax, tDelayMio; float tPinDelaysRes[6], * ptPinDelays[6], tPinDelayMax, tDelayMio;
...@@ -416,7 +430,9 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -416,7 +430,9 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
} if ( pMan->nClasses > nGatesMax )
goto done;
}
break; break;
case 2: // two-input root gate case 2: // two-input root gate
Super_ManForEachGate( ppGatesLimit, nGatesLimit, i0, pGate0 ) Super_ManForEachGate( ppGatesLimit, nGatesLimit, i0, pGate0 )
...@@ -443,6 +459,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -443,6 +459,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
if ( pMan->nClasses > nGatesMax )
goto done;
} }
} }
break; break;
...@@ -480,6 +498,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -480,6 +498,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
if ( pMan->nClasses > nGatesMax )
goto done;
} }
} }
} }
...@@ -526,6 +546,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -526,6 +546,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
if ( pMan->nClasses > nGatesMax )
goto done;
} }
} }
} }
...@@ -581,6 +603,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -581,6 +603,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
if ( pMan->nClasses > nGatesMax )
goto done;
} }
} }
} }
...@@ -648,6 +672,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat ...@@ -648,6 +672,8 @@ Super_Man_t * Super_Compute( Super_Man_t * pMan, Mio_Gate_t ** ppGates, int nGat
// create a new gate // create a new gate
pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax ); pGateNew = Super_CreateGateNew( pMan, ppGates[k], pSupers, nFanins, uTruth, Area, tPinDelaysRes, tPinDelayMax, pMan->nVarsMax );
Super_AddGateToTable( pMan, pGateNew ); Super_AddGateToTable( pMan, pGateNew );
if ( pMan->nClasses > nGatesMax )
goto done;
} }
} }
} }
...@@ -742,7 +768,10 @@ void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate ) ...@@ -742,7 +768,10 @@ void Super_AddGateToTable( Super_Man_t * pMan, Super_Gate_t * pGate )
// Key = pGate->uTruth[0] + 2003 * pGate->uTruth[1]; // Key = pGate->uTruth[0] + 2003 * pGate->uTruth[1];
Key = pGate->uTruth[0] ^ pGate->uTruth[1]; Key = pGate->uTruth[0] ^ pGate->uTruth[1];
if ( !stmm_find_or_add( pMan->tTable, (char *)Key, (char ***)&ppList ) ) if ( !stmm_find_or_add( pMan->tTable, (char *)Key, (char ***)&ppList ) )
{
*ppList = NULL; *ppList = NULL;
pMan->nClasses++;
}
pGate->pNext = *ppList; pGate->pNext = *ppList;
*ppList = pGate; *ppList = pGate;
pMan->nAdded++; pMan->nAdded++;
...@@ -876,8 +905,7 @@ Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Supe ...@@ -876,8 +905,7 @@ Super_Gate_t * Super_CreateGateNew( Super_Man_t * pMan, Mio_Gate_t * pRoot, Supe
Super_Man_t * Super_ManStart() Super_Man_t * Super_ManStart()
{ {
Super_Man_t * pMan; Super_Man_t * pMan;
pMan = ABC_ALLOC( Super_Man_t, 1 ); pMan = ABC_CALLOC( Super_Man_t, 1 );
memset( pMan, 0, sizeof(Super_Man_t) );
pMan->pMem = Extra_MmFixedStart( sizeof(Super_Gate_t) ); pMan->pMem = Extra_MmFixedStart( sizeof(Super_Gate_t) );
pMan->tTable = stmm_init_table( st_ptrcmp, st_ptrhash ); pMan->tTable = stmm_init_table( st_ptrcmp, st_ptrhash );
return pMan; return pMan;
...@@ -1004,8 +1032,8 @@ void Super_WriteFileHeader( Super_Man_t * pMan, FILE * pFile ) ...@@ -1004,8 +1032,8 @@ void Super_WriteFileHeader( Super_Man_t * pMan, FILE * pFile )
fprintf( pFile, "#\n" ); fprintf( pFile, "#\n" );
fprintf( pFile, "# Supergate library derived for \"%s\" on %s.\n", pMan->pName, Extra_TimeStamp() ); fprintf( pFile, "# Supergate library derived for \"%s\" on %s.\n", pMan->pName, Extra_TimeStamp() );
fprintf( pFile, "#\n" ); fprintf( pFile, "#\n" );
fprintf( pFile, "# Command line: \"super -i %d -l %d -d %.2f -a %.2f -t %d %s %s\".\n", fprintf( pFile, "# Command line: \"super -I %d -L %d -N %d -T %d -D %.2f -A %.2f %s %s\".\n",
pMan->nVarsMax, pMan->nLevels, pMan->tDelayMax, pMan->tAreaMax, pMan->TimeLimit, (pMan->fSkipInv? "" : "-s"), pMan->pName ); pMan->nVarsMax, pMan->nLevels, pMan->nGatesMax, pMan->TimeLimit, pMan->tDelayMax, pMan->tAreaMax, (pMan->fSkipInv? "" : "-s"), pMan->pName );
fprintf( pFile, "#\n" ); fprintf( pFile, "#\n" );
fprintf( pFile, "# The number of inputs = %10d.\n", pMan->nVarsMax ); fprintf( pFile, "# The number of inputs = %10d.\n", pMan->nVarsMax );
fprintf( pFile, "# The number of levels = %10d.\n", pMan->nLevels ); fprintf( pFile, "# The number of levels = %10d.\n", pMan->nLevels );
...@@ -1018,7 +1046,7 @@ void Super_WriteFileHeader( Super_Man_t * pMan, FILE * pFile ) ...@@ -1018,7 +1046,7 @@ void Super_WriteFileHeader( Super_Man_t * pMan, FILE * pFile )
fprintf( pFile, "# The number of functions = %10d.\n", pMan->nUnique ); fprintf( pFile, "# The number of functions = %10d.\n", pMan->nUnique );
fprintf( pFile, "# The total functions = %.0f (2^%d).\n", pow((double)2,pMan->nMints), pMan->nMints ); fprintf( pFile, "# The total functions = %.0f (2^%d).\n", pow((double)2,pMan->nMints), pMan->nMints );
fprintf( pFile, "#\n" ); fprintf( pFile, "#\n" );
fprintf( pFile, "# Generation time (sec) = %10.2f.\n", (float)(pMan->Time)/(float)(CLOCKS_PER_SEC) ); fprintf( pFile, "# Generation time = %10.2f sec.\n", (float)(pMan->Time)/(float)(CLOCKS_PER_SEC) );
fprintf( pFile, "#\n" ); fprintf( pFile, "#\n" );
fprintf( pFile, "%s\n", pMan->pName ); fprintf( pFile, "%s\n", pMan->pName );
fprintf( pFile, "%d\n", pMan->nVarsMax ); fprintf( pFile, "%d\n", pMan->nVarsMax );
......
...@@ -57,7 +57,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -57,7 +57,7 @@ ABC_NAMESPACE_HEADER_START
/*=== superAnd.c =============================================================*/ /*=== superAnd.c =============================================================*/
extern void Super2_Precompute( int nInputs, int nLevels, int fVerbose ); extern void Super2_Precompute( int nInputs, int nLevels, int fVerbose );
/*=== superGate.c =============================================================*/ /*=== superGate.c =============================================================*/
extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose ); extern void Super_Precompute( Mio_Library_t * pLibGen, int nInputs, int nLevels, int nGatesMax, float tDelayMax, float tAreaMax, int TimeLimit, int fSkipInv, int fWriteOldFormat, int fVerbose );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment