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

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START void Aig_WriteDotAig (Aig_Man_t *pMan, char *pFileName, int fHaig, Vec_Ptr_t *vBold)
 DECLARATIONS ///. More...
 
void Aig_ManShow (Aig_Man_t *pMan, int fHaig, Vec_Ptr_t *vBold)
 

Function Documentation

void Aig_ManShow ( Aig_Man_t pMan,
int  fHaig,
Vec_Ptr_t vBold 
)

Function*************************************************************

Synopsis []

Description []

SideEffects []

SeeAlso []

Definition at line 340 of file aigShow.c.

341 {
342  extern void Abc_ShowFile( char * FileNameDot );
343  static int Counter = 0;
344  char FileNameDot[200];
345  FILE * pFile;
346  // create the file name
347 // Aig_ShowGetFileName( pMan->pName, FileNameDot );
348  sprintf( FileNameDot, "temp%02d.dot", Counter++ );
349  // check that the file can be opened
350  if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
351  {
352  fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
353  return;
354  }
355  fclose( pFile );
356  // generate the file
357  Aig_WriteDotAig( pMan, FileNameDot, fHaig, vBold );
358  // visualize the file
359  Abc_ShowFile( FileNameDot );
360 }
ABC_NAMESPACE_IMPL_START void Aig_WriteDotAig(Aig_Man_t *pMan, char *pFileName, int fHaig, Vec_Ptr_t *vBold)
DECLARATIONS ///.
Definition: aigShow.c:46
ABC_NAMESPACE_IMPL_START void Abc_ShowFile(char *FileNameDot)
DECLARATIONS ///.
Definition: abcShow.c:245
char * sprintf()
static int Counter
ABC_NAMESPACE_IMPL_START void Aig_WriteDotAig ( Aig_Man_t pMan,
char *  pFileName,
int  fHaig,
Vec_Ptr_t vBold 
)

DECLARATIONS ///.

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

