ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
ioWriteGml.c
Go to the documentation of this file.
1
20
21#include "ioAbc.h"
22
24
25
29
33
46void 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 constant node in the AIG if it has fanouts
65 if ( Abc_NtkIsStrash(pNtk) )
66 {
67 pObj = Abc_AigConst1( pNtk );
68 if ( Abc_ObjFanoutNum(pObj) > 0 )
69 {
70 fprintf( pFile, "\n" );
71 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
72 fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
73 fprintf( pFile, " ]\n" );
74 }
75 }
76 // output the POs
77 fprintf( pFile, "\n" );
78 Abc_NtkForEachPo( pNtk, pObj, i )
79 {
80 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
81 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FFFF\" ]\n" ); // blue
82 fprintf( pFile, " ]\n" );
83 }
84 // output the PIs
85 fprintf( pFile, "\n" );
86 Abc_NtkForEachPi( pNtk, pObj, i )
87 {
88 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
89 fprintf( pFile, " graphics [ type \"triangle\" fill \"#00FF00\" ]\n" ); // green
90 fprintf( pFile, " ]\n" );
91 }
92 // output the latches
93 fprintf( pFile, "\n" );
94 Abc_NtkForEachLatch( pNtk, pObj, i )
95 {
96 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
97 fprintf( pFile, " graphics [ type \"rectangle\" fill \"#FF0000\" ]\n" ); // red
98 fprintf( pFile, " ]\n" );
99 }
100 // output the nodes
101 fprintf( pFile, "\n" );
102 Abc_NtkForEachNode( pNtk, pObj, i )
103 {
104 fprintf( pFile, " node [ id %5d label \"%s\"\n", pObj->Id, Abc_ObjName(pObj) );
105 fprintf( pFile, " graphics [ type \"ellipse\" fill \"#CCCCFF\" ]\n" ); // grey
106 fprintf( pFile, " ]\n" );
107 }
108
109 // output the edges
110 fprintf( pFile, "\n" );
111 Abc_NtkForEachObj( pNtk, pObj, i )
112 {
113 Abc_ObjForEachFanin( pObj, pFanin, k )
114 {
115 fprintf( pFile, " edge [ source %5d target %5d\n", pObj->Id, pFanin->Id );
116 fprintf( pFile, " graphics [ type \"line\" arrow \"first\" ]\n" );
117 fprintf( pFile, " ]\n" );
118 }
119 }
120
121 fprintf( pFile, "]\n" );
122 fprintf( pFile, "\n" );
123 fclose( pFile );
124}
125
126
130
131
133
struct Abc_Obj_t_ Abc_Obj_t
Definition abc.h:116
#define Abc_NtkForEachPo(pNtk, pPo, i)
Definition abc.h:520
#define Abc_NtkForEachLatch(pNtk, pObj, i)
Definition abc.h:500
#define Abc_NtkForEachObj(pNtk, pObj, i)
ITERATORS ///.
Definition abc.h:449
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition abc.h:527
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition abcNames.c:49
struct Abc_Ntk_t_ Abc_Ntk_t
Definition abc.h:115
#define Abc_NtkForEachPi(pNtk, pPi, i)
Definition abc.h:516
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition abcAig.c:683
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition abc.h:464
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
char * Extra_TimeStamp()
ABC_NAMESPACE_IMPL_START void Io_WriteGml(Abc_Ntk_t *pNtk, char *pFileName)
DECLARATIONS ///.
Definition ioWriteGml.c:46
char * pName
Definition abc.h:158
int Id
Definition abc.h:132
#define assert(ex)
Definition util_old.h:213