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

Go to the source code of this file.

Enumerations

enum  Cba_BlifType_t {
  CBA_BLIF_NONE = 0, CBA_BLIF_MODEL, CBA_BLIF_INOUTS, CBA_BLIF_INPUTS,
  CBA_BLIF_OUTPUTS, CBA_BLIF_NAMES, CBA_BLIF_SUBCKT, CBA_BLIF_GATE,
  CBA_BLIF_LATCH, CBA_BLIF_SHORT, CBA_BLIF_END, CBA_BLIF_UNKNOWN
}
 DECLARATIONS ///. More...
 

Functions

static void Cba_PrsAddBlifDirectives (Cba_Prs_t *p)
 
static int Cba_CharIsSpace (char c)
 FUNCTION DEFINITIONS ///. More...
 
static int Cba_CharIsStop (char c)
 
static int Cba_CharIsLit (char c)
 
static int Cba_PrsIsSpace (Cba_Prs_t *p)
 
static int Cba_PrsIsStop (Cba_Prs_t *p)
 
static int Cba_PrsIsLit (Cba_Prs_t *p)
 
static int Cba_PrsIsChar (Cba_Prs_t *p, char c)
 
static int Cba_PrsIsChar2 (Cba_Prs_t *p, char c)
 
static void Cba_PrsSkip (Cba_Prs_t *p)
 
static char Cba_PrsSkip2 (Cba_Prs_t *p)
 
static void Cba_PrsSkipToChar (Cba_Prs_t *p, char c)
 
static void Cba_PrsSkipSpaces (Cba_Prs_t *p)
 
static int Cba_PrsReadName (Cba_Prs_t *p)
 
static int Cba_PrsReadList (Cba_Prs_t *p)
 
static int Cba_PrsReadList2 (Cba_Prs_t *p)
 
static int Cba_PrsReadList3 (Cba_Prs_t *p)
 
static int Cba_PrsReadCube (Cba_Prs_t *p)
 
static void Cba_PrsSaveCover (Cba_Prs_t *p)
 
static int Cba_PrsReadInouts (Cba_Prs_t *p)
 
static int Cba_PrsReadInputs (Cba_Prs_t *p)
 
static int Cba_PrsReadOutputs (Cba_Prs_t *p)
 
static int Cba_PrsReadNode (Cba_Prs_t *p)
 
static int Cba_PrsReadBox (Cba_Prs_t *p, int fGate)
 
static int Cba_PrsReadLatch (Cba_Prs_t *p)
 
static int Cba_PrsReadShort (Cba_Prs_t *p)
 
static int Cba_PrsReadModel (Cba_Prs_t *p)
 
static int Cba_PrsReadEnd (Cba_Prs_t *p)
 
static int Cba_PrsReadDirective (Cba_Prs_t *p)
 
static int Cba_PrsReadLines (Cba_Prs_t *p)
 
Cba_Man_tCba_PrsReadBlif (char *pFileName)
 
void Cba_PrsReadBlifTest (char *pFileName)
 

Variables

const char * s_BlifTypes [CBA_BLIF_UNKNOWN+1]
 

Enumeration Type Documentation

DECLARATIONS ///.

CFile****************************************************************

FileName [cbaReadBlif.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:
cbaReadBlif.c,v 1.00 2014/11/29 00:00:00 alanmi Exp

]

Enumerator
CBA_BLIF_NONE 
CBA_BLIF_MODEL 
CBA_BLIF_INOUTS 
CBA_BLIF_INPUTS 
CBA_BLIF_OUTPUTS 
CBA_BLIF_NAMES 
CBA_BLIF_SUBCKT 
CBA_BLIF_GATE 
CBA_BLIF_LATCH 
CBA_BLIF_SHORT 
CBA_BLIF_END 
CBA_BLIF_UNKNOWN 

Definition at line 31 of file cbaReadBlif.c.