FileName [ivyShow.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [And-Inverter Graph package.]

Synopsis [Visualization of HAIG.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - May 11, 2006.]

Revision [

Id:
ivyShow.c,v 1.00 2006/05/11 00:00:00 alanmi Exp

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

Synopsis [Writes the graph structure of AIG for DOT.]

Description [Useful for graph visualization using tools such as GraphViz: http://www.graphviz.org/]

SideEffects []

SeeAlso []

Definition at line 46 of file aigShow.c.

47 {
48  FILE * pFile;
49  Aig_Obj_t * pNode;//, * pTemp, * pPrev;
50  int LevelMax, Prev, Level, i;
51 
52  if ( Aig_ManNodeNum(pMan) > 200 )
53  {
54  fprintf( stdout, "Cannot visualize AIG with more than 200 nodes.\n" );
55  return;
56  }
57  if ( (pFile = fopen( pFileName, "w" )) == NULL )
58  {
59  fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName );
60  return;
61  }
62 
63  // mark the nodes
64  if ( vBold )
65  Vec_PtrForEachEntry( Aig_Obj_t *, vBold, pNode, i )
66  pNode->fMarkB = 1;
67 
68  // compute levels
69 // LevelMax = 1 + Aig_ManSetLevels( pMan, fHaig );
70  LevelMax = 1 + Aig_ManLevels( pMan );
71  Aig_ManForEachCo( pMan, pNode, i )
72  pNode->Level = LevelMax;
73 
74  // write the DOT header
75  fprintf( pFile, "# %s\n", "AIG structure generated by IVY package" );
76  fprintf( pFile, "\n" );
77  fprintf( pFile, "digraph AIG {\n" );
78  fprintf( pFile, "size = \"7.5,10\";\n" );
79 // fprintf( pFile, "ranksep = 0.5;\n" );
80 // fprintf( pFile, "nodesep = 0.5;\n" );
81  fprintf( pFile, "center = true;\n" );
82 // fprintf( pFile, "orientation = landscape;\n" );
83 // fprintf( pFile, "edge [fontsize = 10];\n" );
84 // fprintf( pFile, "edge [dir = none];\n" );
85  fprintf( pFile, "edge [dir = back];\n" );
86  fprintf( pFile, "\n" );
87 
88  // labels on the left of the picture
89  fprintf( pFile, "{\n" );
90  fprintf( pFile, " node [shape = plaintext];\n" );
91  fprintf( pFile, " edge [style = invis];\n" );
92  fprintf( pFile, " LevelTitle1 [label=\"\"];\n" );
93  fprintf( pFile, " LevelTitle2 [label=\"\"];\n" );
94  // generate node names with labels
95  for ( Level = LevelMax; Level >= 0; Level-- )
96  {
97  // the visible node name
98  fprintf( pFile, " Level%d", Level );
99  fprintf( pFile, " [label = " );
100  // label name
101  fprintf( pFile, "\"" );
102  fprintf( pFile, "\"" );
103  fprintf( pFile, "];\n" );
104  }
105 
106  // genetate the sequence of visible/invisible nodes to mark levels
107  fprintf( pFile, " LevelTitle1 -> LevelTitle2 ->" );
108  for ( Level = LevelMax; Level >= 0; Level-- )
109  {
110  // the visible node name
111  fprintf( pFile, " Level%d", Level );
112  // the connector
113  if ( Level != 0 )
114  fprintf( pFile, " ->" );
115  else
116  fprintf( pFile, ";" );
117  }
118  fprintf( pFile, "\n" );
119  fprintf( pFile, "}" );
120  fprintf( pFile, "\n" );
121  fprintf( pFile, "\n" );
122 
123  // generate title box on top
124  fprintf( pFile, "{\n" );
125  fprintf( pFile, " rank = same;\n" );
126  fprintf( pFile, " LevelTitle1;\n" );
127  fprintf( pFile, " title1 [shape=plaintext,\n" );
128  fprintf( pFile, " fontsize=20,\n" );
129  fprintf( pFile, " fontname = \"Times-Roman\",\n" );
130  fprintf( pFile, " label=\"" );
131  fprintf( pFile, "%s", "AIG structure visualized by ABC" );
132  fprintf( pFile, "\\n" );
133  fprintf( pFile, "Benchmark \\\"%s\\\". ", "aig" );
134 // fprintf( pFile, "Time was %s. ", Extra_TimeStamp() );
135  fprintf( pFile, "\"\n" );
136  fprintf( pFile, " ];\n" );
137  fprintf( pFile, "}" );
138  fprintf( pFile, "\n" );
139  fprintf( pFile, "\n" );
140 
141  // generate statistics box
142  fprintf( pFile, "{\n" );
143  fprintf( pFile, " rank = same;\n" );
144  fprintf( pFile, " LevelTitle2;\n" );
145  fprintf( pFile, " title2 [shape=plaintext,\n" );
146  fprintf( pFile, " fontsize=18,\n" );
147  fprintf( pFile, " fontname = \"Times-Roman\",\n" );
148  fprintf( pFile, " label=\"" );
149  fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Aig_ManNodeNum(pMan), LevelMax );
150  fprintf( pFile, "\\n" );
151  fprintf( pFile, "\"\n" );
152  fprintf( pFile, " ];\n" );
153  fprintf( pFile, "}" );
154  fprintf( pFile, "\n" );
155  fprintf( pFile, "\n" );
156 
157  // generate the COs
158  fprintf( pFile, "{\n" );
159  fprintf( pFile, " rank = same;\n" );
160  // the labeling node of this level
161  fprintf( pFile, " Level%d;\n", LevelMax );
162  // generate the CO nodes
163  Aig_ManForEachCo( pMan, pNode, i )
164  {
165 /*
166  if ( fHaig || pNode->pEquiv == NULL )
167  fprintf( pFile, " Node%d%s [label = \"%d%s\"", pNode->Id,
168  (Aig_ObjIsLatch(pNode)? "_in":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":"") );
169  else
170  fprintf( pFile, " Node%d%s [label = \"%d%s(%d%s)\"", pNode->Id,
171  (Aig_ObjIsLatch(pNode)? "_in":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":""),
172  Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" );
173 */
174  fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
175 
176  fprintf( pFile, ", shape = %s", "invtriangle" );
177  fprintf( pFile, ", color = coral, fillcolor = coral" );
178  fprintf( pFile, "];\n" );
179  }
180  fprintf( pFile, "}" );
181  fprintf( pFile, "\n" );
182  fprintf( pFile, "\n" );
183 
184  // generate nodes of each rank
185  for ( Level = LevelMax - 1; Level > 0; Level-- )
186  {
187  fprintf( pFile, "{\n" );
188  fprintf( pFile, " rank = same;\n" );
189  // the labeling node of this level
190  fprintf( pFile, " Level%d;\n", Level );
191  Aig_ManForEachObj( pMan, pNode, i )
192  {
193  if ( (int)pNode->Level != Level )
194  continue;
195 /*
196  if ( fHaig || pNode->pEquiv == NULL )
197  fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
198  else
199  fprintf( pFile, " Node%d [label = \"%d(%d%s)\"", pNode->Id, pNode->Id,
200  Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" );
201 */
202  fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
203 
204  fprintf( pFile, ", shape = ellipse" );
205  if ( vBold && pNode->fMarkB )
206  fprintf( pFile, ", style = filled" );
207  fprintf( pFile, "];\n" );
208  }
209  fprintf( pFile, "}" );
210  fprintf( pFile, "\n" );
211  fprintf( pFile, "\n" );
212  }
213 
214  // generate the CI nodes
215  fprintf( pFile, "{\n" );
216  fprintf( pFile, " rank = same;\n" );
217  // the labeling node of this level
218  fprintf( pFile, " Level%d;\n", 0 );
219  // generate constant node
220  if ( Aig_ObjRefs(Aig_ManConst1(pMan)) > 0 )
221  {
222  pNode = Aig_ManConst1(pMan);
223  // check if the costant node is present
224  fprintf( pFile, " Node%d [label = \"Const1\"", pNode->Id );
225  fprintf( pFile, ", shape = ellipse" );
226  fprintf( pFile, ", color = coral, fillcolor = coral" );
227  fprintf( pFile, "];\n" );
228  }
229  // generate the CI nodes
230  Aig_ManForEachCi( pMan, pNode, i )
231  {
232 /*
233  if ( fHaig || pNode->pEquiv == NULL )
234  fprintf( pFile, " Node%d%s [label = \"%d%s\"", pNode->Id,
235  (Aig_ObjIsLatch(pNode)? "_out":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_out":"") );
236  else
237  fprintf( pFile, " Node%d%s [label = \"%d%s(%d%s)\"", pNode->Id,
238  (Aig_ObjIsLatch(pNode)? "_out":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_out":""),
239  Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" );
240 */
241  fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id );
242 
243  fprintf( pFile, ", shape = %s", "triangle" );
244  fprintf( pFile, ", color = coral, fillcolor = coral" );
245  fprintf( pFile, "];\n" );
246  }
247  fprintf( pFile, "}" );
248  fprintf( pFile, "\n" );
249  fprintf( pFile, "\n" );
250 
251  // generate invisible edges from the square down
252  fprintf( pFile, "title1 -> title2 [style = invis];\n" );
253  Aig_ManForEachCo( pMan, pNode, i )
254  fprintf( pFile, "title2 -> Node%d [style = invis];\n", pNode->Id );
255  // generate invisible edges among the COs
256  Prev = -1;
257  Aig_ManForEachCo( pMan, pNode, i )
258  {
259  if ( i > 0 )
260  fprintf( pFile, "Node%d -> Node%d [style = invis];\n", Prev, pNode->Id );
261  Prev = pNode->Id;
262  }
263 
264  // generate edges
265  Aig_ManForEachObj( pMan, pNode, i )
266  {
267  if ( !Aig_ObjIsNode(pNode) && !Aig_ObjIsCo(pNode) && !Aig_ObjIsBuf(pNode) )
268  continue;
269  // generate the edge from this node to the next
270  fprintf( pFile, "Node%d", pNode->Id );
271  fprintf( pFile, " -> " );
272  fprintf( pFile, "Node%d", Aig_ObjFaninId0(pNode) );
273  fprintf( pFile, " [" );
274  fprintf( pFile, "style = %s", Aig_ObjFaninC0(pNode)? "dotted" : "bold" );
275 // if ( Aig_NtkIsSeq(pNode->pMan) && Seq_ObjFaninL0(pNode) > 0 )
276 // fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,0) );
277  fprintf( pFile, "]" );
278  fprintf( pFile, ";\n" );
279  if ( !Aig_ObjIsNode(pNode) )
280  continue;
281  // generate the edge from this node to the next
282  fprintf( pFile, "Node%d", pNode->Id );
283  fprintf( pFile, " -> " );
284  fprintf( pFile, "Node%d", Aig_ObjFaninId1(pNode) );
285  fprintf( pFile, " [" );
286  fprintf( pFile, "style = %s", Aig_ObjFaninC1(pNode)? "dotted" : "bold" );
287 // if ( Aig_NtkIsSeq(pNode->pMan) && Seq_ObjFaninL1(pNode) > 0 )
288 // fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,1) );
289  fprintf( pFile, "]" );
290  fprintf( pFile, ";\n" );
291 /*
292  // generate the edges between the equivalent nodes
293  if ( fHaig && pNode->pEquiv && Aig_ObjRefs(pNode) > 0 )
294  {
295  pPrev = pNode;
296  for ( pTemp = pNode->pEquiv; pTemp != pNode; pTemp = Aig_Regular(pTemp->pEquiv) )
297  {
298  fprintf( pFile, "Node%d", pPrev->Id );
299  fprintf( pFile, " -> " );
300  fprintf( pFile, "Node%d", pTemp->Id );
301  fprintf( pFile, " [style = %s]", Aig_IsComplement(pTemp->pEquiv)? "dotted" : "bold" );
302  fprintf( pFile, ";\n" );
303  pPrev = pTemp;
304  }
305  // connect the last node with the first
306  fprintf( pFile, "Node%d", pPrev->Id );
307  fprintf( pFile, " -> " );
308  fprintf( pFile, "Node%d", pNode->Id );
309  fprintf( pFile, " [style = %s]", Aig_IsComplement(pPrev->pEquiv)? "dotted" : "bold" );
310  fprintf( pFile, ";\n" );
311  }
312 */
313  }
314 
315  fprintf( pFile, "}" );
316  fprintf( pFile, "\n" );
317  fprintf( pFile, "\n" );
318  fclose( pFile );
319 
320  // unmark nodes
321  if ( vBold )
322  Vec_PtrForEachEntry( Aig_Obj_t *, vBold, pNode, i )
323  pNode->fMarkB = 0;
324 
325  Aig_ManForEachCo( pMan, pNode, i )
326  pNode->Level = Aig_ObjFanin0(pNode)->Level;
327 }
static int Aig_ObjFaninId0(Aig_Obj_t *pObj)
Definition: aig.h:304
static Aig_Obj_t * Aig_ObjFanin0(Aig_Obj_t *pObj)
Definition: aig.h:308
#define Aig_ManForEachCi(p, pObj, i)
ITERATORS ///.
Definition: aig.h:393
#define Aig_ManForEachCo(p, pObj, i)
Definition: aig.h:398
static int Aig_ObjFaninId1(Aig_Obj_t *pObj)
Definition: aig.h:305
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
static int Aig_ObjIsNode(Aig_Obj_t *pObj)
Definition: aig.h:280
static int Aig_ObjIsBuf(Aig_Obj_t *pObj)
Definition: aig.h:277
Definition: aig.h:69
static int Aig_ObjFaninC0(Aig_Obj_t *pObj)
Definition: aig.h:306
static Aig_Obj_t * Aig_ManConst1(Aig_Man_t *p)
Definition: aig.h:264
#define Aig_ManForEachObj(p, pObj, i)
Definition: aig.h:403
static int Aig_ObjFaninC1(Aig_Obj_t *pObj)
Definition: aig.h:307
static int Aig_ObjRefs(Aig_Obj_t *pObj)
Definition: aig.h:300
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
int Aig_ManLevels(Aig_Man_t *p)
Definition: aigUtil.c:102
static int Aig_ObjIsCo(Aig_Obj_t *pObj)
Definition: aig.h:276