/**Function************************************************************* Synopsis [Transform the logic network into a netlist.] Description [The logic network given to this procedure should have exactly the same structure as the resulting netlist. The COs can only point to CIs if they have identical names. Otherwise, they should have a node between them, even if this node is inverter or buffer.] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Ntk_t * Abc_NtkLogicToNetlist( Abc_Ntk_t * pNtk ) { Abc_Ntk_t * pNtkNew; Abc_Obj_t * pObj, * pNet, * pDriver, * pFanin; int i, k; assert( Abc_NtkIsLogic(pNtk) ); // remove dangling nodes Abc_NtkCleanup( pNtk, 0 ); // make sure the CO names are unique Abc_NtkCheckUniqueCiNames( pNtk ); Abc_NtkCheckUniqueCoNames( pNtk ); Abc_NtkCheckUniqueCioNames( pNtk ); // assert( Abc_NtkLogicHasSimpleCos(pNtk) ); if ( !Abc_NtkLogicHasSimpleCos(pNtk) ) { if ( !Abc_FrameReadFlag("silentmode") ) printf( "Abc_NtkLogicToNetlist() warning: The network is converted to have simple COs.\n" ); Abc_NtkLogicMakeSimpleCos( pNtk, 0 ); } // start the netlist by creating PI/PO/Latch objects pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_NETLIST, pNtk->ntkFunc ); // create the CI nets and remember them in the new CI nodes Abc_NtkForEachCi( pNtk, pObj, i ) { pNet = Abc_NtkFindOrCreateNet( pNtkNew, Abc_ObjName(pObj) ); Abc_ObjAddFanin( pNet, pObj->pCopy ); pObj->pCopy->pCopy = pNet; }
/**Function************************************************************* Synopsis [Returns 1 if the flag is enabled without value or with value 1.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_FrameIsFlagEnabled( char * pFlag ) { char * pValue; // if flag is not defined, it is not enabled pValue = Abc_FrameReadFlag( pFlag ); if ( pValue == NULL ) return 0; // if flag is defined but value is not empty (no parameter) or "1", it is not enabled if ( strcmp(pValue, "") && strcmp(pValue, "1") ) return 0; return 1; }
/**Function************************************************************* Synopsis [Provide an fopen replacement with path lookup] Description [Provide an fopen replacement where the path stored in pathvar MVSIS variable is used to look up the path for name. Returns NULL if file cannot be opened.] SideEffects [] SeeAlso [] ***********************************************************************/ FILE * Io_FileOpen( const char * FileName, const char * PathVar, const char * Mode, int fVerbose ) { char * t = 0, * c = 0, * i; extern char * Abc_FrameReadFlag( char * pFlag ); if ( PathVar == 0 ) { return fopen( FileName, Mode ); } else { if ( c = Abc_FrameReadFlag( (char*)PathVar ) ) { char ActualFileName[4096]; FILE * fp = 0; t = Extra_UtilStrsav( c ); for (i = strtok( t, ":" ); i != 0; i = strtok( 0, ":") ) { #ifdef WIN32 _snprintf ( ActualFileName, 4096, "%s/%s", i, FileName ); #else snprintf ( ActualFileName, 4096, "%s/%s", i, FileName ); #endif if ( ( fp = fopen ( ActualFileName, Mode ) ) ) { if ( fVerbose ) fprintf ( stdout, "Using file %s\n", ActualFileName ); free( t ); return fp; } } free( t ); return 0; } else { return fopen( FileName, Mode ); } } }
/**Function************************************************************* Synopsis [Shows the given DOT file.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ void Abc_ShowFile( char * FileNameDot ) { FILE * pFile; char * FileGeneric; char FileNamePs[200]; char CommandDot[1000]; char * pDotName; char * pDotNameWin = "dot.exe"; char * pDotNameUnix = "dot"; char * pGsNameWin = "gsview32.exe"; char * pGsNameUnix = "gv"; int RetValue; // get DOT names from the resource file if ( Abc_FrameReadFlag("dotwin") ) pDotNameWin = Abc_FrameReadFlag("dotwin"); if ( Abc_FrameReadFlag("dotunix") ) pDotNameUnix = Abc_FrameReadFlag("dotunix"); #ifdef WIN32 pDotName = pDotNameWin; #else pDotName = pDotNameUnix; #endif // check if the input DOT file is okay if ( (pFile = fopen( FileNameDot, "r" )) == NULL ) { fprintf( stdout, "Cannot open the intermediate file \"%s\".\n", FileNameDot ); return; } fclose( pFile ); // create the PostScript file name FileGeneric = Extra_FileNameGeneric( FileNameDot ); sprintf( FileNamePs, "%s.ps", FileGeneric ); free( FileGeneric ); // generate the PostScript file using DOT sprintf( CommandDot, "%s -Tps -o %s %s", pDotName, FileNamePs, FileNameDot ); RetValue = system( CommandDot ); if ( RetValue == -1 ) { fprintf( stdout, "Command \"%s\" did not succeed.\n", CommandDot ); return; } // check that the input PostScript file is okay if ( (pFile = fopen( FileNamePs, "r" )) == NULL ) { fprintf( stdout, "Cannot open intermediate file \"%s\".\n", FileNamePs ); return; } fclose( pFile ); // get GSVIEW names from the resource file if ( Abc_FrameReadFlag("gsviewwin") ) pGsNameWin = Abc_FrameReadFlag("gsviewwin"); if ( Abc_FrameReadFlag("gsviewunix") ) pGsNameUnix = Abc_FrameReadFlag("gsviewunix"); // spawn the viewer #ifdef WIN32 _unlink( FileNameDot ); if ( _spawnl( _P_NOWAIT, pGsNameWin, pGsNameWin, FileNamePs, NULL ) == -1 ) if ( _spawnl( _P_NOWAIT, "C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe", "C:\\Program Files\\Ghostgum\\gsview\\gsview32.exe", FileNamePs, NULL ) == -1 ) { fprintf( stdout, "Cannot find \"%s\".\n", pGsNameWin ); return; } #else { char CommandPs[1000]; unlink( FileNameDot ); sprintf( CommandPs, "%s %s &", pGsNameUnix, FileNamePs ); if ( system( CommandPs ) == -1 ) { fprintf( stdout, "Cannot execute \"%s\".\n", CommandPs ); return; } } #endif }