abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mio.h File Reference

Go to the source code of this file.

Data Structures

struct  Mio_Cell_t_
 

Macros

#define Mio_LibraryForEachGate(Lib, Gate)
 GLOBAL VARIABLES ///. More...
 
#define Mio_LibraryForEachGateSafe(Lib, Gate, Gate2)
 
#define Mio_GateForEachPin(Gate, Pin)
 
#define Mio_GateForEachPinSafe(Gate, Pin, Pin2)
 

Typedefs

typedef struct Mio_LibraryStruct_t_ Mio_Library_t
 
typedef struct Mio_GateStruct_t_ Mio_Gate_t
 
typedef struct Mio_PinStruct_t_ Mio_Pin_t
 
typedef struct Mio_Cell_t_ Mio_Cell_t
 

Enumerations

enum  Mio_PinPhase_t { MIO_PHASE_UNKNOWN, MIO_PHASE_INV, MIO_PHASE_NONINV }
 INCLUDES ///. More...
 

Functions

void Mio_UpdateGenlib (Mio_Library_t *pLib)
 FUNCTION DEFINITIONS ///. More...
 
int Mio_UpdateGenlib2 (Vec_Str_t *vStr, Vec_Str_t *vStr2, char *pFileName, int fVerbose)
 
char * Mio_LibraryReadName (Mio_Library_t *pLib)
 DECLARATIONS ///. More...
 
