#include "aig.h"
Go to the source code of this file.
Functions | |
void | Aig_WriteDotAig (Aig_Man_t *pMan, char *pFileName, int fHaig, Vec_Ptr_t *vBold) |
void | Aig_ManShow (Aig_Man_t *pMan, int fHaig, Vec_Ptr_t *vBold) |
Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 329 of file aigShow.c.
00330 { 00331 extern void Abc_ShowFile( char * FileNameDot ); 00332 static Counter = 0; 00333 char FileNameDot[200]; 00334 FILE * pFile; 00335 // create the file name 00336 // Aig_ShowGetFileName( pMan->pName, FileNameDot ); 00337 sprintf( FileNameDot, "temp%02d.dot", Counter++ ); 00338 // check that the file can be opened 00339 if ( (pFile = fopen( FileNameDot, "w" )) == NULL ) 00340 { 00341 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot ); 00342 return; 00343 } 00344 fclose( pFile ); 00345 // generate the file 00346 Aig_WriteDotAig( pMan, FileNameDot, fHaig, vBold ); 00347 // visualize the file 00348 Abc_ShowFile( FileNameDot ); 00349 }
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 [
] DECLARATIONS /// 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 43 of file aigShow.c.
00044 { 00045 FILE * pFile; 00046 Aig_Obj_t * pNode;//, * pTemp, * pPrev; 00047 int LevelMax, Level, i; 00048 00049 if ( Aig_ManNodeNum(pMan) > 200 ) 00050 { 00051 fprintf( stdout, "Cannot visualize AIG with more than 200 nodes.\n" ); 00052 return; 00053 } 00054 if ( (pFile = fopen( pFileName, "w" )) == NULL ) 00055 { 00056 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", pFileName ); 00057 return; 00058 } 00059 00060 // mark the nodes 00061 if ( vBold ) 00062 Vec_PtrForEachEntry( vBold, pNode, i ) 00063 pNode->fMarkB = 1; 00064 00065 // compute levels 00066 // LevelMax = 1 + Aig_ManSetLevels( pMan, fHaig ); 00067 LevelMax = 1 + Aig_ManLevels( pMan ); 00068 Aig_ManForEachPo( pMan, pNode, i ) 00069 pNode->Level = LevelMax; 00070 00071 // write the DOT header 00072 fprintf( pFile, "# %s\n", "AIG structure generated by IVY package" ); 00073 fprintf( pFile, "\n" ); 00074 fprintf( pFile, "digraph AIG {\n" ); 00075 fprintf( pFile, "size = \"7.5,10\";\n" ); 00076 // fprintf( pFile, "ranksep = 0.5;\n" ); 00077 // fprintf( pFile, "nodesep = 0.5;\n" ); 00078 fprintf( pFile, "center = true;\n" ); 00079 // fprintf( pFile, "orientation = landscape;\n" ); 00080 // fprintf( pFile, "edge [fontsize = 10];\n" ); 00081 // fprintf( pFile, "edge [dir = none];\n" ); 00082 fprintf( pFile, "edge [dir = back];\n" ); 00083 fprintf( pFile, "\n" ); 00084 00085 // labels on the left of the picture 00086 fprintf( pFile, "{\n" ); 00087 fprintf( pFile, " node [shape = plaintext];\n" ); 00088 fprintf( pFile, " edge [style = invis];\n" ); 00089 fprintf( pFile, " LevelTitle1 [label=\"\"];\n" ); 00090 fprintf( pFile, " LevelTitle2 [label=\"\"];\n" ); 00091 // generate node names with labels 00092 for ( Level = LevelMax; Level >= 0; Level-- ) 00093 { 00094 // the visible node name 00095 fprintf( pFile, " Level%d", Level ); 00096 fprintf( pFile, " [label = " ); 00097 // label name 00098 fprintf( pFile, "\"" ); 00099 fprintf( pFile, "\"" ); 00100 fprintf( pFile, "];\n" ); 00101 } 00102 00103 // genetate the sequence of visible/invisible nodes to mark levels 00104 fprintf( pFile, " LevelTitle1 -> LevelTitle2 ->" ); 00105 for ( Level = LevelMax; Level >= 0; Level-- ) 00106 { 00107 // the visible node name 00108 fprintf( pFile, " Level%d", Level ); 00109 // the connector 00110 if ( Level != 0 ) 00111 fprintf( pFile, " ->" ); 00112 else 00113 fprintf( pFile, ";" ); 00114 } 00115 fprintf( pFile, "\n" ); 00116 fprintf( pFile, "}" ); 00117 fprintf( pFile, "\n" ); 00118 fprintf( pFile, "\n" ); 00119 00120 // generate title box on top 00121 fprintf( pFile, "{\n" ); 00122 fprintf( pFile, " rank = same;\n" ); 00123 fprintf( pFile, " LevelTitle1;\n" ); 00124 fprintf( pFile, " title1 [shape=plaintext,\n" ); 00125 fprintf( pFile, " fontsize=20,\n" ); 00126 fprintf( pFile, " fontname = \"Times-Roman\",\n" ); 00127 fprintf( pFile, " label=\"" ); 00128 fprintf( pFile, "%s", "AIG structure visualized by ABC" ); 00129 fprintf( pFile, "\\n" ); 00130 fprintf( pFile, "Benchmark \\\"%s\\\". ", "aig" ); 00131 // fprintf( pFile, "Time was %s. ", Extra_TimeStamp() ); 00132 fprintf( pFile, "\"\n" ); 00133 fprintf( pFile, " ];\n" ); 00134 fprintf( pFile, "}" ); 00135 fprintf( pFile, "\n" ); 00136 fprintf( pFile, "\n" ); 00137 00138 // generate statistics box 00139 fprintf( pFile, "{\n" ); 00140 fprintf( pFile, " rank = same;\n" ); 00141 fprintf( pFile, " LevelTitle2;\n" ); 00142 fprintf( pFile, " title2 [shape=plaintext,\n" ); 00143 fprintf( pFile, " fontsize=18,\n" ); 00144 fprintf( pFile, " fontname = \"Times-Roman\",\n" ); 00145 fprintf( pFile, " label=\"" ); 00146 fprintf( pFile, "The set contains %d logic nodes and spans %d levels.", Aig_ManNodeNum(pMan), LevelMax ); 00147 fprintf( pFile, "\\n" ); 00148 fprintf( pFile, "\"\n" ); 00149 fprintf( pFile, " ];\n" ); 00150 fprintf( pFile, "}" ); 00151 fprintf( pFile, "\n" ); 00152 fprintf( pFile, "\n" ); 00153 00154 // generate the COs 00155 fprintf( pFile, "{\n" ); 00156 fprintf( pFile, " rank = same;\n" ); 00157 // the labeling node of this level 00158 fprintf( pFile, " Level%d;\n", LevelMax ); 00159 // generate the CO nodes 00160 Aig_ManForEachPo( pMan, pNode, i ) 00161 { 00162 /* 00163 if ( fHaig || pNode->pEquiv == NULL ) 00164 fprintf( pFile, " Node%d%s [label = \"%d%s\"", pNode->Id, 00165 (Aig_ObjIsLatch(pNode)? "_in":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":"") ); 00166 else 00167 fprintf( pFile, " Node%d%s [label = \"%d%s(%d%s)\"", pNode->Id, 00168 (Aig_ObjIsLatch(pNode)? "_in":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":""), 00169 Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" ); 00170 */ 00171 fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id ); 00172 00173 fprintf( pFile, ", shape = %s", (Aig_ObjIsLatch(pNode)? "box":"invtriangle") ); 00174 fprintf( pFile, ", color = coral, fillcolor = coral" ); 00175 fprintf( pFile, "];\n" ); 00176 } 00177 fprintf( pFile, "}" ); 00178 fprintf( pFile, "\n" ); 00179 fprintf( pFile, "\n" ); 00180 00181 // generate nodes of each rank 00182 for ( Level = LevelMax - 1; Level > 0; Level-- ) 00183 { 00184 fprintf( pFile, "{\n" ); 00185 fprintf( pFile, " rank = same;\n" ); 00186 // the labeling node of this level 00187 fprintf( pFile, " Level%d;\n", Level ); 00188 Aig_ManForEachObj( pMan, pNode, i ) 00189 { 00190 if ( (int)pNode->Level != Level ) 00191 continue; 00192 /* 00193 if ( fHaig || pNode->pEquiv == NULL ) 00194 fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id ); 00195 else 00196 fprintf( pFile, " Node%d [label = \"%d(%d%s)\"", pNode->Id, pNode->Id, 00197 Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" ); 00198 */ 00199 fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id ); 00200 00201 fprintf( pFile, ", shape = ellipse" ); 00202 if ( vBold && pNode->fMarkB ) 00203 fprintf( pFile, ", style = filled" ); 00204 fprintf( pFile, "];\n" ); 00205 } 00206 fprintf( pFile, "}" ); 00207 fprintf( pFile, "\n" ); 00208 fprintf( pFile, "\n" ); 00209 } 00210 00211 // generate the CI nodes 00212 fprintf( pFile, "{\n" ); 00213 fprintf( pFile, " rank = same;\n" ); 00214 // the labeling node of this level 00215 fprintf( pFile, " Level%d;\n", 0 ); 00216 // generate constant node 00217 if ( Aig_ObjRefs(Aig_ManConst1(pMan)) > 0 ) 00218 { 00219 pNode = Aig_ManConst1(pMan); 00220 // check if the costant node is present 00221 fprintf( pFile, " Node%d [label = \"Const1\"", pNode->Id ); 00222 fprintf( pFile, ", shape = ellipse" ); 00223 fprintf( pFile, ", color = coral, fillcolor = coral" ); 00224 fprintf( pFile, "];\n" ); 00225 } 00226 // generate the CI nodes 00227 Aig_ManForEachPi( pMan, pNode, i ) 00228 { 00229 /* 00230 if ( fHaig || pNode->pEquiv == NULL ) 00231 fprintf( pFile, " Node%d%s [label = \"%d%s\"", pNode->Id, 00232 (Aig_ObjIsLatch(pNode)? "_out":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_out":"") ); 00233 else 00234 fprintf( pFile, " Node%d%s [label = \"%d%s(%d%s)\"", pNode->Id, 00235 (Aig_ObjIsLatch(pNode)? "_out":""), pNode->Id, (Aig_ObjIsLatch(pNode)? "_out":""), 00236 Aig_Regular(pNode->pEquiv)->Id, Aig_IsComplement(pNode->pEquiv)? "\'":"" ); 00237 */ 00238 fprintf( pFile, " Node%d [label = \"%d\"", pNode->Id, pNode->Id ); 00239 00240 fprintf( pFile, ", shape = %s", (Aig_ObjIsLatch(pNode)? "box":"triangle") ); 00241 fprintf( pFile, ", color = coral, fillcolor = coral" ); 00242 fprintf( pFile, "];\n" ); 00243 } 00244 fprintf( pFile, "}" ); 00245 fprintf( pFile, "\n" ); 00246 fprintf( pFile, "\n" ); 00247 00248 // generate invisible edges from the square down 00249 fprintf( pFile, "title1 -> title2 [style = invis];\n" ); 00250 Aig_ManForEachPo( pMan, pNode, i ) 00251 fprintf( pFile, "title2 -> Node%d%s [style = invis];\n", pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":"") ); 00252 00253 // generate edges 00254 Aig_ManForEachObj( pMan, pNode, i ) 00255 { 00256 if ( !Aig_ObjIsNode(pNode) && !Aig_ObjIsPo(pNode) && !Aig_ObjIsBuf(pNode) ) 00257 continue; 00258 // generate the edge from this node to the next 00259 fprintf( pFile, "Node%d%s", pNode->Id, (Aig_ObjIsLatch(pNode)? "_in":"") ); 00260 fprintf( pFile, " -> " ); 00261 fprintf( pFile, "Node%d%s", Aig_ObjFaninId0(pNode), (Aig_ObjIsLatch(Aig_ObjFanin0(pNode))? "_out":"") ); 00262 fprintf( pFile, " [" ); 00263 fprintf( pFile, "style = %s", Aig_ObjFaninC0(pNode)? "dotted" : "bold" ); 00264 // if ( Aig_NtkIsSeq(pNode->pMan) && Seq_ObjFaninL0(pNode) > 0 ) 00265 // fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,0) ); 00266 fprintf( pFile, "]" ); 00267 fprintf( pFile, ";\n" ); 00268 if ( !Aig_ObjIsNode(pNode) ) 00269 continue; 00270 // generate the edge from this node to the next 00271 fprintf( pFile, "Node%d", pNode->Id ); 00272 fprintf( pFile, " -> " ); 00273 fprintf( pFile, "Node%d%s", Aig_ObjFaninId1(pNode), (Aig_ObjIsLatch(Aig_ObjFanin1(pNode))? "_out":"") ); 00274 fprintf( pFile, " [" ); 00275 fprintf( pFile, "style = %s", Aig_ObjFaninC1(pNode)? "dotted" : "bold" ); 00276 // if ( Aig_NtkIsSeq(pNode->pMan) && Seq_ObjFaninL1(pNode) > 0 ) 00277 // fprintf( pFile, ", label = \"%s\"", Seq_ObjFaninGetInitPrintable(pNode,1) ); 00278 fprintf( pFile, "]" ); 00279 fprintf( pFile, ";\n" ); 00280 /* 00281 // generate the edges between the equivalent nodes 00282 if ( fHaig && pNode->pEquiv && Aig_ObjRefs(pNode) > 0 ) 00283 { 00284 pPrev = pNode; 00285 for ( pTemp = pNode->pEquiv; pTemp != pNode; pTemp = Aig_Regular(pTemp->pEquiv) ) 00286 { 00287 fprintf( pFile, "Node%d", pPrev->Id ); 00288 fprintf( pFile, " -> " ); 00289 fprintf( pFile, "Node%d", pTemp->Id ); 00290 fprintf( pFile, " [style = %s]", Aig_IsComplement(pTemp->pEquiv)? "dotted" : "bold" ); 00291 fprintf( pFile, ";\n" ); 00292 pPrev = pTemp; 00293 } 00294 // connect the last node with the first 00295 fprintf( pFile, "Node%d", pPrev->Id ); 00296 fprintf( pFile, " -> " ); 00297 fprintf( pFile, "Node%d", pNode->Id ); 00298 fprintf( pFile, " [style = %s]", Aig_IsComplement(pPrev->pEquiv)? "dotted" : "bold" ); 00299 fprintf( pFile, ";\n" ); 00300 } 00301 */ 00302 } 00303 00304 fprintf( pFile, "}" ); 00305 fprintf( pFile, "\n" ); 00306 fprintf( pFile, "\n" ); 00307 fclose( pFile ); 00308 00309 // unmark nodes 00310 if ( vBold ) 00311 Vec_PtrForEachEntry( vBold, pNode, i ) 00312 pNode->fMarkB = 0; 00313 00314 Aig_ManForEachPo( pMan, pNode, i ) 00315 pNode->Level = Aig_ObjFanin0(pNode)->Level; 00316 }