/**Function************************************************************* Synopsis [Returns cell's function.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Amap_Item_t * Amap_LibertyCellOutput( Amap_Tree_t * p, Amap_Item_t * pCell ) { Amap_Item_t * pPin; Amap_ItemForEachChild( p, pCell, pPin ) { if ( Amap_LibertyCompare(p, pPin->Key, "pin") ) continue; if ( Amap_LibertyPinFunction(p, pPin) ) return pPin; } return NULL; }
/**Function************************************************************* Synopsis [Count cell's output pins (pins with a logic function).] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Amap_LibertyCellCountOutputs( Amap_Tree_t * p, Amap_Item_t * pCell ) { Amap_Item_t * pPin; int Counter = 0; Amap_ItemForEachChild( p, pCell, pPin ) { if ( Amap_LibertyCompare(p, pPin->Key, "pin") ) continue; if ( Amap_LibertyPinFunction(p, pPin) ) Counter++; } return Counter; }
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************************************************************* Synopsis [Prints parse tree in Genlib format.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Amap_LibertyPrintGenlib( Amap_Tree_t * p, char * pFileName, int fVerbose ) { FILE * pFile; Amap_Item_t * pCell, * pArea, * pFunc, * pPin, * pOutput; char * pForm; int Counter; if ( pFileName == NULL ) pFile = stdout; else { pFile = fopen( pFileName, "w" ); if ( pFile == NULL ) { printf( "Amap_LibertyPrintGenlib(): The output file is unavailable (absent or open).\n" ); return 0; } } fprintf( pFile, "# This Genlib file was generated by ABC on %s\n", Amap_LibertyTimeStamp() ); fprintf( pFile, "# The standard cell library \"%s\" is from Liberty file \"%s\"\n", Amap_LibertyGetString(p, Amap_LibertyRoot(p)->Head), p->pFileName ); fprintf( pFile, "# (To find out more about Genlib format, google for \"sis_paper.ps\")\n" ); fprintf( pFile, "GATE " ); fprintf( pFile, "%16s ", "_const0_" ); fprintf( pFile, "%f ", 0.0 ); fprintf( pFile, "%s=", "z" ); fprintf( pFile, "%s;\n", "CONST0" ); fprintf( pFile, "GATE " ); fprintf( pFile, "%16s ", "_const1_" ); fprintf( pFile, "%f ", 0.0 ); fprintf( pFile, "%s=", "z" ); fprintf( pFile, "%s;\n", "CONST1" ); Amap_ItemForEachChild( p, Amap_LibertyRoot(p), pCell ) { /* if ( strcmp(Amap_LibertyGetString(p, pCell->Head), "HA1SVTX1") == 0 ) { int s = 0; } */ if ( Amap_LibertyCompare(p, pCell->Key, "cell") ) continue; if ( Amap_LibertyCellIsFlop(p, pCell) ) { if ( fVerbose ) printf( "Amap_LibertyPrintGenlib() skipped sequential cell \"%s\".\n", Amap_LibertyGetString(p, pCell->Head) ); continue; } Counter = Amap_LibertyCellCountOutputs( p, pCell ); if ( Counter == 0 ) { if ( 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 ) { if ( 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") ) { 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) ); } if ( pFile != stdout ) fclose( pFile ); return 1; }