int Mio_LibraryReadGateNum (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadGates (Mio_Library_t *pLib)
 
Mio_Gate_t ** Mio_LibraryReadGateArray (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadGateByName (Mio_Library_t *pLib, char *pName, char *pOutName)
 
char * Mio_LibraryReadSopByName (Mio_Library_t *pLib, char *pName)
 
Mio_Gate_tMio_LibraryReadConst0 (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadConst1 (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadNand2 (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadAnd2 (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadBuf (Mio_Library_t *pLib)
 
Mio_Gate_tMio_LibraryReadInv (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayInvRise (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayInvFall (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayInvMax (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayNand2Rise (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayNand2Fall (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayNand2Max (Mio_Library_t *pLib)
 
float Mio_LibraryReadDelayAnd2Max (Mio_Library_t *pLib)
 
float Mio_LibraryReadAreaInv (Mio_Library_t *pLib)
 
float Mio_LibraryReadAreaBuf (Mio_Library_t *pLib)
 
float Mio_LibraryReadAreaNand2 (Mio_Library_t *pLib)
 
int Mio_LibraryReadGateNameMax (Mio_Library_t *pLib)
 
char * Mio_GateReadName (Mio_Gate_t *pGate)
 
char * Mio_GateReadOutName (Mio_Gate_t *pGate)
 
double Mio_GateReadArea (Mio_Gate_t *pGate)
 
char * Mio_GateReadForm (Mio_Gate_t *pGate)
 
Mio_Pin_tMio_GateReadPins (Mio_Gate_t *pGate)
 
Mio_Library_tMio_GateReadLib (Mio_Gate_t *pGate)
 
Mio_Gate_tMio_GateReadNext (Mio_Gate_t *pGate)
 
Mio_Gate_tMio_GateReadTwin (Mio_Gate_t *pGate)
 
int Mio_GateReadPinNum (Mio_Gate_t *pGate)
 
double Mio_GateReadDelayMax (Mio_Gate_t *pGate)
 
char * Mio_GateReadSop (Mio_Gate_t *pGate)
 
word Mio_GateReadTruth (Mio_Gate_t *pGate)
 
int Mio_GateReadValue (Mio_Gate_t *pGate)
 
char * Mio_GateReadPinName (Mio_Gate_t *pGate, int iPin)
 
float Mio_GateReadPinDelay (Mio_Gate_t *pGate, int iPin)
 
void Mio_GateSetValue (Mio_Gate_t *pGate, int Value)
 
char * Mio_PinReadName (Mio_Pin_t *pPin)
 
Mio_PinPhase_t Mio_PinReadPhase (Mio_Pin_t *pPin)
 
double Mio_PinReadInputLoad (Mio_Pin_t *pPin)
 
double Mio_PinReadMaxLoad (Mio_Pin_t *pPin)
 
double Mio_PinReadDelayBlockRise (Mio_Pin_t *pPin)
 
double Mio_PinReadDelayFanoutRise (Mio_Pin_t *pPin)
 
double Mio_PinReadDelayBlockFall (Mio_Pin_t *pPin)
 
double Mio_PinReadDelayFanoutFall (Mio_Pin_t *pPin)
 
double Mio_PinReadDelayBlockMax (Mio_Pin_t *pPin)
 
Mio_Pin_tMio_PinReadNext (Mio_Pin_t *pPin)
 
char * Mio_ReadFile (char *FileName, int fAddEnd)
 
Mio_Library_tMio_LibraryRead (char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
 
int Mio_LibraryReadExclude (char *ExcludeFile, st__table *tExcludeGate)
 
int Mio_LibraryParseFormulas (Mio_Library_t *pLib)
 FUNCTION DEFINITIONS ///. More...
 
Vec_Int_tMio_ParseFormula (char *pFormInit, char **ppVarNames, int nVars)
 
Vec_Wrd_tMio_ParseFormulaTruth (char *pFormInit, char **ppVarNames, int nVars)
 
int Mio_ParseCheckFormula (Mio_Gate_t *pGate, char *pForm)
 
char * Mio_LibDeriveSop (int nVars, Vec_Int_t *vExpr, Vec_Str_t *vStr)
 
void Mio_LibraryDelete (Mio_Library_t *pLib)
 DECLARATIONS ///. More...
 
void Mio_GateDelete (Mio_Gate_t *pGate)
 
void Mio_PinDelete (Mio_Pin_t *pPin)
 
Mio_Pin_tMio_PinDup (Mio_Pin_t *pPin)
 
void Mio_WriteLibrary (FILE *pFile, Mio_Library_t *pLib, int fPrintSops)
 
Mio_Gate_t ** Mio_CollectRoots (Mio_Library_t *pLib, int nInputs, float tDelay, int fSkipInv, int *pnGates, int fVerbose)
 
Mio_Cell_tMio_CollectRootsNew (Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
 
Mio_Cell_tMio_CollectRootsNewDefault (int nInputs, int *pnGates, int fVerbose)
 
word Mio_DeriveTruthTable6 (Mio_Gate_t *pGate)
 
void Mio_DeriveTruthTable (Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
 
void Mio_DeriveGateDelays (Mio_Gate_t *pGate, float **ptPinDelays, int nPins, int nInputs, float tDelayZero, float *ptDelaysRes, float *ptPinDelayMax)
 
Mio_Gate_tMio_GateCreatePseudo (int nInputs)
 
void Mio_LibraryShiftDelay (Mio_Library_t *pLib, double Shift)
 
void Mio_LibraryMultiArea (Mio_Library_t *pLib, double Multi)
 
void Mio_LibraryMultiDelay (Mio_Library_t *pLib, double Multi)
 
void Mio_LibraryTransferDelays (Mio_Library_t *pLibD, Mio_Library_t *pLibS)
 
Mio_Library_tAbc_SclDeriveGenlibSimple (void *pScl)
 
Mio_Library_tAbc_SclDeriveGenlib (void *pScl, float Slew, float Gain, int nGatesMin, int fVerbose)
 
int Abc_SclHasDelayInfo (void *pScl)
 

Macro Definition Documentation

#define Mio_GateForEachPin (   Gate,
  Pin 
)
Value:
for ( Pin = Mio_GateReadPins(Gate); \
Pin; \
Pin = Mio_PinReadNext(Pin) )
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179

Definition at line 76 of file mio.h.

#define Mio_GateForEachPinSafe (   Gate,
  Pin,
  Pin2 
)
Value:
for ( Pin = Mio_GateReadPins(Gate), \
Pin2 = (Pin? Mio_PinReadNext(Pin): NULL); \
Pin; \
Pin = Pin2, \
Pin2 = (Pin? Mio_PinReadNext(Pin): NULL) )
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179

Definition at line 80 of file mio.h.

#define Mio_LibraryForEachGate (   Lib,
  Gate 
)
Value:
for ( Gate = Mio_LibraryReadGates(Lib); \
Gate; \
Gate = Mio_GateReadNext(Gate) )
Mio_Gate_t * Mio_LibraryReadGates(Mio_Library_t *pLib)
Definition: mioApi.c:45
Mio_Gate_t * Mio_GateReadNext(Mio_Gate_t *pGate)
Definition: mioApi.c:149

GLOBAL VARIABLES ///.

MACRO DEFINITIONS ///

Definition at line 65 of file mio.h.

#define Mio_LibraryForEachGateSafe (   Lib,
  Gate,
  Gate2 
)
Value:
for ( Gate = Mio_LibraryReadGates(Lib), \
Gate2 = (Gate? Mio_GateReadNext(Gate): NULL); \
Gate; \
Gate = Gate2, \
Gate2 = (Gate? Mio_GateReadNext(Gate): NULL) )
Mio_Gate_t * Mio_LibraryReadGates(Mio_Library_t *pLib)
Definition: mioApi.c:45
Mio_Gate_t * Mio_GateReadNext(Mio_Gate_t *pGate)
Definition: mioApi.c:149

Definition at line 69 of file mio.h.

Typedef Documentation

typedef struct Mio_Cell_t_ Mio_Cell_t

Definition at line 46 of file mio.h.

typedef struct Mio_GateStruct_t_ Mio_Gate_t

Definition at line 43 of file mio.h.

Definition at line 42 of file mio.h.

typedef struct Mio_PinStruct_t_ Mio_Pin_t

Definition at line 44 of file mio.h.

Enumeration Type Documentation

INCLUDES ///.

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

FileName [mio.h]

PackageName [MVSIS 2.0: Multi-valued logic synthesis system.]

Synopsis [File reading/writing for technology mapping.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id:
mio.h,v 1.6 2004/08/09 22:16:31 satrajit Exp

]PARAMETERS ///STRUCTURE DEFINITIONS ///

Enumerator
MIO_PHASE_UNKNOWN 
MIO_PHASE_INV 
MIO_PHASE_NONINV 

Definition at line 40 of file mio.h.

Function Documentation

Mio_Library_t* Abc_SclDeriveGenlib ( void *  pScl,
float  Slew,
float  Gain,
int  nGatesMin,
int  fVerbose 
)

Definition at line 818 of file sclLibUtil.c.

819 {
820  int nCellCount = 0;
821  SC_Lib * p = (SC_Lib *)pScl;
822  float Slew = (SlewInit == 0) ? Abc_SclComputeAverageSlew(p) : SlewInit;
823  Vec_Str_t * vStr = Abc_SclProduceGenlibStr( p, Slew, Gain, nGatesMin, &nCellCount );
824  Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
825  Vec_StrFree( vStr );
826  if ( !pLib )
827  printf( "Reading library has filed.\n" );
828  else if ( fVerbose )
829  printf( "Derived GENLIB library \"%s\" with %d gates using slew %.2f ps and gain %.2f.\n", p->pName, nCellCount, Slew, Gain );
830  return pLib;
831 }
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
char * pFileName
Definition: sclLib.h:205
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
float Abc_SclComputeAverageSlew(SC_Lib *p)
Definition: sclLibUtil.c:317
Vec_Str_t * Abc_SclProduceGenlibStr(SC_Lib *p, float Slew, float Gain, int nGatesMin, int *pnCellCount)
Definition: sclLibUtil.c:735
char * pName
Definition: sclLib.h:204
Mio_Library_t* Abc_SclDeriveGenlibSimple ( void *  pScl)

Definition at line 710 of file sclLibUtil.c.

711 {
712  SC_Lib * p = (SC_Lib *)pScl;
714  Mio_Library_t * pLib = Mio_LibraryRead( p->pFileName, Vec_StrArray(vStr), NULL, 0 );
715  Vec_StrFree( vStr );
716  if ( pLib )
717  printf( "Derived GENLIB library \"%s\" with %d gates.\n", p->pName, SC_LibCellNum(p) );
718  else
719  printf( "Reading library has filed.\n" );
720  return pLib;
721 }
static int SC_LibCellNum(SC_Lib *p)
Definition: sclLib.h:239
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
char * pFileName
Definition: sclLib.h:205
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
Vec_Str_t * Abc_SclProduceGenlibStrSimple(SC_Lib *p)
Definition: sclLibUtil.c:663
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
char * pName
Definition: sclLib.h:204
int Abc_SclHasDelayInfo ( void *  pScl)

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

Synopsis [Returns 1 if the library has delay info.]

Description []

SideEffects []

SeeAlso []

Definition at line 292 of file sclLibUtil.c.

293 {
294  SC_Lib * p = (SC_Lib *)pScl;
295  SC_Cell * pCell;
296  SC_Timing * pTime;
297  pCell = Abc_SclFindInvertor(p, 0);
298  if ( pCell == NULL )
299  return 0;
300  pTime = Scl_CellPinTime( pCell, 0 );
301  if ( pTime == NULL )
302  return 0;
303  return 1;
304 }
static SC_Timing * Scl_CellPinTime(SC_Cell *pCell, int iPin)
Definition: sclLib.h:565
static Llb_Mgr_t * p
Definition: llb3Image.c:950
SC_Cell * Abc_SclFindInvertor(SC_Lib *p, int fFindBuff)
Definition: sclLibUtil.c:197
Mio_Gate_t** Mio_CollectRoots ( Mio_Library_t pLib,
int  nInputs,
float  tDelay,
int  fSkipInv,
int *  pnGates,
int  fVerbose 
)

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

Synopsis [Collects the set of root gates.]

Description [Only collects the gates with unique functionality, which have fewer inputs and shorter delay than the given limits.]

SideEffects []

SeeAlso []

Definition at line 302 of file mioUtils.c.

303 {
304  Mio_Gate_t * pGate;
305  Mio_Gate_t ** ppGates;
306  int i, nGates, iGate;
307  nGates = Mio_LibraryReadGateNum( pLib );
308  ppGates = ABC_ALLOC( Mio_Gate_t *, nGates );
309  iGate = 0;
310  // for each functionality, select gate with the smallest area
311  // if equal areas, select gate with lexicographically smaller name
312  Mio_LibraryForEachGate( pLib, pGate )
313  {
314  if ( pGate->nInputs > nInputs )
315  continue;
316  if ( tDelay > 0.0 && pGate->dDelayMax > (double)tDelay )
317  continue;
318  if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
319  continue;
320  if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) )
321  continue;
322  if ( pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) && fSkipInv )
323  continue;
324  if ( pGate->pTwin ) // skip multi-output gates for now
325  continue;
326  // check if the gate with this functionality already exists
327  for ( i = 0; i < iGate; i++ )
328  if ( ppGates[i]->uTruth == pGate->uTruth )
329  {
330  if ( ppGates[i]->dArea > pGate->dArea ||
331  (ppGates[i]->dArea == pGate->dArea && strcmp(ppGates[i]->pName, pGate->pName) > 0) )
332  ppGates[i] = pGate;
333  break;
334  }
335  if ( i < iGate )
336  continue;
337  assert( iGate < nGates );
338  ppGates[ iGate++ ] = pGate;
339  if ( fVerbose )
340  printf( "Selected gate %3d: %-20s A = %7.2f D = %7.2f %3s = %-s\n",
341  iGate+1, pGate->pName, pGate->dArea, pGate->dDelayMax, pGate->pOutName, pGate->pForm );
342  }
343  // sort by delay
344  if ( iGate > 0 )
345  {
346  qsort( (void *)ppGates, iGate, sizeof(Mio_Gate_t *),
347  (int (*)(const void *, const void *)) Mio_DelayCompare );
348  assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 );
349  }
350  if ( pnGates )
351  *pnGates = iGate;
352  return ppGates;
353 }
char * pName
Definition: mioInt.h:82
int Mio_DelayCompare(Mio_Gate_t **ppG1, Mio_Gate_t **ppG2)
Definition: mioUtils.c:281
Mio_Gate_t * pTwin
Definition: mioInt.h:91
char * pOutName
Definition: mioInt.h:86
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int strcmp()
char * pForm
Definition: mioInt.h:84
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
double dDelayMax
Definition: mioInt.h:95
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define assert(ex)
Definition: util_old.h:213
double dArea
Definition: mioInt.h:83
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition: mioApi.c:44
Mio_Cell_t* Mio_CollectRootsNew ( Mio_Library_t pLib,
int  nInputs,
int *  pnGates,
int  fVerbose 
)

Definition at line 404 of file mioUtils.c.

405 {
406  Mio_Gate_t * pGate;
407  Mio_Cell_t * ppCells;
408  int i, nGates, iCell = 4;
409  nGates = Mio_LibraryReadGateNum( pLib );
410  ppCells = ABC_CALLOC( Mio_Cell_t, nGates + 4 );
411  // for each functionality, select gate with the smallest area
412  // if equal areas, select gate with lexicographically smaller name
413  Mio_LibraryForEachGate( pLib, pGate )
414  {
415  if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
416  continue;
417  // check if the gate with this functionality already exists
418  for ( i = 0; i < iCell; i++ )
419  if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
420  {
421  if ( ppCells[i].Area > pGate->dArea ||
422  (ppCells[i].Area == pGate->dArea && strcmp(ppCells[i].pName, pGate->pName) > 0) )
423  {
424  Mio_CollectCopy( ppCells + i, pGate );
425  }
426  break;
427  }
428  if ( i < iCell )
429  continue;
430  if ( pGate->uTruth == 0 || pGate->uTruth == ~(word)0 )
431  {
432  int Idx = (int)(pGate->uTruth == ~(word)0);
433  assert( pGate->nInputs == 0 );
434  Mio_CollectCopy( ppCells + Idx, pGate );
435  continue;
436  }
437  if ( pGate->uTruth == ABC_CONST(0xAAAAAAAAAAAAAAAA) || pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA) )
438  {
439  int Idx = 2 + (int)(pGate->uTruth == ~ABC_CONST(0xAAAAAAAAAAAAAAAA));
440  assert( pGate->nInputs == 1 );
441  Mio_CollectCopy( ppCells + Idx, pGate );
442  continue;
443  }
444  Mio_CollectCopy( ppCells + iCell++, pGate );
445  }
446  if ( ppCells[0].pName == NULL )
447  { printf( "Error: Cannot find constant 0 gate in the library.\n" ); return NULL; }
448  if ( ppCells[1].pName == NULL )
449  { printf( "Error: Cannot find constant 1 gate in the library.\n" ); return NULL; }
450  if ( ppCells[2].pName == NULL )
451  { printf( "Error: Cannot find buffer gate in the library.\n" ); return NULL; }
452  if ( ppCells[3].pName == NULL )
453  { printf( "Error: Cannot find inverter gate in the library.\n" ); return NULL; }
454  // sort by delay
455  if ( iCell > 1 )
456  {
457  qsort( (void *)(ppCells + 4), iCell - 4, sizeof(Mio_Cell_t),
458  (int (*)(const void *, const void *)) Mio_DelayCompareNew );
459  assert( Mio_DelayCompareNew( ppCells + 4, ppCells + iCell - 1 ) <= 0 );
460  }
461  // assign IDs
462  for ( i = 0; i < iCell; i++ )
463  ppCells[i].Id = ppCells[i].pName ? i : -1;
464 
465  // report
466  if ( fVerbose )
467  {
468  // count gates
469  int * pCounts = ABC_CALLOC( int, nGates + 4 );
470  Mio_LibraryForEachGate( pLib, pGate )
471  {
472  if ( pGate->nInputs > nInputs || pGate->pTwin ) // skip large and multi-output
473  continue;
474  for ( i = 0; i < iCell; i++ )
475  if ( ppCells[i].pName && ppCells[i].uTruth == pGate->uTruth )
476  {
477  pCounts[i]++;
478  break;
479  }
480  assert( i < iCell );
481  }
482  for ( i = 0; i < iCell; i++ )
483  {
484  Mio_Cell_t * pCell = ppCells + i;
485  printf( "%4d : ", i );
486  if ( pCell->pName == NULL )
487  printf( "None\n" );
488  else
489  printf( "%-20s In = %d N = %3d A = %7.2f D = %7.2f\n",
490  pCell->pName, pCell->nFanins, pCounts[i], pCell->Area, pCell->Delays[0] );
491  }
492  ABC_FREE( pCounts );
493  }
494  if ( pnGates )
495  *pnGates = iCell;
496  return ppCells;
497 }
char * pName
Definition: mioInt.h:82
char * pName
Definition: mio.h:49
Mio_Gate_t * pTwin
Definition: mioInt.h:91
int Mio_DelayCompareNew(Mio_Cell_t *pG1, Mio_Cell_t *pG2)
Definition: mioUtils.c:367
int strcmp()
unsigned nFanins
Definition: mio.h:53
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
float Area
Definition: mio.h:51
#define ABC_CONST(number)
PARAMETERS ///.
Definition: abc_global.h:206
#define ABC_FREE(obj)
Definition: abc_global.h:232
void Mio_CollectCopy(Mio_Cell_t *pCell, Mio_Gate_t *pGate)
Definition: mioUtils.c:392
#define ABC_CALLOC(type, num)
Definition: abc_global.h:230
#define assert(ex)
Definition: util_old.h:213
double dArea
Definition: mioInt.h:83
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
float Delays[6]
Definition: mio.h:54
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition: mioApi.c:44
Mio_Cell_t* Mio_CollectRootsNewDefault ( int  nInputs,
int *  pnGates,
int  fVerbose 
)

Definition at line 498 of file mioUtils.c.

499 {
500  return Mio_CollectRootsNew( (Mio_Library_t *)Abc_FrameReadLibGen(), nInputs, pnGates, fVerbose );
501 }
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
Mio_Cell_t * Mio_CollectRootsNew(Mio_Library_t *pLib, int nInputs, int *pnGates, int fVerbose)
Definition: mioUtils.c:404
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
void Mio_DeriveGateDelays ( Mio_Gate_t pGate,
float **  ptPinDelays,
int  nPins,
int  nInputs,
float  tDelayZero,
float *  ptDelaysRes,
float *  ptPinDelayMax 
)

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

Synopsis [Derives the area and delay of the root of the gate.]

Description [Array of the resulting delays should be initialized to the (negative) SUPER_NO_VAR value.]

SideEffects []

SeeAlso []

Definition at line 725 of file mioUtils.c.

728 {
729  Mio_Pin_t * pPin;
730  float Delay, DelayMax;
731  int i, k;
732  assert( pGate->nInputs == nPins );
733  // set all the delays to the unused delay
734  for ( i = 0; i < nInputs; i++ )
735  ptDelaysRes[i] = tDelayZero;
736  // compute the delays for each input and the max delay at the same time
737  DelayMax = 0;
738  for ( i = 0; i < nInputs; i++ )
739  {
740  for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ )
741  {
742  if ( ptPinDelays[k][i] < 0 )
743  continue;
744  Delay = ptPinDelays[k][i] + (float)pPin->dDelayBlockMax;
745  if ( ptDelaysRes[i] < Delay )
746  ptDelaysRes[i] = Delay;
747  }
748  if ( k != nPins )
749  {
750  printf ("DEBUG: problem gate is %s\n", Mio_GateReadName( pGate ));
751  }
752  assert( k == nPins );
753  if ( DelayMax < ptDelaysRes[i] )
754  DelayMax = ptDelaysRes[i];
755  }
756  *ptPinDelayMax = DelayMax;
757 }
Mio_Pin_t * pNext
Definition: mioInt.h:114
double dDelayBlockMax
Definition: mioInt.h:113
Mio_Pin_t * pPins
Definition: mioInt.h:85
if(last==0)
Definition: sparse_int.h:34
#define assert(ex)
Definition: util_old.h:213
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
void Mio_DeriveTruthTable ( Mio_Gate_t pGate,
unsigned  uTruthsIn[][2],
int  nSigns,
int  nInputs,
unsigned  uTruthRes[] 
)

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

Synopsis [Derives the truth table of the gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 608 of file mioUtils.c.

609 {
610  word uRes, uFanins[6];
611  int i;
612  assert( pGate->nInputs == nSigns );
613  for ( i = 0; i < nSigns; i++ )
614  uFanins[i] = (((word)uTruthsIn[i][1]) << 32) | (word)uTruthsIn[i][0];
615  uRes = Exp_Truth6( nSigns, pGate->vExpr, (word *)uFanins );
616  uTruthRes[0] = uRes & 0xFFFFFFFF;
617  uTruthRes[1] = uRes >> 32;
618 }
static word Exp_Truth6(int nVars, Vec_Int_t *p, word *puFanins)
Definition: exp.h:183
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
Vec_Int_t * vExpr
Definition: mioInt.h:97
#define assert(ex)
Definition: util_old.h:213
word Mio_DeriveTruthTable6 ( Mio_Gate_t pGate)

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

Synopsis [Derives the truth table of the gate.]

Description []

SideEffects []

SeeAlso []

Definition at line 514 of file mioUtils.c.

515 {
516  static unsigned uTruths6[6][2] = {
517  { 0xAAAAAAAA, 0xAAAAAAAA },
518  { 0xCCCCCCCC, 0xCCCCCCCC },
519  { 0xF0F0F0F0, 0xF0F0F0F0 },
520  { 0xFF00FF00, 0xFF00FF00 },
521  { 0xFFFF0000, 0xFFFF0000 },
522  { 0x00000000, 0xFFFFFFFF }
523  };
524  union {
525  unsigned u[2];
526  word w;
527  } uTruthRes;
528  assert( pGate->nInputs <= 6 );
529  Mio_DeriveTruthTable( pGate, uTruths6, pGate->nInputs, 6, uTruthRes.u );
530  return uTruthRes.w;
531 }
void Mio_DeriveTruthTable(Mio_Gate_t *pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[])
Definition: mioUtils.c:608
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
#define assert(ex)
Definition: util_old.h:213
Mio_Gate_t* Mio_GateCreatePseudo ( int  nInputs)

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

Synopsis [Creates a pseudo-gate.]

Description [The pseudo-gate is a N-input gate with all info set to 0.]

SideEffects []

SeeAlso []

Definition at line 771 of file mioUtils.c.

772 {
773  Mio_Gate_t * pGate;
774  Mio_Pin_t * pPin;
775  int i;
776  // allocate the gate structure
777  pGate = ABC_ALLOC( Mio_Gate_t, 1 );
778  memset( pGate, 0, sizeof(Mio_Gate_t) );
779  pGate->nInputs = nInputs;
780  // create pins
781  for ( i = 0; i < nInputs; i++ )
782  {
783  pPin = ABC_ALLOC( Mio_Pin_t, 1 );
784  memset( pPin, 0, sizeof(Mio_Pin_t) );
785  pPin->pNext = pGate->pPins;
786  pGate->pPins = pPin;
787  }
788  return pGate;
789 }
char * memset()
Mio_Pin_t * pNext
Definition: mioInt.h:114
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
Mio_Pin_t * pPins
Definition: mioInt.h:85
void Mio_GateDelete ( Mio_Gate_t pGate)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 81 of file mioUtils.c.

82 {
83  Mio_Pin_t * pPin, * pPin2;
84  if ( pGate->nInputs > 6 )
85  ABC_FREE( pGate->pTruth );
86  Vec_IntFreeP( &pGate->vExpr );
87  ABC_FREE( pGate->pOutName );
88  ABC_FREE( pGate->pName );
89  ABC_FREE( pGate->pForm );
90 // if ( pGate->bFunc )
91 // Cudd_RecursiveDeref( pGate->pLib->dd, pGate->bFunc );
92  Mio_GateForEachPinSafe( pGate, pPin, pPin2 )
93  Mio_PinDelete( pPin );
94  ABC_FREE( pGate );
95 }
char * pName
Definition: mioInt.h:82
void Mio_PinDelete(Mio_Pin_t *pPin)
Definition: mioUtils.c:108
char * pOutName
Definition: mioInt.h:86
char * pForm
Definition: mioInt.h:84
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
#define Mio_GateForEachPinSafe(Gate, Pin, Pin2)
Definition: mio.h:80
Vec_Int_t * vExpr
Definition: mioInt.h:97
#define ABC_FREE(obj)
Definition: abc_global.h:232
word * pTruth
Definition: mioInt.h:99
double Mio_GateReadArea ( Mio_Gate_t pGate)

Definition at line 145 of file mioApi.c.

145 { return pGate->dArea; }
double dArea
Definition: mioInt.h:83
double Mio_GateReadDelayMax ( Mio_Gate_t pGate)

Definition at line 152 of file mioApi.c.

152 { return pGate->dDelayMax; }
double dDelayMax
Definition: mioInt.h:95
char* Mio_GateReadForm ( Mio_Gate_t pGate)

Definition at line 146 of file mioApi.c.

146 { return pGate->pForm; }
char * pForm
Definition: mioInt.h:84
Mio_Library_t* Mio_GateReadLib ( Mio_Gate_t pGate)

Definition at line 148 of file mioApi.c.

148 { return pGate->pLib; }
Mio_Library_t * pLib
Definition: mioInt.h:88
char* Mio_GateReadName ( Mio_Gate_t pGate)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file mioApi.c.

143 { return pGate->pName; }
char * pName
Definition: mioInt.h:82
Mio_Gate_t* Mio_GateReadNext ( Mio_Gate_t pGate)

Definition at line 149 of file mioApi.c.

149 { return pGate->pNext; }
Mio_Gate_t * pNext
Definition: mioInt.h:90
char* Mio_GateReadOutName ( Mio_Gate_t pGate)

Definition at line 144 of file mioApi.c.

144 { return pGate->pOutName; }
char * pOutName
Definition: mioInt.h:86
float Mio_GateReadPinDelay ( Mio_Gate_t pGate,
int  iPin 
)

Definition at line 201 of file mioApi.c.

202 {
203  Mio_Pin_t * pPin;
204  int i = 0;
205  Mio_GateForEachPin( pGate, pPin )
206  if ( i++ == iPin )
207  return 0.5 * pPin->dDelayBlockRise + 0.5 * pPin->dDelayBlockFall;
208  return ABC_INFINITY;
209 }
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
if(last==0)
Definition: sparse_int.h:34
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
char* Mio_GateReadPinName ( Mio_Gate_t pGate,
int  iPin 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 192 of file mioApi.c.

193 {
194  Mio_Pin_t * pPin;
195  int i = 0;
196  Mio_GateForEachPin( pGate, pPin )
197  if ( i++ == iPin )
198  return Mio_PinReadName(pPin);
199  return NULL;
200 }
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
if(last==0)
Definition: sparse_int.h:34
int Mio_GateReadPinNum ( Mio_Gate_t pGate)

Definition at line 151 of file mioApi.c.

151 { return pGate->nInputs; }
Mio_Pin_t* Mio_GateReadPins ( Mio_Gate_t pGate)

Definition at line 147 of file mioApi.c.

147 { return pGate->pPins; }
Mio_Pin_t * pPins
Definition: mioInt.h:85
char* Mio_GateReadSop ( Mio_Gate_t pGate)

Definition at line 153 of file mioApi.c.

153 { return pGate->pSop; }
char * pSop
Definition: mioInt.h:96
word Mio_GateReadTruth ( Mio_Gate_t pGate)

Definition at line 154 of file mioApi.c.

154 { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
Mio_Gate_t* Mio_GateReadTwin ( Mio_Gate_t pGate)

Definition at line 150 of file mioApi.c.

150 { return pGate->pTwin; }
Mio_Gate_t * pTwin
Definition: mioInt.h:91
int Mio_GateReadValue ( Mio_Gate_t pGate)

Definition at line 156 of file mioApi.c.

156 { return pGate->Value; }
void Mio_GateSetValue ( Mio_Gate_t pGate,
int  Value 
)

Definition at line 157 of file mioApi.c.

157 { pGate->Value = Value; }
char* Mio_LibDeriveSop ( int  nVars,
Vec_Int_t vExpr,
Vec_Str_t vStr 
)

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

Synopsis [Derives SOP representation.]

Description [The SOP is guaranteed to be SCC-free but not minimal.]

SideEffects []

SeeAlso []

Definition at line 257 of file mioSop.c.

258 {
259  Vec_Int_t * vSop;
260  Vec_Ptr_t * vSops0, * vSops1, * vTemp;
261  int i, Index0, Index1, fCompl0, fCompl1;
262  Vec_StrClear( vStr );
263  if ( Exp_IsConst0(vExpr) )
264  {
265  Vec_StrPrintStr( vStr, " 0\n" );
266  Vec_StrPush( vStr, '\0' );
267  return Vec_StrArray( vStr );
268  }
269  if ( Exp_IsConst1(vExpr) )
270  {
271  Vec_StrPrintStr( vStr, " 1\n" );
272  Vec_StrPush( vStr, '\0' );
273  return Vec_StrArray( vStr );
274  }
275  if ( Exp_IsLit(vExpr) )
276  {
277  for ( i = 0; i < nVars; i++ )
278  Vec_StrPush( vStr, '-' );
279  Vec_StrPrintStr( vStr, " 1\n" );
280  Vec_StrPush( vStr, '\0' );
281  assert( (Vec_IntEntry(vExpr,0) >> 1) < nVars );
282  Vec_StrWriteEntry( vStr, Vec_IntEntry(vExpr,0) >> 1, (char)('1' - (Vec_IntEntry(vExpr,0) & 1)) );
283  return Vec_StrArray( vStr );
284  }
285  vSops0 = Vec_PtrAlloc( nVars + Exp_NodeNum(vExpr) );
286  vSops1 = Vec_PtrAlloc( nVars + Exp_NodeNum(vExpr) );
287  for ( i = 0; i < nVars; i++ )
288  {
289  Vec_PtrPush( vSops0, Mio_SopVar0(i) );
290  Vec_PtrPush( vSops1, Mio_SopVar1(i) );
291  }
292  for ( i = 0; i < Exp_NodeNum(vExpr); i++ )
293  {
294  Index0 = Vec_IntEntry( vExpr, 2*i+0 ) >> 1;
295  Index1 = Vec_IntEntry( vExpr, 2*i+1 ) >> 1;
296  fCompl0 = Vec_IntEntry( vExpr, 2*i+0 ) & 1;
297  fCompl1 = Vec_IntEntry( vExpr, 2*i+1 ) & 1;
298  // positive polarity
299  vSop = Mio_SopCoverAnd( fCompl0 ? (Vec_Int_t *)Vec_PtrEntry(vSops0, Index0) : (Vec_Int_t *)Vec_PtrEntry(vSops1, Index0),
300  fCompl1 ? (Vec_Int_t *)Vec_PtrEntry(vSops0, Index1) : (Vec_Int_t *)Vec_PtrEntry(vSops1, Index1) );
301  Vec_PtrPush( vSops1, vSop );
302  // negative polarity
303  vSop = Mio_SopCoverOr( fCompl0 ? (Vec_Int_t *)Vec_PtrEntry(vSops1, Index0) : (Vec_Int_t *)Vec_PtrEntry(vSops0, Index0),
304  fCompl1 ? (Vec_Int_t *)Vec_PtrEntry(vSops1, Index1) : (Vec_Int_t *)Vec_PtrEntry(vSops0, Index1) );
305  Vec_PtrPush( vSops0, vSop );
306  }
307  // complement
308  if ( Vec_IntEntryLast(vExpr) & 1 )
309  {
310  vTemp = vSops0;
311  vSops0 = vSops1;
312  vSops1 = vTemp;
313  }
314  // select the best polarity
315  if ( Vec_IntSize( (Vec_Int_t *)Vec_PtrEntryLast(vSops0) ) < Vec_IntSize( (Vec_Int_t *)Vec_PtrEntryLast(vSops1) ) )
316  vSop = (Vec_Int_t *)Vec_PtrEntryLast(vSops0);
317  else
318  vSop = (Vec_Int_t *)Vec_PtrEntryLast(vSops1);
319  // convert positive polarity into SOP
320  Mio_SopDeriveFromArray( vSop, nVars, vStr, (vSop == Vec_PtrEntryLast(vSops1)) );
321  Vec_VecFree( (Vec_Vec_t *)vSops0 );
322  Vec_VecFree( (Vec_Vec_t *)vSops1 );
323  return Vec_StrArray( vStr );
324 }
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static int Exp_IsConst0(Vec_Int_t *p)
Definition: exp.h:64
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
static void Vec_StrClear(Vec_Str_t *p)
Definition: vecStr.h:519
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static void Vec_StrPush(Vec_Str_t *p, char Entry)
Definition: vecStr.h:535
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Vec_Int_t * Mio_SopVar0(int i)
Definition: mioSop.c:130
static void Vec_StrWriteEntry(Vec_Str_t *p, int i, char Entry)
Definition: vecStr.h:370
static void * Vec_PtrEntryLast(Vec_Ptr_t *p)
Definition: vecPtr.h:413
char * Mio_SopDeriveFromArray(Vec_Int_t *vSop, int nVars, Vec_Str_t *vStr, int fPolarity)
Definition: mioSop.c:205
static int Vec_IntEntry(Vec_Int_t *p, int i)
Definition: bblif.c:268
Vec_Int_t * Mio_SopCoverOr(Vec_Int_t *p, Vec_Int_t *q)
Definition: mioSop.c:82
static int Exp_NodeNum(Vec_Int_t *p)
Definition: exp.h:89
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static int Vec_IntEntryLast(Vec_Int_t *p)
Definition: bblif.c:319
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
static int Exp_IsLit(Vec_Int_t *p)
Definition: exp.h:85
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
Vec_Int_t * Mio_SopCoverAnd(Vec_Int_t *p, Vec_Int_t *q)
Definition: mioSop.c:106
static int Exp_IsConst1(Vec_Int_t *p)
Definition: exp.h:68
#define assert(ex)
Definition: util_old.h:213
static void Vec_StrPrintStr(Vec_Str_t *p, const char *pStr)
Definition: vecStr.h:627
Vec_Int_t * Mio_SopVar1(int i)
Definition: mioSop.c:149
void Mio_LibraryDelete ( Mio_Library_t pLib)

DECLARATIONS ///.

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

FileName [mioUtils.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [File reading/writing for technology mapping.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id:
mioUtils.c,v 1.6 2004/09/03 18:02:20 satrajit Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 48 of file mioUtils.c.

49 {
50  Mio_Gate_t * pGate, * pGate2;
51  if ( pLib == NULL )
52  return;
53  // free the bindings of nodes to gates from this library for all networks
55  // free the library
56  ABC_FREE( pLib->pName );
57  Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 )
58  Mio_GateDelete( pGate );
59  Mem_FlexStop( pLib->pMmFlex, 0 );
60  Vec_StrFree( pLib->vCube );
61  if ( pLib->tName2Gate )
62  st__free_table( pLib->tName2Gate );
63 // if ( pLib->dd )
64 // Cudd_Quit( pLib->dd );
65  ABC_FREE( pLib->ppGates0 );
66  ABC_FREE( pLib->ppGatesName );
67  ABC_FREE( pLib );
68 }
void st__free_table(st__table *table)
Definition: st.c:81
void Mio_GateDelete(Mio_Gate_t *pGate)
Definition: mioUtils.c:81
ABC_DLL void Abc_FrameUnmapAllNetworks(Abc_Frame_t *p)
Definition: mainFrame.c:532
static void Vec_StrFree(Vec_Str_t *p)
Definition: bblif.c:616
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
if(last==0)
Definition: sparse_int.h:34
void Mem_FlexStop(Mem_Flex_t *p, int fVerbose)
Definition: mem.c:343
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define Mio_LibraryForEachGateSafe(Lib, Gate, Gate2)
Definition: mio.h:69
void Mio_LibraryMultiArea ( Mio_Library_t pLib,
double  Multi 
)

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

Synopsis [Multiply areas/delays by values proportional to fanin count.]

Description []

SideEffects []

SeeAlso []

Definition at line 829 of file mioUtils.c.

830 {
831  Mio_Gate_t * pGate;
832  Mio_LibraryForEachGate( pLib, pGate )
833  {
834  if ( pGate->nInputs < 2 )
835  continue;
836 // printf( "Before %8.3f ", pGate->dArea );
837  pGate->dArea *= pow( pGate->nInputs, Multi );
838 // printf( "After %8.3f Inputs = %d. Factor = %8.3f\n", pGate->dArea, pGate->nInputs, pow( pGate->nInputs, Multi ) );
839  }
840 }
double dArea
Definition: mioInt.h:83
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
void Mio_LibraryMultiDelay ( Mio_Library_t pLib,
double  Multi 
)

Definition at line 841 of file mioUtils.c.

842 {
843  Mio_Gate_t * pGate;
844  Mio_Pin_t * pPin;
845  Mio_LibraryForEachGate( pLib, pGate )
846  {
847  if ( pGate->nInputs < 2 )
848  continue;
849 // printf( "Before %8.3f ", pGate->dDelayMax );
850  pGate->dDelayMax *= pow( pGate->nInputs, Multi );
851 // printf( "After %8.3f Inputs = %d. Factor = %8.3f\n", pGate->dDelayMax, pGate->nInputs, pow( pGate->nInputs, Multi ) );
852  Mio_GateForEachPin( pGate, pPin )
853  {
854  pPin->dDelayBlockRise *= pow( pGate->nInputs, Multi );
855  pPin->dDelayBlockFall *= pow( pGate->nInputs, Multi );
856  pPin->dDelayBlockMax *= pow( pGate->nInputs, Multi );
857  }
858  }
859 }
double dDelayBlockMax
Definition: mioInt.h:113
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
double dDelayBlockFall
Definition: mioInt.h:111
double dDelayMax
Definition: mioInt.h:95
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
double dDelayBlockRise
Definition: mioInt.h:109
int Mio_LibraryParseFormulas ( Mio_Library_t pLib)

FUNCTION DEFINITIONS ///.

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

Synopsis [Deriving the functionality of the gates.]

Description []

SideEffects []

SeeAlso []

Definition at line 58 of file mioForm.c.

59 {
60  Mio_Gate_t * pGate;
61 
62  // count the gates
63  pLib->nGates = 0;
64  Mio_LibraryForEachGate( pLib, pGate )
65  pLib->nGates++;
66 
67  // start a temporary BDD manager
68  pLib->dd = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 );
69  // introduce ZDD variables
70  Cudd_zddVarsFromBddVars( pLib->dd, 2 );
71 
72  // for each gate, derive its function
73  Mio_LibraryForEachGate( pLib, pGate )
74  if ( Mio_GateParseFormula( pGate ) )
75  return 1;
76  return 0;
77 }
#define CUDD_UNIQUE_SLOTS
Definition: cudd.h:97
#define CUDD_CACHE_SLOTS
Definition: cudd.h:98
static int Mio_GateParseFormula(Mio_Gate_t *pGate)
Definition: mioForm.c:111
DdManager * Cudd_Init(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory)
Definition: cuddInit.c:125
if(last==0)
Definition: sparse_int.h:34
int Cudd_zddVarsFromBddVars(DdManager *dd, int multiplicity)
Definition: cuddAPI.c:519
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
Mio_Library_t* Mio_LibraryRead ( char *  FileName,
char *  pBuffer,
char *  ExcludeFile,
int  fVerbose 
)

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

Synopsis [Read the genlib type of library.]

Description []

SideEffects []

SeeAlso []

Definition at line 54 of file mioRead.c.

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 }
void st__free_table(st__table *table)
Definition: st.c:81
int strcmp()
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
Definition: st.c:72
int Mio_LibraryReadExclude(char *ExcludeFile, st__table *tExcludeGate)
Definition: mioRead.c:654
int st__strhash(const char *string, int modulus)
Definition: st.c:449
Definition: st.h:52
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
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
char * Extra_FileNameGenericAppend(char *pBase, char *pSuffix)
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Mio_Gate_t* Mio_LibraryReadAnd2 ( Mio_Library_t pLib)

Definition at line 52 of file mioApi.c.

52 { return pLib->pGateAnd2; }
Mio_Gate_t * pGateAnd2
Definition: mioInt.h:73
float Mio_LibraryReadAreaBuf ( Mio_Library_t pLib)

Definition at line 61 of file mioApi.c.

61 { return (float)(pLib->pGateBuf? pLib->pGateBuf->dArea : 0.0); }
Mio_Gate_t * pGateBuf
Definition: mioInt.h:70
double dArea
Definition: mioInt.h:83
float Mio_LibraryReadAreaInv ( Mio_Library_t pLib)

Definition at line 60 of file mioApi.c.

60 { return (float)(pLib->pGateInv? pLib->pGateInv->dArea : 0.0); }
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
double dArea
Definition: mioInt.h:83
float Mio_LibraryReadAreaNand2 ( Mio_Library_t pLib)

Definition at line 62 of file mioApi.c.

62 { return (float)(pLib->pGateNand2? pLib->pGateNand2->dArea : 0.0); }
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
double dArea
Definition: mioInt.h:83
Mio_Gate_t* Mio_LibraryReadBuf ( Mio_Library_t pLib)

Definition at line 47 of file mioApi.c.

47 { return pLib->pGateBuf; }
Mio_Gate_t * pGateBuf
Definition: mioInt.h:70
Mio_Gate_t* Mio_LibraryReadConst0 ( Mio_Library_t pLib)

Definition at line 49 of file mioApi.c.

49 { return pLib->pGate0; }
Mio_Gate_t * pGate0
Definition: mioInt.h:68
Mio_Gate_t* Mio_LibraryReadConst1 ( Mio_Library_t pLib)

Definition at line 50 of file mioApi.c.

50 { return pLib->pGate1; }
Mio_Gate_t * pGate1
Definition: mioInt.h:69
float Mio_LibraryReadDelayAnd2Max ( Mio_Library_t pLib)

Definition at line 59 of file mioApi.c.

59 { return (float)(pLib->pGateAnd2? pLib->pGateAnd2->pPins->dDelayBlockMax : 0.0); }
double dDelayBlockMax
Definition: mioInt.h:113
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateAnd2
Definition: mioInt.h:73
float Mio_LibraryReadDelayInvFall ( Mio_Library_t pLib)

Definition at line 54 of file mioApi.c.

54 { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockFall : 0.0); }
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
double dDelayBlockFall
Definition: mioInt.h:111
float Mio_LibraryReadDelayInvMax ( Mio_Library_t pLib)

Definition at line 55 of file mioApi.c.

55 { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockMax : 0.0); }
double dDelayBlockMax
Definition: mioInt.h:113
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
float Mio_LibraryReadDelayInvRise ( Mio_Library_t pLib)

Definition at line 53 of file mioApi.c.

53 { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockRise : 0.0); }
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
double dDelayBlockRise
Definition: mioInt.h:109
float Mio_LibraryReadDelayNand2Fall ( Mio_Library_t pLib)

Definition at line 57 of file mioApi.c.

57 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockFall : 0.0); }
Mio_Pin_t * pPins
Definition: mioInt.h:85
double dDelayBlockFall
Definition: mioInt.h:111
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
float Mio_LibraryReadDelayNand2Max ( Mio_Library_t pLib)

Definition at line 58 of file mioApi.c.

58 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockMax : 0.0); }
double dDelayBlockMax
Definition: mioInt.h:113
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
float Mio_LibraryReadDelayNand2Rise ( Mio_Library_t pLib)

