/**Function************************************************************* Synopsis [Returns the file type.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Io_FileType_t Io_ReadFileType( char * pFileName ) { char * pExt; if ( pFileName == NULL ) return IO_FILE_NONE; pExt = Extra_FileNameExtension( pFileName ); if ( pExt == NULL ) return IO_FILE_NONE; if ( !strcmp( pExt, "aig" ) ) return IO_FILE_AIGER; if ( !strcmp( pExt, "baf" ) ) return IO_FILE_BAF; if ( !strcmp( pExt, "blif" ) ) return IO_FILE_BLIF; if ( !strcmp( pExt, "bench" ) ) return IO_FILE_BENCH; if ( !strcmp( pExt, "cnf" ) ) return IO_FILE_CNF; if ( !strcmp( pExt, "dot" ) ) return IO_FILE_DOT; if ( !strcmp( pExt, "edif" ) ) return IO_FILE_EDIF; if ( !strcmp( pExt, "eqn" ) ) return IO_FILE_EQN; if ( !strcmp( pExt, "gml" ) ) return IO_FILE_GML; if ( !strcmp( pExt, "list" ) ) return IO_FILE_LIST; if ( !strcmp( pExt, "mv" ) ) return IO_FILE_BLIFMV; if ( !strcmp( pExt, "pla" ) ) return IO_FILE_PLA; if ( !strcmp( pExt, "v" ) ) return IO_FILE_VERILOG; return IO_FILE_UNKNOWN; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandCec( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc), * pTemp; Gia_Man_t * pFirst, * pSecond, * pMiter; Cec_ParCec_t ParsCec, * pPars = &ParsCec; char * pFileName, * pStr, ** pArgvNew; int c, nArgcNew, fDumpMiter = 0; FILE * pFile; Cec_ManCecSetDefaultParams( pPars ); Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': pPars->fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandCec(): There is no current design.\n" ); return 0; } pArgvNew = argv + globalUtilOptind; nArgcNew = argc - globalUtilOptind; if ( nArgcNew != 1 ) { if ( p->pSpec == NULL ) { Abc_Print( -1, "File name is not given on the command line.\n" ); return 1; } pFileName = p->pSpec; } else pFileName = pArgvNew[0]; // fix the wrong symbol for ( pStr = pFileName; *pStr; pStr++ ) if ( *pStr == '>' ) *pStr = '\\'; if ( (pFile = fopen( pFileName, "r" )) == NULL ) { Abc_Print( -1, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", NULL, NULL, NULL )) ) Abc_Print( 1, "Did you mean \"%s\"?", pFileName ); Abc_Print( 1, "\n" ); return 1; } fclose( pFile ); // extract AIG from the current design pFirst = Cba_ManBlast( p, 0, 0, 0 ); if ( pFirst == NULL ) { Abc_Print( -1, "Extracting AIG from the current design has failed.\n" ); return 0; } // extract AIG from the second design if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) pTemp = Cba_ManReadBlif( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) pTemp = Cba_ManReadVerilog( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) pTemp = Cba_ManReadCba( pFileName ); else assert( 0 ); pSecond = Cba_ManBlast( pTemp, 0, 0, 0 ); Cba_ManFree( pTemp ); if ( pSecond == NULL ) { Gia_ManStop( pFirst ); Abc_Print( -1, "Extracting AIG from the original design has failed.\n" ); return 0; } // compute the miter pMiter = Gia_ManMiter( pFirst, pSecond, 0, 1, 0, 0, pPars->fVerbose ); if ( pMiter ) { if ( fDumpMiter ) { Abc_Print( 0, "The verification miter is written into file \"%s\".\n", "cec_miter.aig" ); Gia_AigerWrite( pMiter, "cec_miter.aig", 0, 0 ); } pAbc->Status = Cec_ManVerify( pMiter, pPars ); //Abc_FrameReplaceCex( pAbc, &pAbc->pGia->pCexComb ); Gia_ManStop( pMiter ); } Gia_ManStop( pFirst ); Gia_ManStop( pSecond ); return 0; usage: Abc_Print( -2, "usage: @cec [-vh]\n" ); Abc_Print( -2, "\t combinational equivalence checking\n" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandWrite( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); char * pFileName = NULL; int fInclineCats = 0; int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "cvh" ) ) != EOF ) { switch ( c ) { case 'c': fInclineCats ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandWrite(): There is no current design.\n" ); return 0; } if ( argc == globalUtilOptind + 1 ) pFileName = argv[globalUtilOptind]; else if ( argc == globalUtilOptind && p ) { pFileName = Extra_FileNameGenericAppend( Cba_ManSpec(p) ? Cba_ManSpec(p) : Cba_ManName(p), "_out.v" ); printf( "Generated output file name \"%s\".\n", pFileName ); } else { printf( "Output file name should be given on the command line.\n" ); return 0; } // perform writing if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) Cba_ManWriteBlif( pFileName, p ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) Cba_ManWriteVerilog( pFileName, p, fInclineCats ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) Cba_ManWriteCba( pFileName, p ); else { printf( "Unrecognized output file extension.\n" ); return 0; } return 0; usage: Abc_Print( -2, "usage: @write [-cvh]\n" ); Abc_Print( -2, "\t writes the design into a file in BLIF or Verilog\n" ); Abc_Print( -2, "\t-c : toggle inlining input concatenations [default = %s]\n", fInclineCats? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandRead( Abc_Frame_t * pAbc, int argc, char ** argv ) { FILE * pFile; Cba_Man_t * p = NULL; char * pFileName = NULL; int c, fTest = 0, fDfs = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "tdvh" ) ) != EOF ) { switch ( c ) { case 't': fTest ^= 1; break; case 'd': fDfs ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { printf( "Cba_CommandRead(): Input file name should be given on the command line.\n" ); return 0; } // get the file name pFileName = argv[globalUtilOptind]; if ( (pFile = fopen( pFileName, "r" )) == NULL ) { Abc_Print( 1, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".v", ".blif", ".smt", ".cba", NULL )) ) Abc_Print( 1, "Did you mean \"%s\"?", pFileName ); Abc_Print( 1, "\n" ); return 0; } fclose( pFile ); if ( fTest ) { if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) Prs_ManReadBlifTest( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) Prs_ManReadVerilogTest( pFileName ); else { printf( "Unrecognized input file extension.\n" ); return 0; } return 0; } if ( !strcmp( Extra_FileNameExtension(pFileName), "blif" ) ) p = Cba_ManReadBlif( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "v" ) ) p = Cba_ManReadVerilog( pFileName ); else if ( !strcmp( Extra_FileNameExtension(pFileName), "cba" ) ) p = Cba_ManReadCba( pFileName ); else { printf( "Unrecognized input file extension.\n" ); return 0; } if ( fDfs ) { Cba_Man_t * pTemp; p = Cba_ManDup( pTemp = p, Cba_NtkCollectDfs ); Cba_ManFree( pTemp ); } Cba_AbcUpdateMan( pAbc, p ); return 0; usage: Abc_Print( -2, "usage: @read [-tdvh] <file_name>\n" ); Abc_Print( -2, "\t reads hierarchical design\n" ); Abc_Print( -2, "\t-t : toggle testing the parser [default = %s]\n", fTest? "yes": "no" ); Abc_Print( -2, "\t-d : toggle computing DFS ordering [default = %s]\n", fDfs? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing verbose information [default = %s]\n", fVerbose? "yes": "no" ); Abc_Print( -2, "\t-h : print the command usage\n"); return 1; }
ABC_NAMESPACE_IMPL_START //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// /**Function************************************************************* Synopsis [Returns the file type.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Io_FileType_t Io_ReadFileType( char * pFileName ) { char * pExt; if ( pFileName == NULL ) return IO_FILE_NONE; pExt = Extra_FileNameExtension( pFileName ); if ( pExt == NULL ) return IO_FILE_NONE; if ( !strcmp( pExt, "aig" ) ) return IO_FILE_AIGER; if ( !strcmp( pExt, "baf" ) ) return IO_FILE_BAF; if ( !strcmp( pExt, "bblif" ) ) return IO_FILE_BBLIF; if ( !strcmp( pExt, "blif" ) ) return IO_FILE_BLIF; if ( !strcmp( pExt, "bench" ) ) return IO_FILE_BENCH; if ( !strcmp( pExt, "cnf" ) ) return IO_FILE_CNF; if ( !strcmp( pExt, "dot" ) ) return IO_FILE_DOT; if ( !strcmp( pExt, "edif" ) ) return IO_FILE_EDIF; if ( !strcmp( pExt, "eqn" ) ) return IO_FILE_EQN; if ( !strcmp( pExt, "gml" ) ) return IO_FILE_GML; if ( !strcmp( pExt, "list" ) ) return IO_FILE_LIST; if ( !strcmp( pExt, "mv" ) ) return IO_FILE_BLIFMV; if ( !strcmp( pExt, "pla" ) ) return IO_FILE_PLA; if ( !strcmp( pExt, "smv" ) ) return IO_FILE_SMV; if ( !strcmp( pExt, "v" ) ) return IO_FILE_VERILOG; return IO_FILE_UNKNOWN; }