00001
00021 #include "io.h"
00022
00026
00030
00043 void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName )
00044 {
00045 FILE * pFile;
00046 Abc_Obj_t * pObj, * pFanin;
00047 int i, k;
00048
00049 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00050
00051
00052 pFile = fopen( pFileName, "w" );
00053 if ( pFile == NULL )
00054 {
00055 fprintf( stdout, "Io_WriteGml(): Cannot open the output file \"%s\".\n", pFileName );
00056 return;
00057 }
00058 fprintf( pFile, "# GML for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
00059 fprintf( pFile, "graph [\n" );
00060
00061
00062 fprintf( pFile, "\n" );
00063 Abc_NtkForEachPo( pNtk, pObj, i )
00064 {
00065 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00066 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" );
00067 fprintf( pFile, " ]\n" );
00068 }
00069
00070 fprintf( pFile, "\n" );
00071 Abc_NtkForEachPi( pNtk, pObj, i )
00072 {
00073 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00074 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" );
00075 fprintf( pFile, " ]\n" );
00076 }
00077
00078 fprintf( pFile, "\n" );
00079 Abc_NtkForEachLatch( pNtk, pObj, i )
00080 {
00081 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00082 fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" );
00083 fprintf( pFile, " ]\n" );
00084 }
00085
00086 fprintf( pFile, "\n" );
00087 Abc_NtkForEachNode( pNtk, pObj, i )
00088 {
00089 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
00090 fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" );
00091 fprintf( pFile, " ]\n" );
00092 }
00093
00094
00095 fprintf( pFile, "\n" );
00096 Abc_NtkForEachObj( pNtk, pObj, i )
00097 {
00098 Abc_ObjForEachFanin( pObj, pFanin, k )
00099 {
00100 fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
00101 fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
00102 fprintf( pFile, " ]\n" );
00103 }
00104 }
00105
00106 fprintf( pFile, "]\n" );
00107 fprintf( pFile, "\n" );
00108 fclose( pFile );
00109 }
00110
00111
00115
00116