31 #define AMAP_STRING_GATE "GATE"
32 #define AMAP_STRING_PIN "PIN"
33 #define AMAP_STRING_NONINV "NONINV"
34 #define AMAP_STRING_INV "INV"
35 #define AMAP_STRING_UNKNOWN "UNKNOWN"
38 #define AMAP_SYMB_AND '*'
39 #define AMAP_SYMB_OR1 '+'
40 #define AMAP_SYMB_OR2 '|'
41 #define AMAP_SYMB_XOR '^'
42 #define AMAP_SYMB_NOT '!'
43 #define AMAP_SYMB_AFTNOT '\''
44 #define AMAP_SYMB_OPEN '('
45 #define AMAP_SYMB_CLOSE ')'
81 pFile =
Io_FileOpen( pFileName,
"open_path",
"rb", 1 );
87 printf(
"Cannot open file \"%s\".\n", pFileName );
93 nFileSize = ftell( pFile );
97 pBuffer =
ABC_ALLOC(
char, nFileSize + 10 );
98 RetValue = fread( pBuffer, nFileSize, 1, pFile );
100 pBuffer[ nFileSize ] =
'\0';
101 strcat( pBuffer,
"\n.end\n" );
127 for ( pCur = pBuffer; *pCur; pCur++ )
132 while ( *pCur !=
'\n' )
136 if ( *pCur ==
'\n' ) {
137 if (*(pCur-1)==
'\r') {
139 if (*(pCur-2)!=
'\\') nLines++;
148 if (*(pCur-1)!=
'\\') nLines++;
156 else if ( *pCur ==
'.' )
181 pToken =
strtok( pBuffer,
" =\t\r\n" );
185 pToken =
strtok( NULL,
" =\t\r\n" );
187 if ( pToken &&
strcmp( pToken,
"LATCH" ) == 0 )
188 while ( pToken &&
strcmp( pToken,
"GATE" ) != 0 )
189 pToken =
strtok( NULL,
" =\t\r\n" );
236 for ( pTemp = Buffer; *pTemp; pTemp++ )
243 pTemp =
strtok( Buffer,
" " );
246 for ( i = 0; i < nPins; i++ )
247 if (
strcmp( pTemp, pPinNames[i] ) == 0 )
254 pTemp =
strtok( NULL,
" " );
274 char * pPinNames[128];
280 pGate->
nPins = nPinNames;
284 pPin->
pName = pPinNames[pPin - pGate->
Pins];
302 char * pNext, * pPrev;
303 pPrev = pToken +
strlen(pToken);
304 while ( *(pPrev-1) !=
';' )
331 char * pToken, * pMoGate = NULL;
332 int i, nPins, iPos = 0, Count = 0;
350 pGate->
nPins = nPins;
368 printf(
"Cannot parse gate %s.\n", pGate->
pName );
384 printf(
"Cannot read phase of pin %s of gate %s\n", pPin->
pName, pGate->
pName );
414 while (
strcmp( pToken,
".end" ) );
420 if ( pPrev && !
strcmp(pPrev->pName, pGate->pName) )
422 pPrev->pTwin = pGate, pGate->pTwin = pPrev;
424 if ( pMoGate == NULL )
425 pMoGate = pGate->pName;
431 printf(
"Warning: Detected %d multi-output gates (for example, \"%s\").\n", Count, pMoGate );
478 if ( pBuffer == NULL )
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Amap_LibForEachGate(pLib, pGate, i)
#define AMAP_STRING_UNKNOWN
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
#define Amap_GateForEachPin(pGate, pPin)
Amap_Lib_t * Amap_ParseTokens(Vec_Ptr_t *vTokens, int fVerbose)
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
int Amap_ParseCountPins(Vec_Ptr_t *vTokens, int iPos)
Amap_Lib_t * Amap_LibAlloc()
DECLARATIONS ///.
char * Amap_LoadFile(char *pFileName)
FUNCTION DEFINITIONS ///.
static Amap_Gat_t * Amap_ParseGateAlloc(Aig_MmFlex_t *p, int nPins)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Amap_Gat_t * Amap_ParseGateWithSamePins(Amap_Gat_t *p)
#define ABC_ALLOC(type, num)
int Amap_GateCollectNames(Aig_MmFlex_t *pMem, char *pForm, char *pPinNames[])
static int Vec_PtrSize(Vec_Ptr_t *p)
static void * Vec_PtrPop(Vec_Ptr_t *p)
Amap_Lib_t * Amap_LibReadFile(char *pFileName, int fVerbose)
static char * Amap_ParseStrsav(Aig_MmFlex_t *p, char *pStr)
void Amap_LibFree(Amap_Lib_t *p)
#define ABC_NAMESPACE_IMPL_END
#define ABC_NAMESPACE_IMPL_START
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
int Amap_CollectFormulaTokens(Vec_Ptr_t *vTokens, char *pToken, int iPos)
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Vec_Ptr_t * Amap_DeriveTokens(char *pBuffer)
#define AMAP_STRING_NONINV
void Amap_RemoveComments(char *pBuffer, int *pnDots, int *pnLines)
char * Abc_UtilStrsav(char *s)
Amap_Lib_t * Amap_LibReadBuffer(char *pBuffer, int fVerbose)
#define AMAP_STRING_GATE
DECLARATIONS ///.
static void Vec_PtrFree(Vec_Ptr_t *p)