31  {
32  CBA_BLIF_NONE = 0, // 0: unused
33  CBA_BLIF_MODEL, // 1: .model
34  CBA_BLIF_INOUTS, // 2: .inouts
35  CBA_BLIF_INPUTS, // 3: .inputs
36  CBA_BLIF_OUTPUTS, // 4: .outputs
37  CBA_BLIF_NAMES, // 5: .names
38  CBA_BLIF_SUBCKT, // 6: .subckt
39  CBA_BLIF_GATE, // 7: .gate
40  CBA_BLIF_LATCH, // 8: .latch
41  CBA_BLIF_SHORT, // 9: .short
42  CBA_BLIF_END, // 10: .end
43  CBA_BLIF_UNKNOWN // 11: unknown
Cba_BlifType_t
DECLARATIONS ///.
Definition: cbaReadBlif.c:31

Function Documentation

static int Cba_CharIsLit ( char  c)
inlinestatic

Definition at line 90 of file cbaReadBlif.c.

90 { return c == '0' || c == '1' || c == '-'; }
static int Cba_CharIsSpace ( char  c)
inlinestatic

FUNCTION DEFINITIONS ///.

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

Synopsis [Reading characters.]

Description []

SideEffects []

SeeAlso []

Definition at line 88 of file cbaReadBlif.c.

88 { return c == ' ' || c == '\t' || c == '\r'; }
static int Cba_CharIsStop ( char  c)
inlinestatic

Definition at line 89 of file cbaReadBlif.c.

89 { return c == '#' || c == '\\' || c == '\n' || c == '='; }
static void Cba_PrsAddBlifDirectives ( Cba_Prs_t p)
inlinestatic

Definition at line 61 of file cbaReadBlif.c.

62 {
63  int i;
64  for ( i = 1; s_BlifTypes[i]; i++ )
65  Abc_NamStrFindOrAdd( p->pDesign->pNames, (char *)s_BlifTypes[i], NULL );
67  Abc_NamStrFindOrAdd( p->pDesign->pFuncs, (char *)" 0\n", NULL ); // default const 0 function
68  Abc_NamStrFindOrAdd( p->pDesign->pFuncs, (char *)"1 1\n", NULL ); // default buffer function
70 }
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
Abc_Nam_t * pFuncs
Definition: cba.h:89
const char * s_BlifTypes[CBA_BLIF_UNKNOWN+1]
Definition: cbaReadBlif.c:46
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsIsChar ( Cba_Prs_t p,
char  c 
)
inlinestatic

Definition at line 96 of file cbaReadBlif.c.

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

Definition at line 97 of file cbaReadBlif.c.

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

Definition at line 94 of file cbaReadBlif.c.

94 { return Cba_CharIsLit(*p->pCur); }
char * pCur
Definition: cbaPrs.h:57
static int Cba_CharIsLit(char c)
Definition: cbaReadBlif.c:90
static int Cba_PrsIsSpace ( Cba_Prs_t p)
inlinestatic

Definition at line 92 of file cbaReadBlif.c.

92 { return Cba_CharIsSpace(*p->pCur); }
char * pCur
Definition: cbaPrs.h:57
static int Cba_CharIsSpace(char c)
FUNCTION DEFINITIONS ///.
Definition: cbaReadBlif.c:88
static int Cba_PrsIsStop ( Cba_Prs_t p)
inlinestatic

Definition at line 93 of file cbaReadBlif.c.

93 { return Cba_CharIsStop(*p->pCur); }
static int Cba_CharIsStop(char c)
Definition: cbaReadBlif.c:89
char * pCur
Definition: cbaPrs.h:57
Cba_Man_t* Cba_PrsReadBlif ( char *  pFileName)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 400 of file cbaReadBlif.c.

401 {
402  Cba_Man_t * pDesign = NULL;
403  Cba_Prs_t * p = Cba_PrsAlloc( pFileName );
404  if ( p == NULL )
405  return NULL;
407  Cba_PrsReadLines( p );
408  if ( Cba_PrsErrorPrint(p) )
409  ABC_SWAP( Cba_Man_t *, pDesign, p->pDesign );
410  Cba_PrsFree( p );
411  return pDesign;
412 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Cba_PrsReadLines(Cba_Prs_t *p)
Definition: cbaReadBlif.c:374
#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_PrsAddBlifDirectives(Cba_Prs_t *p)
Definition: cbaReadBlif.c:61
static void Cba_PrsFree(Cba_Prs_t *p)
Definition: cbaPrs.h:183
void Cba_PrsReadBlifTest ( char *  pFileName)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 425 of file cbaReadBlif.c.

426 {
427  abctime clk = Abc_Clock();
428  extern void Cba_PrsWriteBlif( char * pFileName, Cba_Man_t * pDes );
429  Cba_Man_t * p = Cba_PrsReadBlif( "aga/ray/ray_hie_oper.blif" );
430  if ( !p ) return;
431  printf( "Finished reading %d networks. ", Cba_ManNtkNum(p) );
432  printf( "NameIDs = %d. ", Abc_NamObjNumMax(p->pNames) );
433  printf( "Memory = %.2f MB. ", 1.0*Cba_ManMemory(p)/(1<<20) );
434  Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
435 // Abc_NamPrint( p->pDesign->pNames );
436  Cba_PrsWriteBlif( "aga/ray/ray_hie_oper_out.blif", p );
437  Cba_ManFree( p );
438 }
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
Definition: cba.h:82
static int Cba_ManNtkNum(Cba_Man_t *p)
Definition: cba.h:121
Cba_Man_t * Cba_PrsReadBlif(char *pFileName)
Definition: cbaReadBlif.c:400
void Cba_PrsWriteBlif(char *pFileName, Cba_Man_t *pDes)
Definition: cbaWriteBlif.c:105
ABC_INT64_T abctime
Definition: abc_global.h:278
static int Cba_PrsReadBox ( Cba_Prs_t p,
int  fGate 
)
inlinestatic

Definition at line 273 of file cbaReadBlif.c.

274 {
275  int iToken = Cba_PrsReadName(p);
276  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read model name.", 1);
277  if ( Cba_PrsReadList3(p) ) return 1;
278  // save results
280  Vec_IntPush( &p->vFuncsCur, iToken );
282  return 0;
283 }
static int Cba_PrsReadList3(Cba_Prs_t *p)
Definition: cbaReadBlif.c:170
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
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
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
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadCube ( Cba_Prs_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 201 of file cbaReadBlif.c.

202 {
203  assert( Cba_PrsIsLit(p) );
204  while ( Cba_PrsIsLit(p) )
205  Vec_StrPush( &p->vCover, Cba_PrsSkip2(p) );
206  Cba_PrsSkipSpaces( p );
207  if ( Cba_PrsIsChar(p, '\n') )
208  {
209  if ( Vec_StrSize(&p->vCover) != 1 ) return Cba_PrsErrorSet(p, "Cannot read cube.", 1);
210  // fix single literal cube by adding space
211  Vec_StrPush( &p->vCover, Vec_StrEntry(&p->vCover,0) );
212  Vec_StrWriteEntry( &p->vCover, 0, ' ' );
213  Vec_StrPush( &p->vCover, '\n' );
214  return 0;
215  }
216  if ( !Cba_PrsIsLit(p) ) return Cba_PrsErrorSet(p, "Cannot read output literal.", 1);
217  Vec_StrPush( &p->vCover, ' ' );
218  Vec_StrPush( &p->vCover, Cba_PrsSkip2(p) );
219  Vec_StrPush( &p->vCover, '\n' );
220  Cba_PrsSkipSpaces( p );
221  if ( !Cba_PrsIsChar(p, '\n') ) return Cba_PrsErrorSet(p, "Cannot read end of cube.", 1);
222  return 0;
223 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static char Cba_PrsSkip2(Cba_Prs_t *p)
Definition: cbaReadBlif.c:100
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
Vec_Str_t vCover
Definition: cbaPrs.h:73
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static char Vec_StrEntry(Vec_Str_t *p, int i)
Definition: vecStr.h:336
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsIsLit(Cba_Prs_t *p)
Definition: cbaReadBlif.c:94
static int Cba_PrsReadDirective ( Cba_Prs_t p)
inlinestatic

Definition at line 343 of file cbaReadBlif.c.

344 {
345  int iToken;
346  if ( !Cba_PrsIsChar(p, '.') )
347  return Cba_PrsReadCube( p );
348  if ( Vec_StrSize(&p->vCover) > 0 ) // SOP was specified for the previous node
349  Cba_PrsSaveCover( p );
350  iToken = Cba_PrsReadName( p );
351  if ( iToken == CBA_BLIF_MODEL )
352  return Cba_PrsReadModel( p );
353  if ( iToken == CBA_BLIF_INOUTS )
354  return Cba_PrsReadInouts( p );
355  if ( iToken == CBA_BLIF_INPUTS )
356  return Cba_PrsReadInputs( p );
357  if ( iToken == CBA_BLIF_OUTPUTS )
358  return Cba_PrsReadOutputs( p );
359  if ( iToken == CBA_BLIF_NAMES )
360  return Cba_PrsReadNode( p );
361  if ( iToken == CBA_BLIF_SUBCKT )
362  return Cba_PrsReadBox( p, 0 );
363  if ( iToken == CBA_BLIF_GATE )
364  return Cba_PrsReadBox( p, 1 );
365  if ( iToken == CBA_BLIF_LATCH )
366  return Cba_PrsReadLatch( p );
367  if ( iToken == CBA_BLIF_SHORT )
368  return Cba_PrsReadShort( p );
369  if ( iToken == CBA_BLIF_END )
370  return Cba_PrsReadEnd( p );
371  printf( "Cannot read directive \"%s\".\n", Abc_NamStr(p->pDesign->pNames, iToken) );
372  return 1;
373 }
static int Cba_PrsReadBox(Cba_Prs_t *p, int fGate)
Definition: cbaReadBlif.c:273
static int Cba_PrsReadCube(Cba_Prs_t *p)
Definition: cbaReadBlif.c:201
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSaveCover(Cba_Prs_t *p)
Definition: cbaReadBlif.c:224
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
Abc_Nam_t * pNames
Definition: cba.h:87
Vec_Str_t vCover
Definition: cbaPrs.h:73
static int Cba_PrsReadModel(Cba_Prs_t *p)
Definition: cbaReadBlif.c:324
static int Cba_PrsReadNode(Cba_Prs_t *p)
Definition: cbaReadBlif.c:264
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
static int Cba_PrsReadInputs(Cba_Prs_t *p)
Definition: cbaReadBlif.c:252
static int Cba_PrsReadShort(Cba_Prs_t *p)
Definition: cbaReadBlif.c:307
static int Cba_PrsReadEnd(Cba_Prs_t *p)
Definition: cbaReadBlif.c:332
char * Abc_NamStr(Abc_Nam_t *p, int NameId)
Definition: utilNam.c:479
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
static int Cba_PrsReadInouts(Cba_Prs_t *p)
Definition: cbaReadBlif.c:246
static int Cba_PrsReadOutputs(Cba_Prs_t *p)
Definition: cbaReadBlif.c:258
static int Cba_PrsReadLatch(Cba_Prs_t *p)
Definition: cbaReadBlif.c:284
static int Cba_PrsReadEnd ( Cba_Prs_t p)
inlinestatic

Definition at line 332 of file cbaReadBlif.c.

333 {
334  if ( p->iModuleName == 0 ) return Cba_PrsErrorSet(p, "Directive .end without .model.", 1);
335  //printf( "Saving model \"%s\".\n", Abc_NamStr(p->pDesign->pNames, p->iModuleName) );
337  p->iModuleName = 0;
338  Cba_PrsSkipSpaces( p );
339  if ( !Cba_PrsIsChar(p, '\n') ) return Cba_PrsErrorSet(p, "Trailing symbols on .end line.", 1);
340  return 0;
341 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
int iModuleName
Definition: cbaPrs.h:62
static Cba_Ntk_t * Cba_PrsAddCurrentModel(Cba_Prs_t *p, int iNameId)
Definition: cbaPrs.h:125
static int Cba_PrsReadInouts ( Cba_Prs_t p)
inlinestatic

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 246 of file cbaReadBlif.c.

247 {
248  if ( Cba_PrsReadList(p) ) return 1;
249  Vec_IntAppend( &p->vInoutsCur, &p->vTemp );
250  return 0;
251 }
Vec_Int_t vInoutsCur
Definition: cbaPrs.h:63
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadList(Cba_Prs_t *p)
Definition: cbaReadBlif.c:150
static int Cba_PrsReadInputs ( Cba_Prs_t p)
inlinestatic

Definition at line 252 of file cbaReadBlif.c.

253 {
254  if ( Cba_PrsReadList(p) ) return 1;
255  Vec_IntAppend( &p->vInputsCur, &p->vTemp );
256  return 0;
257 }
Vec_Int_t vInputsCur
Definition: cbaPrs.h:64
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadList(Cba_Prs_t *p)
Definition: cbaReadBlif.c:150
static int Cba_PrsReadLatch ( Cba_Prs_t p)
inlinestatic

Definition at line 284 of file cbaReadBlif.c.

285 {
286  int iToken = Cba_PrsReadName(p);
287  Vec_IntFill( &p->vTemp, 2, -1 );
288  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read latch input.", 1);
289  Vec_IntWriteEntry( &p->vTemp, 1, iToken );
290  iToken = Cba_PrsReadName(p);
291  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read latch output.", 1);
292  Vec_IntWriteEntry( &p->vTemp, 0, iToken );
293  Cba_PrsSkipSpaces( p );
294  if ( Cba_PrsIsChar(p, '0') )
295  iToken = 0;
296  else if ( Cba_PrsIsChar(p, '1') )
297  iToken = 1;
298  else
299  iToken = 2;
300  Cba_PrsSkipToChar( p, '\n' );
301  // save results
303  Vec_IntPush( &p->vFuncsCur, iToken );
305  return 0;
306 }
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_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
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
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static void Cba_PrsSkipToChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:114
static int Cba_PrsReadLines ( Cba_Prs_t p)
inlinestatic

Definition at line 374 of file cbaReadBlif.c.

375 {
376  while ( p->pCur[1] != '\0' )
377  {
378  assert( Cba_PrsIsChar(p, '\n') );
379  Cba_PrsSkip(p);
380  Cba_PrsSkipSpaces( p );
381  if ( Cba_PrsIsChar(p, '\n') )
382  continue;
383  if ( Cba_PrsReadDirective(p) )
384  return 1;
385  }
386  return 0;
387 }
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
char * pCur
Definition: cbaPrs.h:57
static void Cba_PrsSkip(Cba_Prs_t *p)
Definition: cbaReadBlif.c:99
#define assert(ex)
Definition: util_old.h:213
static int Cba_PrsReadDirective(Cba_Prs_t *p)
Definition: cbaReadBlif.c:343
static int Cba_PrsReadList ( Cba_Prs_t p)
inlinestatic

Definition at line 150 of file cbaReadBlif.c.

151 {
152  int iToken;
153  Vec_IntClear( &p->vTemp );
154  while ( (iToken = Cba_PrsReadName(p)) )
155  Vec_IntPush( &p->vTemp, iToken );
156  if ( Vec_IntSize(&p->vTemp) == 0 ) return Cba_PrsErrorSet(p, "Signal list is empty.", 1);
157  return 0;
158 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadList2 ( Cba_Prs_t p)
inlinestatic

Definition at line 159 of file cbaReadBlif.c.

160 {
161  int iToken;
162  Vec_IntFill( &p->vTemp, 1, -1 );
163  while ( (iToken = Cba_PrsReadName(p)) )
164  Vec_IntPush( &p->vTemp, iToken );
165  iToken = Vec_IntPop(&p->vTemp);
166  if ( Vec_IntSize(&p->vTemp) == 0 ) return Cba_PrsErrorSet(p, "Signal list is empty.", 1);
167  Vec_IntWriteEntry( &p->vTemp, 0, iToken );
168  return 0;
169 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static int Vec_IntPop(Vec_Int_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadList3 ( Cba_Prs_t p)
inlinestatic

Definition at line 170 of file cbaReadBlif.c.

171 {
172  Vec_IntClear( &p->vTemp );
173  while ( !Cba_PrsIsChar(p, '\n') )
174  {
175  int iToken = Cba_PrsReadName(p);
176  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read formal name.", 1);
177  Vec_IntPush( &p->vTemp, iToken );
178  Cba_PrsSkipSpaces( p );
179  if ( !Cba_PrsIsChar2(p, '=') ) return Cba_PrsErrorSet(p, "Cannot find symbol \"=\".", 1);
180  iToken = Cba_PrsReadName(p);
181  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read actual name.", 1);
182  Vec_IntPush( &p->vTemp, iToken );
183  Cba_PrsSkipSpaces( p );
184  }
185  if ( Vec_IntSize(&p->vTemp) == 0 ) return Cba_PrsErrorSet(p, "Cannot read a list of formal/actual names.", 1);
186  if ( Vec_IntSize(&p->vTemp) % 2 ) return Cba_PrsErrorSet(p, "The number of formal/actual names is not even.", 1);
187  return 0;
188 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
static int Cba_PrsIsChar2(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:97
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static void Vec_IntClear(Vec_Int_t *p)
Definition: bblif.c:452
static int Cba_PrsReadModel ( Cba_Prs_t p)
inlinestatic

Definition at line 324 of file cbaReadBlif.c.

325 {
326  if ( p->iModuleName > 0 ) return Cba_PrsErrorSet(p, "Parsing previous model is unfinished.", 1);
328  Cba_PrsSkipSpaces( p );
329  if ( !Cba_PrsIsChar(p, '\n') ) return Cba_PrsErrorSet(p, "Trailing symbols on .model line.", 1);
330  return 0;
331 }
static int Cba_PrsErrorSet(Cba_Prs_t *p, char *pError, int Value)
MACRO DEFINITIONS ///.
Definition: cbaPrs.h:92
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
int iModuleName
Definition: cbaPrs.h:62
static int Cba_PrsReadName ( Cba_Prs_t p)
inlinestatic

Definition at line 137 of file cbaReadBlif.c.

138 {
139  char * pStart;
140  Cba_PrsSkipSpaces( p );
141  if ( Cba_PrsIsChar(p, '\n') )
142  return 0;
143  pStart = p->pCur;
144  while ( !Cba_PrsIsSpace(p) && !Cba_PrsIsStop(p) )
145  Cba_PrsSkip(p);
146  if ( pStart == p->pCur )
147  return 0;
148  return Abc_NamStrFindOrAddLim( p->pDesign->pNames, pStart, p->pCur, NULL );
149 }
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static int Cba_PrsIsSpace(Cba_Prs_t *p)
Definition: cbaReadBlif.c:92
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 void Cba_PrsSkip(Cba_Prs_t *p)
Definition: cbaReadBlif.c:99
static int Cba_PrsIsStop(Cba_Prs_t *p)
Definition: cbaReadBlif.c:93
static int Cba_PrsReadNode ( Cba_Prs_t p)
inlinestatic

Definition at line 264 of file cbaReadBlif.c.

265 {
266  if ( Cba_PrsReadList2(p) ) return 1;
267  // save results
269  Vec_IntPush( &p->vFuncsCur, 1 ); // default const 0 function
271  return 0;
272 }
Vec_Int_t vTypesCur
Definition: cbaPrs.h:68
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Cba_PrsReadList2(Cba_Prs_t *p)
Definition: cbaReadBlif.c:159
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
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadOutputs ( Cba_Prs_t p)
inlinestatic

Definition at line 258 of file cbaReadBlif.c.

259 {
260  if ( Cba_PrsReadList(p) ) return 1;
261  Vec_IntAppend( &p->vOutputsCur, &p->vTemp );
262  return 0;
263 }
static void Vec_IntAppend(Vec_Int_t *vVec1, Vec_Int_t *vVec2)
Vec_Int_t vOutputsCur
Definition: cbaPrs.h:65
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static int Cba_PrsReadList(Cba_Prs_t *p)
Definition: cbaReadBlif.c:150
static int Cba_PrsReadShort ( Cba_Prs_t p)
inlinestatic

Definition at line 307 of file cbaReadBlif.c.

308 {
309  int iToken = Cba_PrsReadName(p);
310  Vec_IntFill( &p->vTemp, 2, -1 );
311  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read .short input.", 1);
312  Vec_IntWriteEntry( &p->vTemp, 1, iToken );
313  iToken = Cba_PrsReadName(p);
314  if ( iToken == 0 ) return Cba_PrsErrorSet(p, "Cannot read .short output.", 1);
315  Vec_IntWriteEntry( &p->vTemp, 0, iToken );
316  Cba_PrsSkipSpaces( p );
317  if ( !Cba_PrsIsChar(p, '\n') ) return Cba_PrsErrorSet(p, "Trailing symbols on .short line.", 1);
318  // save results
320  Vec_IntPush( &p->vFuncsCur, 2 ); // default buffer function
322  return 0;
323 }
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_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkipSpaces(Cba_Prs_t *p)
Definition: cbaReadBlif.c:119
static Vec_Int_t * Vec_WecPushLevel(Vec_Wec_t *p)
Definition: vecWec.h:284
static int Cba_PrsReadName(Cba_Prs_t *p)
Definition: cbaReadBlif.c:137
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
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
static void Vec_IntFill(Vec_Int_t *p, int nSize, int Fill)
Definition: bblif.c:356
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
Vec_Wec_t vFaninsCur
Definition: cbaPrs.h:71
Vec_Int_t vTemp
Definition: cbaPrs.h:74
static void Cba_PrsSaveCover ( Cba_Prs_t p)
inlinestatic

Definition at line 224 of file cbaReadBlif.c.

225 {
226  int iToken;
227  assert( Vec_StrSize(&p->vCover) > 0 );
228  Vec_StrPush( &p->vCover, '\0' );
229  iToken = Abc_NamStrFindOrAdd( p->pDesign->pFuncs, Vec_StrArray(&p->vCover), NULL );
230  assert( Vec_IntEntryLast(&p->vFuncsCur) == 1 );
231  Vec_IntWriteEntry( &p->vFuncsCur, Vec_IntSize(&p->vFuncsCur)-1, iToken );
232  Vec_StrClear( &p->vCover );
233 }
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
Vec_Str_t vCover
Definition: cbaPrs.h:73
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
Vec_Int_t vFuncsCur
Definition: cbaPrs.h:69
Cba_Man_t * pDesign
Definition: cbaPrs.h:60
static int Vec_StrSize(Vec_Str_t *p)
Definition: bblif.c:600
Abc_Nam_t * pFuncs
Definition: cba.h:89
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define assert(ex)
Definition: util_old.h:213
static void Cba_PrsSkip ( Cba_Prs_t p)
inlinestatic

Definition at line 99 of file cbaReadBlif.c.

99 { p->pCur++; }
char * pCur
Definition: cbaPrs.h:57
static char Cba_PrsSkip2 ( Cba_Prs_t p)
inlinestatic

Definition at line 100 of file cbaReadBlif.c.

100 { return *p->pCur++; }
char * pCur
Definition: cbaPrs.h:57
static void Cba_PrsSkipSpaces ( Cba_Prs_t p)
inlinestatic

Definition at line 119 of file cbaReadBlif.c.

120 {
121  while ( 1 )
122  {
123  while ( Cba_PrsIsSpace(p) )
124  Cba_PrsSkip(p);
125  if ( Cba_PrsIsChar(p, '\\') )
126  {
127  Cba_PrsSkipToChar( p, '\n' );
128  Cba_PrsSkip(p);
129  continue;
130  }
131  if ( Cba_PrsIsChar(p, '#') )
132  Cba_PrsSkipToChar( p, '\n' );
133  break;
134  }
135  assert( !Cba_PrsIsSpace(p) );
136 }
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static int Cba_PrsIsSpace(Cba_Prs_t *p)
Definition: cbaReadBlif.c:92
static void Cba_PrsSkip(Cba_Prs_t *p)
Definition: cbaReadBlif.c:99
#define assert(ex)
Definition: util_old.h:213
static void Cba_PrsSkipToChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:114
static void Cba_PrsSkipToChar ( Cba_Prs_t p,
char  c 
)
inlinestatic

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

Synopsis [Reading names.]

Description []

SideEffects []

SeeAlso []

Definition at line 114 of file cbaReadBlif.c.

115 {
116  while ( !Cba_PrsIsChar(p, c) )
117  Cba_PrsSkip(p);
118 }
static int Cba_PrsIsChar(Cba_Prs_t *p, char c)
Definition: cbaReadBlif.c:96
static void Cba_PrsSkip(Cba_Prs_t *p)
Definition: cbaReadBlif.c:99

Variable Documentation

const char* s_BlifTypes[CBA_BLIF_UNKNOWN+1]
Initial value:
= {
NULL,
".model",
".inouts",
".inputs",
".outputs",
".names",
".subckt",
".gate",
".latch",
".short",
".end",
NULL
}

Definition at line 46 of file cbaReadBlif.c.