00001
00021 #ifdef WIN32
00022 #include <process.h>
00023 #endif
00024
00025 #include "abc.h"
00026 #include "main.h"
00027 #include "io.h"
00028
00032
00033 extern void Abc_ShowFile( char * FileNameDot );
00034 static void Abc_ShowGetFileName( char * pName, char * pBuffer );
00035
00039
00051 void Abc_NodeShowBdd( Abc_Obj_t * pNode )
00052 {
00053 FILE * pFile;
00054 Vec_Ptr_t * vNamesIn;
00055 char FileNameDot[200];
00056 char * pNameOut;
00057
00058 assert( Abc_NtkIsBddLogic(pNode->pNtk) );
00059
00060 Abc_ShowGetFileName( Abc_ObjName(pNode), FileNameDot );
00061
00062 if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
00063 {
00064 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
00065 return;
00066 }
00067
00068
00069 vNamesIn = Abc_NodeGetFaninNames( pNode );
00070 pNameOut = Abc_ObjName(pNode);
00071 Cudd_DumpDot( pNode->pNtk->pManFunc, 1, (DdNode **)&pNode->pData, (char **)vNamesIn->pArray, &pNameOut, pFile );
00072 Abc_NodeFreeNames( vNamesIn );
00073 Abc_NtkCleanCopy( pNode->pNtk );
00074 fclose( pFile );
00075
00076
00077 Abc_ShowFile( FileNameDot );
00078 }
00079
00091 void Abc_NodeShowCut( Abc_Obj_t * pNode, int nNodeSizeMax, int nConeSizeMax )
00092 {
00093 FILE * pFile;
00094 char FileNameDot[200];
00095 Abc_ManCut_t * p;
00096 Vec_Ptr_t * vCutSmall;
00097 Vec_Ptr_t * vCutLarge;
00098 Vec_Ptr_t * vInside;
00099 Vec_Ptr_t * vNodesTfo;
00100 Abc_Obj_t * pTemp;
00101 int i;
00102
00103 assert( Abc_NtkIsStrash(pNode->pNtk) );
00104
00105
00106 p = Abc_NtkManCutStart( nNodeSizeMax, nConeSizeMax, 2, ABC_INFINITY );
00107
00108 vCutSmall = Abc_NodeFindCut( p, pNode, 1 );
00109
00110 vCutLarge = Abc_NtkManCutReadCutLarge( p );
00111
00112 vInside = Abc_NtkManCutReadVisited( p );
00113
00114 Abc_NodeConeCollect( &pNode, 1, vCutLarge, vInside, 1 );
00115
00116
00117 vNodesTfo = Abc_NodeCollectTfoCands( p, pNode, vCutSmall, ABC_INFINITY );
00118 Vec_PtrForEachEntry( vNodesTfo, pTemp, i )
00119 Vec_PtrPushUnique( vInside, pTemp );
00120
00121
00122 Abc_ShowGetFileName( Abc_ObjName(pNode), FileNameDot );
00123
00124 if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
00125 {
00126 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
00127 return;
00128 }
00129
00130 Vec_PtrPush( vCutSmall, pNode );
00131
00132 Io_WriteDotNtk( pNode->pNtk, vInside, vCutSmall, FileNameDot, 0, 0 );
00133
00134 Abc_NtkManCutStop( p );
00135
00136
00137 Abc_ShowFile( FileNameDot );
00138 }
00139
00151 void Abc_NtkShow( Abc_Ntk_t * pNtk, int fGateNames, int fSeq, int fUseReverse )
00152 {
00153 FILE * pFile;
00154 Abc_Obj_t * pNode;
00155 Vec_Ptr_t * vNodes;
00156 char FileNameDot[200];
00157 int i;
00158
00159 assert( Abc_NtkIsStrash(pNtk) || Abc_NtkIsLogic(pNtk) );
00160 if ( Abc_NtkIsStrash(pNtk) && Abc_NtkGetChoiceNum(pNtk) )
00161 {
00162 printf( "Temporarily visualization of AIGs with choice nodes is disabled.\n" );
00163 return;
00164 }
00165
00166 if ( Abc_NtkIsLogic(pNtk) )
00167 Abc_NtkToSop( pNtk, 0 );
00168
00169 Abc_ShowGetFileName( pNtk->pName, FileNameDot );
00170
00171 if ( (pFile = fopen( FileNameDot, "w" )) == NULL )
00172 {
00173 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
00174 return;
00175 }
00176 fclose( pFile );
00177
00178
00179 vNodes = Vec_PtrAlloc( 100 );
00180 Abc_NtkForEachObj( pNtk, pNode, i )
00181 Vec_PtrPush( vNodes, pNode );
00182
00183 if ( fSeq )
00184 Io_WriteDotSeq( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse );
00185 else
00186 Io_WriteDotNtk( pNtk, vNodes, NULL, FileNameDot, fGateNames, fUseReverse );
00187 Vec_PtrFree( vNodes );
00188
00189
00190 Abc_ShowFile( FileNameDot );
00191 }
00192
00193
00205 void Abc_ShowFile( char * FileNameDot )
00206 {
00207 FILE * pFile;
00208 char * FileGeneric;
00209 char FileNamePs[200];
00210 char CommandDot[1000];
00211 char * pDotName;
00212 char * pDotNameWin = "dot.exe";
00213 char * pDotNameUnix = "dot";
00214 char * pGsNameWin = "gsview32.exe";
00215 char * pGsNameUnix = "gv";
00216 int RetValue;
00217
00218
00219 if ( Abc_FrameReadFlag("dotwin") )
00220 pDotNameWin = Abc_FrameReadFlag("dotwin");
00221 if ( Abc_FrameReadFlag("dotunix") )
00222 pDotNameUnix = Abc_FrameReadFlag("dotunix");
00223
00224 #ifdef WIN32
00225 pDotName = pDotNameWin;
00226 #else
00227 pDotName = pDotNameUnix;
00228 #endif
00229
00230
00231 if ( (pFile = fopen( FileNameDot, "r" )) == NULL )
00232 {
00233 fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot );
00234 return;
00235 }
00236 fclose( pFile );
00237
00238
00239 FileGeneric = Extra_FileNameGeneric( FileNameDot );
00240 sprintf( FileNamePs, "%s.ps", FileGeneric );
00241 free( FileGeneric );
00242
00243
00244 sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot );
00245 RetValue = system( CommandDot );
00246 if ( RetValue == -1 )
00247 {
00248 fprintf( stdout, "Command \"%s\" did not succeed.\n", CommandDot );
00249 return;
00250 }
00251
00252 if ( (pFile = fopen( FileNamePs, "r" )) == NULL )
00253 {
00254 fprintf( stdout, "Cannot open intermediate file \"%s\".\n", FileNamePs );
00255 return;
00256 }
00257 fclose( pFile );
00258
00259
00260
00261 if ( Abc_FrameReadFlag("gsviewwin") )
00262 pGsNameWin = Abc_FrameReadFlag("gsviewwin");
00263 if ( Abc_FrameReadFlag("gsviewunix") )
00264 pGsNameUnix = Abc_FrameReadFlag("gsviewunix");
00265
00266
00267 #ifdef WIN32
00268 _unlink( FileNameDot );
00269 if ( _spawnl( _P_NOWAIT, pGsNameWin, pGsNameWin, FileNamePs, NULL ) == -1 )
00270 if ( _spawnl( _P_NOWAIT, "C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe",
00271 "C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe", FileNamePs, NULL ) == -1 )
00272 {
00273 fprintf( stdout, "Cannot find \"%s\".\n", pGsNameWin );
00274 return;
00275 }
00276 #else
00277 {
00278 char CommandPs[1000];
00279 unlink( FileNameDot );
00280 sprintf( CommandPs, "%s %s &", pGsNameUnix, FileNamePs );
00281 if ( system( CommandPs ) == -1 )
00282 {
00283 fprintf( stdout, "Cannot execute \"%s\".\n", CommandPs );
00284 return;
00285 }
00286 }
00287 #endif
00288 }
00289
00301 void Abc_ShowGetFileName( char * pName, char * pBuffer )
00302 {
00303 char * pCur;
00304
00305 sprintf( pBuffer, "%s.dot", pName );
00306
00307 for ( pCur = pBuffer; *pCur; pCur++ )
00308 if ( !((*pCur >= '0' && *pCur <= '9') || (*pCur >= 'a' && *pCur <= 'z') ||
00309 (*pCur >= 'A' && *pCur <= 'Z') || (*pCur == '.')) )
00310 *pCur = '_';
00311 }
00312
00313
00317
00318