summaryrefslogtreecommitdiffstats
path: root/src/map/amap
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2012-09-19 17:35:04 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2012-09-19 17:35:04 -0700
commit480ca14c75e9f8c54ca9b55c39162324aaa1e288 (patch)
tree446dc0fd3a98d5d60c01f01f5b95e380b002ce34 /src/map/amap
parent3af0f719afa368cafbe7c8178d0995819b47be90 (diff)
downloadabc-480ca14c75e9f8c54ca9b55c39162324aaa1e288.tar.gz
abc-480ca14c75e9f8c54ca9b55c39162324aaa1e288.tar.bz2
abc-480ca14c75e9f8c54ca9b55c39162324aaa1e288.zip
Extending Liberty parser to handle multi-output cells.
Diffstat (limited to 'src/map/amap')
-rw-r--r--src/map/amap/amapInt.h1
-rw-r--r--src/map/amap/amapLib.c4
-rw-r--r--src/map/amap/amapLiberty.c58
-rw-r--r--src/map/amap/amapRead.c17
4 files changed, 57 insertions, 23 deletions
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;
}