ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
wlcShow.c
Go to the documentation of this file.
1
20
21#include "wlc.h"
22
24
28
32
33
46void Wlc_NtkDumpDot( Wlc_Ntk_t * p, char * pFileName, Vec_Int_t * vBold )
47{
48 FILE * pFile;
49 Wlc_Obj_t * pNode;
50 int LevelMax, Prev, Level, i;
51
52 if ( vBold ? (Vec_IntSize(vBold) > 2000) : (Wlc_NtkObjNum(p) > 2000) )
53 {
54 fprintf( stdout, "Cannot visualize WLC with more than %d nodes.\n", 2000 );
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 Wlc_NtkForEachObjVec( vBold, p, pNode, i )
66 pNode->Mark = 1;
67
68 // compute levels
69 LevelMax = 1 + Wlc_NtkCreateLevels( p );
70 if ( vBold )
71 LevelMax = Wlc_NtkRemapLevels( p, vBold, LevelMax );
72
73// Wlc_NtkForEachObj( p, pNode, i )
74// printf( "Obj=%d Lev=%d\n", i, Wlc_ObjLevel(p, pNode) );
75// printf( "\n" );
76
77 // write the DOT header
78 fprintf( pFile, "# %s\n", "WLC structure generated by ABC" );
79 fprintf( pFile, "\n" );
80 fprintf( pFile, "digraph WLC {\n" );
81 fprintf( pFile, "size = \"7.5,10\";\n" );
82// fprintf( pFile, "ranksep = 0.5;\n" );
83// fprintf( pFile, "nodesep = 0.5;\n" );
84 fprintf( pFile, "center = true;\n" );
85// fprintf( pFile, "orientation = landscape;\n" );
86// fprintf( pFile, "edge [fontsize = 10];\n" );
87// fprintf( pFile, "edge [dir = none];\n" );
88 fprintf( pFile, "edge [dir = back];\n" );
89 fprintf( pFile, "\n" );
90
91 // labels on the left of the picture
92 fprintf( pFile, "{\n" );
93 fprintf( pFile, " node [shape = plaintext];\n" );
94 fprintf( pFile, " edge [style = invis];\n" );
95 fprintf( pFile, " LevelTitle1 [label=\"\"];\n" );
96 fprintf( pFile, " LevelTitle2 [label=\"\"];\n" );
97 // generate node names with labels
98 for ( Level = LevelMax; Level >= 0; Level-- )
99 {
100 // the visible node name
101 fprintf( pFile, " Level%d", Level );
102 fprintf( pFile, " [label = " );
103 // label name
104 fprintf( pFile, "\"" );
105 fprintf( pFile, "\"" );
106 fprintf( pFile, "];\n" );
107 }
108
109 // genetate the sequence of visible/invisible nodes to mark levels
110 fprintf( pFile, " LevelTitle1 -> LevelTitle2 ->" );
111 for ( Level = LevelMax; Level >= 0; Level-- )
112 {
113 // the visible node name
114 fprintf( pFile, " Level%d", Level );
115 // the connector
116 if ( Level != 0 )
117 fprintf( pFile, " ->" );
118 else
119 fprintf( pFile, ";" );
120 }
121 fprintf( pFile, "\n" );
122 fprintf( pFile, "}" );
123 fprintf( pFile, "\n" );
124 fprintf( pFile, "\n" );
125
126 // generate title box on top
127 fprintf( pFile, "{\n" );
128 fprintf( pFile, " rank = same;\n" );
129 fprintf( pFile, " LevelTitle1;\n" );
130 fprintf( pFile, " title1 [shape=plaintext,\n" );
131 fprintf( pFile, " fontsize=20,\n" );
132 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
133 fprintf( pFile, " label=\"" );
134 fprintf( pFile, "%s", "WLC structure generated by ABC" );
135 fprintf( pFile, "\\n" );
136 fprintf( pFile, "Benchmark \\\"%s\\\" from file \\\"%s\\\". ", p->pName, p->pSpec ? Extra_FileNameWithoutPath(p->pSpec) : "unknown" );
137// fprintf( pFile, "Time was %s. ", Extra_TimeStamp() );
138 fprintf( pFile, "\"\n" );
139 fprintf( pFile, " ];\n" );
140 fprintf( pFile, "}" );
141 fprintf( pFile, "\n" );
142 fprintf( pFile, "\n" );
143
144 // generate statistics box
145 fprintf( pFile, "{\n" );
146 fprintf( pFile, " rank = same;\n" );
147 fprintf( pFile, " LevelTitle2;\n" );
148 fprintf( pFile, " title2 [shape=plaintext,\n" );
149 fprintf( pFile, " fontsize=18,\n" );
150 fprintf( pFile, " fontname = \"Times-Roman\",\n" );
151 fprintf( pFile, " label=\"" );
152 fprintf( pFile, "The word-level network contains %d nodes and spans %d levels.", Wlc_NtkObjNum(p)-Wlc_NtkCiNum(p), LevelMax-1 );
153 fprintf( pFile, "\\n" );
154 fprintf( pFile, "\"\n" );
155 fprintf( pFile, " ];\n" );
156 fprintf( pFile, "}" );
157 fprintf( pFile, "\n" );
158 fprintf( pFile, "\n" );
159
160 // generate the COs
161 fprintf( pFile, "{\n" );
162 fprintf( pFile, " rank = same;\n" );
163 // the labeling node of this level
164 fprintf( pFile, " Level%d;\n", LevelMax );
165 // generate the CO nodes
166 Wlc_NtkForEachCo( p, pNode, i )
167 {
168 if ( vBold && !pNode->Mark )
169 continue;
170 pNode = Wlc_ObjCo2PoFo(p, i);
171 fprintf( pFile, " NodePo%d [label = \"%s%s %d\"", Wlc_ObjId(p, pNode), Wlc_ObjName(p, Wlc_ObjId(p, pNode)), Wlc_ObjIsPo(pNode)? "":"_in", Wlc_ObjRange(pNode) );
172 fprintf( pFile, ", shape = %s", i < Wlc_NtkPoNum(p) ? "invtriangle" : "box" );
173 fprintf( pFile, ", color = coral, fillcolor = coral" );
174 fprintf( pFile, "];\n" );
175 }
176 fprintf( pFile, "}" );
177 fprintf( pFile, "\n" );
178 fprintf( pFile, "\n" );
179
180 // generate nodes of each rank
181 for ( Level = LevelMax - 1; Level > 0; Level-- )
182 {
183 fprintf( pFile, "{\n" );
184 fprintf( pFile, " rank = same;\n" );
185 // the labeling node of this level
186 fprintf( pFile, " Level%d;\n", Level );
187 Wlc_NtkForEachObj( p, pNode, i )
188 {
189 if ( (int)Wlc_ObjLevel(p, pNode) != Level )
190 continue;
191 if ( vBold && !pNode->Mark )
192 continue;
193
194 if ( pNode->Type == WLC_OBJ_CONST )
195 {
196 //char * pName = Wlc_ObjName(p, i);
197 fprintf( pFile, " Node%d [label = \"%d:%d\'h", i, i, Wlc_ObjRange(pNode) );
198 if ( Wlc_ObjRange(pNode) > 64 )
199 {
200 Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), 16 );
201 fprintf( pFile, "..." );
202 }
203 else
204 Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), (Wlc_ObjRange(pNode) + 3) / 4 );
205 fprintf( pFile, "\"" );
206 }
207 else if ( pNode->Type == WLC_OBJ_BUF || pNode->Type == WLC_OBJ_MUX )
208 fprintf( pFile, " Node%d [label = \"%d: %d\"", i, i, Wlc_ObjRange(pNode) );
209 else if ( pNode->Type >= WLC_OBJ_LOGIC_NOT && pNode->Type <= WLC_OBJ_COMP_MOREEQU )
210 fprintf( pFile, " Node%d [label = \"%d:%s\"", i, i, Wlc_ObjTypeName(pNode) );
211 else
212 fprintf( pFile, " Node%d [label = \"%d:%s %d\"", i, i, Wlc_ObjTypeName(pNode), Wlc_ObjRange(pNode) );
213
214 if ( pNode->Type == WLC_OBJ_ARI_MULTI )
215 fprintf( pFile, ", shape = doublecircle" );
216 else if ( pNode->Type >= WLC_OBJ_COMP_EQU && pNode->Type <= WLC_OBJ_COMP_MOREEQU )
217 fprintf( pFile, ", shape = diamond" );
218 else if ( pNode->Type == WLC_OBJ_BIT_SELECT || pNode->Type == WLC_OBJ_BIT_CONCAT || pNode->Type == WLC_OBJ_FF )
219 fprintf( pFile, ", shape = box" );
220 else if ( pNode->Type == WLC_OBJ_BUF || pNode->Type == WLC_OBJ_BIT_ZEROPAD || pNode->Type == WLC_OBJ_BIT_SIGNEXT )
221 fprintf( pFile, ", shape = triangle" );
222 else if ( pNode->Type == WLC_OBJ_MUX )
223 fprintf( pFile, ", shape = trapezium" );
224 else
225 fprintf( pFile, ", shape = ellipse" );
226
227 if ( vBold ? pNode->Mark : ((pNode->Type >= WLC_OBJ_ARI_ADD && pNode->Type <= WLC_OBJ_ARI_SQUARE) || pNode->Type == WLC_OBJ_BIT_NOT) )
228 fprintf( pFile, ", style = filled" );
229 fprintf( pFile, "];\n" );
230 }
231 fprintf( pFile, "}" );
232 fprintf( pFile, "\n" );
233 fprintf( pFile, "\n" );
234 }
235
236 // generate the CI nodes
237 fprintf( pFile, "{\n" );
238 fprintf( pFile, " rank = same;\n" );
239 // the labeling node of this level
240 fprintf( pFile, " Level%d;\n", 0 );
241 // generate the CI nodes
242 Wlc_NtkForEachObj( p, pNode, i )
243 {
244 if ( !Wlc_ObjIsCi(pNode) && Wlc_ObjFaninNum(pNode) > 0 )
245 continue;
246 if ( vBold && !pNode->Mark )
247 continue;
248 if ( pNode->Type == WLC_OBJ_CONST )
249 {
250 //char * pName = Wlc_ObjName(p, i);
251 fprintf( pFile, " Node%d [label = \"%d:%d\'h", i, i, Wlc_ObjRange(pNode) );
252 if ( Wlc_ObjRange(pNode) > 64 )
253 {
254 Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), 16 );
255 fprintf( pFile, "..." );
256 }
257 else
258 Abc_TtPrintHexArrayRev( pFile, (word *)Wlc_ObjConstValue(pNode), (Wlc_ObjRange(pNode) + 3) / 4 );
259 fprintf( pFile, "\"" );
260 }
261 else
262 {
263 fprintf( pFile, " Node%d [label = \"%d:%s %d\"", Wlc_ObjId(p, pNode), Wlc_ObjId(p, pNode), Wlc_ObjName(p, Wlc_ObjId(p, pNode)), Wlc_ObjRange(pNode) );
264 fprintf( pFile, ", shape = %s", (Vec_IntSize(&p->vFfs2) > 0 || Wlc_ObjCiId(pNode) < Wlc_NtkPiNum(p)) ? "triangle" : "box" );
265 fprintf( pFile, ", color = coral, fillcolor = coral" );
266 }
267 fprintf( pFile, "];\n" );
268 }
269 fprintf( pFile, "}" );
270 fprintf( pFile, "\n" );
271 fprintf( pFile, "\n" );
272
273 // generate invisible edges from the square down
274 fprintf( pFile, "title1 -> title2 [style = invis];\n" );
275 Wlc_NtkForEachCo( p, pNode, i )
276 {
277 if ( vBold && !pNode->Mark )
278 continue;
279 pNode = Wlc_ObjCo2PoFo( p, i );
280 fprintf( pFile, "title2 -> NodePo%d [style = invis];\n", Wlc_ObjId(p, pNode) );
281 }
282 // generate invisible edges among the COs
283 Prev = -1;
284 Wlc_NtkForEachCo( p, pNode, i )
285 {
286 pNode = Wlc_ObjCo2PoFo( p, i );
287 if ( vBold && !pNode->Mark )
288 continue;
289 if ( Prev >= 0 )
290 fprintf( pFile, "NodePo%d -> NodePo%d [style = invis];\n", Prev, Wlc_ObjId(p, pNode) );
291 Prev = Wlc_ObjId(p, pNode);
292 }
293 // generate invisible edges among the CIs
294 Prev = -1;
295 Wlc_NtkForEachCi( p, pNode, i )
296 {
297 if ( vBold && !pNode->Mark )
298 continue;
299 if ( Prev >= 0 )
300 fprintf( pFile, "Node%d -> Node%d [style = invis];\n", Prev, Wlc_ObjId(p, pNode) );
301 Prev = Wlc_ObjId(p, pNode);
302 }
303
304 // generate edges
305 Wlc_NtkForEachCo( p, pNode, i )
306 {
307 if ( vBold && !pNode->Mark )
308 continue;
309 fprintf( pFile, "NodePo%d", Wlc_ObjId(p, Wlc_ObjCo2PoFo(p, i)) );
310 fprintf( pFile, " -> " );
311 fprintf( pFile, "Node%d", Wlc_ObjId(p, pNode) );
312 fprintf( pFile, " [" );
313 fprintf( pFile, "style = %s", pNode->Signed? "dotted" : "solid" );
314 fprintf( pFile, "]" );
315 fprintf( pFile, ";\n" );
316 }
317 Wlc_NtkForEachObj( p, pNode, i )
318 {
319 int k, iFanin;
320 if ( Wlc_ObjIsCi(pNode) )
321 continue;
322 if ( vBold && !pNode->Mark )
323 continue;
324 // generate the edge from this node to the next
325 Wlc_ObjForEachFanin( pNode, iFanin, k ) if ( iFanin )
326 {
327 fprintf( pFile, "Node%d", i );
328 fprintf( pFile, " -> " );
329 fprintf( pFile, "Node%d", iFanin );
330 fprintf( pFile, " [" );
331 fprintf( pFile, "style = %s", Wlc_NtkObj(p, iFanin)->Signed? "dotted" : "solid" );
332 if ( pNode->Type == WLC_OBJ_MUX && k == 0 )
333 fprintf( pFile, ", style = %s", "bold" );
334 fprintf( pFile, "]" );
335 fprintf( pFile, ";\n" );
336 }
337 }
338 fprintf( pFile, "}" );
339 fprintf( pFile, "\n" );
340 fprintf( pFile, "\n" );
341 fclose( pFile );
342
343 // unmark nodes
344 if ( vBold )
346}
347
360{
361 extern void Abc_ShowFile( char * FileNameDot, int fKeepDot );
362 FILE * pFile;
363 char FileNameDot[200];
364 char * pName = Extra_FileDesignName(p->pName);
365 char * pSpec = p->pSpec ? Extra_FileDesignName(p->pSpec) : (char *)"unknown";
366 sprintf( FileNameDot, "%s_%s.dot", pName, pSpec );
367 ABC_FREE( pName );
368 if ( strcmp(pSpec, "unknown") )
369 ABC_FREE( pSpec );
370 // check that the file can be opened
371 if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
372 {
373 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
374 return;
375 }
376 fclose( pFile );
377 // generate the file
378 Wlc_NtkDumpDot( p, FileNameDot, vBold );
379 // visualize the file
380 Abc_ShowFile( FileNameDot, 0 );
381}
382
386
387
389
ABC_NAMESPACE_IMPL_START void Abc_ShowFile(char *FileNameDot, int fKeepDot)
DECLARATIONS ///.
Definition abcShow.c:326
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
Cube * p
Definition exorList.c:222
char * Extra_FileNameWithoutPath(char *FileName)
char * Extra_FileDesignName(char *pFileName)
unsigned __int64 word
DECLARATIONS ///.
Definition kitPerm.c:36
unsigned Type
Definition wlc.h:121
unsigned Signed
Definition wlc.h:122
unsigned Mark
Definition wlc.h:123
int strcmp()
char * sprintf()
void Wlc_NtkShow(Wlc_Ntk_t *p, Vec_Int_t *vBold)
Definition wlcShow.c:359
ABC_NAMESPACE_IMPL_START void Wlc_NtkDumpDot(Wlc_Ntk_t *p, char *pFileName, Vec_Int_t *vBold)
DECLARATIONS ///.
Definition wlcShow.c:46
#define Wlc_NtkForEachCi(p, pCi, i)
Definition wlc.h:366
void Wlc_NtkCleanMarks(Wlc_Ntk_t *p)
Definition wlcNtk.c:1135
#define Wlc_NtkForEachObjVec(vVec, p, pObj, i)
Definition wlc.h:360
struct Wlc_Ntk_t_ Wlc_Ntk_t
Definition wlc.h:135
char * Wlc_ObjTypeName(Wlc_Obj_t *p)
Definition wlcNtk.c:97
#define Wlc_NtkForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
Definition wlc.h:356
int Wlc_NtkCreateLevels(Wlc_Ntk_t *p)
Definition wlcNtk.c:372
#define Wlc_ObjForEachFanin(pObj, iFanin, i)
Definition wlc.h:375
char * Wlc_ObjName(Wlc_Ntk_t *p, int iObj)
Definition wlcNtk.c:225
int Wlc_NtkRemapLevels(Wlc_Ntk_t *p, Vec_Int_t *vObjs, int nLevels)
Definition wlcNtk.c:387
@ WLC_OBJ_ARI_MULTI
Definition wlc.h:90
@ WLC_OBJ_BIT_SIGNEXT
Definition wlc.h:70
@ WLC_OBJ_BIT_ZEROPAD
Definition wlc.h:69
@ WLC_OBJ_COMP_MOREEQU
Definition wlc.h:81
@ WLC_OBJ_BUF
Definition wlc.h:52
@ WLC_OBJ_ARI_SQUARE
Definition wlc.h:97
@ WLC_OBJ_BIT_NOT
Definition wlc.h:60
@ WLC_OBJ_CONST
Definition wlc.h:51
@ WLC_OBJ_BIT_SELECT
Definition wlc.h:67
@ WLC_OBJ_MUX
Definition wlc.h:53
@ WLC_OBJ_LOGIC_NOT
Definition wlc.h:71
@ WLC_OBJ_BIT_CONCAT
Definition wlc.h:68
@ WLC_OBJ_ARI_ADD
Definition wlc.h:88
@ WLC_OBJ_COMP_EQU
Definition wlc.h:76
@ WLC_OBJ_FF
Definition wlc.h:50
struct Wlc_Obj_t_ Wlc_Obj_t
BASIC TYPES ///.
Definition wlc.h:118
#define Wlc_NtkForEachCo(p, pCo, i)
Definition wlc.h:368