Definition at line 56 of file mioApi.c.

56 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockRise : 0.0); }
Mio_Pin_t * pPins
Definition: mioInt.h:85
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
double dDelayBlockRise
Definition: mioInt.h:109
int Mio_LibraryReadExclude ( char *  ExcludeFile,
st__table tExcludeGate 
)

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

Synopsis [populate hash table of gates to be exlcuded from genlib]

Description []

SideEffects []

SeeAlso []

Definition at line 654 of file mioRead.c.

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 }
int st__insert(st__table *table, const char *key, char *value)
Definition: st.c:171
#define assert(ex)
Definition: util_old.h:213
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
Mio_Gate_t** Mio_LibraryReadGateArray ( Mio_Library_t pLib)

Definition at line 46 of file mioApi.c.

46 { return pLib->ppGatesName;}
Mio_Gate_t ** ppGatesName
Definition: mioInt.h:66
Mio_Gate_t* Mio_LibraryReadGateByName ( Mio_Library_t pLib,
char *  pName,
char *  pOutName 
)

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

Synopsis [Read Mvc of the gate by name.]

Description []

SideEffects []

SeeAlso []

Definition at line 99 of file mioApi.c.

100 {
101  Mio_Gate_t * pGate;
102  if ( ! st__lookup( pLib->tName2Gate, pName, (char **)&pGate ) )
103  return NULL;
104  if ( pOutName == NULL )
105  return pGate;
106  if ( !strcmp(pGate->pOutName, pOutName) )
107  return pGate;
108  if ( pGate->pTwin && !strcmp(pGate->pTwin->pOutName, pOutName) )
109  return pGate->pTwin;
110  return NULL;
111 }
Mio_Gate_t * pTwin
Definition: mioInt.h:91
char * pOutName
Definition: mioInt.h:86
int strcmp()
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
st__table * tName2Gate
Definition: mioInt.h:74
int Mio_LibraryReadGateNameMax ( Mio_Library_t pLib)

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

