Go to the source code of this file.
#define Mio_GateForEachPin | ( | Gate, | |||
Pin | ) |
for ( Pin = Mio_GateReadPins(Gate); \ Pin; \ Pin = Mio_PinReadNext(Pin) )
#define Mio_GateForEachPinSafe | ( | Gate, | |||
Pin, | |||||
Pin2 | ) |
for ( Pin = Mio_GateReadPins(Gate), \ Pin2 = (Pin? Mio_PinReadNext(Pin): NULL); \ Pin; \ Pin = Pin2, \ Pin2 = (Pin? Mio_PinReadNext(Pin): NULL) )
#define Mio_LibraryForEachGate | ( | Lib, | |||
Gate | ) |
for ( Gate = Mio_LibraryReadGates(Lib); \ Gate; \ Gate = Mio_GateReadNext(Gate) )
GLOBAL VARIABLES /// MACRO DEFINITIONS ///
#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) )
typedef struct Mio_GateStruct_t_ Mio_Gate_t |
typedef struct Mio_LibraryStruct_t_ Mio_Library_t |
typedef struct Mio_PinStruct_t_ Mio_Pin_t |
enum Mio_PinPhase_t |
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 [
] INCLUDES /// PARAMETERS /// STRUCTURE DEFINITIONS ///
Definition at line 38 of file mio.h.
00038 { MIO_PHASE_UNKNOWN, MIO_PHASE_INV, MIO_PHASE_NONINV } Mio_PinPhase_t;
Mio_Gate_t** Mio_CollectRoots | ( | Mio_Library_t * | pLib, | |
int | nInputs, | |||
float | tDelay, | |||
bool | fSkipInv, | |||
int * | pnGates | |||
) |
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 218 of file mioUtils.c.
00219 { 00220 Mio_Gate_t * pGate; 00221 Mio_Gate_t ** ppGates; 00222 /* st_table * tFuncs; */ 00223 /* st_generator * gen; */ 00224 DdNode * bFunc; 00225 DdManager * dd; 00226 int nGates, iGate; 00227 00228 dd = Mio_LibraryReadDd( pLib ); 00229 nGates = Mio_LibraryReadGateNum( pLib ); 00230 00231 /* 00232 00233 // for each functionality select one gate; skip constants and buffers 00234 tFuncs = st_init_table( st_ptrcmp, st_ptrhash ); 00235 Mio_LibraryForEachGate( pLib, pGate ) 00236 { 00237 bFunc = Mio_GateReadFunc(pGate); 00238 if ( pGate->nInputs > nInputs ) 00239 continue; 00240 if ( pGate->dDelayMax > (double)tDelay ) 00241 continue; 00242 if ( bFunc == b0 || bFunc == b1 ) 00243 continue; 00244 if ( bFunc == dd->vars[0] ) 00245 continue; 00246 if ( bFunc == Cudd_Not(dd->vars[0]) && fSkipInv ) 00247 continue; 00248 if ( st_is_member( tFuncs, (char *)bFunc ) ) 00249 continue; 00250 st_insert( tFuncs, (char *)bFunc, (char *)pGate ); 00251 } 00252 00253 // collect the gates into the array 00254 ppGates = ALLOC( Mio_Gate_t *, nGates ); 00255 iGate = 0; 00256 st_foreach_item( tFuncs, gen, (char **)&bFunc, (char **)&pGate ) 00257 ppGates[ iGate++ ] = pGate; 00258 assert( iGate <= nGates ); 00259 st_free_table( tFuncs ); 00260 00261 */ 00262 00263 ppGates = ALLOC( Mio_Gate_t *, nGates ); 00264 iGate = 0; 00265 Mio_LibraryForEachGate( pLib, pGate ) 00266 { 00267 bFunc = Mio_GateReadFunc(pGate); 00268 if ( pGate->nInputs > nInputs ) 00269 continue; 00270 if ( pGate->dDelayMax > (double)tDelay ) 00271 continue; 00272 if ( bFunc == b0 || bFunc == b1 ) 00273 continue; 00274 if ( bFunc == dd->vars[0] ) 00275 continue; 00276 if ( bFunc == Cudd_Not(dd->vars[0]) && fSkipInv ) 00277 continue; 00278 00279 assert( iGate < nGates ); 00280 ppGates[ iGate++ ] = pGate; 00281 } 00282 00283 if ( iGate > 0 ) 00284 { 00285 // sort the gates by delay 00286 qsort( (void *)ppGates, iGate, sizeof(Mio_Gate_t *), 00287 (int (*)(const void *, const void *)) Mio_DelayCompare ); 00288 assert( Mio_DelayCompare( ppGates, ppGates + iGate - 1 ) <= 0 ); 00289 } 00290 00291 if ( pnGates ) 00292 *pnGates = iGate; 00293 return ppGates; 00294 }
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 461 of file mioUtils.c.
00464 { 00465 Mio_Pin_t * pPin; 00466 float Delay, DelayMax; 00467 int i, k; 00468 assert( pGate->nInputs == nPins ); 00469 // set all the delays to the unused delay 00470 for ( i = 0; i < nInputs; i++ ) 00471 ptDelaysRes[i] = tDelayZero; 00472 // compute the delays for each input and the max delay at the same time 00473 DelayMax = 0; 00474 for ( i = 0; i < nInputs; i++ ) 00475 { 00476 for ( k = 0, pPin = pGate->pPins; pPin; pPin = pPin->pNext, k++ ) 00477 { 00478 if ( ptPinDelays[k][i] < 0 ) 00479 continue; 00480 Delay = ptPinDelays[k][i] + (float)pPin->dDelayBlockMax; 00481 if ( ptDelaysRes[i] < Delay ) 00482 ptDelaysRes[i] = Delay; 00483 } 00484 if ( k != nPins ) 00485 { 00486 printf ("DEBUG: problem gate is %s\n", Mio_GateReadName( pGate )); 00487 } 00488 assert( k == nPins ); 00489 if ( DelayMax < ptDelaysRes[i] ) 00490 DelayMax = ptDelaysRes[i]; 00491 } 00492 *ptPinDelayMax = DelayMax; 00493 }
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 327 of file mioUtils.c.
00328 { 00329 Mio_DeriveTruthTable_rec( pGate->bFunc, uTruthsIn, uTruthRes ); 00330 }
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 507 of file mioUtils.c.
00508 { 00509 Mio_Gate_t * pGate; 00510 Mio_Pin_t * pPin; 00511 int i; 00512 // allocate the gate structure 00513 pGate = ALLOC( Mio_Gate_t, 1 ); 00514 memset( pGate, 0, sizeof(Mio_Gate_t) ); 00515 pGate->nInputs = nInputs; 00516 // create pins 00517 for ( i = 0; i < nInputs; i++ ) 00518 { 00519 pPin = ALLOC( Mio_Pin_t, 1 ); 00520 memset( pPin, 0, sizeof(Mio_Pin_t) ); 00521 pPin->pNext = pGate->pPins; 00522 pGate->pPins = pPin; 00523 } 00524 return pGate; 00525 }
void Mio_GateDelete | ( | Mio_Gate_t * | pGate | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 76 of file mioUtils.c.
00077 { 00078 Mio_Pin_t * pPin, * pPin2; 00079 FREE( pGate->pOutName ); 00080 FREE( pGate->pName ); 00081 FREE( pGate->pForm ); 00082 if ( pGate->bFunc ) 00083 Cudd_RecursiveDeref( pGate->pLib->dd, pGate->bFunc ); 00084 Mio_GateForEachPinSafe( pGate, pPin, pPin2 ) 00085 Mio_PinDelete( pPin ); 00086 free( pGate ); 00087 }
double Mio_GateReadArea | ( | Mio_Gate_t * | pGate | ) |
double Mio_GateReadDelayMax | ( | Mio_Gate_t * | pGate | ) |
char* Mio_GateReadForm | ( | Mio_Gate_t * | pGate | ) |
DdNode* Mio_GateReadFunc | ( | Mio_Gate_t * | pGate | ) |
int Mio_GateReadInputs | ( | Mio_Gate_t * | pGate | ) |
Mio_Library_t* Mio_GateReadLib | ( | Mio_Gate_t * | pGate | ) |
char* Mio_GateReadName | ( | Mio_Gate_t * | pGate | ) |
Mio_Gate_t* Mio_GateReadNext | ( | Mio_Gate_t * | pGate | ) |
char* Mio_GateReadOutName | ( | Mio_Gate_t * | pGate | ) |
Mio_Pin_t* Mio_GateReadPins | ( | Mio_Gate_t * | pGate | ) |
char* Mio_GateReadSop | ( | Mio_Gate_t * | pGate | ) |
void Mio_LibraryDelete | ( | Mio_Library_t * | pLib | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 45 of file mioUtils.c.
00046 { 00047 Mio_Gate_t * pGate, * pGate2; 00048 if ( pLib == NULL ) 00049 return; 00050 // free the bindings of nodes to gates from this library for all networks 00051 Abc_FrameUnmapAllNetworks( Abc_FrameGetGlobalFrame() ); 00052 // free the library 00053 FREE( pLib->pName ); 00054 Mio_LibraryForEachGateSafe( pLib, pGate, pGate2 ) 00055 Mio_GateDelete( pGate ); 00056 Extra_MmFlexStop( pLib->pMmFlex ); 00057 Vec_StrFree( pLib->vCube ); 00058 if ( pLib->tName2Gate ) 00059 st_free_table( pLib->tName2Gate ); 00060 if ( pLib->dd ) 00061 Cudd_Quit( pLib->dd ); 00062 free( pLib ); 00063 }
int Mio_LibraryParseFormulas | ( | Mio_Library_t * | pLib | ) |
FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis [Deriving the functionality of the gates.]
Description []
SideEffects []
SeeAlso []
Definition at line 52 of file mioFunc.c.
00053 { 00054 Mio_Gate_t * pGate; 00055 00056 // count the gates 00057 pLib->nGates = 0; 00058 Mio_LibraryForEachGate( pLib, pGate ) 00059 pLib->nGates++; 00060 00061 // start a temporary BDD manager 00062 pLib->dd = Cudd_Init( 20, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); 00063 // introduce ZDD variables 00064 Cudd_zddVarsFromBddVars( pLib->dd, 2 ); 00065 00066 // for each gate, derive its function 00067 Mio_LibraryForEachGate( pLib, pGate ) 00068 if ( Mio_GateParseFormula( pGate ) ) 00069 return 1; 00070 return 0; 00071 }
Mio_Library_t* Mio_LibraryRead | ( | void * | pAbc, | |
char * | FileName, | |||
char * | ExcludeFile, | |||
int | fVerbose | |||
) |
Function*************************************************************
Synopsis [Read the genlib type of library.]
Description []
SideEffects []
SeeAlso []
Definition at line 52 of file mioRead.c.
00053 { 00054 Mio_Library_t * pLib; 00055 int num; 00056 00057 st_table * tExcludeGate = 0; 00058 00059 if ( ExcludeFile ) 00060 { 00061 tExcludeGate = st_init_table(strcmp, st_strhash); 00062 if ( (num = Mio_LibraryReadExclude( pAbc, ExcludeFile, tExcludeGate )) == -1 ) 00063 { 00064 st_free_table( tExcludeGate ); 00065 tExcludeGate = 0; 00066 return 0; 00067 } 00068 00069 fprintf ( Abc_FrameReadOut( pAbc ), "Read %d gates from exclude file\n", num ); 00070 } 00071 00072 pLib = Mio_LibraryReadOne( pAbc, FileName, 0, tExcludeGate, fVerbose ); // try normal format first .. 00073 if ( pLib == NULL ) 00074 { 00075 pLib = Mio_LibraryReadOne( pAbc, FileName, 1, tExcludeGate, fVerbose ); // .. otherwise try extended format 00076 if ( pLib != NULL ) 00077 printf ( "Warning: Read extended GENLIB format but ignoring extensions\n" ); 00078 } 00079 00080 return pLib; 00081 }
Mio_Gate_t* Mio_LibraryReadAnd2 | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadAreaBuf | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadAreaInv | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadAreaNand2 | ( | Mio_Library_t * | pLib | ) |
Definition at line 59 of file mioApi.c.
00059 { return (float)(pLib->pGateNand2? pLib->pGateNand2->dArea : 0.0); }
Mio_Gate_t* Mio_LibraryReadBuf | ( | Mio_Library_t * | pLib | ) |
Mio_Gate_t* Mio_LibraryReadConst0 | ( | Mio_Library_t * | pLib | ) |
Mio_Gate_t* Mio_LibraryReadConst1 | ( | Mio_Library_t * | pLib | ) |
DdManager* Mio_LibraryReadDd | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadDelayAnd2Max | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadDelayInvFall | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadDelayInvMax | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadDelayInvRise | ( | Mio_Library_t * | pLib | ) |
float Mio_LibraryReadDelayNand2Fall | ( | Mio_Library_t * | pLib | ) |
Definition at line 54 of file mioApi.c.
00054 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockFall : 0.0); }
float Mio_LibraryReadDelayNand2Max | ( | Mio_Library_t * | pLib | ) |
Definition at line 55 of file mioApi.c.
00055 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockMax : 0.0); }
float Mio_LibraryReadDelayNand2Rise | ( | Mio_Library_t * | pLib | ) |
Definition at line 53 of file mioApi.c.
00053 { return (float)(pLib->pGateNand2? pLib->pGateNand2->pPins->dDelayBlockRise : 0.0); }
int Mio_LibraryReadExclude | ( | void * | pAbc, | |
char * | ExcludeFile, | |||
st_table * | tExcludeGate | |||
) |
Function*************************************************************
Synopsis [populate hash table of gates to be exlcuded from genlib]
Description []
SideEffects []
SeeAlso []
Definition at line 489 of file mioRead.c.
00490 { 00491 int nDel = 0; 00492 FILE *pEx; 00493 char buffer[128]; 00494 00495 assert ( tExcludeGate ); 00496 00497 if ( ExcludeFile ) 00498 { 00499 pEx = fopen( ExcludeFile, "r" ); 00500 00501 if ( pEx == NULL ) 00502 { 00503 fprintf ( Abc_FrameReadErr( pAbc ), "Error: Could not open exclude file %s. Stop.\n", ExcludeFile ); 00504 return -1; 00505 } 00506 00507 while (1 == fscanf( pEx, "%127s", buffer )) 00508 { 00509 //printf ("Read: '%s'\n", buffer ); 00510 st_insert( tExcludeGate, Extra_UtilStrsav( buffer ), (char *)0 ); 00511 nDel++; 00512 } 00513 00514 fclose( pEx ); 00515 } 00516 00517 return nDel; 00518 }
Mio_Gate_t* Mio_LibraryReadGateByName | ( | Mio_Library_t * | pLib, | |
char * | pName | |||
) |
Function*************************************************************
Synopsis [Read Mvc of the gate by name.]
Description []
SideEffects []
SeeAlso []
Definition at line 96 of file mioApi.c.
00097 { 00098 Mio_Gate_t * pGate; 00099 if ( st_lookup( pLib->tName2Gate, pName, (char **)&pGate ) ) 00100 return pGate; 00101 return NULL; 00102 }
int Mio_LibraryReadGateNameMax | ( | Mio_Library_t * | pLib | ) |
Function*************************************************************
Synopsis [Returns the longest gate name.]
Description []
SideEffects []
SeeAlso []
Definition at line 72 of file mioApi.c.
00073 { 00074 Mio_Gate_t * pGate; 00075 int LenMax = 0, LenCur; 00076 Mio_LibraryForEachGate( pLib, pGate ) 00077 { 00078 LenCur = strlen( Mio_GateReadName(pGate) ); 00079 if ( LenMax < LenCur ) 00080 LenMax = LenCur; 00081 } 00082 return LenMax; 00083 }
int Mio_LibraryReadGateNum | ( | Mio_Library_t * | pLib | ) |
Mio_Gate_t* Mio_LibraryReadGates | ( | Mio_Library_t * | pLib | ) |
Mio_Gate_t* Mio_LibraryReadInv | ( | Mio_Library_t * | pLib | ) |
char* Mio_LibraryReadName | ( | Mio_Library_t * | pLib | ) |
FUNCTION DEFINITIONS ///
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 [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 40 of file mioApi.c.
00040 { return pLib->pName; }
Mio_Gate_t* Mio_LibraryReadNand2 | ( | Mio_Library_t * | pLib | ) |
Definition at line 48 of file mioApi.c.
00048 { return pLib->pGateNand2; }
char* Mio_LibraryReadSopByName | ( | Mio_Library_t * | pLib, | |
char * | pName | |||
) |
Function*************************************************************
Synopsis [Read Mvc of the gate by name.]
Description []
SideEffects []
SeeAlso []
Definition at line 115 of file mioApi.c.
00116 { 00117 Mio_Gate_t * pGate; 00118 if ( st_lookup( pLib->tName2Gate, pName, (char **)&pGate ) ) 00119 return pGate->pSop; 00120 return NULL; 00121 }
void Mio_PinDelete | ( | Mio_Pin_t * | pPin | ) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 100 of file mioUtils.c.
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 117 of file mioUtils.c.
double Mio_PinReadDelayBlockFall | ( | Mio_Pin_t * | pPin | ) |
Definition at line 163 of file mioApi.c.
00163 { return pPin->dDelayBlockFall; }
double Mio_PinReadDelayBlockMax | ( | Mio_Pin_t * | pPin | ) |
Definition at line 165 of file mioApi.c.
00165 { return pPin->dDelayBlockMax; }
double Mio_PinReadDelayBlockRise | ( | Mio_Pin_t * | pPin | ) |
Definition at line 161 of file mioApi.c.
00161 { return pPin->dDelayBlockRise; }
double Mio_PinReadDelayFanoutFall | ( | Mio_Pin_t * | pPin | ) |
Definition at line 164 of file mioApi.c.
00164 { return pPin->dDelayFanoutFall;}
double Mio_PinReadDelayFanoutRise | ( | Mio_Pin_t * | pPin | ) |
Definition at line 162 of file mioApi.c.
00162 { return pPin->dDelayFanoutRise;}
double Mio_PinReadInputLoad | ( | Mio_Pin_t * | pPin | ) |
Definition at line 159 of file mioApi.c.
00159 { return pPin->dLoadInput; }
double Mio_PinReadMaxLoad | ( | Mio_Pin_t * | pPin | ) |
char* Mio_PinReadName | ( | Mio_Pin_t * | pPin | ) |
Mio_PinPhase_t Mio_PinReadPhase | ( | Mio_Pin_t * | pPin | ) |
void Mio_WriteLibrary | ( | FILE * | pFile, | |
Mio_Library_t * | pLib, | |||
int | fPrintSops | |||
) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 143 of file mioUtils.c.
00144 { 00145 Mio_Gate_t * pGate; 00146 00147 fprintf( pFile, "# The genlib library \"%s\".\n", pLib->pName ); 00148 Mio_LibraryForEachGate( pLib, pGate ) 00149 Mio_WriteGate( pFile, pGate, fPrintSops ); 00150 }