abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
amapRead.c File Reference
#include "amapInt.h"
#include "base/io/ioAbc.h"

Go to the source code of this file.

Macros

#define AMAP_STRING_GATE   "GATE"
 DECLARATIONS ///. More...
 
#define AMAP_STRING_PIN   "PIN"
 
#define AMAP_STRING_NONINV   "NONINV"
 
#define AMAP_STRING_INV   "INV"
 
#define AMAP_STRING_UNKNOWN   "UNKNOWN"
 
#define AMAP_SYMB_AND   '*'
 
#define AMAP_SYMB_OR1   '+'
 
#define AMAP_SYMB_OR2   '|'
 
#define AMAP_SYMB_XOR   '^'
 
#define AMAP_SYMB_NOT   '!'
 
#define AMAP_SYMB_AFTNOT   '\''
 
#define AMAP_SYMB_OPEN   '('
 
#define AMAP_SYMB_CLOSE   ')'
 

Enumerations

enum  Amap_PinPhase_t { AMAP_PHASE_UNKNOWN, AMAP_PHASE_INV, AMAP_PHASE_NONINV }
 

Functions

static Amap_Gat_tAmap_ParseGateAlloc (Aig_MmFlex_t *p, int nPins)
 
static char * Amap_ParseStrsav (Aig_MmFlex_t *p, char *pStr)
 
char * Amap_LoadFile (char *pFileName)
 FUNCTION DEFINITIONS ///. More...
 
void Amap_RemoveComments (char *pBuffer, int *pnDots, int *pnLines)
 
Vec_Ptr_tAmap_DeriveTokens (char *pBuffer)
 
int Amap_ParseCountPins (Vec_Ptr_t *vTokens, int iPos)
 
int Amap_GateCollectNames (Aig_MmFlex_t *pMem, char *pForm, char *pPinNames[])
 
Amap_Gat_tAmap_ParseGateWithSamePins (Amap_Gat_t *p)
 
int Amap_CollectFormulaTokens (Vec_Ptr_t *vTokens, char *pToken, int iPos)
 
Amap_Lib_tAmap_ParseTokens (Vec_Ptr_t *vTokens, int fVerbose)
 
Amap_Lib_tAmap_LibReadBuffer (char *pBuffer, int fVerbose)
 
Amap_Lib_tAmap_LibReadFile (char *pFileName, int fVerbose)
 

Macro Definition Documentation

#define AMAP_STRING_GATE   "GATE"

DECLARATIONS ///.

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

FileName [amapRead.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Technology mapper for standard cells.]

Synopsis []

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
amapRead.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]

Definition at line 31 of file amapRead.c.

#define AMAP_STRING_INV   "INV"

Definition at line 34 of file amapRead.c.

#define AMAP_STRING_NONINV   "NONINV"

Definition at line 33 of file amapRead.c.

#define AMAP_STRING_PIN   "PIN"

Definition at line 32 of file amapRead.c.

#define AMAP_STRING_UNKNOWN   "UNKNOWN"

Definition at line 35 of file amapRead.c.

#define AMAP_SYMB_AFTNOT   '\''

Definition at line 43 of file amapRead.c.

#define AMAP_SYMB_AND   '*'

Definition at line 38 of file amapRead.c.

#define AMAP_SYMB_CLOSE   ')'

Definition at line 45 of file amapRead.c.

#define AMAP_SYMB_NOT   '!'

Definition at line 42 of file amapRead.c.

#define AMAP_SYMB_OPEN   '('

Definition at line 44 of file amapRead.c.

#define AMAP_SYMB_OR1   '+'

Definition at line 39 of file amapRead.c.

#define AMAP_SYMB_OR2   '|'

Definition at line 40 of file amapRead.c.

#define AMAP_SYMB_XOR   '^'

Definition at line 41 of file amapRead.c.

Enumeration Type Documentation

Enumerator
AMAP_PHASE_UNKNOWN 
AMAP_PHASE_INV 
AMAP_PHASE_NONINV 

Definition at line 47 of file amapRead.c.

Function Documentation

