39 static char *
chomp(
char *s );
70 fprintf ( stdout,
"Read %d gates from exclude file\n", num );
73 if ( pBuffer == NULL )
83 if ( pBuffer == NULL )
92 printf (
"Warning: Read extended genlib format but ignoring extensions\n" );
119 pFile =
Io_FileOpen( FileName,
"open_path",
"rb", 1 );
126 nFileSize = ftell( pFile );
130 pBuffer =
ABC_ALLOC(
char, nFileSize + 10 );
131 RetValue = fread( pBuffer, nFileSize, 1, pFile );
133 pBuffer[ nFileSize ] =
'\0';
135 strcat( pBuffer,
"\n.end\n" );
174 printf(
"Mio_LibraryRead: Had problems parsing formulas.\n" );
205 if ( pBuffer == NULL )
237 pToken =
strtok( pBuffer,
" \t\r\n" );
247 pToken =
strtok( NULL,
" \t\r\n" );
248 printf(
"Skipping latch \"%s\"...\n", pToken );
251 pToken =
strtok( NULL,
" \t\r\n" );
284 ppGate = &pGate->
pNext;
293 if ( pBase->
pTwin != NULL )
295 printf(
"Gates with more than 2 outputs are not supported.\n" );
298 pBase->
pTwin = pGate;
299 pGate->
pTwin = pBase;
307 printf(
"The library contains no gates.\n" );
312 if ( pToken &&
strcmp( pToken,
".end" ) != 0 )
316 printf(
"Actually excluded %d cells\n", nDel );
336 char * pToken = *ppToken;
342 pToken =
strtok( NULL,
" \t\r\n" );
346 pToken =
strtok( NULL,
" \t\r\n" );
352 pToken =
strtok( NULL,
"=" );
356 pToken =
strtok( NULL,
";" );
362 ppPin = &pGate->
pPins;
365 pToken =
strtok( NULL,
" \t\r\n" );
378 ppPin = &pPin->
pNext;
380 pToken =
strtok( NULL,
" \t\r\n" );
403 char * pToken = *ppToken;
409 pToken =
strtok( NULL,
" \t\r\n" );
413 pToken =
strtok( NULL,
" \t\r\n" );
422 printf(
"Cannot read pin phase specification\n" );
428 pToken =
strtok( NULL,
" \t\r\n" );
431 pToken =
strtok( NULL,
" \t\r\n" );
434 pToken =
strtok( NULL,
" \t\r\n" );
437 pToken =
strtok( NULL,
" \t\r\n" );
440 pToken =
strtok( NULL,
" \t\r\n" );
443 pToken =
strtok( NULL,
" \t\r\n" );
446 if ( fExtendedFormat )
454 pToken =
strtok( NULL,
" \t" );
458 pToken =
strtok( NULL,
" \t\r\n" );
487 for ( b = s; *b; b++ )
493 for ( c = a+
strlen(a); c > a; c-- )
494 if ( *c == 0 || isspace(*c) )
514 double Diff = (*pp1)->dArea - (*pp2)->dArea;
535 int Diff =
strcmp( (*pp1)->pName, (*pp2)->pName );
560 ppGates[i++] = pGate;
564 for ( i = 0; i < pLib->
nGates; i++ )
566 qsort( (
void *)ppGates, pLib->
nGates,
sizeof(
void *),
568 for ( i = 0; i < pLib->
nGates; i++ )
569 ppGates[i]->pNext = (i < pLib->nGates-1)? ppGates[i+1] : NULL;
570 pLib->
pGates = ppGates[0];
574 for ( i = 0; i < pLib->
nGates; i++ )
593 if ( pNew->
uTruth != uTruth )
604 word uFuncBuf, uFuncInv, uFuncNand2, uFuncAnd2;
608 uFuncBuf =
ABC_CONST(0xAAAAAAAAAAAAAAAA);
610 uFuncInv = ~uFuncBuf;
611 uFuncNand2 = ~uFuncAnd2;
618 printf(
"Warnings: genlib library reader cannot detect the buffer gate.\n" );
619 printf(
"Some parts of the supergate-based technology mapper may not work correctly.\n" );
627 printf(
"Warnings: genlib library reader cannot detect the invertor gate.\n" );
628 printf(
"Some parts of the supergate-based technology mapper may not work correctly.\n" );
638 printf(
"Warnings: genlib library reader cannot detect the AND2 or NAND2 gate.\n" );
639 printf(
"Some parts of the supergate-based technology mapper may not work correctly.\n" );
664 pEx = fopen( ExcludeFile,
"r" );
668 fprintf ( stdout,
"Error: Could not open exclude file %s. Stop.\n", ExcludeFile );
672 while (1 == fscanf( pEx,
"%127s", buffer ))
705 for ( pCur = pBuffer; *pCur; pCur++ )
710 while ( *pCur !=
'\n' )
714 if ( *pCur ==
'\n' ) {
715 if (*(pCur-1)==
'\r') {
717 if (*(pCur-2)!=
'\\') nLines++;
726 if (*(pCur-1)!=
'\\') nLines++;
734 else if ( *pCur ==
'.' )
int Mio_LibraryParseFormulas(Mio_Library_t *pLib)
FUNCTION DEFINITIONS ///.
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
void st__free_table(st__table *table)
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
int Mio_ParseCheckFormula(Mio_Gate_t *pGate, char *pForm)
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
int st__insert(st__table *table, const char *key, char *value)
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
static char * chomp(char *s)
#define ABC_ALLOC(type, num)
static Vec_Str_t * Vec_StrAlloc(int nCap)
char * Mio_ReadFile(char *FileName, int fAddEnd)
#define st__is_member(table, key)
int Mio_LibraryCompareGatesByArea(Mio_Gate_t **pp1, Mio_Gate_t **pp2)
void Mio_GateDelete(Mio_Gate_t *pGate)
void Mio_LibrarySortGates(Mio_Library_t *pLib)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
#define MIO_STRING_UNKNOWN
int Mio_LibraryReadExclude(char *ExcludeFile, st__table *tExcludeGate)
void Mio_PinDelete(Mio_Pin_t *pPin)
int st__strhash(const char *string, int modulus)
Mem_Flex_t * Mem_FlexStart()
#define MIO_STRING_GATE
INCLUDES ///.
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static Mio_Gate_t * Mio_LibraryReadGate(char **ppToken, int fExtendedFormat)
STRUCTURE DEFINITIONS ///.
int Mio_LibraryCompareGatesByName(Mio_Gate_t **pp1, Mio_Gate_t **pp2)
static void Mio_LibraryDetectSpecialGates(Mio_Library_t *pLib)
#define ABC_NAMESPACE_IMPL_START
static Mio_Pin_t * Mio_LibraryReadPin(char **ppToken, int fExtendedFormat)
static Mio_Library_t * Mio_LibraryReadBuffer(char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
static ABC_NAMESPACE_IMPL_START Mio_Library_t * Mio_LibraryReadOne(char *FileName, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
DECLARATIONS ///.
#define ABC_CONST(number)
PARAMETERS ///.
static int Mio_LibraryReadInternal(Mio_Library_t *pLib, char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
#define ABC_CALLOC(type, num)
static Mio_Gate_t * Mio_GateCompare(Mio_Gate_t *pThis, Mio_Gate_t *pNew, word uTruth)
Mio_Gate_t ** ppGatesName
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
char * Abc_UtilStrsav(char *s)
#define MIO_STRING_NONINV
static void Io_ReadFileRemoveComments(char *pBuffer, int *pnDots, int *pnLines)