abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteGml.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [ioWriteGml.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Command processing package.]
8 
9  Synopsis [Procedures to write the graph structure of AIG in GML.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: ioWriteGml.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "ioAbc.h"
22 
24 
25 
26 ////////////////////////////////////////////////////////////////////////
27 /// DECLARATIONS ///
28 ////////////////////////////////////////////////////////////////////////
29 
30 ////////////////////////////////////////////////////////////////////////
31 /// FUNCTION DEFINITIONS ///
32 ////////////////////////////////////////////////////////////////////////
33 
34 /**Function*************************************************************
35 
36  Synopsis [Writes the graph structure of AIG in GML.]
37 
38  Description [Useful for graph visualization using tools such as yEd:
39  http://www.yworks.com/]
40 
41  SideEffects []
42 
43  SeeAlso []
44 
45 ***********************************************************************/
46 void Io_WriteGml( Abc_Ntk_t * pNtk, char * pFileName )
47 {
48  FILE * pFile;
49  Abc_Obj_t * pObj, * pFanin;
50  int i, k;
51 
52  assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
53 
54  // start the output stream
55  pFile = fopen( pFileName, "w" );
56  if ( pFile == NULL )
57  {
58  fprintf( stdout, "Io_WriteGml(): Cannot open the output file \"%s\".\n", pFileName );
59  return;
60  }
61  fprintf( pFile, "# GML for \"%s\" written by ABC on %s\n", pNtk->pName, Extra_TimeStamp() );
62  fprintf( pFile, "graph [\n" );
63 
64  // output the POs
65  fprintf( pFile, "\n" );
66  Abc_NtkForEachPo( pNtk, pObj, i )
67  {
68  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
69  fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" ); // blue
70  fprintf( pFile, " ]\n" );
71  }
72  // output the PIs
73  fprintf( pFile, "\n" );
74  Abc_NtkForEachPi( pNtk, pObj, i )
75  {
76  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
77  fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" ); // green
78  fprintf( pFile, " ]\n" );
79  }
80  // output the latches
81  fprintf( pFile, "\n" );
82  Abc_NtkForEachLatch( pNtk, pObj, i )
83  {
84  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
85  fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" ); // red
86  fprintf( pFile, " ]\n" );
87  }
88  // output the nodes
89  fprintf( pFile, "\n" );
90  Abc_NtkForEachNode( pNtk, pObj, i )
91  {
92  fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
93  fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
94  fprintf( pFile, " ]\n" );
95  }
96 
97  // output the edges
98  fprintf( pFile, "\n" );
99  Abc_NtkForEachObj( pNtk, pObj, i )
100  {
101  Abc_ObjForEachFanin( pObj, pFanin, k )
102  {
103  fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
104  fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
105  fprintf( pFile, " ]\n" );
106  }
107  }
108 
109  fprintf( pFile, "]\n" );
110  fprintf( pFile, "\n" );
111  fclose( pFile );
112 }
113 
114 
115 ////////////////////////////////////////////////////////////////////////
116 /// END OF FILE ///
117 ////////////////////////////////////////////////////////////////////////
118 
119 
121 
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
static int Abc_NtkIsLogic(Abc_Ntk_t *pNtk)
Definition: abc.h:250
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
int Id
Definition: abc.h:132
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
char * Extra_TimeStamp()
#define assert(ex)
Definition: util_old.h:213
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition: abc.h:517
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition: abc.h:446
char * pName
Definition: abc.h:158
ABC_NAMESPACE_IMPL_START void Io_WriteGml(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
Definition: ioWriteGml.c:46
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513