abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mioRead.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mioRead.c]
4 
5  PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]
6 
7  Synopsis [File reading/writing for technology mapping.]
8 
9  Author [MVSIS Group]
10 
11  Affiliation [UC Berkeley]
12 
13  Date [Ver. 1.0. Started - September 8, 2003.]
14 
15  Revision [$Id: mioRead.c,v 1.9 2004/10/19 06:40:16 satrajit Exp $]
16 
17 ***********************************************************************/
18 
19 #include <ctype.h>
20 #include "mioInt.h"
21 #include "base/io/ioAbc.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 static Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st__table * tExcludeGate, int fVerbose );
35 static Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose );
36 static int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose );
37 static Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat );
38 static Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat );
39 static char * chomp( char *s );
40 static void Mio_LibraryDetectSpecialGates( Mio_Library_t * pLib );
41 static void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, int * pnLines );
42 
43 /**Function*************************************************************
44 
45  Synopsis [Read the genlib type of library.]
46 
47  Description []
48 
49  SideEffects []
50 
51  SeeAlso []
52 
53 ***********************************************************************/
54 Mio_Library_t * Mio_LibraryRead( char * FileName, char * pBuffer, char * ExcludeFile, int fVerbose )
55 {
56  Mio_Library_t * pLib;
57  int num;
58 
59  st__table * tExcludeGate = 0;
60 
61  if ( ExcludeFile )
62  {
63  tExcludeGate = st__init_table(strcmp, st__strhash);
64  if ( (num = Mio_LibraryReadExclude( ExcludeFile, tExcludeGate )) == -1 )
65  {
66  st__free_table( tExcludeGate );
67  tExcludeGate = 0;
68  return 0;
69  }
70  fprintf ( stdout, "Read %d gates from exclude file\n", num );
71  }
72 
73  if ( pBuffer == NULL )
74  pLib = Mio_LibraryReadOne( FileName, 0, tExcludeGate, fVerbose ); // try normal format first ..
75  else
76  {
77  pLib = Mio_LibraryReadBuffer( pBuffer, 0, tExcludeGate, fVerbose ); // try normal format first ..
78  if ( pLib )
79  pLib->pName = Abc_UtilStrsav( Extra_FileNameGenericAppend(FileName, ".genlib") );
80  }
81  if ( pLib == NULL )
82  {
83  if ( pBuffer == NULL )
84  pLib = Mio_LibraryReadOne( FileName, 1, tExcludeGate, fVerbose ); // try normal format first ..
85  else
86  {
87  pLib = Mio_LibraryReadBuffer( pBuffer, 1, tExcludeGate, fVerbose ); // try normal format first ..
88  if ( pLib )
89  pLib->pName = Abc_UtilStrsav( Extra_FileNameGenericAppend(FileName, ".genlib") );
90  }
91  if ( pLib != NULL )
92  printf ( "Warning: Read extended genlib format but ignoring extensions\n" );
93  }
94  if ( tExcludeGate )
95  st__free_table( tExcludeGate );
96 
97  return pLib;
98 }
99 
100 /**Function*************************************************************
101 
102  Synopsis [Read contents of the file.]
103 
104  Description []
105 
106  SideEffects []
107 
108  SeeAlso []
109 
110 ***********************************************************************/
111 char * Mio_ReadFile( char * FileName, int fAddEnd )
112 {
113  char * pBuffer;
114  FILE * pFile;
115  int nFileSize;
116  int RetValue;
117 
118  // open the BLIF file for binary reading
119  pFile = Io_FileOpen( FileName, "open_path", "rb", 1 );
120 // pFile = fopen( FileName, "rb" );
121  // if we got this far, file should be okay otherwise would
122  // have been detected by caller
123  assert ( pFile != NULL );
124  // get the file size, in bytes
125  fseek( pFile, 0, SEEK_END );
126  nFileSize = ftell( pFile );
127  // move the file current reading position to the beginning
128  rewind( pFile );
129  // load the contents of the file into memory
130  pBuffer = ABC_ALLOC( char, nFileSize + 10 );
131  RetValue = fread( pBuffer, nFileSize, 1, pFile );
132  // terminate the string with '\0'
133  pBuffer[ nFileSize ] = '\0';
134  if ( fAddEnd )
135  strcat( pBuffer, "\n.end\n" );
136  // close file
137  fclose( pFile );
138  return pBuffer;
139 }
140 
141 /**Function*************************************************************
142 
143  Synopsis [Read the genlib type of library.]
144 
145  Description []
146 
147  SideEffects []
148 
149  SeeAlso []
150 
151 ***********************************************************************/
152 Mio_Library_t * Mio_LibraryReadBuffer( char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose )
153 {
154  Mio_Library_t * pLib;
155 
156  // allocate the genlib structure
157  pLib = ABC_CALLOC( Mio_Library_t, 1 );
159  pLib->pMmFlex = Mem_FlexStart();
160  pLib->vCube = Vec_StrAlloc( 100 );
161 
162  Io_ReadFileRemoveComments( pBuffer, NULL, NULL );
163 
164  // parse the contents of the file
165  if ( Mio_LibraryReadInternal( pLib, pBuffer, fExtendedFormat, tExcludeGate, fVerbose ) )
166  {
167  Mio_LibraryDelete( pLib );
168  return NULL;
169  }
170 
171  // derive the functinality of gates
172  if ( Mio_LibraryParseFormulas( pLib ) )
173  {
174  printf( "Mio_LibraryRead: Had problems parsing formulas.\n" );
175  Mio_LibraryDelete( pLib );
176  return NULL;
177  }
178 
179  // detect INV and NAND2
181 //Mio_WriteLibrary( stdout, pLib );
182  return pLib;
183 }
184 
185 /**Function*************************************************************
186 
187  Synopsis [Read the genlib type of library.]
188 
189  Description []
190 
191  SideEffects []
192 
193  SeeAlso []
194 
195 ***********************************************************************/
196 Mio_Library_t * Mio_LibraryReadOne( char * FileName, int fExtendedFormat, st__table * tExcludeGate, int fVerbose )
197 {
198  Mio_Library_t * pLib;
199  char * pBuffer;
200  // read the file and clean comments
201  // pBuffer = Io_ReadFileFileContents( FileName, NULL );
202  // we don't use above function but actually do the same thing explicitly
203  // to handle open_path expansion correctly
204  pBuffer = Mio_ReadFile( FileName, 1 );
205  if ( pBuffer == NULL )
206  return NULL;
207  pLib = Mio_LibraryReadBuffer( pBuffer, fExtendedFormat, tExcludeGate, fVerbose );
208  ABC_FREE( pBuffer );
209  if ( pLib )
210  pLib->pName = Abc_UtilStrsav( FileName );
211  return pLib;
212 }
213 
214 /**Function*************************************************************
215 
216  Synopsis [Read the genlib type of library.]
217 
218  Description []
219 
220  SideEffects []
221 
222  SeeAlso []
223 
224 ***********************************************************************/
225 int Mio_LibraryReadInternal( Mio_Library_t * pLib, char * pBuffer, int fExtendedFormat, st__table * tExcludeGate, int fVerbose )
226 {
227  Mio_Gate_t * pGate, ** ppGate;
228  char * pToken;
229  int nGates = 0;
230  int nDel = 0;
231 
232  // start the linked list of gates
233  pLib->pGates = NULL;
234  ppGate = &pLib->pGates;
235 
236  // read gates one by one
237  pToken = strtok( pBuffer, " \t\r\n" );
238  while ( pToken && (strcmp( pToken, MIO_STRING_GATE ) == 0 || strcmp( pToken, MIO_STRING_LATCH ) == 0) )
239  {
240  // skip latches
241  if ( strcmp( pToken, MIO_STRING_LATCH ) == 0 )
242  {
243  while ( pToken && strcmp( pToken, MIO_STRING_GATE ) != 0 && strcmp( pToken, ".end" ) != 0 )
244  {
245  if ( strcmp( pToken, MIO_STRING_LATCH ) == 0 )
246  {
247  pToken = strtok( NULL, " \t\r\n" );
248  printf( "Skipping latch \"%s\"...\n", pToken );
249  continue;
250  }
251  pToken = strtok( NULL, " \t\r\n" );
252  }
253  if ( !(pToken && strcmp( pToken, MIO_STRING_GATE ) == 0) )
254  break;
255  }
256 
257  // derive the next gate
258  pGate = Mio_LibraryReadGate( &pToken, fExtendedFormat );
259  if ( pGate == NULL )
260  return 1;
261 
262  // skip the gate if its formula has problems
263  if ( !Mio_ParseCheckFormula(pGate, pGate->pForm) )
264  {
265  Mio_GateDelete( pGate );
266  continue;
267  }
268 
269  // set the library
270  pGate->pLib = pLib;
271 
272  // printf ("Processing: '%s'\n", pGate->pName);
273 
274  if ( tExcludeGate && st__is_member( tExcludeGate, pGate->pName ) )
275  {
276  //printf ("Excluding: '%s'\n", pGate->pName);
277  Mio_GateDelete( pGate );
278  nDel++;
279  }
280  else
281  {
282  // add this gate to the list
283  *ppGate = pGate;
284  ppGate = &pGate->pNext;
285  nGates++;
286 
287  // remember this gate by name
288  if ( ! st__is_member( pLib->tName2Gate, pGate->pName ) )
289  st__insert( pLib->tName2Gate, pGate->pName, (char *)pGate );
290  else
291  {
292  Mio_Gate_t * pBase = Mio_LibraryReadGateByName( pLib, pGate->pName, NULL );
293  if ( pBase->pTwin != NULL )
294  {
295  printf( "Gates with more than 2 outputs are not supported.\n" );
296  continue;
297  }
298  pBase->pTwin = pGate;
299  pGate->pTwin = pBase;
300 // printf( "Gate \"%s\" appears two times. Creating a 2-output gate.\n", pGate->pName );
301  }
302  }
303  }
304 
305  if ( nGates == 0 )
306  {
307  printf( "The library contains no gates.\n" );
308  return 1;
309  }
310 
311  // check what is the last word read
312  if ( pToken && strcmp( pToken, ".end" ) != 0 )
313  return 1;
314 
315  if ( nDel != 0 )
316  printf( "Actually excluded %d cells\n", nDel );
317 
318  return 0;
319 }
320 
321 /**Function*************************************************************
322 
323  Synopsis [Read the genlib type of gate.]
324 
325  Description []
326 
327  SideEffects []
328 
329  SeeAlso []
330 
331 ***********************************************************************/
332 Mio_Gate_t * Mio_LibraryReadGate( char ** ppToken, int fExtendedFormat )
333 {
334  Mio_Gate_t * pGate;
335  Mio_Pin_t * pPin, ** ppPin;
336  char * pToken = *ppToken;
337 
338  // allocate the gate structure
339  pGate = ABC_CALLOC( Mio_Gate_t, 1 );
340 
341  // read the name
342  pToken = strtok( NULL, " \t\r\n" );
343  pGate->pName = Abc_UtilStrsav( pToken );
344 
345  // read the area
346  pToken = strtok( NULL, " \t\r\n" );
347  pGate->dArea = atof( pToken );
348 
349  // read the formula
350 
351  // first the output name
352  pToken = strtok( NULL, "=" );
353  pGate->pOutName = chomp( pToken );
354 
355  // then rest of the expression
356  pToken = strtok( NULL, ";" );
357  pGate->pForm = chomp( pToken );
358 
359  // read the pin info
360  // start the linked list of pins
361  pGate->pPins = NULL;
362  ppPin = &pGate->pPins;
363 
364  // read gates one by one
365  pToken = strtok( NULL, " \t\r\n" );
366  while ( pToken && strcmp( pToken, MIO_STRING_PIN ) == 0 )
367  {
368  // derive the next gate
369  pPin = Mio_LibraryReadPin( &pToken, fExtendedFormat );
370  if ( pPin == NULL )
371  {
372  Mio_GateDelete( pGate );
373  *ppToken = pToken;
374  return NULL;
375  }
376  // add this pin to the list
377  *ppPin = pPin;
378  ppPin = &pPin->pNext;
379  // get the next token
380  pToken = strtok( NULL, " \t\r\n" );
381  }
382 
383  *ppToken = pToken;
384  return pGate;
385 }
386 
387 
388 
389 /**Function*************************************************************
390 
391  Synopsis [Read the genlib type of pin.]
392 
393  Description []
394 
395  SideEffects []
396 
397  SeeAlso []
398 
399 ***********************************************************************/
400 Mio_Pin_t * Mio_LibraryReadPin( char ** ppToken, int fExtendedFormat )
401 {
402  Mio_Pin_t * pPin;
403  char * pToken = *ppToken;
404 
405  // allocate the gate structure
406  pPin = ABC_CALLOC( Mio_Pin_t, 1 );
407 
408  // read the name
409  pToken = strtok( NULL, " \t\r\n" );
410  pPin->pName = Abc_UtilStrsav( pToken );
411 
412  // read the pin phase
413  pToken = strtok( NULL, " \t\r\n" );
414  if ( strcmp( pToken, MIO_STRING_UNKNOWN ) == 0 )
415  pPin->Phase = MIO_PHASE_UNKNOWN;
416  else if ( strcmp( pToken, MIO_STRING_INV ) == 0 )
417  pPin->Phase = MIO_PHASE_INV;
418  else if ( strcmp( pToken, MIO_STRING_NONINV ) == 0 )
419  pPin->Phase = MIO_PHASE_NONINV;
420  else
421  {
422  printf( "Cannot read pin phase specification\n" );
423  Mio_PinDelete( pPin );
424  *ppToken = pToken;
425  return NULL;
426  }
427 
428  pToken = strtok( NULL, " \t\r\n" );
429  pPin->dLoadInput = atof( pToken );
430 
431  pToken = strtok( NULL, " \t\r\n" );
432  pPin->dLoadMax = atof( pToken );
433 
434  pToken = strtok( NULL, " \t\r\n" );
435  pPin->dDelayBlockRise = atof( pToken );
436 
437  pToken = strtok( NULL, " \t\r\n" );
438  pPin->dDelayFanoutRise = atof( pToken );
439 
440  pToken = strtok( NULL, " \t\r\n" );
441  pPin->dDelayBlockFall = atof( pToken );
442 
443  pToken = strtok( NULL, " \t\r\n" );
444  pPin->dDelayFanoutFall = atof( pToken );
445 
446  if ( fExtendedFormat )
447  {
448  /* In extended format, the field after dDelayFanoutRise
449  * is to be ignored
450  **/
451 
452  pPin->dDelayBlockFall = pPin->dDelayFanoutFall;
453 
454  pToken = strtok( NULL, " \t" );
455  pPin->dDelayFanoutFall = atof( pToken );
456 
457  /* last field is ignored */
458  pToken = strtok( NULL, " \t\r\n" );
459  }
460 
461  if ( pPin->dDelayBlockRise > pPin->dDelayBlockFall )
462  pPin->dDelayBlockMax = pPin->dDelayBlockRise;
463  else
464  pPin->dDelayBlockMax = pPin->dDelayBlockFall;
465 
466  *ppToken = pToken;
467  return pPin;
468 }
469 
470 
471 /**Function*************************************************************
472 
473  Synopsis [Duplicates string and returns it with leading and
474  trailing spaces removed.]
475 
476  Description []
477 
478  SideEffects []
479 
480  SeeAlso []
481 
482 ***********************************************************************/
483 char * chomp( char *s )
484 {
485  char *a, *b, *c;
486  // remove leading spaces
487  for ( b = s; *b; b++ )
488  if ( !isspace(*b) )
489  break;
490  // strsav the string
491  a = strcpy( ABC_ALLOC(char, strlen(b)+1), b );
492  // remove trailing spaces
493  for ( c = a+strlen(a); c > a; c-- )
494  if ( *c == 0 || isspace(*c) )
495  *c = 0;
496  else
497  break;
498  return a;
499 }
500 
501 /**Function*************************************************************
502 
503  Synopsis []
504 
505  Description []
506 
507  SideEffects []
508 
509  SeeAlso []
510 
511 ***********************************************************************/
513 {
514  double Diff = (*pp1)->dArea - (*pp2)->dArea;
515  if ( Diff < 0.0 )
516  return -1;
517  if ( Diff > 0.0 )
518  return 1;
519  return 0;
520 }
521 
522 /**Function*************************************************************
523 
524  Synopsis []
525 
526  Description []
527 
528  SideEffects []
529 
530  SeeAlso []
531 
532 ***********************************************************************/
534 {
535  int Diff = strcmp( (*pp1)->pName, (*pp2)->pName );
536  if ( Diff < 0.0 )
537  return -1;
538  if ( Diff > 0.0 )
539  return 1;
540  return 0;
541 }
542 
543 /**Function*************************************************************
544 
545  Synopsis []
546 
547  Description []
548 
549  SideEffects []
550 
551  SeeAlso []
552 
553 ***********************************************************************/
555 {
556  Mio_Gate_t ** ppGates, * pGate;
557  int i = 0;
558  ppGates = ABC_ALLOC( Mio_Gate_t *, pLib->nGates );
559  Mio_LibraryForEachGate( pLib, pGate )
560  ppGates[i++] = pGate;
561  assert( i == pLib->nGates );
562  // sort gates by area
563  pLib->ppGates0 = ABC_ALLOC( Mio_Gate_t *, pLib->nGates );
564  for ( i = 0; i < pLib->nGates; i++ )
565  pLib->ppGates0[i] = ppGates[i];
566  qsort( (void *)ppGates, pLib->nGates, sizeof(void *),
567  (int (*)(const void *, const void *)) Mio_LibraryCompareGatesByArea );
568  for ( i = 0; i < pLib->nGates; i++ )
569  ppGates[i]->pNext = (i < pLib->nGates-1)? ppGates[i+1] : NULL;
570  pLib->pGates = ppGates[0];
571  ABC_FREE( ppGates );
572  // sort gates by name
573  pLib->ppGatesName = ABC_ALLOC( Mio_Gate_t *, pLib->nGates );
574  for ( i = 0; i < pLib->nGates; i++ )
575  pLib->ppGatesName[i] = pLib->ppGates0[i];
576  qsort( (void *)pLib->ppGatesName, pLib->nGates, sizeof(void *),
577  (int (*)(const void *, const void *)) Mio_LibraryCompareGatesByName );
578 }
579 
580 /**Function*************************************************************
581 
582  Synopsis []
583 
584  Description []
585 
586  SideEffects []
587 
588  SeeAlso []
589 
590 ***********************************************************************/
591 static inline Mio_Gate_t * Mio_GateCompare( Mio_Gate_t * pThis, Mio_Gate_t * pNew, word uTruth )
592 {
593  if ( pNew->uTruth != uTruth )
594  return pThis;
595  if ( pThis == NULL )
596  return pNew;
597  if ( pThis->dArea > pNew->dArea || (pThis->dArea == pNew->dArea && strcmp(pThis->pName, pNew->pName) > 0) )
598  return pNew;
599  return pThis;
600 }
602 {
603  Mio_Gate_t * pGate;
604  word uFuncBuf, uFuncInv, uFuncNand2, uFuncAnd2;
605 
606  Mio_LibrarySortGates( pLib );
607 
608  uFuncBuf = ABC_CONST(0xAAAAAAAAAAAAAAAA);
609  uFuncAnd2 = ABC_CONST(0xAAAAAAAAAAAAAAAA) & ABC_CONST(0xCCCCCCCCCCCCCCCC);
610  uFuncInv = ~uFuncBuf;
611  uFuncNand2 = ~uFuncAnd2;
612 
613  // get smallest-area buffer
614  Mio_LibraryForEachGate( pLib, pGate )
615  pLib->pGateBuf = Mio_GateCompare( pLib->pGateBuf, pGate, uFuncBuf );
616  if ( pLib->pGateBuf == NULL )
617  {
618  printf( "Warnings: genlib library reader cannot detect the buffer gate.\n" );
619  printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
620  }
621 
622  // get smallest-area inverter
623  Mio_LibraryForEachGate( pLib, pGate )
624  pLib->pGateInv = Mio_GateCompare( pLib->pGateInv, pGate, uFuncInv );
625  if ( pLib->pGateInv == NULL )
626  {
627  printf( "Warnings: genlib library reader cannot detect the invertor gate.\n" );
628  printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
629  }
630 
631  // get smallest-area NAND2/AND2 gates
632  Mio_LibraryForEachGate( pLib, pGate )
633  pLib->pGateNand2 = Mio_GateCompare( pLib->pGateNand2, pGate, uFuncNand2 );
634  Mio_LibraryForEachGate( pLib, pGate )
635  pLib->pGateAnd2 = Mio_GateCompare( pLib->pGateAnd2, pGate, uFuncAnd2 );
636  if ( pLib->pGateAnd2 == NULL && pLib->pGateNand2 == NULL )
637  {
638  printf( "Warnings: genlib library reader cannot detect the AND2 or NAND2 gate.\n" );
639  printf( "Some parts of the supergate-based technology mapper may not work correctly.\n" );
640  }
641 }
642 
643 /**Function*************************************************************
644 
645  Synopsis [populate hash table of gates to be exlcuded from genlib]
646 
647  Description []
648 
649  SideEffects []
650 
651  SeeAlso []
652 
653 ***********************************************************************/
654 int Mio_LibraryReadExclude( char * ExcludeFile, st__table * tExcludeGate )
655 {
656  int nDel = 0;
657  FILE *pEx;
658  char buffer[128];
659 
660  assert ( tExcludeGate );
661 
662  if ( ExcludeFile )
663  {
664  pEx = fopen( ExcludeFile, "r" );
665 
666  if ( pEx == NULL )
667  {
668  fprintf ( stdout, "Error: Could not open exclude file %s. Stop.\n", ExcludeFile );
669  return -1;
670  }
671 
672  while (1 == fscanf( pEx, "%127s", buffer ))
673  {
674  //printf ("Read: '%s'\n", buffer );
675  st__insert( tExcludeGate, Abc_UtilStrsav( buffer ), (char *)0 );
676  nDel++;
677  }
678 
679  fclose( pEx );
680  }
681 
682  return nDel;
683 }
684 
685 /**Function*************************************************************
686 
687  Synopsis [Eliminates comments from the input file.]
688 
689  Description [As a byproduct, this procedure also counts the number
690  lines and dot-statements in the input file. This also joins non-comment
691  lines that are joined with a backspace '\']
692 
693  SideEffects []
694 
695  SeeAlso []
696 
697 ***********************************************************************/
698 void Io_ReadFileRemoveComments( char * pBuffer, int * pnDots, int * pnLines )
699 {
700  char * pCur;
701  int nDots, nLines;
702  // scan through the buffer and eliminate comments
703  // (in the BLIF file, comments are lines starting with "#")
704  nDots = nLines = 0;
705  for ( pCur = pBuffer; *pCur; pCur++ )
706  {
707  // if this is the beginning of comment
708  // clean it with spaces until the new line statement
709  if ( *pCur == '#' )
710  while ( *pCur != '\n' )
711  *pCur++ = ' ';
712 
713  // count the number of new lines and dots
714  if ( *pCur == '\n' ) {
715  if (*(pCur-1)=='\r') {
716  // DOS(R) file support
717  if (*(pCur-2)!='\\') nLines++;
718  else {
719  // rewind to backslash and overwrite with a space
720  *(pCur-2) = ' ';
721  *(pCur-1) = ' ';
722  *pCur = ' ';
723  }
724  } else {
725  // UNIX(TM) file support
726  if (*(pCur-1)!='\\') nLines++;
727  else {
728  // rewind to backslash and overwrite with a space
729  *(pCur-1) = ' ';
730  *pCur = ' ';
731  }
732  }
733  }
734  else if ( *pCur == '.' )
735  nDots++;
736  }
737  if ( pnDots )
738  *pnDots = nDots;
739  if ( pnLines )
740  *pnLines = nLines;
741 }
742 
743 ////////////////////////////////////////////////////////////////////////
744 /// END OF FILE ///
745 ////////////////////////////////////////////////////////////////////////
746 
747 
749 
Mio_Gate_t ** ppGates0
Definition: mioInt.h:65
int Mio_LibraryParseFormulas(Mio_Library_t *pLib)
FUNCTION DEFINITIONS ///.
Definition: mioForm.c:58
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition: mioApi.c:99
void st__free_table(st__table *table)
Definition: st.c:81
char * pName
Definition: mioInt.h:82
Mio_Pin_t * pNext
Definition: mioInt.h:114
FILE * Io_FileOpen(const char *FileName, const char *PathVar, const char *Mode, int fVerbose)
Definition: ioUtil.c:819
int Mio_ParseCheckFormula(Mio_Gate_t *pGate, char *pForm)
Definition: mioParse.c:444
Mio_Gate_t * pTwin
Definition: mioInt.h:91
#define MIO_STRING_PIN
Definition: mioInt.h:45
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioUtils.c:48
char * pOutName
Definition: mioInt.h:86
double dDelayBlockMax
Definition: mioInt.h:113
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
Mio_Gate_t * pGates
Definition: mioInt.h:67
#define SEEK_END
Definition: zconf.h:392
char * strtok()
Mem_Flex_t * pMmFlex
Definition: mioInt.h:75
Mio_Library_t * pLib
Definition: mioInt.h:88
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
#define MIO_STRING_LATCH
Definition: mioInt.h:44
static char * chomp(char *s)
Definition: mioRead.c:483
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static Vec_Str_t * Vec_StrAlloc(int nCap)
Definition: bblif.c:495
char * Mio_ReadFile(char *FileName, int fAddEnd)
Definition: mioRead.c:111
#define st__is_member(table, key)
Definition: st.h:70
int Mio_LibraryCompareGatesByArea(Mio_Gate_t **pp1, Mio_Gate_t **pp2)
Definition: mioRead.c:512
char * pName
Definition: mioInt.h:105
void Mio_GateDelete(Mio_Gate_t *pGate)
Definition: mioUtils.c:81
Mio_Pin_t * pPins
Definition: mioInt.h:85
int strcmp()
void Mio_LibrarySortGates(Mio_Library_t *pLib)
Definition: mioRead.c:554
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
#define MIO_STRING_UNKNOWN
Definition: mioInt.h:48
int Mio_LibraryReadExclude(char *ExcludeFile, st__table *tExcludeGate)
Definition: mioRead.c:654
void Mio_PinDelete(Mio_Pin_t *pPin)
Definition: mioUtils.c:108
int st__strhash(const char *string, int modulus)
Definition: st.c:449
Mem_Flex_t * Mem_FlexStart()
Definition: mem.c:311
#define MIO_STRING_GATE
INCLUDES ///.
Definition: mioInt.h:43
double dDelayFanoutFall
Definition: mioInt.h:112
char * pForm
Definition: mioInt.h:84
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
double dDelayBlockFall
Definition: mioInt.h:111
Definition: st.h:52
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
Vec_Str_t * vCube
Definition: mioInt.h:76
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
static Mio_Gate_t * Mio_LibraryReadGate(char **ppToken, int fExtendedFormat)
Definition: mioRead.c:332
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
int Mio_LibraryCompareGatesByName(Mio_Gate_t **pp1, Mio_Gate_t **pp2)
Definition: mioRead.c:533
static void Mio_LibraryDetectSpecialGates(Mio_Library_t *pLib)
Definition: mioRead.c:601
#define MIO_STRING_INV
Definition: mioInt.h:47
Mio_PinPhase_t Phase
Definition: mioInt.h:106
char * strcpy()
double atof()
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
Mio_Gate_t * pGateAnd2
Definition: mioInt.h:73
static Mio_Pin_t * Mio_LibraryReadPin(char **ppToken, int fExtendedFormat)
Definition: mioRead.c:400
double dLoadMax
Definition: mioInt.h:108
double dLoadInput
Definition: mioInt.h:107
Mio_Gate_t * pNext
Definition: mioInt.h:90
static Mio_Library_t * Mio_LibraryReadBuffer(char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
Definition: mioRead.c:152
static ABC_NAMESPACE_IMPL_START Mio_Library_t * Mio_LibraryReadOne(char *FileName, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
DECLARATIONS ///.
Definition: mioRead.c:196
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
double dDelayFanoutRise
Definition: mioInt.h:110
static int Mio_LibraryReadInternal(Mio_Library_t *pLib, char *pBuffer, int fExtendedFormat, st__table *tExcludeGate, int fVerbose)
Definition: mioRead.c:225
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
char * strcat()
#define assert(ex)
Definition: util_old.h:213
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
int strlen()
static Mio_Gate_t * Mio_GateCompare(Mio_Gate_t *pThis, Mio_Gate_t *pNew, word uTruth)
Definition: mioRead.c:591
Mio_Gate_t * pGateBuf
Definition: mioInt.h:70
Mio_Gate_t ** ppGatesName
Definition: mioInt.h:66
double dArea
Definition: mioInt.h:83
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
double dDelayBlockRise
Definition: mioInt.h:109
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
st__table * tName2Gate
Definition: mioInt.h:74
VOID_HACK rewind()
#define MIO_STRING_NONINV
Definition: mioInt.h:46
static void Io_ReadFileRemoveComments(char *pBuffer, int *pnDots, int *pnLines)
Definition: mioRead.c:698