abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cbaReadVer.c File Reference
#include "cba.h"
#include "cbaPrs.h"

Go to the source code of this file.

Enumerations

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...
 

Functions

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_tCba_PrsReadVerilog (char *pFileName)
 
void Cba_PrsReadVerilogTest (char *pFileName)
 

Variables

const char * s_VerTypes [CBA_VER_UNKNOWN+1]
 
const char * s_KnownModules [100]
 FUNCTION DEFINITIONS ///. More...
 

Enumeration Type Documentation

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.

31  {
32  CBA_VER_NONE = 0, // 0: unused
33  CBA_VER_MODULE, // 1: module
34  CBA_VER_INOUT, // 2: inout
35  CBA_VER_INPUT, // 3: input
36  CBA_VER_OUTPUT, // 4: output
37  CBA_VER_WIRE, // 5: wire
38  CBA_VER_ASSIGN, // 6: assign
39  CBA_VER_REG, // 7: reg
40  CBA_VER_ALWAYS, // 8: always
41  CBA_VER_DEFPARAM, // 9: always
42  CBA_VER_BEGIN, // 10: begin
43  CBA_VER_END, // 11: end
44  CBA_VER_ENDMODULE, // 12: endmodule
45  CBA_VER_UNKNOWN // 13: unknown
Cba_VerType_t
DECLARATIONS ///.
Definition: cbaReadVer.c:31

Function Documentation

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.

80 { return Cba_IsChar(c) || c == '_'; }
static int Cba_IsChar(char c)
Definition: cbaReadVer.c:79
static int Cba_IsSymb2 ( char  c)
inlinestatic

Definition at line 81 of file cbaReadVer.c.

81 { return Cba_IsSymb1(c) || Cba_IsDigit(c) || c == '$'; }
static int Cba_IsDigit(char c)
Definition: cbaReadVer.c:76
static int Cba_IsSymb1(char c)
Definition: cbaReadVer.c:80
static void Cba_PrsAddVerilogDirectives ( Cba_Prs_t p)
inlinestatic

Definition at line 65 of file cbaReadVer.c.

66 {
67  int i;
68  for ( i = 1; s_VerTypes[i]; i++ )
69  Abc_NamStrFindOrAdd( p->pDesign->pNames, (char *)s_VerTypes[i], NULL );
71 }
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition: utilNam.c:392
Abc_Nam_t * pNames
Definition: cba.h:87
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
const char * s_VerTypes[CBA_VER_UNKNOWN+1]
Definition: cbaReadVer.c:48
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsIsChar ( Cba_Prs_t p,
char  c 
)
inlinestatic

Definition at line 83 of file cbaReadVer.c.

83 { return *p->pCur == c; }
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsChar1 ( Cba_Prs_t p,
char  c 
)
inlinestatic

Definition at line 84 of file cbaReadVer.c.

84 { return p->pCur[1] == c; }
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsDigit ( Cba_Prs_t p)
inlinestatic

Definition at line 85 of file cbaReadVer.c.

85 { return Cba_IsDigit(*p->pCur); }
static int Cba_IsDigit(char c)
Definition: cbaReadVer.c:76
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsKnownModule ( Cba_Prs_t p,
char *  pName 
)
inlinestatic

Definition at line 138 of file cbaReadVer.c.

139 {
140  int i;
141  for ( i = 1; s_KnownModules[i]; i++ )
142  if ( !strncmp(pName, s_KnownModules[i], strlen(s_KnownModules[i])) )
143  return i;
144  return 0;
145 }
const char * s_KnownModules[100]
FUNCTION DEFINITIONS ///.
Definition: cbaReadVer.c:104
int strncmp()
int strlen()
void Cba_PrsPrintModules ( Cba_Prs_t p)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 686 of file cbaReadVer.c.

687 {
688  char * pName; int i;
689  printf( "Succeeded parsing %d models:\n", Vec_IntSize(&p->vSucceeded) );
690  Cba_PrsForEachModelVec( &p->vSucceeded, p, pName, i )
691  printf( " %s", pName );
692  printf( "\n" );
693  printf( "Skipped %d known models:\n", Vec_IntSize(&p->vKnown) );
694  Cba_PrsForEachModelVec( &p->vKnown, p, pName, i )
695  printf( " %s", pName );
696  printf( "\n" );
697  printf( "Skipped %d failed models:\n", Vec_IntSize(&p->vFailed) );
698  Cba_PrsForEachModelVec( &p->vFailed, p, pName, i )
699  printf( " %s", pName );
700  printf( "\n" );
701 }
Vec_Int_t vSucceeded
Definition: cbaPrs.h:79
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define Cba_PrsForEachModelVec(vVec, p, pName, i)
Definition: cbaPrs.h:84
static int Cba_PrsReadAssign ( Cba_Prs_t p)
inlinestatic

Definition at line 477 of file cbaReadVer.c.

478 {
479  int OutName = 0, InName = 0, RangeId = 0, fCompl = 0, Oper = 0;
480  Vec_IntClear( &p->vTemp );
481  // read output name
482  if ( !Cba_PrsReadSignal(p, &OutName, &RangeId) ) return 0;
483  if ( OutName == 0 ) return Cba_PrsErrorSet(p, "Cannot read output in assign-statement.", 0);
484  if ( !Cba_PrsIsChar(p, '=') ) return Cba_PrsErrorSet(p, "Expecting \"=\" in assign-statement.", 0);
485  p->pCur++;
486  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
487  if ( Cba_PrsIsChar(p, '~') )
488  {
489  fCompl = 1;
490  p->pCur++;
491  }
492  Vec_IntPush( &p->vTemp, OutName );
493  Vec_IntPush( &p->vTemp, RangeId );
494  // read first name
495  if ( !Cba_PrsReadSignal(p, &InName, &RangeId)) return 0;
496  if ( InName == 0 ) return Cba_PrsErrorSet(p, "Cannot read first input name in the assign-statement.", 0);
497  Vec_IntPush( &p->vTemp, InName );
498  Vec_IntPush( &p->vTemp, RangeId );
499  // check unary operator
500  if ( Cba_PrsIsChar(p, ';') )
501  {
503  Vec_IntPush( &p->vFuncsCur, fCompl ? CBA_NODE_INV : CBA_NODE_BUF );
504  Vec_IntPush( &p->vInstIdsCur, 0 );
506  return 1;
507  }
508  if ( Cba_PrsIsChar(p, '&') )
509  Oper = CBA_NODE_AND;
510  else if ( Cba_PrsIsChar(p, '|') )
511  Oper = CBA_NODE_OR;
512  else if ( Cba_PrsIsChar(p, '^') )
513  Oper = fCompl ? CBA_NODE_XNOR : CBA_NODE_XOR;
514  else if ( Cba_PrsIsChar(p, '?') )
515  Oper = CBA_NODE_MUX;
516  else return Cba_PrsErrorSet(p, "Unrecognized operator in the assign-statement.", 0);
517  p->pCur++;
518  // read second name
519  if ( !Cba_PrsReadSignal(p, &InName, &RangeId)) return 0;
520  if ( InName == 0 ) return Cba_PrsErrorSet(p, "Cannot read second input name in the assign-statement.", 0);
521  Vec_IntPush( &p->vTemp, InName );
522  Vec_IntPush( &p->vTemp, RangeId );
523  // read third argument
524  if ( Oper == CBA_NODE_MUX )
525  {
526  assert( fCompl == 0 );
527  if ( !Cba_PrsIsChar(p, ':') ) return Cba_PrsErrorSet(p, "Expected colon in the MUX assignment.", 0);
528  p->pCur++;
529  // read third name
530  if ( !Cba_PrsReadSignal(p, &InName, &RangeId)) return 0;
531  if ( InName == 0 ) return Cba_PrsErrorSet(p, "Cannot read third input name in the assign-statement.", 0);
532  Vec_IntPush( &p->vTemp, InName );
533  Vec_IntPush( &p->vTemp, RangeId );
534  if ( !Cba_PrsIsChar(p, ';') ) return Cba_PrsErrorSet(p, "Expected semicolon at the end of the assign-statement.", 0);
535  }
536  // write binary operator
538  Vec_IntPush( &p->vFuncsCur, Oper );
539  Vec_IntPush( &p->vInstIdsCur, 0 );
541  return 1;
542 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
Vec_Int_t vTypesCur
Definition: cbaPrs.h:68
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:317
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
Vec_Int_t vFuncsCur
Definition: cbaPrs.h:69
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
Definition: cbaPrs.h:116
char * pCur
Definition: cbaPrs.h:57
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
Vec_Int_t vInstIdsCur
Definition: cbaPrs.h:70
Vec_Int_t vTemp
Definition: cbaPrs.h:74
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadConcat ( Cba_Prs_t p,
Vec_Int_t vTemp2 
)
inlinestatic

Definition at line 357 of file cbaReadVer.c.

358 {
359  assert( Cba_PrsIsChar(p, '{') );
360  p->pCur++;
361  if ( !Cba_PrsReadSignalList(p, vTemp2, '}') ) return 0;
362  // check final
363  assert( Cba_PrsIsChar(p, '}') );
364  p->pCur++;
365  // return special case
366  if ( Vec_IntSize(vTemp2) == 2 ) return -1; // trivial concatentation
367  assert( Vec_IntSize(vTemp2) > 2 );
368  assert( Vec_IntSize(vTemp2) % 2 == 0 );
369  // create new concatentation
371  Vec_IntPush( &p->vFuncsCur, 0 );
372  Vec_IntPush( &p->vInstIdsCur, 0 );
374  // return the result
375  assert( Vec_WecSize(&p->vFaninsCur) > 0 );
376  return Vec_WecSize(&p->vFaninsCur);
377 }
Vec_Int_t vTypesCur
Definition: cbaPrs.h:68
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Vec_WecSize(Vec_Wec_t *p)
Definition: vecWec.h:193
Vec_Int_t vFuncsCur
Definition: cbaPrs.h:69
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
Definition: cbaPrs.h:116
char * pCur
Definition: cbaPrs.h:57
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t vInstIdsCur
Definition: cbaPrs.h:70
static int Cba_PrsReadSignalList(Cba_Prs_t *p, Vec_Int_t *vTemp, char LastSymb)
Definition: cbaReadVer.c:340
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsReadConstant ( Cba_Prs_t p)
inlinestatic

Definition at line 264 of file cbaReadVer.c.

265 {
266  char * pStart = p->pCur;
267  assert( Cba_PrsIsDigit(p) );
268  while ( Cba_PrsIsDigit(p) )
269  p->pCur++;
270  if ( !Cba_PrsIsChar(p, '\'') ) return Cba_PrsErrorSet(p, "Cannot read constant.", 0);
271  p->pCur++;
272  if ( Cba_PrsIsChar(p, 'b') )
273  {
274  p->pCur++;
275  while ( Cba_IsDigitB(*p->pCur) )
276  p->pCur++;
277  }
278  else if ( Cba_PrsIsChar(p, 'h') )
279  {
280  p->pCur++;
281  while ( Cba_IsDigitH(*p->pCur) )
282  p->pCur++;
283  }
284  else if ( Cba_PrsIsChar(p, 'd') )
285  {
286  p->pCur++;
287  while ( Cba_PrsIsDigit(p) )
288  p->pCur++;
289  }
290  else return Cba_PrsErrorSet(p, "Cannot read radix of constant.", 0);
291  return Abc_NamStrFindOrAddLim( p->pDesign->pNames, pStart, p->pCur, NULL );
292 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_IsDigitH(char c)
Definition: cbaReadVer.c:78
Abc_Nam_t * pNames
Definition: cba.h:87
static int Cba_PrsIsDigit(Cba_Prs_t *p)
Definition: cbaReadVer.c:85
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
Definition: utilNam.c:431
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
#define assert(ex)
Definition: util_old.h:213
static int Cba_IsDigitB(char c)
Definition: cbaReadVer.c:77
static int Cba_PrsReadDeclaration ( Cba_Prs_t p,
int  Type 
)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 461 of file cbaReadVer.c.

462 {
463  int NameId, RangeId, RangeIdTemp, i;
464  Vec_Int_t * vSigs[4] = { &p->vInoutsCur, &p->vInputsCur, &p->vOutputsCur, &p->vWiresCur };
465  assert( Type >= CBA_VER_INOUT && Type <= CBA_VER_WIRE );
466  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
467  RangeId = 0;
468  if ( Cba_PrsIsChar(p, '[') && !(RangeId = Cba_PrsReadRange(p)) ) return 0;
469  if ( !Cba_PrsReadSignalList( p, &p->vTemp, ';' ) ) return 0;
470  Vec_IntForEachEntryDouble( &p->vTemp, NameId, RangeIdTemp, i )
471  {
472  if ( RangeIdTemp ) return Cba_PrsErrorSet(p, "Range is specified twice in the declaration.", 0);
473  Vec_IntPushTwo( vSigs[Type - CBA_VER_INOUT], NameId, RangeId );
474  }
475  return 1;
476 }
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
Definition: vecInt.h:701
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static int Cba_PrsReadRange(Cba_Prs_t *p)
Definition: cbaReadVer.c:293
Vec_Int_t vInoutsCur
Definition: cbaPrs.h:63
Vec_Int_t vInputsCur
Definition: cbaPrs.h:64
Vec_Int_t vWiresCur
Definition: cbaPrs.h:66
Vec_Int_t vOutputsCur
Definition: cbaPrs.h:65
#define Vec_IntForEachEntryDouble(vVec, Entry1, Entry2, i)
Definition: vecInt.h:66
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Cba_PrsReadSignalList(Cba_Prs_t *p, Vec_Int_t *vTemp, char LastSymb)
Definition: cbaReadVer.c:340
Vec_Int_t vTemp
Definition: cbaPrs.h:74
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsReadDesign ( Cba_Prs_t p)
inlinestatic

Definition at line 655 of file cbaReadVer.c.

656 {
657  while ( 1 )
658  {
659  int RetValue = Cba_PrsReadModule( p );
660  if ( RetValue == 0 ) // end of file
661  break;
662  if ( RetValue == 1 ) // successfully parsed
663  continue;
664  if ( RetValue == 2 ) // recognized as primitive
665  continue;
666  if ( RetValue == 3 ) // failed and skipped
667  continue;
668  if ( RetValue == 4 ) // error
669  return 0;
670  assert( 0 );
671  }
672  return 1;
673 }
static int Cba_PrsReadModule(Cba_Prs_t *p)
Definition: cbaReadVer.c:576
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsReadInstance ( Cba_Prs_t p,
int  Func 
)
inlinestatic

Definition at line 543 of file cbaReadVer.c.

544 {
545  // have to assign Type, Func, InstId, vFanins
546  int InstId, Status, Type;
547  Vec_IntClear( &p->vTemp );
548  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
549  InstId = Cba_PrsReadName( p );
550  if ( InstId && Cba_PrsUtilSkipSpaces(p) ) return 0;
551  if ( !Cba_PrsIsChar(p, '(') ) return Cba_PrsErrorSet(p, "Expecting \"(\" in module instantiation.", 0);
552  p->pCur++;
553  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
554  if ( Cba_PrsIsChar(p, '.') ) // node
555  Status = Cba_PrsReadSignalList2(p, &p->vTemp), Type = CBA_PRS_BOX;
556  else
557  Status = Cba_PrsReadSignalList1(p, &p->vTemp), Type = CBA_PRS_NODE;
558  if ( Status == 0 ) return 0;
559  // translate elementary gate
560  if ( Type == CBA_PRS_NODE )
561  {
562  int iFuncNew = Cba_PrsIsKnownModule(p, Abc_NamStr(p->pDesign->pNames, Func));
563  if ( iFuncNew == 0 ) return Cba_PrsErrorSet(p, "Cannot find elementary gate.", 0);
564  Func = iFuncNew;
565  }
566  // assign
567  Vec_IntPush( &p->vTypesCur, Type );
568  Vec_IntPush( &p->vFuncsCur, Func );
569  Vec_IntPush( &p->vInstIdsCur, InstId );
571  return 1;
572 }
static int Cba_PrsReadSignalList2(Cba_Prs_t *p, Vec_Int_t *vTemp)
Definition: cbaReadVer.c:416
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
Vec_Int_t vTypesCur
Definition: cbaPrs.h:68
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
Abc_Nam_t * pNames
Definition: cba.h:87
Vec_Int_t vFuncsCur
Definition: cbaPrs.h:69
static void Cba_PrsSetupVecInt(Cba_Prs_t *p, Vec_Int_t *vTo, Vec_Int_t *vFrom)
Definition: cbaPrs.h:116
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
char * pCur
Definition: cbaPrs.h:57
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Cba_PrsReadSignalList1(Cba_Prs_t *p, Vec_Int_t *vTemp)
Definition: cbaReadVer.c:396
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
Vec_Int_t vInstIdsCur
Definition: cbaPrs.h:70
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadVer.c:245
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsIsKnownModule(Cba_Prs_t *p, char *pName)
Definition: cbaReadVer.c:138
static int Cba_PrsReadModule ( Cba_Prs_t p)
inlinestatic

Definition at line 576 of file cbaReadVer.c.

577 {
578  int iToken, Status;
579  if ( p->iModuleName != 0 ) return Cba_PrsErrorSet(p, "Parsing previous module is unfinished.", 4);
580  if ( Cba_PrsUtilSkipSpaces(p) )
581  {
582  Cba_PrsErrorClear( p );
583  return 0;
584  }
585  // read keyword
586  iToken = Cba_PrsReadName( p );
587  if ( iToken != CBA_VER_MODULE ) return Cba_PrsErrorSet(p, "Cannot read \"module\" keyword.", 4);
588  if ( Cba_PrsUtilSkipSpaces(p) ) return 4;
589  // read module name
590  p->iModuleName = Cba_PrsReadName( p );
591  if ( p->iModuleName == 0 ) return Cba_PrsErrorSet(p, "Cannot read module name.", 4);
593  {
594  if ( Cba_PrsUtilSkipUntilWord( p, "endmodule" ) ) return Cba_PrsErrorSet(p, "Cannot find \"endmodule\" keyword.", 4);
595  //printf( "Warning! Skipped known module \"%s\".\n", Abc_NamStr(p->pDesign->pNames, p->iModuleName) );
596  Vec_IntPush( &p->vKnown, p->iModuleName );
597  p->iModuleName = 0;
598  return 2;
599  }
600  // skip arguments
601  if ( Cba_PrsUtilSkipSpaces(p) ) return 4;
602  if ( !Cba_PrsIsChar(p, '(') ) return Cba_PrsErrorSet(p, "Cannot find \"(\" in the argument declaration.", 4);
603  if ( !Cba_PrsUtilSkipUntil(p,')') ) return 4;
604  assert( *p->pCur == ')' );
605  p->pCur++;
606  if ( Cba_PrsUtilSkipSpaces(p) ) return 4;
607  // read declarations and instances
608  while ( Cba_PrsIsChar(p, ';') )
609  {
610  p->pCur++;
611  if ( Cba_PrsUtilSkipSpaces(p) ) return 4;
612  iToken = Cba_PrsReadName( p );
613  if ( iToken == CBA_VER_ENDMODULE )
614  {
617  p->iModuleName = 0;
618  return 1;
619  }
620  if ( iToken >= CBA_VER_INOUT && iToken <= CBA_VER_WIRE ) // declaration
621  Status = Cba_PrsReadDeclaration( p, iToken );
622  else if ( iToken == CBA_VER_REG || iToken == CBA_VER_DEFPARAM ) // unsupported keywords
623  Status = Cba_PrsUtilSkipUntil( p, ';' );
624  else // read instance
625  {
626  if ( iToken == CBA_VER_ASSIGN )
627  Status = Cba_PrsReadAssign( p );
628  else
629  Status = Cba_PrsReadInstance( p, iToken );
630  if ( Status == 0 )
631  {
632  if ( Cba_PrsUtilSkipUntilWord( p, "endmodule" ) ) return Cba_PrsErrorSet(p, "Cannot find \"endmodule\" keyword.", 4);
633  //printf( "Warning! Failed to parse \"%s\". Adding module \"%s\" as blackbox.\n",
634  // Abc_NamStr(p->pDesign->pNames, iToken), Abc_NamStr(p->pDesign->pNames, p->iModuleName) );
635  Vec_IntPush( &p->vFailed, p->iModuleName );
636  // cleanup
637  Vec_IntClear( &p->vWiresCur );
638  ABC_FREE( p->vFaninsCur.pArray );
639  Vec_WecZero( &p->vFaninsCur );
640  Vec_IntClear( &p->vTypesCur );
641  Vec_IntClear( &p->vFuncsCur );
642  Vec_IntClear( &p->vInstIdsCur );
643  // add
645  Cba_PrsErrorClear( p );
646  p->iModuleName = 0;
647  return 3;
648  }
649  }
650  if ( !Status ) return 4;
651  if ( Cba_PrsUtilSkipSpaces(p) ) return 4;
652  }
653  return Cba_PrsErrorSet(p, "Cannot find \";\" in the module definition.", 4);
654 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadInstance(Cba_Prs_t *p, int Func)
Definition: cbaReadVer.c:543
Vec_Int_t vTypesCur
Definition: cbaPrs.h:68
Vec_Int_t vKnown
Definition: cbaPrs.h:77
Vec_Int_t vSucceeded
Definition: cbaPrs.h:79
static int Cba_PrsUtilSkipUntil(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:204
static int Cba_PrsReadAssign(Cba_Prs_t *p)
Definition: cbaReadVer.c:477
static int Cba_PrsUtilSkipUntilWord(Cba_Prs_t *p, char *pWord)
Definition: cbaReadVer.c:219
Abc_Nam_t * pNames
Definition: cba.h:87
Vec_Int_t vFailed
Definition: cbaPrs.h:78
static void Vec_WecZero(Vec_Wec_t *p)
Definition: vecWec.h:330
int iModuleName
Definition: cbaPrs.h:62
Vec_Int_t vFuncsCur
Definition: cbaPrs.h:69
static void Cba_PrsErrorClear(Cba_Prs_t *p)
Definition: cbaPrs.h:99
static int Cba_PrsReadDeclaration(Cba_Prs_t *p, int Type)
Definition: cbaReadVer.c:461
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
Vec_Int_t vWiresCur
Definition: cbaPrs.h:66
char * pCur
Definition: cbaPrs.h:57
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
static Cba_Ntk_t * Cba_PrsAddCurrentModel(Cba_Prs_t *p, int iNameId)
Definition: cbaPrs.h:125
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
Vec_Int_t vInstIdsCur
Definition: cbaPrs.h:70
#define ABC_FREE(obj)
Definition: abc_global.h:232
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadVer.c:245
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsIsKnownModule(Cba_Prs_t *p, char *pName)
Definition: cbaReadVer.c:138
static int Cba_PrsReadName ( Cba_Prs_t p)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file cbaReadVer.c.

246 {
247  char * pStart = p->pCur;
248  if ( Cba_PrsIsChar(p, '\\') ) // escaped name
249  {
250  pStart = ++p->pCur;
251  while ( !Cba_PrsIsChar(p, ' ') )
252  p->pCur++;
253  }
254  else if ( Cba_IsSymb1(*p->pCur) ) // simple name
255  {
256  p->pCur++;
257  while ( Cba_IsSymb2(*p->pCur) )
258  p->pCur++;
259  }
260  else
261  return 0;
262  return Abc_NamStrFindOrAddLim( p->pDesign->pNames, pStart, p->pCur, NULL );
263 }
static int Cba_IsSymb2(char c)
Definition: cbaReadVer.c:81
Abc_Nam_t * pNames
Definition: cba.h:87
int Abc_NamStrFindOrAddLim(Abc_Nam_t *p, char *pStr, char *pLim, int *pfFound)
Definition: utilNam.c:431
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
char * pCur
Definition: cbaPrs.h:57
static int Cba_IsSymb1(char c)
Definition: cbaReadVer.c:80
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Cba_PrsReadRange ( Cba_Prs_t p)
inlinestatic

Definition at line 293 of file cbaReadVer.c.

294 {
295  assert( Cba_PrsIsChar(p, '[') );
296  Vec_StrClear( &p->vCover );
297  Vec_StrPush( &p->vCover, *p->pCur++ );
298  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
299  if ( !Cba_PrsIsDigit(p) ) return Cba_PrsErrorSet(p, "Cannot read digit in range specification.", 0);
300  while ( Cba_PrsIsDigit(p) )
301  Vec_StrPush( &p->vCover, *p->pCur++ );
302  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
303  if ( Cba_PrsIsChar(p, ':') )
304  {
305  Vec_StrPush( &p->vCover, *p->pCur++ );
306  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
307  if ( !Cba_PrsIsDigit(p) ) return Cba_PrsErrorSet(p, "Cannot read digit in range specification.", 0);
308  while ( Cba_PrsIsDigit(p) )
309  Vec_StrPush( &p->vCover, *p->pCur++ );
310  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
311  }
312  if ( !Cba_PrsIsChar(p, ']') ) return Cba_PrsErrorSet(p, "Cannot read closing brace in range specification.", 0);
313  Vec_StrPush( &p->vCover, *p->pCur++ );
314  Vec_StrPush( &p->vCover, '\0' );
315  return Abc_NamStrFindOrAdd( p->pDesign->pNames, Vec_StrArray(&p->vCover), NULL );
316 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
int Abc_NamStrFindOrAdd(Abc_Nam_t *p, char *pStr, int *pfFound)
Definition: utilNam.c:392
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
Abc_Nam_t * pNames
Definition: cba.h:87
static int Cba_PrsIsDigit(Cba_Prs_t *p)
Definition: cbaReadVer.c:85
Vec_Str_t vCover
Definition: cbaPrs.h:73
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsReadSignal ( Cba_Prs_t p,
int *  pName,
int *  pRange 
)
inlinestatic

Definition at line 317 of file cbaReadVer.c.

318 {
319  *pName = *pRange = 0;
320  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
321  if ( Cba_PrsIsDigit(p) )
322  {
323  *pName = Cba_PrsReadConstant(p);
324  if ( *pName == 0 ) return 0;
325  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
326  *pRange = -1;
327  return 1;
328  }
329  *pName = Cba_PrsReadName( p );
330  if ( *pName == 0 )
331  return 1;
332  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
333  if ( !Cba_PrsIsChar(p, '[') )
334  return 1;
335  *pRange = Cba_PrsReadRange(p);
336  if ( *pRange == 0 ) return 0;
337  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
338  return 1;
339 }
static int Cba_PrsReadRange(Cba_Prs_t *p)
Definition: cbaReadVer.c:293
static int Cba_PrsIsDigit(Cba_Prs_t *p)
Definition: cbaReadVer.c:85
static int Cba_PrsReadConstant(Cba_Prs_t *p)
Definition: cbaReadVer.c:264
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadVer.c:245
static int Cba_PrsReadSignalList ( Cba_Prs_t p,
Vec_Int_t vTemp,
char  LastSymb 
)
inlinestatic

Definition at line 340 of file cbaReadVer.c.

341 {
342  Vec_IntClear( vTemp );
343  while ( 1 )
344  {
345  int NameId, RangeId;
346  if ( !Cba_PrsReadSignal(p, &NameId, &RangeId) ) return 0;
347  if ( NameId == 0 ) return Cba_PrsErrorSet(p, "Cannot read signal in the list.", 0);
348  Vec_IntPushTwo( vTemp, NameId, RangeId );
349  if ( Cba_PrsIsChar(p, LastSymb) ) break;
350  if ( !Cba_PrsIsChar(p, ',') ) return Cba_PrsErrorSet(p, "Expecting comma in the list.", 0);
351  p->pCur++;
352  }
353  assert( Vec_IntSize(vTemp) > 0 );
354  assert( Vec_IntSize(vTemp) % 2 == 0 );
355  return 1;
356 }
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
Definition: vecInt.h:701
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:317
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadSignalList1 ( Cba_Prs_t p,
Vec_Int_t vTemp 
)
inlinestatic

Definition at line 396 of file cbaReadVer.c.

397 {
398  Vec_IntClear( vTemp );
399  while ( 1 )
400  {
401  int NameId, RangeId;
402  if ( !Cba_PrsReadSignalOrConcat(p, &NameId, &RangeId) ) return 0;
403  if ( NameId == 0 ) return Cba_PrsErrorSet(p, "Cannot read signal or concatenation in the list.", 0);
404  Vec_IntPushTwo( vTemp, NameId, RangeId );
405  if ( Cba_PrsIsChar(p, ')') ) break;
406  if ( !Cba_PrsIsChar(p, ',') ) return Cba_PrsErrorSet(p, "Expecting comma in the list.", 0);
407  p->pCur++;
408  }
409  p->pCur++;
410  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
411  if ( !Cba_PrsIsChar(p, ';') ) return Cba_PrsErrorSet(p, "Expecting semicolon in the instance.", 0);
412  assert( Vec_IntSize(vTemp) > 0 );
413  assert( Vec_IntSize(vTemp) % 2 == 0 );
414  return 1;
415 }
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
Definition: vecInt.h:701
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Cba_PrsReadSignalOrConcat(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:378
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadSignalList2 ( Cba_Prs_t p,
Vec_Int_t vTemp 
)
inlinestatic

Definition at line 416 of file cbaReadVer.c.

417 {
418  int FormId, NameId, RangeId;
419  Vec_IntClear( vTemp );
420  assert( Cba_PrsIsChar(p, '.') );
421  while ( Cba_PrsIsChar(p, '.') )
422  {
423  p->pCur++;
424  if ( !Cba_PrsReadSignal(p, &FormId, &RangeId) ) return 0;
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);
427  if ( !Cba_PrsIsChar(p, '(') ) return Cba_PrsErrorSet(p, "Cannot read \"(\" in the instance.", 0);
428  p->pCur++;
429  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
430  if ( !Cba_PrsReadSignalOrConcat(p, &NameId, &RangeId) ) return 0;
431  if ( NameId == 0 ) return Cba_PrsErrorSet(p, "Cannot read actual name of the instance.", 0);
432  if ( !Cba_PrsIsChar(p, ')') ) return Cba_PrsErrorSet(p, "Cannot read \")\" in the instance.", 0);
433  p->pCur++;
434  Vec_IntPush( vTemp, FormId );
435  Vec_IntPushTwo( vTemp, NameId, RangeId );
436  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
437  if ( Cba_PrsIsChar(p, ')') ) break;
438  if ( !Cba_PrsIsChar(p, ',') ) return Cba_PrsErrorSet(p, "Expecting comma in the instance.", 0);
439  p->pCur++;
440  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
441  }
442  p->pCur++;
443  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
444  if ( !Cba_PrsIsChar(p, ';') ) return Cba_PrsErrorSet(p, "Expecting semicolon in the instance.", 0);
445  assert( Vec_IntSize(vTemp) > 0 );
446  assert( Vec_IntSize(vTemp) % 3 == 0 );
447  return 1;
448 }
static void Vec_IntPushTwo(Vec_Int_t *p, int Entry1, int Entry2)
Definition: vecInt.h:701
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:317
char * pCur
Definition: cbaPrs.h:57
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Cba_PrsReadSignalOrConcat(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:378
#define assert(ex)
Definition: util_old.h:213
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadSignalOrConcat ( Cba_Prs_t p,
int *  pName,
int *  pRange 
)
inlinestatic

Definition at line 378 of file cbaReadVer.c.

379 {
380  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
381  if ( Cba_PrsIsChar(p, '{') )
382  {
383  int Status = Cba_PrsReadConcat(p, &p->vTemp2);
384  if ( Status == 0 ) return 0;
385  *pName = Status == -1 ? Vec_IntEntry( &p->vTemp2, 0 ) : Status;
386  *pRange = Status == -1 ? Vec_IntEntry( &p->vTemp2, 1 ) : -2;
387  if ( Cba_PrsUtilSkipSpaces(p) ) return 0;
388  }
389  else
390  {
391  if ( !Cba_PrsReadSignal(p, pName, pRange) ) return 0;
392  if ( *pName == 0 ) return Cba_PrsErrorSet(p, "Cannot read formal name in the list.", 0);
393  }
394  return 1;
395 }
static int Cba_PrsReadConcat(Cba_Prs_t *p, Vec_Int_t *vTemp2)
Definition: cbaReadVer.c:357
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadSignal(Cba_Prs_t *p, int *pName, int *pRange)
Definition: cbaReadVer.c:317
Vec_Int_t vTemp2
Definition: cbaPrs.h:75
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
static int Cba_PrsUtilSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadVer.c:190
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
Cba_Man_t* Cba_PrsReadVerilog ( char *  pFileName)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 714 of file cbaReadVer.c.

715 {
716  Cba_Man_t * pDesign = NULL;
717  Cba_Prs_t * p = Cba_PrsAlloc( pFileName );
718  if ( p == NULL )
719  return NULL;
721  Cba_PrsReadDesign( p );
722  Cba_PrsPrintModules( p );
723  if ( Cba_PrsErrorPrint(p) )
724  ABC_SWAP( Cba_Man_t *, pDesign, p->pDesign );
725  Cba_PrsFree( p );
726  return pDesign;
727 }
void Cba_PrsPrintModules(Cba_Prs_t *p)
Definition: cbaReadVer.c:686
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Cba_PrsReadDesign(Cba_Prs_t *p)
Definition: cbaReadVer.c:655
#define ABC_SWAP(Type, a, b)
Definition: abc_global.h:218
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
static Cba_Prs_t * Cba_PrsAlloc(char *pFileName)
Definition: cbaPrs.h:168
static int Cba_PrsErrorPrint(Cba_Prs_t *p)
Definition: cbaPrs.h:104
Definition: cba.h:82
static void Cba_PrsFree(Cba_Prs_t *p)
Definition: cbaPrs.h:183
static void Cba_PrsAddVerilogDirectives(Cba_Prs_t *p)
Definition: cbaReadVer.c:65
void Cba_PrsReadVerilogTest ( char *  pFileName)

Definition at line 729 of file cbaReadVer.c.

730 {
731  abctime clk = Abc_Clock();
732  extern void Cba_PrsWriteVerilog( char * pFileName, Cba_Man_t * pDes );
733 // Cba_Man_t * p = Cba_PrsReadVerilog( "c/hie/dump/1/netlist_1.v" );
734 // Cba_Man_t * p = Cba_PrsReadVerilog( "aga/me/me_wide.v" );
735  Cba_Man_t * p = Cba_PrsReadVerilog( "aga/ray/ray_wide.v" );
736  if ( !p ) return;
737  printf( "Finished reading %d networks. ", Cba_ManNtkNum(p) );
738  printf( "NameIDs = %d. ", Abc_NamObjNumMax(p->pNames) );
739  printf( "Memory = %.2f MB. ", 1.0*Cba_ManMemory(p)/(1<<20) );
740  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
741 // Abc_NamPrint( p->pDesign->pNames );
742 // Cba_PrsWriteVerilog( "c/hie/dump/1/netlist_1_out.v", p );
743 // Cba_PrsWriteVerilog( "aga/me/me_wide_out.v", p );
744  Cba_PrsWriteVerilog( "aga/ray/ray_wide_out.v", p );
745  Cba_ManFree( p );
746 }
void Cba_PrsWriteVerilog(char *pFileName, Cba_Man_t *pDes)
Definition: cbaWriteVer.c:207
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Abc_NamObjNumMax(Abc_Nam_t *p)
Definition: utilNam.c:186
static abctime Abc_Clock()
Definition: abc_global.h:279
Abc_Nam_t * pNames
Definition: cba.h:87
static void Abc_PrintTime(int level, const char *pStr, abctime time)
Definition: abc_global.h:367
static void Cba_ManFree(Cba_Man_t *p)
Definition: cba.h:214
static int Cba_ManMemory(Cba_Man_t *p)
Definition: cba.h:229
Cba_Man_t * Cba_PrsReadVerilog(char *pFileName)
Definition: cbaReadVer.c:714
Definition: cba.h:82
static int Cba_ManNtkNum(Cba_Man_t *p)
Definition: cba.h:121
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Cba_PrsUtilSkipComments ( Cba_Prs_t p)
inlinestatic

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 161 of file cbaReadVer.c.

162 {
163  if ( !Cba_PrsIsChar(p, '/') )
164  return 0;
165  if ( Cba_PrsIsChar1(p, '/') )
166  {
167  for ( p->pCur += 2; p->pCur < p->pLimit; p->pCur++ )
168  if ( Cba_PrsIsChar(p, '\n') )
169  { p->pCur++; return 1; }
170  }
171  else if ( Cba_PrsIsChar1(p, '*') )
172  {
173  for ( p->pCur += 2; p->pCur < p->pLimit; p->pCur++ )
174  if ( Cba_PrsIsChar(p, '*') && Cba_PrsIsChar1(p, '/') )
175  { p->pCur++; p->pCur++; return 1; }
176  }
177  return 0;
178 }
static int Cba_PrsIsChar1(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:84
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
char * pLimit
Definition: cbaPrs.h:56
static int Cba_PrsUtilSkipName ( Cba_Prs_t p)
inlinestatic

Definition at line 179 of file cbaReadVer.c.

180 {
181  if ( !Cba_PrsIsChar(p, '\\') )
182  return 0;
183  for ( p->pCur++; p->pCur < p->pLimit; p->pCur++ )
184  if ( Cba_PrsIsChar(p, ' ') )
185  { p->pCur++; return 1; }
186  return 0;
187 }
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
char * pLimit
Definition: cbaPrs.h:56
static int Cba_PrsUtilSkipSpaces ( Cba_Prs_t p)
inlinestatic

Definition at line 190 of file cbaReadVer.c.

191 {
192  while ( p->pCur < p->pLimit )
193  {
194  while ( Cba_IsSpace(*p->pCur) )
195  p->pCur++;
196  if ( !*p->pCur )
197  return Cba_PrsErrorSet(p, "Unexpectedly reached end-of-file.", 1);
198  if ( !Cba_PrsUtilSkipComments(p) )
199  return 0;
200  }
201  return Cba_PrsErrorSet(p, "Unexpectedly reached end-of-file.", 1);
202 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_IsSpace(char c)
Definition: cbaReadVer.c:75
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsUtilSkipComments(Cba_Prs_t *p)
Definition: cbaReadVer.c:161
char * pLimit
Definition: cbaPrs.h:56
static int Cba_PrsUtilSkipUntil ( Cba_Prs_t p,
char  c 
)
inlinestatic

Definition at line 204 of file cbaReadVer.c.

205 {
206  while ( p->pCur < p->pLimit )
207  {
208  if ( Cba_PrsIsChar(p, c) )
209  return 1;
210  if ( Cba_PrsUtilSkipComments(p) )
211  continue;
212  if ( Cba_PrsUtilSkipName(p) )
213  continue;
214  p->pCur++;
215  }
216  return 0;
217 }
char * pCur
Definition: cbaPrs.h:57
static int Cba_PrsUtilSkipName(Cba_Prs_t *p)
Definition: cbaReadVer.c:179
static int Cba_PrsUtilSkipComments(Cba_Prs_t *p)
Definition: cbaReadVer.c:161
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadVer.c:83
char * pLimit
Definition: cbaPrs.h:56
static int Cba_PrsUtilSkipUntilWord ( Cba_Prs_t p,
char *  pWord 
)
inlinestatic

Definition at line 219 of file cbaReadVer.c.

220 {
221  char * pPlace = strstr( p->pCur, pWord );
222  if ( pPlace == NULL ) return 1;
223  p->pCur = pPlace + strlen(pWord);
224  return 0;
225 }
char * strstr()
char * pCur
Definition: cbaPrs.h:57
int strlen()

Variable Documentation

const char* s_KnownModules[100]

FUNCTION DEFINITIONS ///.

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 104 of file cbaReadVer.c.

const char* s_VerTypes[CBA_VER_UNKNOWN+1]
Initial value:
= {
NULL,
"module",
"inout",
"input",
"output",
"wire",
"assign",
"reg",
"always",
"defparam",
"begin",
"end",
"endmodule",
NULL
}

Definition at line 48 of file cbaReadVer.c.