Synopsis [Returns the longest gate name.]

Description []

SideEffects []

SeeAlso []

Definition at line 75 of file mioApi.c.

76 {
77  Mio_Gate_t * pGate;
78  int LenMax = 0, LenCur;
79  Mio_LibraryForEachGate( pLib, pGate )
80  {
81  LenCur = strlen( Mio_GateReadName(pGate) );
82  if ( LenMax < LenCur )
83  LenMax = LenCur;
84  }
85  return LenMax;
86 }
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
int strlen()
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
int Mio_LibraryReadGateNum ( Mio_Library_t pLib)

Definition at line 44 of file mioApi.c.

44 { return pLib->nGates; }
Mio_Gate_t* Mio_LibraryReadGates ( Mio_Library_t pLib)

Definition at line 45 of file mioApi.c.

45 { return pLib->pGates; }
Mio_Gate_t * pGates
Definition: mioInt.h:67
Mio_Gate_t* Mio_LibraryReadInv ( Mio_Library_t pLib)

Definition at line 48 of file mioApi.c.

48 { return pLib->pGateInv; }
Mio_Gate_t * pGateInv
Definition: mioInt.h:71
char* Mio_LibraryReadName ( Mio_Library_t pLib)

DECLARATIONS ///.

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

FileName [mioApi.c]

