56 pFile = fopen( pFileName,
"r" );
59 printf(
"Cannot open input file \"%s\".\n", pFileName );
88 int nCounter, nGatesTotal;
93 while ( fgets( pBuffer, 2000, pFile ) != NULL )
96 for ( pTemp = pBuffer; *pTemp ==
' ' || *pTemp ==
'\r' || *pTemp ==
'\n'; pTemp++ );
98 if ( *pTemp != 0 && *pTemp !=
'#' )
103 pLibName =
strtok( pTemp,
" \t\r\n" );
104 if (
strcmp( pLibName,
"GATE" ) == 0 )
106 printf(
"The input file \"%s\" looks like a genlib file and not a supergate library file.\n", pLib->
pName );
109 pFileGen = fopen( pLibName,
"r" );
110 if ( pFileGen == NULL )
112 printf(
"Cannot open the genlib file \"%s\".\n", pLibName );
121 printf(
"Cannot read genlib file \"%s\".\n", pLibName );
126 RetValue = fscanf( pFile,
"%d\n", &pLib->
nVarsMax );
129 printf(
"Suspicious number of variables (%d).\n", pLib->
nVarsMax );
134 RetValue = fscanf( pFile,
"%d\n", &nGatesTotal );
135 if ( nGatesTotal < 1 || nGatesTotal > 10000000 )
137 printf(
"Suspicious number of gates (%d).\n", nGatesTotal );
144 while ( fgets( pBuffer, 5000, pFile ) != NULL )
146 for ( pTemp = pBuffer; *pTemp ==
' ' || *pTemp ==
'\r' || *pTemp ==
'\n'; pTemp++ );
147 if ( pTemp[0] ==
'\0' )
153 for ( pTemp = pGate->
pFormula; *pTemp; pTemp++ )
154 pGate->
nGates += (*pTemp ==
'(');
167 if ( nCounter != nGatesTotal )
168 printf(
"The number of gates read (%d) is different what the file says (%d).\n", nGatesTotal, nCounter );
194 pTemp =
strtok( pBuffer,
" " );
195 pGate->
Num = atoi(pTemp);
198 pTemp =
strtok( NULL,
" " );
212 pTemp =
strtok( NULL,
" " );
217 for ( i = 0; i < nVars; i++ )
219 pTemp =
strtok( NULL,
" " );
225 pTemp =
strtok( NULL,
" " );
229 pTemp =
strtok( NULL,
" \r\n" );
231 printf(
"A gate name is empty.\n" );
238 pTemp =
strtok( NULL,
" \n\0" );
240 printf(
"The following trailing symbols found \"%s\".\n", pTemp );
258 char * pName, * pPar1, * pPar2, * pCur;
259 int nStrings, CountPars;
262 for ( pName = pFormula; *pName && *pName ==
' '; pName++ );
265 for ( pPar1 = pName; *pPar1 && *pPar1 !=
'('; pPar1++ );
275 for ( CountPars = 1, pPar2 = pPar1 + 1; *pPar2 && CountPars; pPar2++ )
278 else if ( *pPar2 ==
')' )
291 pStrings[ nStrings++ ] = pCur;
293 for ( CountPars = 0; *pCur && (CountPars || *pCur !=
','); pCur++ )
296 else if ( *pCur ==
')' )
305 *pnStrings = nStrings;
323 unsigned uTruthRes[2];
325 if ( uTruthRes[0] != pGate->
uTruth[0] || uTruthRes[1] != pGate->
uTruth[1] )
347 strcpy( Buffer, pFormula );
367 char * pGateName, * pStrings[6];
368 unsigned uTruthsFanins[6][2];
377 uTruthRes[0] = uTruthsIn[pGateName[0] -
'a'][0];
378 uTruthRes[1] = uTruthsIn[pGateName[0] -
'a'][1];
382 for ( i = 0; i < nStrings; i++ )
386 if ( pMioGate == NULL )
405 printf(
"%5d : ", pGate->
nUsed );
406 printf(
"%5d ", pGate->
Num );
407 printf(
"A = %5.2f ", pGate->
Area );
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
static ABC_NAMESPACE_IMPL_START int Map_LibraryReadFile(Map_SuperLib_t *pLib, FILE *pFile)
DECLARATIONS ///.
int Map_LibraryRead(Map_SuperLib_t *pLib, char *pFileName)
FUNCTION DEFINITIONS ///.
static int Map_LibraryTruthVerify(Map_SuperLib_t *pLib, Map_Super_t *pGate)
char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
static void Map_LibraryPrintClasses(Map_SuperLib_t *p)
static void Map_LibraryComputeTruth_rec(Map_SuperLib_t *pLib, char *pFormula, unsigned uTruthsIn[][2], unsigned uTruthRes[])
static Map_Super_t * Map_LibraryReadGate(Map_SuperLib_t *pLib, char *pBuffer, int nVars)
#define ABC_NAMESPACE_IMPL_END
Extra_MmFixed_t * mmSupers
char * Map_LibraryReadFormulaStep(char *pFormula, char *pStrings[], int *pnStrings)
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
#define ABC_NAMESPACE_IMPL_START
int Map_CanonComputeSlow(unsigned uTruths[][2], int nVarsMax, int nVarsReal, unsigned uTruth[], unsigned char *puPhases, unsigned uTruthRes[])
FUNCTION DEFINITIONS ///.
void Map_LibraryPrintSupergate(Map_Super_t *pGate)
int Map_SuperTableInsertC(Map_HashTable_t *pLib, unsigned uTruthC[], Map_Super_t *pGate)
Map_HashTable_t * tTableC
static void Map_LibraryComputeTruth(Map_SuperLib_t *pLib, char *pFormula, unsigned uTruthRes[])