#include "cba.h"
#include "cbaPrs.h"
Go to the source code of this file.
|
enum | Cba_VerType_t {
CBA_VER_NONE = 0,
CBA_VER_MODULE,
CBA_VER_INOUT,
CBA_VER_INPUT,
CBA_VER_OUTPUT,
CBA_VER_WIRE,
CBA_VER_ASSIGN,
CBA_VER_REG,
CBA_VER_ALWAYS,
CBA_VER_DEFPARAM,
CBA_VER_BEGIN,
CBA_VER_END,
CBA_VER_ENDMODULE,
CBA_VER_UNKNOWN
} |
| DECLARATIONS ///. More...
|
|
|
static void | Cba_PrsAddVerilogDirectives (Cba_Prs_t *p) |
|
static int | Cba_IsSpace (char c) |
|
static int | Cba_IsDigit (char c) |
|
static int | Cba_IsDigitB (char c) |
|
static int | Cba_IsDigitH (char c) |
|
static int | Cba_IsChar (char c) |
|
static int | Cba_IsSymb1 (char c) |
|
static int | Cba_IsSymb2 (char c) |
|
static int | Cba_PrsIsChar (Cba_Prs_t *p, char c) |
|
static int | Cba_PrsIsChar1 (Cba_Prs_t *p, char c) |
|
static int | Cba_PrsIsDigit (Cba_Prs_t *p) |
|
static int | Cba_PrsIsKnownModule (Cba_Prs_t *p, char *pName) |
|
static int | Cba_PrsUtilSkipComments (Cba_Prs_t *p) |
|
static int | Cba_PrsUtilSkipName (Cba_Prs_t *p) |
|
static int | Cba_PrsUtilSkipSpaces (Cba_Prs_t *p) |
|
static int | Cba_PrsUtilSkipUntil (Cba_Prs_t *p, char c) |
|
static int | Cba_PrsUtilSkipUntilWord (Cba_Prs_t *p, char *pWord) |
|
static int | Cba_PrsReadName (Cba_Prs_t *p) |
|
static int | Cba_PrsReadConstant (Cba_Prs_t *p) |
|
static int | Cba_PrsReadRange (Cba_Prs_t *p) |
|
static int | Cba_PrsReadSignal (Cba_Prs_t *p, int *pName, int *pRange) |
|
static int | Cba_PrsReadSignalList (Cba_Prs_t *p, Vec_Int_t *vTemp, char LastSymb) |
|
static int | Cba_PrsReadConcat (Cba_Prs_t *p, Vec_Int_t *vTemp2) |
|
static int | Cba_PrsReadSignalOrConcat (Cba_Prs_t *p, int *pName, int *pRange) |
|
static int | Cba_PrsReadSignalList1 (Cba_Prs_t *p, Vec_Int_t *vTemp) |
|
static int | Cba_PrsReadSignalList2 (Cba_Prs_t *p, Vec_Int_t *vTemp) |
|
static int | Cba_PrsReadDeclaration (Cba_Prs_t *p, int Type) |
|
static int | Cba_PrsReadAssign (Cba_Prs_t *p) |
|
static int | Cba_PrsReadInstance (Cba_Prs_t *p, int Func) |
|
static int | Cba_PrsReadModule (Cba_Prs_t *p) |
|
static int | Cba_PrsReadDesign (Cba_Prs_t *p) |
|
void | Cba_PrsPrintModules (Cba_Prs_t *p) |
|
Cba_Man_t * | Cba_PrsReadVerilog (char *pFileName) |
|
void | Cba_PrsReadVerilogTest (char *pFileName) |
|
DECLARATIONS ///.
CFile****************************************************************
FileName [cbaReadVer.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [Verilog parser.]
Synopsis [Parses several flavors of word-level Verilog.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - November 29, 2014.]
Revision [
- Id:
- cbaReadVer.c,v 1.00 2014/11/29 00:00:00 alanmi Exp
]
Enumerator |
---|
CBA_VER_NONE |
|
CBA_VER_MODULE |
|
CBA_VER_INOUT |
|
CBA_VER_INPUT |
|
CBA_VER_OUTPUT |
|
CBA_VER_WIRE |
|
CBA_VER_ASSIGN |
|
CBA_VER_REG |
|
CBA_VER_ALWAYS |
|
CBA_VER_DEFPARAM |
|
CBA_VER_BEGIN |
|
CBA_VER_END |
|
CBA_VER_ENDMODULE |
|
CBA_VER_UNKNOWN |
|
Definition at line 31 of file cbaReadVer.c.
Cba_VerType_t
DECLARATIONS ///.
static int Cba_IsChar |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 79 of file cbaReadVer.c.
79 {
return (c >=
'a' && c <=
'z') || (c >=
'A' && c <=
'Z'); }
static int Cba_IsDigit |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 76 of file cbaReadVer.c.
76 {
return (c >=
'0' && c <=
'9'); }
static int Cba_IsDigitB |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 77 of file cbaReadVer.c.
77 {
return (c ==
'0' || c ==
'1' || c ==
'x' || c ==
'z'); }
static int Cba_IsDigitH |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 78 of file cbaReadVer.c.
78 {
return (c >=
'0' && c <=
'9') || (c >=
'A' && c <= 'F') || (c >=
'a' && c <=
'f'); }
static int Cba_IsSpace |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 75 of file cbaReadVer.c.
75 {
return (c ==
' ' || c ==
'\t' || c ==
'\r' || c ==
'\n'); }
static int Cba_IsSymb1 |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 80 of file cbaReadVer.c.
static int Cba_IsChar(char c)
static int Cba_IsSymb2 |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 81 of file cbaReadVer.c.
static int Cba_IsDigit(char c)
static int Cba_IsSymb1(char c)
static void Cba_PrsAddVerilogDirectives |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 65 of file cbaReadVer.c.
int Abc_NamObjNumMax(Abc_Nam_t *p)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
const char * s_VerTypes[CBA_VER_UNKNOWN+1]
static int Cba_PrsIsChar |
( |
Cba_Prs_t * |
p, |
|
|
char |
c |
|
) |
| |
|
inlinestatic |
static int Cba_PrsIsChar1 |
( |
Cba_Prs_t * |
p, |
|
|
char |
c |
|
) |
| |
|
inlinestatic |
Definition at line 85 of file cbaReadVer.c.
static int Cba_IsDigit(char c)
static int Cba_PrsIsKnownModule |
( |
Cba_Prs_t * |
p, |
|
|
char * |
pName |
|
) |
| |
|
inlinestatic |
Definition at line 138 of file cbaReadVer.c.
const char * s_KnownModules[100]
FUNCTION DEFINITIONS ///.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 686 of file cbaReadVer.c.
691 printf( " %s", pName );
693 printf( "Skipped %d known models:\n",
Vec_IntSize(&p->vKnown) );
695 printf( " %s", pName );
697 printf( "Skipped %d failed models:\n",
Vec_IntSize(&p->vFailed) );
699 printf( " %s", pName );
static int Vec_IntSize(Vec_Int_t *p)
#define Cba_PrsForEachModelVec(vVec, p, pName, i)
static int Cba_PrsReadAssign |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 477 of file cbaReadVer.c.
479 int OutName = 0, InName = 0, RangeId = 0, fCompl = 0, Oper = 0;
483 if ( OutName == 0 )
return Cba_PrsErrorSet(p,
"Cannot read output in assign-statement.", 0);
496 if ( InName == 0 )
return Cba_PrsErrorSet(p,
"Cannot read first input name in the assign-statement.", 0);
516 else return Cba_PrsErrorSet(p,
"Unrecognized operator in the assign-statement.", 0);
520 if ( InName == 0 )
return Cba_PrsErrorSet(p,
"Cannot read second input name in the assign-statement.", 0);
531 if ( InName == 0 )
return Cba_PrsErrorSet(p,
"Cannot read third input name in the assign-statement.", 0);
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static void Vec_IntClear(Vec_Int_t *p)
Definition at line 357 of file cbaReadVer.c.
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
static int Vec_WecSize(Vec_Wec_t *p)
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Vec_IntSize(Vec_Int_t *p)
static int Cba_PrsReadSignalList(Cba_Prs_t *p, Vec_Int_t *vTemp, char LastSymb)
static int Cba_PrsReadConstant |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 264 of file cbaReadVer.c.
266 char * pStart = p->
pCur;
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_IsDigitH(char c)
static int Cba_PrsIsDigit(Cba_Prs_t *p)
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_IsDigitB(char c)
static int Cba_PrsReadDeclaration |
( |
Cba_Prs_t * |
p, |
|
|
int |
Type |
|
) |
| |
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 461 of file cbaReadVer.c.
463 int NameId, RangeId, RangeIdTemp, i;
472 if ( RangeIdTemp )
return Cba_PrsErrorSet(p,
"Range is specified twice in the declaration.", 0);
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static int Cba_PrsReadRange(Cba_Prs_t *p)
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsReadSignalList(Cba_Prs_t *p, Vec_Int_t *vTemp, char LastSymb)
static int Cba_PrsReadDesign |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 655 of file cbaReadVer.c.
static int Cba_PrsReadModule(Cba_Prs_t *p)
static int Cba_PrsReadInstance |
( |
Cba_Prs_t * |
p, |
|
|
int |
Func |
|
) |
| |
|
inlinestatic |
Definition at line 543 of file cbaReadVer.c.
546 int InstId, Status, Type;
558 if ( Status == 0 )
return 0;
563 if ( iFuncNew == 0 )
return Cba_PrsErrorSet(p,
"Cannot find elementary gate.", 0);
static int Cba_PrsReadSignalList2(Cba_Prs_t *p, Vec_Int_t *vTemp)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Cba_PrsReadSignalList1(Cba_Prs_t *p, Vec_Int_t *vTemp)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsReadName(Cba_Prs_t *p)
static void Vec_IntClear(Vec_Int_t *p)
static int Cba_PrsIsKnownModule(Cba_Prs_t *p, char *pName)
static int Cba_PrsReadModule |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 576 of file cbaReadVer.c.
650 if ( !Status )
return 4;
653 return Cba_PrsErrorSet(p,
"Cannot find \";\" in the module definition.", 4);
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsReadInstance(Cba_Prs_t *p, int Func)
static int Cba_PrsUtilSkipUntil(Cba_Prs_t *p, char c)
static int Cba_PrsReadAssign(Cba_Prs_t *p)
static int Cba_PrsUtilSkipUntilWord(Cba_Prs_t *p, char *pWord)
static void Vec_WecZero(Vec_Wec_t *p)
static void Cba_PrsErrorClear(Cba_Prs_t *p)
static int Cba_PrsReadDeclaration(Cba_Prs_t *p, int Type)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static Cba_Ntk_t * Cba_PrsAddCurrentModel(Cba_Prs_t *p, int iNameId)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsReadName(Cba_Prs_t *p)
static void Vec_IntClear(Vec_Int_t *p)
static int Cba_PrsIsKnownModule(Cba_Prs_t *p, char *pName)
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 245 of file cbaReadVer.c.
247 char * pStart = p->
pCur;
static int Cba_IsSymb2(char c)
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
static int Cba_IsSymb1(char c)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition at line 293 of file cbaReadVer.c.
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static char * Vec_StrArray(Vec_Str_t *p)
static void Vec_StrClear(Vec_Str_t *p)
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
static void Vec_StrPush(Vec_Str_t *p, char Entry)
static int Cba_PrsIsDigit(Cba_Prs_t *p)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsReadSignal |
( |
Cba_Prs_t * |
p, |
|
|
int * |
pName, |
|
|
int * |
pRange |
|
) |
| |
|
inlinestatic |
Definition at line 317 of file cbaReadVer.c.
319 *pName = *pRange = 0;
324 if ( *pName == 0 )
return 0;
336 if ( *pRange == 0 )
return 0;
static int Cba_PrsReadRange(Cba_Prs_t *p)
static int Cba_PrsIsDigit(Cba_Prs_t *p)
static int Cba_PrsReadConstant(Cba_Prs_t *p)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition at line 340 of file cbaReadVer.c.
347 if ( NameId == 0 )
return Cba_PrsErrorSet(p,
"Cannot read signal in the list.", 0);
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Vec_IntSize(Vec_Int_t *p)
static void Vec_IntClear(Vec_Int_t *p)
Definition at line 396 of file cbaReadVer.c.
403 if ( NameId == 0 )
return Cba_PrsErrorSet(p,
"Cannot read signal or concatenation in the list.", 0);
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Vec_IntSize(Vec_Int_t *p)
static int Cba_PrsReadSignalOrConcat(Cba_Prs_t *p, int *pName, int *pRange)
static void Vec_IntClear(Vec_Int_t *p)
Definition at line 416 of file cbaReadVer.c.
418 int FormId, NameId, RangeId;
425 if ( FormId == 0 )
return Cba_PrsErrorSet(p,
"Cannot read formal name of the instance.", 0);
426 if ( RangeId != 0 )
return Cba_PrsErrorSet(p,
"Formal signal cannot have range.", 0);
431 if ( NameId == 0 )
return Cba_PrsErrorSet(p,
"Cannot read actual name of the instance.", 0);
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Vec_IntSize(Vec_Int_t *p)
static int Cba_PrsReadSignalOrConcat(Cba_Prs_t *p, int *pName, int *pRange)
static void Vec_IntClear(Vec_Int_t *p)
static int Cba_PrsReadSignalOrConcat |
( |
Cba_Prs_t * |
p, |
|
|
int * |
pName, |
|
|
int * |
pRange |
|
) |
| |
|
inlinestatic |
Definition at line 378 of file cbaReadVer.c.
384 if ( Status == 0 )
return 0;
392 if ( *pName == 0 )
return Cba_PrsErrorSet(p,
"Cannot read formal name in the list.", 0);
static int Cba_PrsReadConcat(Cba_Prs_t *p, Vec_Int_t *vTemp2)
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Cba_Man_t* Cba_PrsReadVerilog |
( |
char * |
pFileName | ) |
|
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 714 of file cbaReadVer.c.
void Cba_PrsPrintModules(Cba_Prs_t *p)
static int Cba_PrsReadDesign(Cba_Prs_t *p)
#define ABC_SWAP(Type, a, b)
static Cba_Prs_t * Cba_PrsAlloc(char *pFileName)
static int Cba_PrsErrorPrint(Cba_Prs_t *p)
static void Cba_PrsFree(Cba_Prs_t *p)
static void Cba_PrsAddVerilogDirectives(Cba_Prs_t *p)
void Cba_PrsReadVerilogTest |
( |
char * |
pFileName | ) |
|
Definition at line 729 of file cbaReadVer.c.
737 printf(
"Finished reading %d networks. ",
Cba_ManNtkNum(p) );
739 printf(
"Memory = %.2f MB. ", 1.0*
Cba_ManMemory(p)/(1<<20) );
void Cba_PrsWriteVerilog(char *pFileName, Cba_Man_t *pDes)
int Abc_NamObjNumMax(Abc_Nam_t *p)
static abctime Abc_Clock()
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static void Cba_ManFree(Cba_Man_t *p)
static int Cba_ManMemory(Cba_Man_t *p)
Cba_Man_t * Cba_PrsReadVerilog(char *pFileName)
static int Cba_ManNtkNum(Cba_Man_t *p)
static int Cba_PrsUtilSkipComments |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 161 of file cbaReadVer.c.
169 { p->
pCur++;
return 1; }
static int Cba_PrsIsChar1(Cba_Prs_t *p, char c)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsUtilSkipName |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 179 of file cbaReadVer.c.
185 { p->
pCur++;
return 1; }
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsUtilSkipSpaces |
( |
Cba_Prs_t * |
p | ) |
|
|
inlinestatic |
Definition at line 190 of file cbaReadVer.c.
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
static int Cba_IsSpace(char c)
static int Cba_PrsUtilSkipComments(Cba_Prs_t *p)
static int Cba_PrsUtilSkipUntil |
( |
Cba_Prs_t * |
p, |
|
|
char |
c |
|
) |
| |
|
inlinestatic |
Definition at line 204 of file cbaReadVer.c.
static int Cba_PrsUtilSkipName(Cba_Prs_t *p)
static int Cba_PrsUtilSkipComments(Cba_Prs_t *p)
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
static int Cba_PrsUtilSkipUntilWord |
( |
Cba_Prs_t * |
p, |
|
|
char * |
pWord |
|
) |
| |
|
inlinestatic |
Definition at line 219 of file cbaReadVer.c.
222 if ( pPlace == NULL )
return 1;
const char* s_KnownModules[100] |
FUNCTION DEFINITIONS ///.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 104 of file cbaReadVer.c.
Initial value:= {
NULL,
"module",
"inout",
"input",
"output",
"wire",
"assign",
"reg",
"always",
"defparam",
"begin",
"end",
"endmodule",
NULL
}
Definition at line 48 of file cbaReadVer.c.