PackageName [MVSIS 1.3: Multi-valued logic synthesis system.]

Synopsis [File reading/writing for technology mapping.]

Author [MVSIS Group]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - September 8, 2003.]

Revision [

Id:
mioApi.c,v 1.4 2004/06/28 14:20:25 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 43 of file mioApi.c.

43 { return pLib->pName; }
Mio_Gate_t* Mio_LibraryReadNand2 ( Mio_Library_t pLib)

Definition at line 51 of file mioApi.c.

51 { return pLib->pGateNand2; }
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
char* Mio_LibraryReadSopByName ( Mio_Library_t pLib,
char *  pName 
)

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

Synopsis [Read Mvc of the gate by name.]

Description []

SideEffects []

SeeAlso []

Definition at line 124 of file mioApi.c.

125 {
126  Mio_Gate_t * pGate;
127  if ( st__lookup( pLib->tName2Gate, pName, (char **)&pGate ) )
128  return pGate->pSop;
129  return NULL;
130 }
char * pSop
Definition: mioInt.h:96
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
st__table * tName2Gate
Definition: mioInt.h:74
void Mio_LibraryShiftDelay ( Mio_Library_t pLib,
double  Shift 
)

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

Synopsis [Adds constant value to all delay values.]

Description [The pseudo-gate is a N-input gate with all info set to 0.]

SideEffects []

SeeAlso []

Definition at line 802 of file mioUtils.c.

803 {
804  Mio_Gate_t * pGate;
805  Mio_Pin_t * pPin;
806  Mio_LibraryForEachGate( pLib, pGate )
807  {
808  pGate->dDelayMax += Shift;
809  Mio_GateForEachPin( pGate, pPin )
810  {
811  pPin->dDelayBlockRise += Shift;
812  pPin->dDelayBlockFall += Shift;
813  pPin->dDelayBlockMax += Shift;
814  }
815  }
816 }
double dDelayBlockMax
Definition: mioInt.h:113
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
double dDelayBlockFall
Definition: mioInt.h:111
double dDelayMax
Definition: mioInt.h:95
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
double dDelayBlockRise
Definition: mioInt.h:109
void Mio_LibraryTransferDelays ( Mio_Library_t pLibD,
Mio_Library_t pLibS 
)

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

Synopsis [Transfers delays from the second to the first.]

Description []

SideEffects []

SeeAlso []

Definition at line 872 of file mioUtils.c.

873 {
874  Mio_Gate_t * pGateD, * pGateS;
875  Mio_Pin_t * pPinD, * pPinS;
876  Mio_LibraryForEachGate( pLibS, pGateS )
877  {
878  Mio_LibraryForEachGate( pLibD, pGateD )
879  {
880  if ( pGateD->uTruth != pGateS->uTruth )
881  continue;
882  pPinS = Mio_GateReadPins( pGateS );
883  Mio_GateForEachPin( pGateD, pPinD )
884  {
885  if (pPinS)
886  {
887  pPinD->dDelayBlockRise = pPinS->dDelayBlockRise;
888  pPinD->dDelayBlockFall = pPinS->dDelayBlockFall;
889  pPinD->dDelayBlockMax = pPinS->dDelayBlockMax;
890  pPinS = Mio_PinReadNext(pPinS);
891  }
892  else
893  {
894  pPinD->dDelayBlockRise = 0;
895  pPinD->dDelayBlockFall = 0;
896  pPinD->dDelayBlockMax = 0;
897  }
898  }
899  }
900  }
901 }
double dDelayBlockMax
Definition: mioInt.h:113
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
double dDelayBlockFall
Definition: mioInt.h:111
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
double dDelayBlockRise
Definition: mioInt.h:109
int Mio_ParseCheckFormula ( Mio_Gate_t pGate,
char *  pForm 
)

Definition at line 444 of file mioParse.c.

445 {
446  Mio_Pin_t * pPin;
447  char * pStr;
448  int i, iPin, fVisit[32] = {0};
449  if ( Mio_GateReadPins(pGate) == NULL || !strcmp(Mio_PinReadName(Mio_GateReadPins(pGate)), "*") )
450  return 1;
451 /*
452  // find the equality sign
453  pForm = strstr( pForm, "=" );
454  if ( pForm == NULL )
455  {
456  printf( "Skipping gate \"%s\" because formula \"%s\" has not equality sign (=).\n", pGate->pName, pForm );
457  return 0;
458  }
459 */
460 //printf( "Checking gate %s\n", pGate->pName );
461 
462  for ( pStr = pForm; *pStr; pStr++ )
463  {
464  if ( *pStr == ' ' ||
465  *pStr == MIO_EQN_SYM_OPEN ||
466  *pStr == MIO_EQN_SYM_CLOSE ||
467  *pStr == MIO_EQN_SYM_CONST0 ||
468  *pStr == MIO_EQN_SYM_CONST1 ||
469  *pStr == MIO_EQN_SYM_NEG ||
470  *pStr == MIO_EQN_SYM_NEGAFT ||
471  *pStr == MIO_EQN_SYM_AND ||
472  *pStr == MIO_EQN_SYM_AND2 ||
473  *pStr == MIO_EQN_SYM_XOR ||
474  *pStr == MIO_EQN_SYM_OR ||
475  *pStr == MIO_EQN_SYM_OR2
476  )
477  continue;
478  // return the number of the pin which has this name
479  iPin = Mio_ParseCheckName( pGate, &pStr );
480  if ( iPin == -1 )
481  {
482  printf( "Skipping gate \"%s\" because substring \"%s\" does not match with a pin name.\n", pGate->pName, pStr );
483  return 0;
484  }
485  assert( iPin < 32 );
486  fVisit[iPin] = 1;
487  }
488  // check that all pins are used
489  for ( pPin = Mio_GateReadPins(pGate), i = 0; pPin; pPin = Mio_PinReadNext(pPin), i++ )
490  if ( fVisit[i] == 0 )
491  {
492 // printf( "Skipping gate \"%s\" because pin \"%s\" does not appear in the formula \"%s\".\n", pGate->pName, Mio_PinReadName(pPin), pForm );
493  return 0;
494  }
495  return 1;
496 }
#define MIO_EQN_SYM_XOR
Definition: mioParse.c:38
char * pName
Definition: mioInt.h:82
#define MIO_EQN_SYM_CONST1
Definition: mioParse.c:33
#define MIO_EQN_SYM_OR2
Definition: mioParse.c:40
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
#define MIO_EQN_SYM_OPEN
DECLARATIONS ///.
Definition: mioParse.c:30
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
#define MIO_EQN_SYM_OR
Definition: mioParse.c:39
#define MIO_EQN_SYM_CLOSE
Definition: mioParse.c:31
int strcmp()
#define MIO_EQN_SYM_CONST0
Definition: mioParse.c:32
#define MIO_EQN_SYM_AND
Definition: mioParse.c:36
int Mio_ParseCheckName(Mio_Gate_t *pGate, char **ppStr)
Definition: mioParse.c:429
#define MIO_EQN_SYM_AND2
Definition: mioParse.c:37
#define assert(ex)
Definition: util_old.h:213
#define MIO_EQN_SYM_NEGAFT
Definition: mioParse.c:35
#define MIO_EQN_SYM_NEG
Definition: mioParse.c:34
Vec_Int_t* Mio_ParseFormula ( char *  pFormInit,
char **  ppVarNames,
int  nVars 
)

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

Synopsis [Derives the AIG corresponding to the equation.]

Description [Takes the stream to output messages, the formula, the vector of variable names and the AIG manager.]

SideEffects []

SeeAlso []

Definition at line 105 of file mioParse.c.

106 {
107  char * pFormula;
108  int Man = nVars, * pMan = &Man;
109  Vec_Ptr_t * pStackFn;
110  Vec_Int_t * pStackOp;
111  Vec_Int_t * gFunc;
112  char * pTemp, * pName;
113  int nParans, fFound, Flag;
114  int Oper, Oper1, Oper2;
115  int i, v;
116 
117  // make sure that the number of opening and closing parantheses is the same
118  nParans = 0;
119  for ( pTemp = pFormInit; *pTemp; pTemp++ )
120  if ( *pTemp == '(' )
121  nParans++;
122  else if ( *pTemp == ')' )
123  nParans--;
124  if ( nParans != 0 )
125  {
126  fprintf( stdout, "Mio_ParseFormula(): Different number of opening and closing parantheses ().\n" );
127  return NULL;
128  }
129 
130  // copy the formula
131  pFormula = ABC_ALLOC( char, strlen(pFormInit) + 3 );
132  sprintf( pFormula, "(%s)", pFormInit );
133 
134  // start the stacks
135  pStackFn = Vec_PtrAlloc( 100 );
136  pStackOp = Vec_IntAlloc( 100 );
137 
138  Flag = MIO_EQN_FLAG_START;
139  for ( pTemp = pFormula; *pTemp; pTemp++ )
140  {
141  switch ( *pTemp )
142  {
143  // skip all spaces, tabs, and end-of-lines
144  case ' ':
145  case '\t':
146  case '\r':
147  case '\n':
148  continue;
149  case MIO_EQN_SYM_CONST0:
150  Vec_PtrPush( pStackFn, Exp_Const0() ); // Cudd_Ref( b0 );
151  if ( Flag == MIO_EQN_FLAG_VAR )
152  {
153  fprintf( stdout, "Mio_ParseFormula(): No operation symbol before constant 0.\n" );
154  Flag = MIO_EQN_FLAG_ERROR;
155  break;
156  }
157  Flag = MIO_EQN_FLAG_VAR;
158  break;
159  case MIO_EQN_SYM_CONST1:
160  Vec_PtrPush( pStackFn, Exp_Const1() ); // Cudd_Ref( b1 );
161  if ( Flag == MIO_EQN_FLAG_VAR )
162  {
163  fprintf( stdout, "Mio_ParseFormula(): No operation symbol before constant 1.\n" );
164  Flag = MIO_EQN_FLAG_ERROR;
165  break;
166  }
167  Flag = MIO_EQN_FLAG_VAR;
168  break;
169  case MIO_EQN_SYM_NEG:
170  if ( Flag == MIO_EQN_FLAG_VAR )
171  {// if NEGBEF follows a variable, AND is assumed
172  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
173  Flag = MIO_EQN_FLAG_OPER;
174  }
175  Vec_IntPush( pStackOp, MIO_EQN_OPER_NEG );
176  break;
177  case MIO_EQN_SYM_NEGAFT:
178  if ( Flag != MIO_EQN_FLAG_VAR )
179  {// if there is no variable before NEGAFT, it is an error
180  fprintf( stdout, "Mio_ParseFormula(): No variable is specified before the negation suffix.\n" );
181  Flag = MIO_EQN_FLAG_ERROR;
182  break;
183  }
184  else // if ( Flag == PARSE_FLAG_VAR )
185  Vec_PtrPush( pStackFn, Exp_Not( (Vec_Int_t *)Vec_PtrPop(pStackFn) ) );
186  break;
187  case MIO_EQN_SYM_AND:
188  case MIO_EQN_SYM_AND2:
189  case MIO_EQN_SYM_OR:
190  case MIO_EQN_SYM_OR2:
191  case MIO_EQN_SYM_XOR:
192  if ( Flag != MIO_EQN_FLAG_VAR )
193  {
194  fprintf( stdout, "Mio_ParseFormula(): There is no variable before AND, EXOR, or OR.\n" );
195  Flag = MIO_EQN_FLAG_ERROR;
196  break;
197  }
198  if ( *pTemp == MIO_EQN_SYM_AND || *pTemp == MIO_EQN_SYM_AND2 )
199  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
200  else if ( *pTemp == MIO_EQN_SYM_OR || *pTemp == MIO_EQN_SYM_OR2 )
201  Vec_IntPush( pStackOp, MIO_EQN_OPER_OR );
202  else //if ( *pTemp == MIO_EQN_SYM_XOR )
203  Vec_IntPush( pStackOp, MIO_EQN_OPER_XOR );
204  Flag = MIO_EQN_FLAG_OPER;
205  break;
206  case MIO_EQN_SYM_OPEN:
207  if ( Flag == MIO_EQN_FLAG_VAR )
208  {
209  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
210 // fprintf( stdout, "Mio_ParseFormula(): An opening paranthesis follows a var without operation sign.\n" );
211 // Flag = MIO_EQN_FLAG_ERROR;
212 // break;
213  }
214  Vec_IntPush( pStackOp, MIO_EQN_OPER_MARK );
215  // after an opening bracket, it feels like starting over again
216  Flag = MIO_EQN_FLAG_START;
217  break;
218  case MIO_EQN_SYM_CLOSE:
219  if ( Vec_IntSize( pStackOp ) != 0 )
220  {
221  while ( 1 )
222  {
223  if ( Vec_IntSize( pStackOp ) == 0 )
224  {
225  fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
226  Flag = MIO_EQN_FLAG_ERROR;
227  break;
228  }
229  Oper = Vec_IntPop( pStackOp );
230  if ( Oper == MIO_EQN_OPER_MARK )
231  break;
232 
233  // perform the given operation
234  if ( Mio_ParseFormulaOper( pMan, nVars, pStackFn, Oper ) == NULL )
235  {
236  fprintf( stdout, "Mio_ParseFormula(): Unknown operation\n" );
237  ABC_FREE( pFormula );
238  Vec_PtrFreeP( &pStackFn );
239  Vec_IntFreeP( &pStackOp );
240  return NULL;
241  }
242  }
243  }
244  else
245  {
246  fprintf( stdout, "Mio_ParseFormula(): There is no opening paranthesis\n" );
247  Flag = MIO_EQN_FLAG_ERROR;
248  break;
249  }
250  if ( Flag != MIO_EQN_FLAG_ERROR )
251  Flag = MIO_EQN_FLAG_VAR;
252  break;
253 
254 
255  default:
256  // scan the next name
257  for ( i = 0; pTemp[i] &&
258  pTemp[i] != ' ' && pTemp[i] != '\t' && pTemp[i] != '\r' && pTemp[i] != '\n' &&
259  pTemp[i] != MIO_EQN_SYM_AND && pTemp[i] != MIO_EQN_SYM_AND2 && pTemp[i] != MIO_EQN_SYM_OR && pTemp[i] != MIO_EQN_SYM_OR2 &&
260  pTemp[i] != MIO_EQN_SYM_XOR && pTemp[i] != MIO_EQN_SYM_NEGAFT && pTemp[i] != MIO_EQN_SYM_CLOSE;
261  i++ )
262  {
263  if ( pTemp[i] == MIO_EQN_SYM_NEG || pTemp[i] == MIO_EQN_SYM_OPEN )
264  {
265  fprintf( stdout, "Mio_ParseFormula(): The negation sign or an opening paranthesis inside the variable name.\n" );
266  Flag = MIO_EQN_FLAG_ERROR;
267  break;
268  }
269  }
270  // variable name is found
271  fFound = 0;
272 // Vec_PtrForEachEntry( char *, vVarNames, pName, v )
273  for ( v = 0; v < nVars; v++ )
274  {
275  pName = ppVarNames[v];
276  if ( strncmp(pTemp, pName, i) == 0 && strlen(pName) == (unsigned)i )
277  {
278  pTemp += i-1;
279  fFound = 1;
280  break;
281  }
282  }
283  if ( !fFound )
284  {
285  fprintf( stdout, "Mio_ParseFormula(): The parser cannot find var \"%s\" in the input var list.\n", pTemp );
286  Flag = MIO_EQN_FLAG_ERROR;
287  break;
288  }
289 /*
290  if ( Flag == MIO_EQN_FLAG_VAR )
291  {
292  fprintf( stdout, "Mio_ParseFormula(): The variable name \"%s\" follows another var without operation sign.\n", pTemp );
293  Flag = MIO_EQN_FLAG_ERROR;
294  break;
295  }
296 */
297  if ( Flag == MIO_EQN_FLAG_VAR )
298  Vec_IntPush( pStackOp, MIO_EQN_OPER_AND );
299 
300  Vec_PtrPush( pStackFn, Exp_Var(v) ); // Cudd_Ref( pbVars[v] );
301  Flag = MIO_EQN_FLAG_VAR;
302  break;
303  }
304 
305  if ( Flag == MIO_EQN_FLAG_ERROR )
306  break; // error exit
307  else if ( Flag == MIO_EQN_FLAG_START )
308  continue; // go on parsing
309  else if ( Flag == MIO_EQN_FLAG_VAR )
310  while ( 1 )
311  { // check if there are negations in the OpStack
312  if ( Vec_IntSize( pStackOp ) == 0 )
313  break;
314  Oper = Vec_IntPop( pStackOp );
315  if ( Oper != MIO_EQN_OPER_NEG )
316  {
317  Vec_IntPush( pStackOp, Oper );
318  break;
319  }
320  else
321  {
322  Vec_PtrPush( pStackFn, Exp_Not((Vec_Int_t *)Vec_PtrPop(pStackFn)) );
323  }
324  }
325  else // if ( Flag == MIO_EQN_FLAG_OPER )
326  while ( 1 )
327  { // execute all the operations in the OpStack
328  // with precedence higher or equal than the last one
329  Oper1 = Vec_IntPop( pStackOp ); // the last operation
330  if ( Vec_IntSize( pStackOp ) == 0 )
331  { // if it is the only operation, push it back
332  Vec_IntPush( pStackOp, Oper1 );
333  break;
334  }
335  Oper2 = Vec_IntPop( pStackOp ); // the operation before the last one
336  if ( Oper2 >= Oper1 )
337  { // if Oper2 precedence is higher or equal, execute it
338  if ( Mio_ParseFormulaOper( pMan, nVars, pStackFn, Oper2 ) == NULL )
339  {
340  fprintf( stdout, "Mio_ParseFormula(): Unknown operation\n" );
341  ABC_FREE( pFormula );
342  Vec_PtrFreeP( &pStackFn );
343  Vec_IntFreeP( &pStackOp );
344  return NULL;
345  }
346  Vec_IntPush( pStackOp, Oper1 ); // push the last operation back
347  }
348  else
349  { // if Oper2 precedence is lower, push them back and done
350  Vec_IntPush( pStackOp, Oper2 );
351  Vec_IntPush( pStackOp, Oper1 );
352  break;
353  }
354  }
355  }
356 
357  if ( Flag != MIO_EQN_FLAG_ERROR )
358  {
359  if ( Vec_PtrSize(pStackFn) != 0 )
360  {
361  gFunc = (Vec_Int_t *)Vec_PtrPop(pStackFn);
362  if ( Vec_PtrSize(pStackFn) == 0 )
363  if ( Vec_IntSize( pStackOp ) == 0 )
364  {
365 // Cudd_Deref( gFunc );
366  ABC_FREE( pFormula );
367  Vec_PtrFreeP( &pStackFn );
368  Vec_IntFreeP( &pStackOp );
369  return Exp_Reverse(gFunc);
370  }
371  else
372  fprintf( stdout, "Mio_ParseFormula(): Something is left in the operation stack\n" );
373  else
374  fprintf( stdout, "Mio_ParseFormula(): Something is left in the function stack\n" );
375  }
376  else
377  fprintf( stdout, "Mio_ParseFormula(): The input string is empty\n" );
378  }
379  ABC_FREE( pFormula );
380  Vec_PtrFreeP( &pStackFn );
381  Vec_IntFreeP( &pStackOp );
382  return NULL;
383 }
#define MIO_EQN_SYM_XOR
Definition: mioParse.c:38
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
#define MIO_EQN_SYM_CONST1
Definition: mioParse.c:33
static Vec_Int_t * Exp_Var(int iVar)
Definition: exp.h:72
#define MIO_EQN_SYM_OR2
Definition: mioParse.c:40
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
#define MIO_EQN_SYM_OPEN
DECLARATIONS ///.
Definition: mioParse.c:30
#define MIO_EQN_OPER_XOR
Definition: mioParse.c:45
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void * Vec_PtrPop(Vec_Ptr_t *p)
Definition: vecPtr.h:677
#define MIO_EQN_SYM_OR
Definition: mioParse.c:39
#define MIO_EQN_OPER_MARK
Definition: mioParse.c:47
#define MIO_EQN_SYM_CLOSE
Definition: mioParse.c:31
#define MIO_EQN_FLAG_ERROR
Definition: mioParse.c:53
static Vec_Int_t * Exp_Const0()
Definition: exp.h:46
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
#define MIO_EQN_SYM_CONST0
Definition: mioParse.c:32
static int Vec_IntPop(Vec_Int_t *p)
#define MIO_EQN_OPER_AND
Definition: mioParse.c:44
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
char * sprintf()
#define MIO_EQN_OPER_NEG
Definition: mioParse.c:43
#define MIO_EQN_SYM_AND
Definition: mioParse.c:36
static void Vec_IntFreeP(Vec_Int_t **p)
Definition: vecInt.h:289
static Vec_Int_t * Exp_Reverse(Vec_Int_t *p)
Definition: exp.h:124
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
#define MIO_EQN_FLAG_START
Definition: mioParse.c:50
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define MIO_EQN_FLAG_OPER
Definition: mioParse.c:52
#define MIO_EQN_FLAG_VAR
Definition: mioParse.c:51
int strncmp()
static void Vec_PtrFreeP(Vec_Ptr_t **p)
Definition: vecPtr.h:240
#define MIO_EQN_SYM_AND2
Definition: mioParse.c:37
int strlen()
static Vec_Int_t * Exp_Not(Vec_Int_t *p)
Definition: exp.h:93
#define MIO_EQN_SYM_NEGAFT
Definition: mioParse.c:35
Vec_Int_t * Mio_ParseFormulaOper(int *pMan, int nVars, Vec_Ptr_t *pStackFn, int Oper)
FUNCTION DEFINITIONS ///.
Definition: mioParse.c:70
static Vec_Int_t * Exp_Const1()
Definition: exp.h:53
#define MIO_EQN_SYM_NEG
Definition: mioParse.c:34
#define MIO_EQN_OPER_OR
Definition: mioParse.c:46
Vec_Wrd_t* Mio_ParseFormulaTruth ( char *  pFormInit,
char **  ppVarNames,
int  nVars 
)

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

Synopsis [Derives the TT corresponding to the equation.]

Description []

SideEffects []

SeeAlso []

Definition at line 396 of file mioParse.c.

397 {
398  Vec_Int_t * vExpr;
399  Vec_Wrd_t * vTruth;
400  // derive expression
401  vExpr = Mio_ParseFormula( pFormInit, ppVarNames, nVars );
402  if ( vExpr == NULL )
403  return NULL;
404  // convert it into a truth table
405  vTruth = Vec_WrdStart( Abc_Truth6WordNum(nVars) );
406  Exp_Truth( nVars, vExpr, Vec_WrdArray(vTruth) );
407  Vec_IntFree( vExpr );
408  return vTruth;
409 }
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
Vec_Int_t * Mio_ParseFormula(char *pFormInit, char **ppVarNames, int nVars)
Definition: mioParse.c:105
static int Abc_Truth6WordNum(int nVars)
Definition: abc_global.h:257
static Vec_Wrd_t * Vec_WrdStart(int nSize)
Definition: vecWrd.h:103
static void Exp_Truth(int nVars, Vec_Int_t *p, word *pRes)
Definition: exp.h:221
static word * Vec_WrdArray(Vec_Wrd_t *p)
Definition: vecWrd.h:316
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.
Definition: vecWrd.h:42
void Mio_PinDelete ( Mio_Pin_t pPin)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 108 of file mioUtils.c.

109 {
110  ABC_FREE( pPin->pName );
111  ABC_FREE( pPin );
112 }
char * pName
Definition: mioInt.h:105
#define ABC_FREE(obj)
Definition: abc_global.h:232
Mio_Pin_t* Mio_PinDup ( Mio_Pin_t pPin)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 125 of file mioUtils.c.

126 {
127  Mio_Pin_t * pPinNew;
128 
129  pPinNew = ABC_ALLOC( Mio_Pin_t, 1 );
130  *pPinNew = *pPin;
131  pPinNew->pName = (pPinNew->pName ? Abc_UtilStrsav(pPinNew->pName) : NULL);
132  pPinNew->pNext = NULL;
133 
134  return pPinNew;
135 }
Mio_Pin_t * pNext
Definition: mioInt.h:114
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pName
Definition: mioInt.h:105
char * Abc_UtilStrsav(char *s)
Definition: starter.c:47
double Mio_PinReadDelayBlockFall ( Mio_Pin_t pPin)

Definition at line 176 of file mioApi.c.

176 { return pPin->dDelayBlockFall; }
double dDelayBlockFall
Definition: mioInt.h:111
double Mio_PinReadDelayBlockMax ( Mio_Pin_t pPin)

Definition at line 178 of file mioApi.c.

178 { return pPin->dDelayBlockMax; }
double dDelayBlockMax
Definition: mioInt.h:113
double Mio_PinReadDelayBlockRise ( Mio_Pin_t pPin)

Definition at line 174 of file mioApi.c.

174 { return pPin->dDelayBlockRise; }
double dDelayBlockRise
Definition: mioInt.h:109
double Mio_PinReadDelayFanoutFall ( Mio_Pin_t pPin)

Definition at line 177 of file mioApi.c.

177 { return pPin->dDelayFanoutFall;}
double dDelayFanoutFall
Definition: mioInt.h:112
double Mio_PinReadDelayFanoutRise ( Mio_Pin_t pPin)

Definition at line 175 of file mioApi.c.

175 { return pPin->dDelayFanoutRise;}
double dDelayFanoutRise
Definition: mioInt.h:110
double Mio_PinReadInputLoad ( Mio_Pin_t pPin)

Definition at line 172 of file mioApi.c.

172 { return pPin->dLoadInput; }
double dLoadInput
Definition: mioInt.h:107
double Mio_PinReadMaxLoad ( Mio_Pin_t pPin)

Definition at line 173 of file mioApi.c.

173 { return pPin->dLoadMax; }
double dLoadMax
Definition: mioInt.h:108
char* Mio_PinReadName ( Mio_Pin_t pPin)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 170 of file mioApi.c.

170 { return pPin->pName; }
char * pName
Definition: mioInt.h:105
Mio_Pin_t* Mio_PinReadNext ( Mio_Pin_t pPin)

Definition at line 179 of file mioApi.c.

179 { return pPin->pNext; }
Mio_Pin_t * pNext
Definition: mioInt.h:114
Mio_PinPhase_t Mio_PinReadPhase ( Mio_Pin_t pPin)

Definition at line 171 of file mioApi.c.

171 { return pPin->Phase; }
Mio_PinPhase_t Phase
Definition: mioInt.h:106
char* Mio_ReadFile ( char *  FileName,
int  fAddEnd 
)

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

Synopsis [Read contents of the file.]

Description []

SideEffects []

SeeAlso []

Definition at line 111 of file mioRead.c.

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 }
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()
void Mio_UpdateGenlib ( Mio_Library_t pLib)

