abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
mioApi.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [mioApi.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: mioApi.c,v 1.4 2004/06/28 14:20:25 alanmi Exp $]
16 
17 ***********************************************************************/
18 
19 #include "mioInt.h"
20 
22 
23 
24 ////////////////////////////////////////////////////////////////////////
25 /// DECLARATIONS ///
26 ////////////////////////////////////////////////////////////////////////
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// FUNCTION DEFINITIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 /**Function*************************************************************
33 
34  Synopsis []
35 
36  Description []
37 
38  SideEffects []
39 
40  SeeAlso []
41 
42 ***********************************************************************/
43 char * Mio_LibraryReadName ( Mio_Library_t * pLib ) { return pLib->pName; }
44 int Mio_LibraryReadGateNum ( Mio_Library_t * pLib ) { return pLib->nGates; }
45 Mio_Gate_t * Mio_LibraryReadGates ( Mio_Library_t * pLib ) { return pLib->pGates; }
47 Mio_Gate_t * Mio_LibraryReadBuf ( Mio_Library_t * pLib ) { return pLib->pGateBuf; }
48 Mio_Gate_t * Mio_LibraryReadInv ( Mio_Library_t * pLib ) { return pLib->pGateInv; }
49 Mio_Gate_t * Mio_LibraryReadConst0 ( Mio_Library_t * pLib ) { return pLib->pGate0; }
50 Mio_Gate_t * Mio_LibraryReadConst1 ( Mio_Library_t * pLib ) { return pLib->pGate1; }
52 Mio_Gate_t * Mio_LibraryReadAnd2 ( Mio_Library_t * pLib ) { return pLib->pGateAnd2; }
53 float Mio_LibraryReadDelayInvRise ( Mio_Library_t * pLib ) { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockRise : 0.0); }
54 float Mio_LibraryReadDelayInvFall ( Mio_Library_t * pLib ) { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockFall : 0.0); }
55 float Mio_LibraryReadDelayInvMax ( Mio_Library_t * pLib ) { return (float)(pLib->pGateInv? pLib->pGateInv->pPins->dDelayBlockMax : 0.0); }
56 float Mio_LibraryReadDelayNand2Rise( Mio_Library_t * pLib ) { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockRise : 0.0); }
57 float Mio_LibraryReadDelayNand2Fall( Mio_Library_t * pLib ) { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockFall : 0.0); }
58 float Mio_LibraryReadDelayNand2Max ( Mio_Library_t * pLib ) { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockMax : 0.0); }
59 float Mio_LibraryReadDelayAnd2Max ( Mio_Library_t * pLib ) { return (float)(pLib->pGateAnd2? pLib->pGateAnd2->pPins->dDelayBlockMax : 0.0); }
60 float Mio_LibraryReadAreaInv ( Mio_Library_t * pLib ) { return (float)(pLib->pGateInv? pLib->pGateInv->dArea : 0.0); }
61 float Mio_LibraryReadAreaBuf ( Mio_Library_t * pLib ) { return (float)(pLib->pGateBuf? pLib->pGateBuf->dArea : 0.0); }
62 float Mio_LibraryReadAreaNand2 ( Mio_Library_t * pLib ) { return (float)(pLib->pGateNand2? pLib->pGateNand2->dArea : 0.0); }
63 
64 /**Function*************************************************************
65 
66  Synopsis [Returns the longest gate name.]
67 
68  Description []
69 
70  SideEffects []
71 
72  SeeAlso []
73 
74 ***********************************************************************/
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 }
87 
88 /**Function*************************************************************
89 
90  Synopsis [Read Mvc of the gate by name.]
91 
92  Description []
93 
94  SideEffects []
95 
96  SeeAlso []
97 
98 ***********************************************************************/
99 Mio_Gate_t * Mio_LibraryReadGateByName( Mio_Library_t * pLib, char * pName, char * pOutName )
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 }
112 
113 /**Function*************************************************************
114 
115  Synopsis [Read Mvc of the gate by name.]
116 
117  Description []
118 
119  SideEffects []
120 
121  SeeAlso []
122 
123 ***********************************************************************/
124 char * Mio_LibraryReadSopByName( Mio_Library_t * pLib, char * pName )
125 {
126  Mio_Gate_t * pGate;
127  if ( st__lookup( pLib->tName2Gate, pName, (char **)&pGate ) )
128  return pGate->pSop;
129  return NULL;
130 }
131 
132 /**Function*************************************************************
133 
134  Synopsis []
135 
136  Description []
137 
138  SideEffects []
139 
140  SeeAlso []
141 
142 ***********************************************************************/
143 char * Mio_GateReadName ( Mio_Gate_t * pGate ) { return pGate->pName; }
144 char * Mio_GateReadOutName ( Mio_Gate_t * pGate ) { return pGate->pOutName; }
145 double Mio_GateReadArea ( Mio_Gate_t * pGate ) { return pGate->dArea; }
146 char * Mio_GateReadForm ( Mio_Gate_t * pGate ) { return pGate->pForm; }
147 Mio_Pin_t * Mio_GateReadPins ( Mio_Gate_t * pGate ) { return pGate->pPins; }
148 Mio_Library_t * Mio_GateReadLib ( Mio_Gate_t * pGate ) { return pGate->pLib; }
149 Mio_Gate_t * Mio_GateReadNext ( Mio_Gate_t * pGate ) { return pGate->pNext; }
150 Mio_Gate_t * Mio_GateReadTwin ( Mio_Gate_t * pGate ) { return pGate->pTwin; }
151 int Mio_GateReadPinNum ( Mio_Gate_t * pGate ) { return pGate->nInputs; }
152 double Mio_GateReadDelayMax( Mio_Gate_t * pGate ) { return pGate->dDelayMax; }
153 char * Mio_GateReadSop ( Mio_Gate_t * pGate ) { return pGate->pSop; }
154 word Mio_GateReadTruth ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? pGate->uTruth : 0; }
155 word * Mio_GateReadTruthP ( Mio_Gate_t * pGate ) { return pGate->nInputs <= 6 ? NULL: pGate->pTruth; }
156 int Mio_GateReadValue ( Mio_Gate_t * pGate ) { return pGate->Value; }
157 void Mio_GateSetValue ( Mio_Gate_t * pGate, int Value ) { pGate->Value = Value; }
158 
159 /**Function*************************************************************
160 
161  Synopsis []
162 
163  Description []
164 
165  SideEffects []
166 
167  SeeAlso []
168 
169 ***********************************************************************/
170 char * Mio_PinReadName ( Mio_Pin_t * pPin ) { return pPin->pName; }
171 Mio_PinPhase_t Mio_PinReadPhase ( Mio_Pin_t * pPin ) { return pPin->Phase; }
172 double Mio_PinReadInputLoad ( Mio_Pin_t * pPin ) { return pPin->dLoadInput; }
173 double Mio_PinReadMaxLoad ( Mio_Pin_t * pPin ) { return pPin->dLoadMax; }
174 double Mio_PinReadDelayBlockRise ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockRise; }
175 double Mio_PinReadDelayFanoutRise( Mio_Pin_t * pPin ) { return pPin->dDelayFanoutRise;}
176 double Mio_PinReadDelayBlockFall ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockFall; }
177 double Mio_PinReadDelayFanoutFall( Mio_Pin_t * pPin ) { return pPin->dDelayFanoutFall;}
178 double Mio_PinReadDelayBlockMax ( Mio_Pin_t * pPin ) { return pPin->dDelayBlockMax; }
179 Mio_Pin_t * Mio_PinReadNext ( Mio_Pin_t * pPin ) { return pPin->pNext; }
180 
181 /**Function*************************************************************
182 
183  Synopsis []
184 
185  Description []
186 
187  SideEffects []
188 
189  SeeAlso []
190 
191 ***********************************************************************/
192 char * Mio_GateReadPinName( Mio_Gate_t * pGate, int iPin )
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 }
201 float Mio_GateReadPinDelay( Mio_Gate_t * pGate, int iPin )
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 }
210 
211 ////////////////////////////////////////////////////////////////////////
212 /// END OF FILE ///
213 ////////////////////////////////////////////////////////////////////////
214 
215 
217 
Mio_Pin_t * Mio_PinReadNext(Mio_Pin_t *pPin)
Definition: mioApi.c:179
char * pName
Definition: mioInt.h:82
char * Mio_GateReadSop(Mio_Gate_t *pGate)
Definition: mioApi.c:153
Mio_Pin_t * pNext
Definition: mioInt.h:114
Mio_Gate_t * pTwin
Definition: mioInt.h:91
float Mio_LibraryReadDelayInvRise(Mio_Library_t *pLib)
Definition: mioApi.c:53
double Mio_PinReadInputLoad(Mio_Pin_t *pPin)
Definition: mioApi.c:172
float Mio_LibraryReadAreaNand2(Mio_Library_t *pLib)
Definition: mioApi.c:62
char * pOutName
Definition: mioInt.h:86
float Mio_LibraryReadDelayNand2Fall(Mio_Library_t *pLib)
Definition: mioApi.c:57
word * Mio_GateReadTruthP(Mio_Gate_t *pGate)
Definition: mioApi.c:155
Mio_Gate_t * Mio_LibraryReadConst1(Mio_Library_t *pLib)
Definition: mioApi.c:50
double dDelayBlockMax
Definition: mioInt.h:113
#define Mio_GateForEachPin(Gate, Pin)
Definition: mio.h:76
word Mio_GateReadTruth(Mio_Gate_t *pGate)
Definition: mioApi.c:154
double Mio_PinReadDelayFanoutFall(Mio_Pin_t *pPin)
Definition: mioApi.c:177
Mio_Gate_t * pGates
Definition: mioInt.h:67
char * Mio_GateReadName(Mio_Gate_t *pGate)
Definition: mioApi.c:143
Mio_Gate_t * Mio_LibraryReadConst0(Mio_Library_t *pLib)
Definition: mioApi.c:49
char * pSop
Definition: mioInt.h:96
Mio_Gate_t * Mio_LibraryReadInv(Mio_Library_t *pLib)
Definition: mioApi.c:48
float Mio_LibraryReadAreaBuf(Mio_Library_t *pLib)
Definition: mioApi.c:61
float Mio_LibraryReadAreaInv(Mio_Library_t *pLib)
Definition: mioApi.c:60
Mio_PinPhase_t
INCLUDES ///.
Definition: mio.h:40
Mio_Pin_t * Mio_GateReadPins(Mio_Gate_t *pGate)
Definition: mioApi.c:147
Mio_Library_t * pLib
Definition: mioInt.h:88
char * Mio_GateReadOutName(Mio_Gate_t *pGate)
Definition: mioApi.c:144
float Mio_GateReadPinDelay(Mio_Gate_t *pGate, int iPin)
Definition: mioApi.c:201
char * Mio_GateReadPinName(Mio_Gate_t *pGate, int iPin)
Definition: mioApi.c:192
Mio_Gate_t * Mio_LibraryReadBuf(Mio_Library_t *pLib)
Definition: mioApi.c:47
char * Mio_LibraryReadSopByName(Mio_Library_t *pLib, char *pName)
Definition: mioApi.c:124
Mio_Gate_t * pGate0
Definition: mioInt.h:68
char * Mio_GateReadForm(Mio_Gate_t *pGate)
Definition: mioApi.c:146
char * Mio_PinReadName(Mio_Pin_t *pPin)
Definition: mioApi.c:170
char * pName
Definition: mioInt.h:105
Mio_Pin_t * pPins
Definition: mioInt.h:85
int strcmp()
double Mio_GateReadDelayMax(Mio_Gate_t *pGate)
Definition: mioApi.c:152
Mio_Gate_t * Mio_GateReadTwin(Mio_Gate_t *pGate)
Definition: mioApi.c:150
int Mio_LibraryReadGateNameMax(Mio_Library_t *pLib)
Definition: mioApi.c:75
double Mio_PinReadDelayBlockFall(Mio_Pin_t *pPin)
Definition: mioApi.c:176
float Mio_LibraryReadDelayAnd2Max(Mio_Library_t *pLib)
Definition: mioApi.c:59
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
Mio_Gate_t * Mio_LibraryReadNand2(Mio_Library_t *pLib)
Definition: mioApi.c:51
Mio_PinPhase_t Mio_PinReadPhase(Mio_Pin_t *pPin)
Definition: mioApi.c:171
unsigned __int64 word
DECLARATIONS ///.
Definition: kitPerm.c:36
double Mio_PinReadDelayBlockRise(Mio_Pin_t *pPin)
Definition: mioApi.c:174
float Mio_LibraryReadDelayNand2Rise(Mio_Library_t *pLib)
Definition: mioApi.c:56
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
float Mio_LibraryReadDelayInvMax(Mio_Library_t *pLib)
Definition: mioApi.c:55
double Mio_PinReadDelayBlockMax(Mio_Pin_t *pPin)
Definition: mioApi.c:178
Mio_Gate_t * pGateNand2
Definition: mioInt.h:72
STRUCTURE DEFINITIONS ///.
Definition: mioInt.h:61
int Mio_GateReadValue(Mio_Gate_t *pGate)
Definition: mioApi.c:156
Mio_PinPhase_t Phase
Definition: mioInt.h:106
double Mio_GateReadArea(Mio_Gate_t *pGate)
Definition: mioApi.c:145
double dDelayMax
Definition: mioInt.h:95
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
ABC_NAMESPACE_IMPL_START char * Mio_LibraryReadName(Mio_Library_t *pLib)
DECLARATIONS ///.
Definition: mioApi.c:43
Mio_Gate_t * pGateAnd2
Definition: mioInt.h:73
double dLoadMax
Definition: mioInt.h:108
int st__lookup(st__table *table, const char *key, char **value)
Definition: st.c:114
double dLoadInput
Definition: mioInt.h:107
float Mio_LibraryReadDelayInvFall(Mio_Library_t *pLib)
Definition: mioApi.c:54
Mio_Gate_t * pNext
Definition: mioInt.h:90
double Mio_PinReadMaxLoad(Mio_Pin_t *pPin)
Definition: mioApi.c:173
Mio_Gate_t * Mio_LibraryReadAnd2(Mio_Library_t *pLib)
Definition: mioApi.c:52
double dDelayFanoutRise
Definition: mioInt.h:110
Mio_Gate_t * Mio_GateReadNext(Mio_Gate_t *pGate)
Definition: mioApi.c:149
int Mio_GateReadPinNum(Mio_Gate_t *pGate)
Definition: mioApi.c:151
#define ABC_INFINITY
MACRO DEFINITIONS ///.
Definition: abc_global.h:216
double Mio_PinReadDelayFanoutRise(Mio_Pin_t *pPin)
Definition: mioApi.c:175
int strlen()
Mio_Gate_t ** Mio_LibraryReadGateArray(Mio_Library_t *pLib)
Definition: mioApi.c:46
Mio_Gate_t * pGateBuf
Definition: mioInt.h:70
Mio_Gate_t ** ppGatesName
Definition: mioInt.h:66
double dArea
Definition: mioInt.h:83
Mio_Gate_t * Mio_LibraryReadGates(Mio_Library_t *pLib)
Definition: mioApi.c:45
word * pTruth
Definition: mioInt.h:99
#define Mio_LibraryForEachGate(Lib, Gate)
GLOBAL VARIABLES ///.
Definition: mio.h:65
double dDelayBlockRise
Definition: mioInt.h:109
float Mio_LibraryReadDelayNand2Max(Mio_Library_t *pLib)
Definition: mioApi.c:58
st__table * tName2Gate
Definition: mioInt.h:74
void Mio_GateSetValue(Mio_Gate_t *pGate, int Value)
Definition: mioApi.c:157
Mio_Library_t * Mio_GateReadLib(Mio_Gate_t *pGate)
Definition: mioApi.c:148
int Mio_LibraryReadGateNum(Mio_Library_t *pLib)
Definition: mioApi.c:44
Mio_Gate_t * pGate1
Definition: mioInt.h:69
Mio_Gate_t * Mio_LibraryReadGateByName(Mio_Library_t *pLib, char *pName, char *pOutName)
Definition: mioApi.c:99