From 480ca14c75e9f8c54ca9b55c39162324aaa1e288 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Wed, 19 Sep 2012 17:35:04 -0700 Subject: Extending Liberty parser to handle multi-output cells. --- src/map/amap/amapInt.h | 1 + src/map/amap/amapLib.c | 4 ++-- src/map/amap/amapLiberty.c | 58 +++++++++++++++++++++++++++++++--------------- src/map/amap/amapRead.c | 17 ++++++++++++-- src/map/mio/mioUtils.c | 2 ++ 5 files changed, 59 insertions(+), 23 deletions(-) (limited to 'src/map') diff --git a/src/map/amap/amapInt.h b/src/map/amap/amapInt.h index a9a593c0..e2284ce6 100644 --- a/src/map/amap/amapInt.h +++ b/src/map/amap/amapInt.h @@ -149,6 +149,7 @@ struct Amap_Pin_t_ struct Amap_Gat_t_ { Amap_Lib_t * pLib; // library + Amap_Gat_t * pTwin; // twin gate char * pName; // the name of the gate char * pOutName; // name of the output double dArea; // the area of the gate diff --git a/src/map/amap/amapLib.c b/src/map/amap/amapLib.c index cf087218..002386ad 100644 --- a/src/map/amap/amapLib.c +++ b/src/map/amap/amapLib.c @@ -269,11 +269,11 @@ Vec_Ptr_t * Amap_LibSelectGates( Amap_Lib_t * p, int fVerbose ) vSelect = Vec_PtrAlloc( 100 ); Vec_PtrForEachEntry( Amap_Gat_t *, p->vSorted, pGate, i ) { - if ( pGate->pFunc == NULL ) + if ( pGate->pFunc == NULL || pGate->pTwin != NULL ) continue; Vec_PtrForEachEntryStop( Amap_Gat_t *, p->vSorted, pGate2, k, i ) { - if ( pGate2->pFunc == NULL ) + if ( pGate2->pFunc == NULL || pGate2->pTwin != NULL ) continue; if ( pGate2->nPins != pGate->nPins ) continue; diff --git a/src/map/amap/amapLiberty.c b/src/map/amap/amapLiberty.c index 7e8a9af5..e961b68c 100644 --- a/src/map/amap/amapLiberty.c +++ b/src/map/amap/amapLiberty.c @@ -229,7 +229,7 @@ Amap_Item_t * Amap_LibertyPinFunction( Amap_Tree_t * p, Amap_Item_t * pPin ) /**Function************************************************************* - Synopsis [Returns cell's function.] + Synopsis [Returns output pin(s).] Description [] @@ -250,6 +250,20 @@ Amap_Item_t * Amap_LibertyCellOutput( Amap_Tree_t * p, Amap_Item_t * pCell ) } return NULL; } +Vec_Ptr_t * Amap_LibertyCellOutputs( Amap_Tree_t * p, Amap_Item_t * pCell ) +{ + Amap_Item_t * pPin; + Vec_Ptr_t * vOutPins; + vOutPins = Vec_PtrAlloc( 2 ); + Amap_ItemForEachChild( p, pCell, pPin ) + { + if ( Amap_LibertyCompare(p, pPin->Key, "pin") ) + continue; + if ( Amap_LibertyPinFunction(p, pPin) ) + Vec_PtrPush( vOutPins, pPin ); + } + return vOutPins; +} /**Function************************************************************* @@ -353,9 +367,10 @@ char * Amap_LibertyGetStringFormula( Amap_Tree_t * p, Amap_Pair_t Pair ) int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName, int fVerbose ) { FILE * pFile; + Vec_Ptr_t * vOutputs; Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput; char * pForm; - int Counter; + int i, Counter; if ( pFileName == NULL ) pFile = stdout; else @@ -406,12 +421,14 @@ int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName, int fVerbose ) printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" without logic function.\n", Amap_LibertyGetString(p, pCell->Head) ); continue; } +/* if ( Counter > 1 ) { if ( fVerbose ) printf( "Amap_LibertyPrintGenlib() skipped multi-output cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) ); continue; } +*/ pArea = Amap_LibertyCellArea( p, pCell ); if ( pArea == NULL ) { @@ -419,25 +436,28 @@ int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName, int fVerbose ) printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with unspecified area.\n", Amap_LibertyGetString(p, pCell->Head) ); continue; } - pOutput = Amap_LibertyCellOutput( p, pCell ); - pFunc = Amap_LibertyPinFunction( p, pOutput ); - pForm = Amap_LibertyGetStringFormula( p, pFunc->Head ); - if ( !strcmp(pForm, "0") || !strcmp(pForm, "1") ) +// pOutput = Amap_LibertyCellOutput( p, pCell ); + vOutputs = Amap_LibertyCellOutputs( p, pCell ); + Vec_PtrForEachEntry( Amap_Item_t *, vOutputs, pOutput, i ) { - if ( fVerbose ) - printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n", Amap_LibertyGetString(p, pCell->Head), pForm ); - continue; + pFunc = Amap_LibertyPinFunction( p, pOutput ); + pForm = Amap_LibertyGetStringFormula( p, pFunc->Head ); + if ( !strcmp(pForm, "0") || !strcmp(pForm, "1") ) + { + if ( fVerbose ) + printf( "Amap_LibertyPrintGenlib() skipped cell \"%s\" with constant formula \"%s\".\n", Amap_LibertyGetString(p, pCell->Head), pForm ); + continue; + } + fprintf( pFile, "GATE " ); + fprintf( pFile, "%16s ", Amap_LibertyGetString(p, pCell->Head) ); + fprintf( pFile, "%f ", atof(Amap_LibertyGetString(p, pArea->Head)) ); + fprintf( pFile, "%s=", Amap_LibertyGetString(p, pOutput->Head) ); + fprintf( pFile, "%s;\n", Amap_LibertyGetStringFormula(p, pFunc->Head) ); + Amap_ItemForEachChild( p, pCell, pPin ) + if ( pPin != pOutput && !Amap_LibertyCompare(p, pPin->Key, "pin") ) + fprintf( pFile, " PIN %13s UNKNOWN 1 999 1.00 0.00 1.00 0.00\n", Amap_LibertyGetString(p, pPin->Head) ); } - - fprintf( pFile, "GATE " ); - fprintf( pFile, "%16s ", Amap_LibertyGetString(p, pCell->Head) ); - fprintf( pFile, "%f ", atof(Amap_LibertyGetString(p, pArea->Head)) ); - fprintf( pFile, "%s=", Amap_LibertyGetString(p, pOutput->Head) ); - fprintf( pFile, "%s;\n", Amap_LibertyGetStringFormula(p, pFunc->Head) ); - - Amap_ItemForEachChild( p, pCell, pPin ) - if ( pPin != pOutput && !Amap_LibertyCompare(p, pPin->Key, "pin") ) - fprintf( pFile, " PIN %13s UNKNOWN 1 999 1.00 0.00 1.00 0.00\n", Amap_LibertyGetString(p, pPin->Head) ); + Vec_PtrFree( vOutputs ); } if ( pFile != stdout ) fclose( pFile ); diff --git a/src/map/amap/amapRead.c b/src/map/amap/amapRead.c index bf308c08..e8206e31 100644 --- a/src/map/amap/amapRead.c +++ b/src/map/amap/amapRead.c @@ -326,10 +326,10 @@ int Amap_CollectFormulaTokens( Vec_Ptr_t * vTokens, char * pToken, int iPos ) Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose ) { Amap_Lib_t * p; - Amap_Gat_t * pGate; + Amap_Gat_t * pGate, * pPrev; Amap_Pin_t * pPin; char * pToken; - int nPins, iPos = 0; + int i, nPins, iPos = 0; p = Amap_LibAlloc(); pToken = (char *)Vec_PtrEntry(vTokens, iPos++); do @@ -409,8 +409,21 @@ Amap_Lib_t * Amap_ParseTokens( Vec_Ptr_t * vTokens, int fVerbose ) Vec_PtrPush( p->vGates, pGate ); } pToken = (char *)Vec_PtrEntry(vTokens, iPos++); +//printf( "Finished reading gate %s (%s)\n", pGate->pName, pGate->pOutName ); } while ( strcmp( pToken, ".end" ) ); + + // check if there are gates with identical names + pPrev = NULL; + Amap_LibForEachGate( p, pGate, i ) + { + if ( pPrev && !strcmp(pPrev->pName, pGate->pName) ) + { + pPrev->pTwin = pGate, pGate->pTwin = pPrev; + printf( "Warning: Detected multi-output gate \"%s\".\n", pGate->pName ); + } + pPrev = pGate; + } return p; } diff --git a/src/map/mio/mioUtils.c b/src/map/mio/mioUtils.c index 41b03d7d..347d81f5 100644 --- a/src/map/mio/mioUtils.c +++ b/src/map/mio/mioUtils.c @@ -319,6 +319,8 @@ Mio_Gate_t ** Mio_CollectRoots( Mio_Library_t * pLib, int nInputs, float tDelay, continue; if ( pGate->uTruth == ~0xAAAAAAAAAAAAAAAA && fSkipInv ) continue; + if ( pGate->pTwin ) // skip multi-output gates for now + continue; // check if the gate with this functionality already exists for ( i = 0; i < iGate; i++ ) if ( ppGates[i]->uTruth == pGate->uTruth ) -- cgit v1.2.3