30 #define ABC_MAX_LIB_STR_LEN 5000
76 static inline void Amap_PrintSpace( FILE * pFile,
int nOffset ) {
int i;
for ( i = 0; i < nOffset; i++ ) fputc(
' ', pFile); }
79 #define Amap_ItemForEachChild( p, pItem, pChild ) \
80 for ( pChild = Amap_LibertyItem(p, pItem->Child); pChild; pChild = Amap_LibertyItem(p, pChild->Next) )
103 fprintf( pFile,
"(" );
105 fprintf( pFile,
") {\n" );
109 fprintf( pFile,
"}\n" );
115 fprintf( pFile,
" : " );
117 fprintf( pFile,
";\n" );
123 fprintf( pFile,
"(" );
125 fprintf( pFile,
");\n" );
146 if ( pFileName == NULL )
150 pFile = fopen( pFileName,
"w" );
153 printf(
"Amap_LibertyPrintLiberty(): The output file is unavailable (absent or open).\n" );
158 if ( pFile != stdout )
177 static char Buffer[100];
182 TimeStamp = asctime( localtime( <ime ) );
183 TimeStamp[
strlen(TimeStamp) - 1 ] = 0;
185 strcpy( Buffer, TimeStamp );
332 Buffer[Pair.
End-Pair.
Beg] = 0;
352 Buffer[Pair.
End-Pair.
Beg-2] = 0;
371 Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput;
374 if ( pFileName == NULL )
378 pFile = fopen( pFileName,
"w" );
381 printf(
"Amap_LibertyPrintGenlib(): The output file is unavailable (absent or open).\n" );
387 fprintf( pFile,
"# (To find out more about Genlib format, google for \"sis_paper.ps\")\n" );
389 fprintf( pFile,
"GATE " );
390 fprintf( pFile,
"%16s ",
"_const0_" );
391 fprintf( pFile,
"%f ", 0.0 );
392 fprintf( pFile,
"%s=",
"z" );
393 fprintf( pFile,
"%s;\n",
"CONST0" );
395 fprintf( pFile,
"GATE " );
396 fprintf( pFile,
"%16s ",
"_const1_" );
397 fprintf( pFile,
"%f ", 0.0 );
398 fprintf( pFile,
"%s=",
"z" );
399 fprintf( pFile,
"%s;\n",
"CONST1" );
421 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n",
Amap_LibertyGetString(p, pCell->
Head) );
436 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n",
Amap_LibertyGetString(p, pCell->
Head) );
448 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n",
Amap_LibertyGetString(p, pCell->
Head), pForm );
451 fprintf( pFile,
"GATE " );
462 if ( pFile != stdout )
483 Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput;
505 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n",
Amap_LibertyGetString(p, pCell->
Head) );
512 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n",
Amap_LibertyGetString(p, pCell->
Head) );
523 printf(
"Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n",
Amap_LibertyGetString(p, pCell->
Head), pForm );
578 pFile = fopen( pFileName,
"rb" );
581 printf(
"Amap_LibertyFileSize(): The input file is unavailable (absent or open).\n" );
585 nFileSize = ftell( pFile );
604 for ( pHead = pFileName; *pHead; pHead++ )
623 for ( ; pBeg < pEnd; pBeg++ )
624 Counter += (*pBeg ==
'(' || *pBeg ==
':');
641 char * pCur, * pStart;
642 for ( pCur = pBeg; pCur < pEnd; pCur++ )
643 if ( pCur[0] ==
'/' && pCur[1] ==
'*' )
644 for ( pStart = pCur; pCur < pEnd; pCur++ )
645 if ( pCur[0] ==
'*' && pCur[1] ==
'/' )
647 for ( ; pStart < pCur + 2; pStart++ )
648 if ( *pStart !=
'\n' ) *pStart =
' ';
666 return c ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n' || c ==
'\\';
682 char * pPos = *ppPos;
683 for ( ; pPos < pEnd; pPos++ )
688 if ( fStopAtNewLine )
711 char * pPos = *ppPos;
714 for ( pPos++; pPos < pEnd; pPos++ )
723 for ( ; pPos < pEnd; pPos++ )
724 if ( *pPos ==
' ' || *pPos ==
'\r' || *pPos ==
'\n' || *pPos ==
'\t' ||
725 *pPos ==
':' || *pPos ==
';' ||
726 *pPos ==
'(' || *pPos ==
')' ||
727 *pPos ==
'{' || *pPos ==
'}' )
748 assert( *pPos ==
'(' || *pPos ==
'{' );
751 for ( ; pPos < pEnd; pPos++ )
763 for ( ; pPos < pEnd; pPos++ )
773 assert( *pPos ==
')' || *pPos ==
'}' );
793 char * pFirstNonSpace = NULL;
794 char * pLastNonSpace = NULL;
796 for ( pChar = pBeg; pChar < pEnd; pChar++ )
798 if ( *pChar ==
'\n' )
802 pLastNonSpace = pChar;
803 if ( pFirstNonSpace == NULL )
804 pFirstNonSpace = pChar;
806 if ( pFirstNonSpace == NULL || pLastNonSpace == NULL )
808 assert( pFirstNonSpace && pLastNonSpace );
849 char * pNext, * pStop;
872 if ( *pNext !=
';' && *pNext !=
'\n' )
880 if ( pItem->
Next == -1 )
911 if ( pItem->
Child == -1 )
915 if ( pItem->
Next == -1 )
926 if ( pItem->
Next == -1 )
934 sprintf( p->
pError,
"File \"%s\". Line %6d. Failed to parse entry \"%s\".\n",
967 pFile = fopen( pFileName,
"rb" );
1026 printf(
"Parsing finished successfully.\n" );
1034 printf(
"%s", p->
pError );
1036 printf(
"Parsing failed.\n" );
1074 printf(
"Parsing finished successfully.\n" );
1082 printf(
"%s", p->
pError );
1084 printf(
"Parsing failed.\n" );
int Amap_LibertyPrintGenlib(Amap_Tree_t *p, char *pFileName, int fVerbose)
int Amap_LibertyCountItems(char *pBeg, char *pEnd)
static int Amap_LibertyCompare(Amap_Tree_t *p, Amap_Pair_t Pair, char *pStr)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
int Amap_LibertyFileSize(char *pFileName)
void Amap_LibertyStop(Amap_Tree_t *p)
int Amap_LibertyCellCountOutputs(Amap_Tree_t *p, Amap_Item_t *pCell)
static void Amap_PrintSpace(FILE *pFile, int nOffset)
Amap_Item_t * Amap_LibertyPinFunction(Amap_Tree_t *p, Amap_Item_t *pPin)
Vec_Str_t * Amap_LibertyParseStr(char *pFileName, int fVerbose)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
#define ABC_ALLOC(type, num)
static Vec_Str_t * Vec_StrAlloc(int nCap)
static abctime Abc_Clock()
static void Vec_StrPush(Vec_Str_t *p, char Entry)
#define ABC_MAX_LIB_STR_LEN
DECLARATIONS ///.
static char * Amap_LibertyFindMatch(char *pPos, char *pEnd)
static int Vec_PtrFind(Vec_Ptr_t *p, void *Entry)
static int Amap_LibertySkipEntry(char **ppPos, char *pEnd)
int Amap_LibertyPrintLiberty(Amap_Tree_t *p, char *pFileName)
static Amap_Item_t * Amap_LibertyNewItem(Amap_Tree_t *p, int Type)
void Amap_LibertyWipeOutComments(char *pBeg, char *pEnd)
char * Amap_LibertyGetString(Amap_Tree_t *p, Amap_Pair_t Pair)
#define ABC_NAMESPACE_IMPL_END
void Amap_LibertyPrintLibertyItem(FILE *pFile, Amap_Tree_t *p, Amap_Item_t *pItem, int nOffset)
FUNCTION DEFINITIONS ///.
Vec_Str_t * Amap_LibertyPrintGenlibStr(Amap_Tree_t *p, int fVerbose)
#define Amap_ItemForEachChild(p, pItem, pChild)
int Amap_LibertyParse(char *pFileName, int fVerbose)
Amap_Item_t * Amap_LibertyCellOutput(Amap_Tree_t *p, Amap_Item_t *pCell)
#define ABC_NAMESPACE_IMPL_START
char * Amap_LibertyGetStringFormula(Amap_Tree_t *p, Amap_Pair_t Pair)
int Amap_LibertyBuildItem(Amap_Tree_t *p, char **ppPos, char *pEnd)
Vec_Ptr_t * Amap_LibertyCellOutputs(Amap_Tree_t *p, Amap_Item_t *pCell)
static int Amap_LibertyCharIsSpace(char c)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
char * Amap_LibertyTimeStamp()
Amap_Tree_t * Amap_LibertyStart(char *pFileName)
static int Amap_LibertySkipSpaces(Amap_Tree_t *p, char **ppPos, char *pEnd, int fStopAtNewLine)
#define ABC_CALLOC(type, num)
static int Amap_LibertyItemId(Amap_Tree_t *p, Amap_Item_t *pItem)
int Amap_LibertyCellIsFlop(Amap_Tree_t *p, Amap_Item_t *pCell)
void Amap_LibertyFixFileHead(char *pFileName)
static void Vec_StrPrintStr(Vec_Str_t *p, const char *pStr)
static void Amap_PrintWord(FILE *pFile, Amap_Tree_t *p, Amap_Pair_t Pair)
static Amap_Pair_t Amap_LibertyUpdateHead(Amap_Tree_t *p, Amap_Pair_t Head)
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
char * Abc_UtilStrsav(char *s)
Amap_Item_t * Amap_LibertyCellArea(Amap_Tree_t *p, Amap_Item_t *pCell)
static Amap_Item_t * Amap_LibertyItem(Amap_Tree_t *p, int v)
static void Vec_PtrFree(Vec_Ptr_t *p)
static Amap_Item_t * Amap_LibertyRoot(Amap_Tree_t *p)