mio.h 10.4 KB
Newer Older
Alan Mishchenko committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/**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 $]

***********************************************************************/

19 20
#ifndef ABC__map__mio__mio_h
#define ABC__map__mio__mio_h
Alan Mishchenko committed
21

22

Alan Mishchenko committed
23 24 25 26 27 28 29 30
////////////////////////////////////////////////////////////////////////
///                          INCLUDES                                ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
///                         PARAMETERS                               ///
////////////////////////////////////////////////////////////////////////

31 32 33 34


ABC_NAMESPACE_HEADER_START

Alan Mishchenko committed
35

Alan Mishchenko committed
36 37 38 39 40 41 42 43 44 45
////////////////////////////////////////////////////////////////////////
///                    STRUCTURE DEFINITIONS                         ///
////////////////////////////////////////////////////////////////////////

typedef enum { MIO_PHASE_UNKNOWN, MIO_PHASE_INV, MIO_PHASE_NONINV } Mio_PinPhase_t;

typedef struct  Mio_LibraryStruct_t_      Mio_Library_t;
typedef struct  Mio_GateStruct_t_         Mio_Gate_t;
typedef struct  Mio_PinStruct_t_          Mio_Pin_t;

46 47
static inline char *    Mio_UtilStrsav( char * s )     { return s ? strcpy(ABC_ALLOC(char, strlen(s)+1), s) : NULL;   }

Alan Mishchenko committed
48 49 50 51 52
////////////////////////////////////////////////////////////////////////
///                       GLOBAL VARIABLES                           ///
////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
53
///                       MACRO DEFINITIONS                          ///
Alan Mishchenko committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
////////////////////////////////////////////////////////////////////////
 
#define Mio_LibraryForEachGate( Lib, Gate )                   \
    for ( Gate = Mio_LibraryReadGates(Lib);                   \
          Gate;                                               \
          Gate = Mio_GateReadNext(Gate) )
#define Mio_LibraryForEachGateSafe( Lib, Gate, Gate2 )        \
    for ( Gate = Mio_LibraryReadGates(Lib),                   \
          Gate2 = (Gate? Mio_GateReadNext(Gate): NULL);       \
          Gate;                                               \
          Gate = Gate2,                                       \
          Gate2 = (Gate? Mio_GateReadNext(Gate): NULL) )

#define Mio_GateForEachPin( Gate, Pin )                       \
    for ( Pin = Mio_GateReadPins(Gate);                       \
          Pin;                                                \
          Pin = Mio_PinReadNext(Pin) )
71 72
#define Mio_GateForEachPinSafe( Gate, Pin, Pin2 )             \
    for ( Pin = Mio_GateReadPins(Gate),                       \
Alan Mishchenko committed
73 74 75 76 77 78
          Pin2 = (Pin? Mio_PinReadNext(Pin): NULL);           \
          Pin;                                                \
          Pin = Pin2,                                         \
          Pin2 = (Pin? Mio_PinReadNext(Pin): NULL) )

////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
79
///                     FUNCTION DEFINITIONS                         ///
Alan Mishchenko committed
80 81
////////////////////////////////////////////////////////////////////////

