abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ioWriteGml.c File Reference
#include "ioAbc.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Io_WriteGml (Abc_Ntk_t *pNtk, char *pFileName)
 DECLARATIONS ///. More...
 

Function Documentation

ABC_NAMESPACE_IMPL_START void Io_WriteGml ( Abc_Ntk_t pNtk,
char *  pFileName 
)

DECLARATIONS ///.

CFile****************************************************************

FileName [ioWriteGml.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [Command processing package.]

Synopsis [Procedures to write the graph structure of AIG in GML.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
ioWriteGml.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Writes the graph structure of AIG in GML.]

Description [Useful for graph visualization using tools such as yEd: http://www.yworks.com/]

SideEffects []

SeeAlso []

Definition at line 46 of file ioWriteGml.c.

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 }
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_NtkForEachLatch(pNtk, pObj, i)
Definition: abc.h:497
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
#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
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition: abc.h:513