FUNCTION DEFINITIONS ///.

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 124 of file mio.c.

125 {
126  // free the current superlib because it depends on the old Mio library
127  if ( Abc_FrameReadLibSuper() )
128  {
130  Abc_FrameSetLibSuper( NULL );
131  }
132 
133  // replace the current library
135  Abc_FrameSetLibGen( pLib );
136 
137  // replace the current library
139  Abc_FrameSetLibGen2( NULL );
140 }
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition: mainFrame.c:84
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
ABC_DLL void * Abc_FrameReadLibGen2()
Definition: mainFrame.c:57
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioUtils.c:48
ABC_DLL void Abc_FrameSetLibGen2(void *pLib)
Definition: mainFrame.c:83
void Amap_LibFree(Amap_Lib_t *p)
Definition: amapLib.c:67
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
ABC_DLL void Abc_FrameSetLibGen(void *pLib)
Definition: mainFrame.c:82
int Mio_UpdateGenlib2 ( Vec_Str_t vStr,
Vec_Str_t vStr2,
char *  pFileName,
int  fVerbose 
)

Definition at line 141 of file mio.c.

142 {
143  Mio_Library_t * pLib;
144  // set the new network
145  pLib = Mio_LibraryRead( pFileName, Vec_StrArray(vStr), NULL, fVerbose );
146  if ( pLib == NULL )
147  return 0;
148 
149  // free the current superlib because it depends on the old Mio library
150  if ( Abc_FrameReadLibSuper() )
151  {
153  Abc_FrameSetLibSuper( NULL );
154  }
155 
156  // replace the current library
158  Abc_FrameSetLibGen( pLib );
159 
160  // set the new network
161  pLib = (Mio_Library_t *)Amap_LibReadAndPrepare( pFileName, Vec_StrArray(vStr2), 0, 0 );
162  if ( pLib == NULL )
163  return 0;
164 
165  // replace the current library
167  Abc_FrameSetLibGen2( pLib );
168  return 1;
169 }
ABC_DLL void Abc_FrameSetLibSuper(void *pLib)
Definition: mainFrame.c:84
void Map_SuperLibFree(Map_SuperLib_t *p)
Definition: mapperLib.c:167
ABC_DLL void * Abc_FrameReadLibGen()
Definition: mainFrame.c:56
Mio_Library_t * Mio_LibraryRead(char *FileName, char *pBuffer, char *ExcludeFile, int fVerbose)
Definition: mioRead.c:54
ABC_DLL void * Abc_FrameReadLibGen2()
Definition: mainFrame.c:57
void Mio_LibraryDelete(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioUtils.c:48
static char * Vec_StrArray(Vec_Str_t *p)
Definition: vecStr.h:272
ABC_DLL void Abc_FrameSetLibGen2(void *pLib)
Definition: mainFrame.c:83
Amap_Lib_t * Amap_LibReadAndPrepare(char *pFileName, char *pBuffer, int fVerbose, int fVeryVerbose)
Definition: amapLib.c:329
void Amap_LibFree(Amap_Lib_t *p)
Definition: amapLib.c:67
ABC_DLL void * Abc_FrameReadLibSuper()
Definition: mainFrame.c:58
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
typedefABC_NAMESPACE_HEADER_START struct Amap_Lib_t_ Amap_Lib_t
INCLUDES ///.
Definition: amap.h:42
ABC_DLL void Abc_FrameSetLibGen(void *pLib)
Definition: mainFrame.c:82
void Mio_WriteLibrary ( FILE *  pFile,
Mio_Library_t pLib,
int  fPrintSops 
)

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

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 251 of file mioUtils.c.

252 {
253  Mio_Gate_t * pGate;
254  Mio_Pin_t * pPin;
255  int i, GateLen = 0, NameLen = 0, FormLen = 0;
256  int fAllPins = Mio_CheckGates( pLib );
257  Mio_LibraryForEachGate( pLib, pGate )
258  {
259  GateLen = Abc_MaxInt( GateLen, strlen(pGate->pName) );
260  NameLen = Abc_MaxInt( NameLen, strlen(pGate->pOutName) );
261  FormLen = Abc_MaxInt( FormLen, strlen(pGate->pForm) );
262  Mio_GateForEachPin( pGate, pPin )
263  NameLen = Abc_MaxInt( NameLen, strlen(pPin->pName) );
264  }
265  fprintf( pFile, "# The genlib library \"%s\" written by ABC on %s\n\n", pLib->pName, Extra_TimeStamp() );
266  for ( i = 0; i < pLib->nGates; i++ )
267  Mio_WriteGate( pFile, pLib->ppGates0[i], GateLen, NameLen, FormLen, fPrintSops, fAllPins );
268 }
Mio_Gate_t ** ppGates0
Definition: mioInt.h:65
char * pName
Definition: mioInt.h:82
char * pOutName
Definition: mioInt.h:86
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
void Mio_WriteGate(FILE *pFile, Mio_Gate_t *pGate, int GateLen, int NameLen, int FormLen, int fPrintSops, int fAllPins)
Definition: mioUtils.c:220
int Mio_CheckGates(Mio_Library_t *pLib)
Definition: mioUtils.c:169
static int Abc_MaxInt(int a, int b)
Definition: abc_global.h:238
char * pForm
Definition: mioInt.h:84
int strlen()
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65