82 83 84
/*=== mio.c =============================================================*/
extern void              Mio_UpdateGenlib( Mio_Library_t * pLib );
extern int               Mio_UpdateGenlib2( Vec_Str_t * vStr, Vec_Str_t * vStr2, char * pFileName, int fVerbose );
Alan Mishchenko committed
85 86 87 88
/*=== mioApi.c =============================================================*/
extern char *            Mio_LibraryReadName       ( Mio_Library_t * pLib );
extern int               Mio_LibraryReadGateNum    ( Mio_Library_t * pLib );
extern Mio_Gate_t *      Mio_LibraryReadGates      ( Mio_Library_t * pLib );
89 90
extern Mio_Gate_t **     Mio_LibraryReadGateArray  ( Mio_Library_t * pLib );
extern Mio_Gate_t *      Mio_LibraryReadGateByName ( Mio_Library_t * pLib, char * pName, char * pOutName );
Alan Mishchenko committed
91 92 93 94
extern char *            Mio_LibraryReadSopByName  ( Mio_Library_t * pLib, char * pName );    
extern Mio_Gate_t *      Mio_LibraryReadConst0     ( Mio_Library_t * pLib );
extern Mio_Gate_t *      Mio_LibraryReadConst1     ( Mio_Library_t * pLib );
extern Mio_Gate_t *      Mio_LibraryReadNand2      ( Mio_Library_t * pLib );
Alan Mishchenko committed
95
extern Mio_Gate_t *      Mio_LibraryReadAnd2       ( Mio_Library_t * pLib );
Alan Mishchenko committed
96 97 98 99 100 101 102 103
extern Mio_Gate_t *      Mio_LibraryReadBuf        ( Mio_Library_t * pLib );
extern Mio_Gate_t *      Mio_LibraryReadInv        ( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayInvRise( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayInvFall( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayInvMax( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayNand2Rise( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayNand2Fall( Mio_Library_t * pLib );
extern float             Mio_LibraryReadDelayNand2Max( Mio_Library_t * pLib );
Alan Mishchenko committed
104
extern float             Mio_LibraryReadDelayAnd2Max( Mio_Library_t * pLib );
Alan Mishchenko committed
105
extern float             Mio_LibraryReadAreaInv    ( Mio_Library_t * pLib );
Alan Mishchenko committed
106
extern float             Mio_LibraryReadAreaBuf    ( Mio_Library_t * pLib );
Alan Mishchenko committed
107
extern float             Mio_LibraryReadAreaNand2  ( Mio_Library_t * pLib );
Alan Mishchenko committed
108
extern int               Mio_LibraryReadGateNameMax( Mio_Library_t * pLib );
Alan Mishchenko committed
109 110 111 112 113 114 115
extern char *            Mio_GateReadName          ( Mio_Gate_t * pGate );      
extern char *            Mio_GateReadOutName       ( Mio_Gate_t * pGate );      
extern double            Mio_GateReadArea          ( Mio_Gate_t * pGate );      
extern char *            Mio_GateReadForm          ( Mio_Gate_t * pGate );      
extern Mio_Pin_t *       Mio_GateReadPins          ( Mio_Gate_t * pGate );      
extern Mio_Library_t *   Mio_GateReadLib           ( Mio_Gate_t * pGate );      
extern Mio_Gate_t *      Mio_GateReadNext          ( Mio_Gate_t * pGate );      
116
extern Mio_Gate_t *      Mio_GateReadTwin          ( Mio_Gate_t * pGate );      
117
extern int               Mio_GateReadPinNum        ( Mio_Gate_t * pGate );      
Alan Mishchenko committed
118 119
extern double            Mio_GateReadDelayMax      ( Mio_Gate_t * pGate );      
extern char *            Mio_GateReadSop           ( Mio_Gate_t * pGate );      
120
extern word              Mio_GateReadTruth         ( Mio_Gate_t * pGate );
Alan Mishchenko committed
121
extern int               Mio_GateReadValue         ( Mio_Gate_t * pGate );
122
extern char *            Mio_GateReadPinName       ( Mio_Gate_t * pGate, int iPin );
Alan Mishchenko committed
123
extern float             Mio_GateReadPinDelay      ( Mio_Gate_t * pGate, int iPin );
Alan Mishchenko committed
124
extern void              Mio_GateSetValue          ( Mio_Gate_t * pGate, int Value );
Alan Mishchenko committed
125 126 127 128 129 130 131 132 133 134 135
extern char *            Mio_PinReadName           ( Mio_Pin_t * pPin );  
extern Mio_PinPhase_t    Mio_PinReadPhase          ( Mio_Pin_t * pPin );  
extern double            Mio_PinReadInputLoad      ( Mio_Pin_t * pPin );  
extern double            Mio_PinReadMaxLoad        ( Mio_Pin_t * pPin );  
extern double            Mio_PinReadDelayBlockRise ( Mio_Pin_t * pPin );  
extern double            Mio_PinReadDelayFanoutRise( Mio_Pin_t * pPin );  
extern double            Mio_PinReadDelayBlockFall ( Mio_Pin_t * pPin );  
extern double            Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin );  
extern double            Mio_PinReadDelayBlockMax  ( Mio_Pin_t * pPin );  
extern Mio_Pin_t *       Mio_PinReadNext           ( Mio_Pin_t * pPin );  
/*=== mioRead.c =============================================================*/
136
extern char *            Mio_ReadFile( char * FileName, int fAddEnd );
137
extern Mio_Library_t *   Mio_LibraryRead( char * FileName, char * pBuffer, char * ExcludeFile, int fVerbose );
138
extern int               Mio_LibraryReadExclude( char * ExcludeFile, st__table * tExcludeGate );
Alan Mishchenko committed
139 140
/*=== mioFunc.c =============================================================*/
extern int               Mio_LibraryParseFormulas( Mio_Library_t * pLib );
141 142
/*=== mioParse.c =============================================================*/
extern Vec_Int_t *       Mio_ParseFormula( char * pFormInit, char ** ppVarNames, int nVars );
143
extern Vec_Wrd_t *       Mio_ParseFormulaTruth( char * pFormInit, char ** ppVarNames, int nVars );
144
extern int               Mio_ParseCheckFormula( Mio_Gate_t * pGate, char * pForm );
145 146
/*=== mioSop.c =============================================================*/
extern char *            Mio_LibDeriveSop( int nVars, Vec_Int_t * vExpr, Vec_Str_t * vStr );
Alan Mishchenko committed
147 148 149 150 151 152
/*=== mioUtils.c =============================================================*/
extern void              Mio_LibraryDelete( Mio_Library_t * pLib );
extern void              Mio_GateDelete( Mio_Gate_t * pGate );
extern void              Mio_PinDelete( Mio_Pin_t * pPin );
extern Mio_Pin_t *       Mio_PinDup( Mio_Pin_t * pPin );
extern void              Mio_WriteLibrary( FILE * pFile, Mio_Library_t * pLib, int fPrintSops );
153
extern Mio_Gate_t **     Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, int fSkipInv, int * pnGates, int fVerbose );
154
extern word              Mio_DeriveTruthTable6( Mio_Gate_t * pGate );
Alan Mishchenko committed
155 156 157 158 159
extern void              Mio_DeriveTruthTable( Mio_Gate_t * pGate, unsigned uTruthsIn[][2], int nSigns, int nInputs, unsigned uTruthRes[] );
extern void              Mio_DeriveGateDelays( Mio_Gate_t * pGate, 
                            float ** ptPinDelays, int nPins, int nInputs, float tDelayZero, 
                            float * ptDelaysRes, float * ptPinDelayMax );
extern Mio_Gate_t *      Mio_GateCreatePseudo( int nInputs );
160
extern void              Mio_LibraryShiftDelay( Mio_Library_t * pLib, double Shift );
161 162
extern void              Mio_LibraryMultiArea( Mio_Library_t * pLib, double Multi );
extern void              Mio_LibraryMultiDelay( Mio_Library_t * pLib, double Multi );
163
extern void              Mio_LibraryTransferDelays( Mio_Library_t * pLibD, Mio_Library_t * pLibS );
164

165 166
/*=== sclUtil.c =========================================================*/
extern Mio_Library_t *   Abc_SclDeriveGenlibSimple( void * pScl );
167
extern Mio_Library_t *   Abc_SclDeriveGenlib( void * pScl, float Slew, float Gain, int nGatesMin, int fVerbose );
168

169
ABC_NAMESPACE_HEADER_END
Alan Mishchenko committed
170 171 172

#endif

Alan Mishchenko committed
173 174 175
////////////////////////////////////////////////////////////////////////
///                       END OF FILE                                ///
////////////////////////////////////////////////////////////////////////
Alan Mishchenko committed
176