int Amap_CollectFormulaTokens ( Vec_Ptr_t vTokens,
char *  pToken,
int  iPos 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 300 of file amapRead.c.

301 {
302  char * pNext, * pPrev;
303  pPrev = pToken + strlen(pToken);
304  while ( *(pPrev-1) != ';' )
305  {
306  *pPrev++ = ' ';
307  pNext = (char *)Vec_PtrEntry(vTokens, iPos++);
308  while ( *pNext )
309  *pPrev++ = *pNext++;
310  }
311  *(pPrev-1) = 0;
312  return iPos;
313 }
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int strlen()
Vec_Ptr_t* Amap_DeriveTokens ( char *  pBuffer)

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

Synopsis [Splits the stream into tokens.]

Description []

SideEffects []

SeeAlso []

Definition at line 176 of file amapRead.c.

177 {
178  Vec_Ptr_t * vTokens;
179  char * pToken;
180  vTokens = Vec_PtrAlloc( 1000 );
181  pToken = strtok( pBuffer, " =\t\r\n" );
182  while ( pToken )
183  {
184  Vec_PtrPush( vTokens, pToken );
185  pToken = strtok( NULL, " =\t\r\n" );
186  // skip latches
187  if ( pToken && strcmp( pToken, "LATCH" ) == 0 )
188  while ( pToken && strcmp( pToken, "GATE" ) != 0 )
189  pToken = strtok( NULL, " =\t\r\n" );
190  }
191  return vTokens;
192 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
char * strtok()
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
int strcmp()
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Amap_GateCollectNames ( Aig_MmFlex_t pMem,
char *  pForm,
char *  pPinNames[] 
)

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

Synopsis [Collect the pin names used in the formula.]

Description []

SideEffects []

SeeAlso []

Definition at line 228 of file amapRead.c.

229 {
230  char Buffer[1000];
231  char * pTemp;
232  int nPins, i;
233  // save the formula as it was
234  strcpy( Buffer, pForm );
235  // remove the non-name symbols
236  for ( pTemp = Buffer; *pTemp; pTemp++ )
237  if ( *pTemp == AMAP_SYMB_AND || *pTemp == AMAP_SYMB_OR1 || *pTemp == AMAP_SYMB_OR2
238  || *pTemp == AMAP_SYMB_XOR || *pTemp == AMAP_SYMB_NOT || *pTemp == AMAP_SYMB_OPEN
239  || *pTemp == AMAP_SYMB_CLOSE || *pTemp == AMAP_SYMB_AFTNOT )
240  *pTemp = ' ';
241  // save the names
242  nPins = 0;
243  pTemp = strtok( Buffer, " " );
244  while ( pTemp )
245  {
246  for ( i = 0; i < nPins; i++ )
247  if ( strcmp( pTemp, pPinNames[i] ) == 0 )
248  break;
249  if ( i == nPins )
250  { // cannot find this name; save it
251  pPinNames[nPins++] = Amap_ParseStrsav( pMem, pTemp );
252  }
253  // get the next name
254  pTemp = strtok( NULL, " " );
255  }
256  return nPins;
257 }
#define AMAP_SYMB_XOR
Definition: amapRead.c:41
char * strtok()
#define AMAP_SYMB_OR2
Definition: amapRead.c:40
static char * Amap_ParseStrsav(Aig_MmFlex_t *p, char *pStr)
Definition: amapRead.c:55
int strcmp()
#define AMAP_SYMB_AFTNOT
Definition: amapRead.c:43
#define AMAP_SYMB_NOT
Definition: amapRead.c:42
#define AMAP_SYMB_AND
Definition: amapRead.c:38
char * strcpy()
#define AMAP_SYMB_CLOSE
Definition: amapRead.c:45
#define AMAP_SYMB_OR1
Definition: amapRead.c:39
#define AMAP_SYMB_OPEN
Definition: amapRead.c:44
Amap_Lib_t* Amap_LibReadBuffer ( char *  pBuffer,
int  fVerbose 
)

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

Synopsis [Reads the library from the input file.]

Description []

SideEffects []

SeeAlso []

Definition at line 446 of file amapRead.c.

447 {
448  Amap_Lib_t * pLib;
449  Vec_Ptr_t * vTokens;
450  Amap_RemoveComments( pBuffer, NULL, NULL );
451  vTokens = Amap_DeriveTokens( pBuffer );
452  pLib = Amap_ParseTokens( vTokens, fVerbose );
453  if ( pLib == NULL )
454  {
455  Vec_PtrFree( vTokens );
456  return NULL;
457  }
458  Vec_PtrFree( vTokens );
459  return pLib;
460 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
Amap_Lib_t * Amap_ParseTokens(Vec_Ptr_t *vTokens, int fVerbose)
Definition: amapRead.c:326
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
Vec_Ptr_t * Amap_DeriveTokens(char *pBuffer)
Definition: amapRead.c:176
void Amap_RemoveComments(char *pBuffer, int *pnDots, int *pnLines)
Definition: amapRead.c:120
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
Amap_Lib_t* Amap_LibReadFile ( char *  pFileName,
int  fVerbose 
)

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

Synopsis [Reads the library from the input file.]

Description []

SideEffects []

SeeAlso []

Definition at line 473 of file amapRead.c.

474 {
475  Amap_Lib_t * pLib;
476  char * pBuffer;
477  pBuffer = Amap_LoadFile( pFileName );
478  if ( pBuffer == NULL )
479  return NULL;
480  pLib = Amap_LibReadBuffer( pBuffer, fVerbose );
481  if ( pLib )
482  pLib->pName = Abc_UtilStrsav( pFileName );
483  ABC_FREE( pBuffer );
484  return pLib;
485 }
char * Amap_LoadFile(char *pFileName)
FUNCTION DEFINITIONS ///.
Definition: amapRead.c:73
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
#define ABC_FREE(obj)
Definition: abc_global.h:232
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Amap_Lib_t * Amap_LibReadBuffer(char *pBuffer, int fVerbose)
Definition: amapRead.c:446
char* Amap_LoadFile ( char *  pFileName)

FUNCTION DEFINITIONS ///.

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

Synopsis [Loads the file into temporary buffer.]

Description []

SideEffects []

SeeAlso []

Definition at line 73 of file amapRead.c.

74 {
75 // extern FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose );
76  FILE * pFile;
77  char * pBuffer;
78  int nFileSize;
79  int RetValue;
80  // open the BLIF file for binary reading
81  pFile = Io_FileOpen( pFileName, "open_path", "rb", 1 );
82 // pFile = fopen( FileName, "rb" );
83  // if we got this far, file should be okay otherwise would
84  // have been detected by caller
85  if ( pFile == NULL )
86  {
87  printf( "Cannot open file \"%s\".\n", pFileName );
88  return NULL;
89  }
90  assert ( pFile != NULL );
91  // get the file size, in bytes
92  fseek( pFile, 0, SEEK_END );
93  nFileSize = ftell( pFile );
94  // move the file current reading position to the beginning
95  rewind( pFile );
96  // load the contents of the file into memory
97  pBuffer = ABC_ALLOC( char, nFileSize + 10 );
98  RetValue = fread( pBuffer, nFileSize, 1, pFile );
99  // terminate the string with '\0'
100  pBuffer[ nFileSize ] = '\0';
101  strcat( pBuffer, "\n.end\n" );
102  // close file
103  fclose( pFile );
104  return pBuffer;
105 }
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition: ioUtil.c:819
#define SEEK_END
Definition: zconf.h:392
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * strcat()
#define assert(ex)
Definition: util_old.h:213
VOID_HACK rewind()
int Amap_ParseCountPins ( Vec_Ptr_t vTokens,
int  iPos 
)

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

Synopsis [Finds the number of pins.]

Description []

SideEffects []

SeeAlso []

Definition at line 205 of file amapRead.c.

206 {
207  char * pToken;
208  int i, Counter = 0;
209  Vec_PtrForEachEntryStart( char *, vTokens, pToken, i, iPos )
210  if ( !strcmp( pToken, AMAP_STRING_PIN ) )
211  Counter++;
212  else if ( !strcmp( pToken, AMAP_STRING_GATE ) )
213  return Counter;
214  return Counter;
215 }
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
#define AMAP_STRING_PIN
Definition: amapRead.c:32
int strcmp()
if(last==0)
Definition: sparse_int.h:34
else
Definition: sparse_int.h:55
static int Counter
#define AMAP_STRING_GATE
DECLARATIONS ///.
Definition: amapRead.c:31
static Amap_Gat_t* Amap_ParseGateAlloc ( Aig_MmFlex_t p,
int  nPins 
)
inlinestatic

Definition at line 53 of file amapRead.c.

54 { return (Amap_Gat_t *)Aig_MmFlexEntryFetch( p, sizeof(Amap_Gat_t)+sizeof(Amap_Pin_t)*nPins ); }
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
Amap_Gat_t* Amap_ParseGateWithSamePins ( Amap_Gat_t p)

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

Synopsis [Creates a duplicate gate with pins specified.]

Description []

SideEffects []

SeeAlso []

Definition at line 270 of file amapRead.c.

271 {
272  Amap_Gat_t * pGate;
273  Amap_Pin_t * pPin;
274  char * pPinNames[128];
275  int nPinNames;
276  assert( p->nPins == 1 && !strcmp( p->Pins->pName, "*" ) );
277  nPinNames = Amap_GateCollectNames( p->pLib->pMemGates, p->pForm, pPinNames );
278  pGate = Amap_ParseGateAlloc( p->pLib->pMemGates, nPinNames );
279  *pGate = *p;
280  pGate->nPins = nPinNames;
281  Amap_GateForEachPin( pGate, pPin )
282  {
283  *pPin = *p->Pins;
284  pPin->pName = pPinNames[pPin - pGate->Pins];
285  }
286  return pGate;
287 }
Amap_Lib_t * pLib
Definition: amapInt.h:152
char * pForm
Definition: amapInt.h:157
#define Amap_GateForEachPin(pGate, pPin)
Definition: amapInt.h:296
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static Amap_Gat_t * Amap_ParseGateAlloc(Aig_MmFlex_t *p, int nPins)
Definition: amapRead.c:53
int Amap_GateCollectNames(Aig_MmFlex_t *pMem, char *pForm, char *pPinNames[])
Definition: amapRead.c:228
int strcmp()
Amap_Pin_t Pins[0]
Definition: amapInt.h:162
unsigned nPins
Definition: amapInt.h:161
char * pName
Definition: amapInt.h:140
#define assert(ex)
Definition: util_old.h:213
static char* Amap_ParseStrsav ( Aig_MmFlex_t p,
char *  pStr 
)
inlinestatic

Definition at line 55 of file amapRead.c.

56 { return pStr ? strcpy(Aig_MmFlexEntryFetch(p, strlen(pStr)+1), pStr) : NULL; }
char * Aig_MmFlexEntryFetch(Aig_MmFlex_t *p, int nBytes)
Definition: aigMem.c:366
char * strcpy()
int strlen()
Amap_Lib_t* Amap_ParseTokens ( Vec_Ptr_t vTokens,
int  fVerbose 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 326 of file amapRead.c.

327 {
328  Amap_Lib_t * p;
329  Amap_Gat_t * pGate, * pPrev;
330  Amap_Pin_t * pPin;
331  char * pToken, * pMoGate = NULL;
332  int i, nPins, iPos = 0, Count = 0;
333  p = Amap_LibAlloc();
334  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
335  do
336  {
337  if ( strcmp( pToken, AMAP_STRING_GATE ) )
338  {
339  Amap_LibFree( p );
340  printf( "The first line should begin with %s.\n", AMAP_STRING_GATE );
341  return NULL;
342  }
343  // start gate
344  nPins = Amap_ParseCountPins( vTokens, iPos );
345  pGate = Amap_ParseGateAlloc( p->pMemGates, nPins );
346  memset( pGate, 0, sizeof(Amap_Gat_t) );
347  pGate->Id = Vec_PtrSize( p->vGates );
348  Vec_PtrPush( p->vGates, pGate );
349  pGate->pLib = p;
350  pGate->nPins = nPins;
351  // read gate
352  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
353  pGate->pName = Amap_ParseStrsav( p->pMemGates, pToken );
354  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
355  pGate->dArea = atof( pToken );
356  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
357  pGate->pOutName = Amap_ParseStrsav( p->pMemGates, pToken );
358  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
359  iPos = Amap_CollectFormulaTokens( vTokens, pToken, iPos );
360  pGate->pForm = Amap_ParseStrsav( p->pMemGates, pToken );
361  // read pins
362  Amap_GateForEachPin( pGate, pPin )
363  {
364  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
365  if ( strcmp( pToken, AMAP_STRING_PIN ) )
366  {
367  Amap_LibFree( p );
368  printf( "Cannot parse gate %s.\n", pGate->pName );
369  return NULL;
370  }
371  // read pin
372  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
373  pPin->pName = Amap_ParseStrsav( p->pMemGates, pToken );
374  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
375  if ( strcmp( pToken, AMAP_STRING_UNKNOWN ) == 0 )
376  pPin->Phase = AMAP_PHASE_UNKNOWN;
377  else if ( strcmp( pToken, AMAP_STRING_INV ) == 0 )
378  pPin->Phase = AMAP_PHASE_INV;
379  else if ( strcmp( pToken, AMAP_STRING_NONINV ) == 0 )
380  pPin->Phase = AMAP_PHASE_NONINV;
381  else
382  {
383  Amap_LibFree( p );
384  printf( "Cannot read phase of pin %s of gate %s\n", pPin->pName, pGate->pName );
385  return NULL;
386  }
387  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
388  pPin->dLoadInput = atof( pToken );
389  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
390  pPin->dLoadMax = atof( pToken );
391  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
392  pPin->dDelayBlockRise = atof( pToken );
393  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
394  pPin->dDelayFanoutRise = atof( pToken );
395  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
396  pPin->dDelayBlockFall = atof( pToken );
397  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
398  pPin->dDelayFanoutFall = atof( pToken );
399  if ( pPin->dDelayBlockRise > pPin->dDelayBlockFall )
400  pPin->dDelayBlockMax = pPin->dDelayBlockRise;
401  else
402  pPin->dDelayBlockMax = pPin->dDelayBlockFall;
403  }
404  // fix the situation when all pins are represented as one
405  if ( pGate->nPins == 1 && !strcmp( pGate->Pins->pName, "*" ) )
406  {
407  pGate = Amap_ParseGateWithSamePins( pGate );
408  Vec_PtrPop( p->vGates );
409  Vec_PtrPush( p->vGates, pGate );
410  }
411  pToken = (char *)Vec_PtrEntry(vTokens, iPos++);
412 //printf( "Finished reading gate %s (%s)\n", pGate->pName, pGate->pOutName );
413  }
414  while ( strcmp( pToken, ".end" ) );
415 
416  // check if there are gates with identical names
417  pPrev = NULL;
418  Amap_LibForEachGate( p, pGate, i )
419  {
420  if ( pPrev && !strcmp(pPrev->pName, pGate->pName) )
421  {
422  pPrev->pTwin = pGate, pGate->pTwin = pPrev;
423 // printf( "Warning: Detected multi-output gate \"%s\".\n", pGate->pName );
424  if ( pMoGate == NULL )
425  pMoGate = pGate->pName;
426  Count++;
427  }
428  pPrev = pGate;
429  }
430  if ( Count )
431  printf( "Warning: Detected %d multi-output gates (for example, \"%s\").\n", Count, pMoGate );
432  return p;
433 }
char * memset()
Amap_Lib_t * pLib
Definition: amapInt.h:152
#define Amap_LibForEachGate(pLib, pGate, i)
Definition: amapInt.h:293
#define AMAP_STRING_UNKNOWN
Definition: amapRead.c:35
double dLoadInput
Definition: amapInt.h:142
char * pForm
Definition: amapInt.h:157
#define Amap_GateForEachPin(pGate, pPin)
Definition: amapInt.h:296
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int Phase
Definition: amapInt.h:141
#define AMAP_STRING_PIN
Definition: amapRead.c:32
int Amap_ParseCountPins(Vec_Ptr_t *vTokens, int iPos)
Definition: amapRead.c:205
Amap_Lib_t * Amap_LibAlloc()
DECLARATIONS ///.
Definition: amapLib.c:45
static Amap_Gat_t * Amap_ParseGateAlloc(Aig_MmFlex_t *p, int nPins)
Definition: amapRead.c:53
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
Amap_Gat_t * Amap_ParseGateWithSamePins(Amap_Gat_t *p)
Definition: amapRead.c:270
char * pOutName
Definition: amapInt.h:155
double dDelayBlockRise
Definition: amapInt.h:144
double dLoadMax
Definition: amapInt.h:143
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
double dDelayBlockMax
Definition: amapInt.h:148
static char * Amap_ParseStrsav(Aig_MmFlex_t *p, char *pStr)
Definition: amapRead.c:55
int strcmp()
Amap_Pin_t Pins[0]
Definition: amapInt.h:162
Amap_Gat_t * pTwin
Definition: amapInt.h:153
void Amap_LibFree(Amap_Lib_t *p)
Definition: amapLib.c:67
if(last==0)
Definition: sparse_int.h:34
unsigned nPins
Definition: amapInt.h:161
double dDelayFanoutFall
Definition: amapInt.h:147
char * pName
Definition: amapInt.h:140
double dArea
Definition: amapInt.h:156
double atof()
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
int Amap_CollectFormulaTokens(Vec_Ptr_t *vTokens, char *pToken, int iPos)
Definition: amapRead.c:300
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
double dDelayFanoutRise
Definition: amapInt.h:145
#define AMAP_STRING_INV
Definition: amapRead.c:34
double dDelayBlockFall
Definition: amapInt.h:146
#define AMAP_STRING_NONINV
Definition: amapRead.c:33
char * pName
Definition: amapInt.h:154
unsigned Id
Definition: amapInt.h:159
#define AMAP_STRING_GATE
DECLARATIONS ///.
Definition: amapRead.c:31
void Amap_RemoveComments ( char *  pBuffer,
int *  pnDots,
int *  pnLines 
)

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

Synopsis [Eliminates comments from the input file.]

Description [As a byproduct, this procedure also counts the number lines and dot-statements in the input file. This also joins non-comment lines that are joined with a backspace '\']

SideEffects []

SeeAlso []

Definition at line 120 of file amapRead.c.

121 {
122  char * pCur;
123  int nDots, nLines;
124  // scan through the buffer and eliminate comments
125  // (in the BLIF file, comments are lines starting with "#")
126  nDots = nLines = 0;
127  for ( pCur = pBuffer; *pCur; pCur++ )
128  {
129  // if this is the beginning of comment
130  // clean it with spaces until the new line statement
131  if ( *pCur == '#' )
132  while ( *pCur != '\n' )
133  *pCur++ = ' ';
134 
135  // count the number of new lines and dots
136  if ( *pCur == '\n' ) {
137  if (*(pCur-1)=='\r') {
138  // DOS(R) file support
139  if (*(pCur-2)!='\\') nLines++;
140  else {
141  // rewind to backslash and overwrite with a space
142  *(pCur-2) = ' ';
143  *(pCur-1) = ' ';
144  *pCur = ' ';
145  }
146  } else {
147  // UNIX(TM) file support
148  if (*(pCur-1)!='\\') nLines++;
149  else {
150  // rewind to backslash and overwrite with a space
151  *(pCur-1) = ' ';
152  *pCur = ' ';
153  }
154  }
155  }
156  else if ( *pCur == '.' )
157  nDots++;
158  }
159  if ( pnDots )
160  *pnDots = nDots;
161  if ( pnLines )
162  *pnLines = nLines;
163 }