31 #define WLV_PRS_MAX_LINE 1000
53 #define Wlc_PrsForEachLine( p, pLine, i ) \
54 for ( i = 0; (i < Vec_IntSize((p)->vStarts)) && ((pLine) = Wlc_PrsStr(p, Vec_IntEntry((p)->vStarts, i))); i++ )
55 #define Wlc_PrsForEachLineStart( p, pLine, i, Start ) \
56 for ( i = Start; (i < Vec_IntSize((p)->vStarts)) && ((pLine) = Wlc_PrsStr(p, Vec_IntEntry((p)->vStarts, i))); i++ )
121 va_start( args, format );
131 int Entry, iLine = 0;
133 if ( Entry > pCur - p->
pBuffer )
144 fprintf( stdout,
"%s", p->
sError );
160 return (pStr[0] >=
'0' && pStr[0] <=
'9');
164 return (pStr[0] >=
'a' && pStr[0] <=
'z') ||
165 (pStr[0] >=
'A' && pStr[0] <=
'Z') ||
166 (pStr[0] >=
'0' && pStr[0] <=
'9') ||
167 pStr[0] ==
'_' || pStr[0] ==
'$' || pStr[0] ==
'\\';
171 while ( *pStr && *pStr ==
' ' )
178 for ( ; *pStr; pStr++ )
180 if ( fNotName && *pStr == Symb )
182 if ( pStr[0] ==
'\\' )
184 else if ( !fNotName && *pStr ==
' ' )
191 for ( ; pStr[1]; pStr++ )
192 if ( pStr[0] == Symb && pStr[1] == Symb2 )
201 for ( ; *pStr; pStr++ )
207 if ( *pStr == Close )
214 else if ( !fNotName && *pStr ==
' ' )
221 int fSpecifyFound = 0;
223 for ( pCur = p->
pBuffer; pCur < pEnd; pCur++ )
226 if ( *pCur ==
'/' && pCur[1] ==
'/' )
228 if ( pCur + 5 < pEnd && pCur[2] ==
'a' && pCur[3] ==
'b' && pCur[4] ==
'c' && pCur[5] ==
'2' )
229 pCur[0] = pCur[1] = pCur[2] = pCur[3] = pCur[4] = pCur[5] =
' ';
235 for ( ; pCur < pNext; pCur++ )
240 else if ( *pCur ==
'`' )
245 for ( ; pCur < pNext; pCur++ )
249 else if ( *pCur ==
'/' && pCur[1] ==
'*' )
255 for ( ; pCur < pNext + 2; pCur++ )
259 else if ( *pCur ==
's' && pCur[1] ==
'p' && pCur[2] ==
'e' && !
strncmp(pCur,
"specify", 7) )
261 for ( pNext = pCur; pNext < pEnd - 10; pNext++ )
262 if ( *pNext ==
'e' && pNext[1] ==
'n' && pNext[2] ==
'd' && !
strncmp(pNext,
"endspecify", 10) )
265 for ( ; pCur < pNext + 10; pCur++ )
267 if ( fSpecifyFound == 0 )
268 Abc_Print( 0,
"Ignoring specify/endspecify directives.\n" );
274 else if ( *pCur ==
'e' && pCur[1] ==
'n' && pCur[2] ==
'd' && !
strncmp(pCur,
"endmodule", 9) )
275 pCur[
strlen(
"endmodule")] =
';';
277 if ( *pCur ==
'\n' || *pCur ==
'\r' || *pCur ==
'\t' )
284 int fPrettyPrint = 0;
286 char * pTemp, * pPrev, * pThis;
289 for ( pTemp = p->
pBuffer; *pTemp; pTemp++ )
290 if ( *pTemp ==
'\n' )
297 for ( pPrev = pThis = p->
pBuffer; *pThis; pThis++ )
299 if ( fNotName && *pThis ==
';' )
305 if ( *pThis ==
'\\' )
307 else if ( !fNotName && *pThis ==
' ' )
321 printf(
"%c", pTemp[0] );
322 for ( k = 1; pTemp[k]; k++ )
323 if ( pTemp[k] !=
' ' || pTemp[k-1] !=
' ' )
324 printf(
"%c", pTemp[k] );
361 if (s == NULL && (s = last) == NULL)
366 for (spanp = delim; (sc = *spanp++) != 0;)
370 return (last = NULL);
390 if ((sc = *spanp++) == c)
420 if ( pStr[0] !=
'[' )
425 *End = *Beg = atoi( pStr );
453 return pStr +
strlen(pWord);
458 char * pThis = *ppPlace = Buffer;
471 else if ( !fNotName && *pStr ==
' ' )
480 int i, nDigits, nBits = atoi( pStr );
487 int Number = atoi( pStr );
496 if ( pStr[1] ==
's' )
501 if ( pStr[1] ==
'b' )
504 for ( i = 0; i < nBits; i++ )
505 if ( pStr[2+i] ==
'1' )
507 else if ( pStr[2+i] !=
'0' )
508 return (
char *)(ABC_PTRINT_T)
Wlc_PrsWriteErrorMessage( p, pStr,
"Wrong digit in binary constant \"%c\".", pStr[2+i] );
513 if ( pStr[1] !=
'h' )
514 return (
char *)(ABC_PTRINT_T)
Wlc_PrsWriteErrorMessage( p, pStr,
"Expecting hexadecimal constant and not \"%c\".", pStr[1] );
517 if ( nDigits != (nBits + 3)/4 )
530 int NameId, fFound, iObj;
574 if ( pStr[0] !=
'=' )
577 if ( pStr[0] ==
'(' )
584 if ( pClose == NULL )
586 *pStr =
' '; *pClose = 0;
593 if ( pClose == NULL )
595 *pStr = *pClose =
' ';
607 else if ( pStr[0] ==
'!' || pStr[0] ==
'~' )
609 if ( pStr[0] ==
'!' )
611 else if ( pStr[0] ==
'~' )
616 if ( pStr[0] ==
'(' )
619 if ( pClose == NULL )
621 *pStr = *pClose =
' ';
626 else if ( pStr[0] ==
'&' || pStr[0] ==
'|' || pStr[0] ==
'^' || pStr[0] ==
'-' )
628 if ( pStr[0] ==
'&' )
630 else if ( pStr[0] ==
'|' )
632 else if ( pStr[0] ==
'^' )
634 else if ( pStr[0] ==
'-' )
640 else if ( pStr[0] ==
'{' )
655 if ( pStr[0] !=
'}' )
665 if ( pStr[0] ==
'}' )
667 if ( pStr[0] !=
',' )
682 else if ( pStr[0] ==
'?' )
686 if ( pStr[0] !=
':' )
694 else if ( pStr[0] ==
'[' )
704 else if ( pStr[0] ==
'>' && pStr[1] ==
'>' && pStr[2] ==
'>' ) pStr += 3, Type =
WLC_OBJ_SHIFT_RA;
706 else if ( pStr[0] ==
'<' && pStr[1] ==
'<' && pStr[2] ==
'<' ) pStr += 3, Type =
WLC_OBJ_SHIFT_LA;
707 else if ( pStr[0] ==
'&' && pStr[1] !=
'&' ) pStr += 1, Type =
WLC_OBJ_BIT_AND;
708 else if ( pStr[0] ==
'|' && pStr[1] !=
'|' ) pStr += 1, Type =
WLC_OBJ_BIT_OR;
709 else if ( pStr[0] ==
'^' && pStr[1] !=
'^' ) pStr += 1, Type =
WLC_OBJ_BIT_XOR;
710 else if ( pStr[0] ==
'&' && pStr[1] ==
'&' ) pStr += 2, Type =
WLC_OBJ_LOGIC_AND;
711 else if ( pStr[0] ==
'|' && pStr[1] ==
'|' ) pStr += 2, Type =
WLC_OBJ_LOGIC_OR;
712 else if ( pStr[0] ==
'=' && pStr[1] ==
'=' ) pStr += 2, Type =
WLC_OBJ_COMP_EQU;
714 else if ( pStr[0] ==
'<' && pStr[1] !=
'=' ) pStr += 1, Type =
WLC_OBJ_COMP_LESS;
715 else if ( pStr[0] ==
'>' && pStr[1] !=
'=' ) pStr += 1, Type =
WLC_OBJ_COMP_MORE;
720 else if ( pStr[0] ==
'*' && pStr[1] !=
'*' ) pStr += 1, Type =
WLC_OBJ_ARI_MULTI;
723 else if ( pStr[0] ==
'*' && pStr[1] ==
'*' ) pStr += 2, Type =
WLC_OBJ_ARI_POWER;
741 int Signed = 0, Beg = 0, End = 0, NameId, fIsPo = 0;
745 pStart +=
strlen(
"output"), fIsPo = 1;
755 if ( pStart == NULL )
762 if ( pStart == NULL )
772 if ( pStart[0] ==
',' )
792 char * pStart, * pName;
810 pStart =
strstr( pStart,
"endmodule" );
811 if ( pStart != NULL )
819 int Width1 = -1, Width2 = -1;
820 int v, b, Value, nBits, nInts;
828 if ( pStart == NULL )
830 Width1 = atoi(pStart-1);
832 if ( pStart == NULL )
834 Width2 = atoi(pStart-1);
846 assert( Width1 == nBits );
850 memset( pTable, 0, nInts *
sizeof(
unsigned) );
852 for ( b = 0; b < Width2; b++ )
853 if ( (Value >> b) & 1 )
859 if ( p->
pNtk != NULL )
899 int Type, NameId, fFound;
900 pStart +=
strlen(
"assign");
903 if ( pStart == NULL )
922 int NameId, fFound, iTable = atoi( pStart +
strlen(
"table") );
925 if ( pStart == NULL )
929 if ( pStart == NULL )
940 if ( pStart == NULL )
944 if ( pStart == NULL )
956 int NameId, NameIdOut = -1, fFound;
959 if ( pStart == NULL )
963 if ( pStart == NULL )
966 if ( pStart == NULL )
969 if ( pStart == NULL )
981 if ( pStart == NULL )
985 if ( pStart == NULL )
992 if ( pStart == NULL )
997 if ( pStart == NULL )
1006 printf(
"Ignoring default in Line %d.\n", i );
1011 if ( pStart == NULL )
1015 if ( pStart == NULL )
1031 int NameId = -1, NameIdOut = -1, fFound, nBits = 1, fFlopOut;
1032 pStart +=
strlen(
"CPL_FF");
1033 if ( pStart[0] ==
'#' )
1034 nBits = atoi(pStart+1);
1039 if ( pStart == NULL )
1042 if ( pStart[0] !=
'd' && (pStart[0] !=
'q' || pStart[1] ==
'b') )
1044 fFlopOut = (pStart[0] ==
'd');
1046 if ( pStart == NULL )
1049 if ( pStart == NULL )
1058 if ( NameId == -1 || NameIdOut == -1 )
1065 printf(
"Warning! Flop input has bit-width (%d) that differs from the declaration (%d)\n", nBits,
Wlc_ObjRange(pObj) );
1070 printf(
"Warning! Flop output has bit-width (%d) that differs from the declaration (%d)\n", nBits,
Wlc_ObjRange(pObj) );
1072 else if ( pStart[0] !=
'`' )
#define Wlc_PrsForEachLineStart(p, pLine, i, Start)
static int * Vec_IntArray(Vec_Int_t *p)
static int Abc_TtReadHexNumber(word *pTruth, char *pString)
static int Wlc_PrsIsDigit(char *pStr)
int Wlc_PrsRemoveComments(Wlc_Prs_t *p)
char sError[WLV_PRS_MAX_LINE]
Wlc_Ntk_t * Wlc_NtkAlloc(char *pName, int nObjsAlloc)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
static char * Wlc_PrsReadConstant(Wlc_Prs_t *p, char *pStr, Vec_Int_t *vFanins, int *pRange, int *pSigned)
void Gia_ManStop(Gia_Man_t *p)
static char * Wlc_PrsSkipSpaces(char *pStr)
static char * Wlc_PrsFindClosingParanthesis(char *pStr, char Open, char Close)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
#define Wlc_PrsForEachLine(p, pLine, i)
static Wlc_Obj_t * Wlc_NtkObj(Wlc_Ntk_t *p, int Id)
void Wlc_PrsStop(Wlc_Prs_t *p)
void Wlc_NtkTransferNames(Wlc_Ntk_t *pNew, Wlc_Ntk_t *p)
int Wlc_PrsPrepare(Wlc_Prs_t *p)
static char * Wlc_PrsFindSymbol(char *pStr, char Symb)
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
static int Wlc_PrsFindDefinition(Wlc_Prs_t *p, char *pStr, Vec_Int_t *vFanins)
int Wlc_PrsWriteErrorMessage(Wlc_Prs_t *p, char *pCur, const char *format,...)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
void Wlc_WriteVer(Wlc_Ntk_t *p, char *pFileName)
static int Wlc_ObjRange(Wlc_Obj_t *p)
static Vec_Int_t * Vec_IntStartNatural(int nSize)
static int Wlc_PrsStrCmp(char *pStr, char *pWhat)
void Wlc_ObjUpdateType(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, int Type)
Abc_Nam_t * Abc_NamStart(int nObjs, int nAveSize)
FUNCTION DEFINITIONS ///.
#define ABC_SWAP(Type, a, b)
char * Mem_FlexEntryFetch(Mem_Flex_t *p, int nBytes)
int Wlc_ObjAlloc(Wlc_Ntk_t *p, int Type, int Signed, int End, int Beg)
int Wlc_PrsReadDeclaration(Wlc_Prs_t *p, char *pStart)
static char * Wlc_PrsFindSymbolTwo(char *pStr, char Symb, char Symb2)
Mem_Flex_t * Mem_FlexStart()
int Wlc_PrsDerive(Wlc_Prs_t *p)
#define Wlc_NtkForEachFf(p, pFf, i)
void Wlc_ObjSetCi(Wlc_Ntk_t *p, Wlc_Obj_t *pObj)
static char * Wlc_PrsReadName(Wlc_Prs_t *p, char *pStr, Vec_Int_t *vFanins)
void Wlc_PrsPrintErrorMessage(Wlc_Prs_t *p)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
char * vnsprintf(const char *format, va_list args)
char * Wlc_PrsStrtok(char *s, const char *delim)
static char * Wlc_PrsStr(Wlc_Prs_t *p, int iOffset)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
void Wlc_NtkFree(Wlc_Ntk_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Wlc_PrsOffset(Wlc_Prs_t *p, char *pStr)
static void Abc_Print(int level, const char *format,...)
void Gia_AigerWrite(Gia_Man_t *p, char *pFileName, int fWriteSymbols, int fCompact)
static char * Wlc_PrsFindName(char *pStr, char **ppPlace)
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Wlc_Prs_t * Wlc_PrsStart(char *pFileName)
FUNCTION DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
static void Abc_InfoSetBit(unsigned *p, int i)
#define WLV_PRS_MAX_LINE
DECLARATIONS ///.
Wlc_Ntk_t * Wlc_NtkDupDfs(Wlc_Ntk_t *p)
static char * Wlc_PrsFindWord(char *pStr, char *pWord, int *fFound)
Gia_Man_t * Wlc_NtkBitBlast(Wlc_Ntk_t *p, Vec_Int_t *vBoxIds)
static int Vec_IntSize(Vec_Int_t *p)
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Wlc_Ntk_t * Wlc_ReadVer(char *pFileName)
void Io_ReadWordTest(char *pFileName)
static int Abc_Base2Log(unsigned n)
void Wlc_ObjAddFanins(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, Vec_Int_t *vFanins)
#define ABC_CALLOC(type, num)
static int Wlc_PrsIsChar(char *pStr)
static void Vec_PtrFreeP(Vec_Ptr_t **p)
static int Wlc_NtkObjNumMax(Wlc_Ntk_t *p)
void Wlc_ObjSetCo(Wlc_Ntk_t *p, Wlc_Obj_t *pObj, int fFlopInput)
static int Abc_BitWordNum(int nBits)
static char * Wlc_PrsFindRange(char *pStr, int *End, int *Beg)
static void Vec_IntFree(Vec_Int_t *p)
static void Vec_IntClear(Vec_Int_t *p)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.