/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandTest(): There is no current design.\n" ); return 0; } return 0; usage: Abc_Print( -2, "usage: @test [-vh]\n" ); Abc_Print( -2, "\t experiments with word-level networks\n" ); 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_CommandClp( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc); int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "vh" ) ) != EOF ) { switch ( c ) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" ); return 0; } pNew = Cba_ManCollapse( p ); Cba_AbcUpdateMan( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: @clp [-vh]\n" ); Abc_Print( -2, "\t collapses the current hierarchical design\n" ); 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 Mio_CommandReadProfile( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile, * pOut, * pErr; Mio_Library_t * pLib; char * pFileName; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "h")) != EOF ) { switch (c) { case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { goto usage; } pLib = (Mio_Library_t *)Abc_FrameReadLibGen(); if ( pLib == NULL ) { fprintf( pErr, "There is no Genlib library entered.\n" ); return 1; } // get the input file name pFileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".profile", NULL, NULL, NULL, NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", pFileName ); fprintf( pErr, "\n" ); return 1; } // set the new network Mio_LibraryReadProfile( pFile, pLib ); fclose( pFile ); return 0; usage: fprintf( pErr, "usage: read_profile [-h] <file>\n"); fprintf( pErr, "\t read a gate profile from a profile file\n" ); fprintf( pErr, "\t-h : enable verbose output\n"); fprintf( pErr, "\t<file> : file name to read the profile\n"); return 1; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Super_CommandSupergatesAnd( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr; int nVarsMax, nLevels; int fVerbose; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults nVarsMax = 4; nLevels = 3; fVerbose = 0; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "ilvh")) != EOF ) { switch (c) { case 'i': nVarsMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nVarsMax < 0 ) goto usage; break; case 'l': nLevels = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nLevels < 0 ) goto usage; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } Super2_Precompute( nVarsMax, nLevels, fVerbose ); return 0; usage: fprintf( pErr, "usage: super2 [-i num] [-l num] [-vh]\n"); fprintf( pErr, "\t precomputes the supergates composed of AND2s and INVs\n" ); fprintf( pErr, "\t-i num : the max number of inputs to the supergate [default = %d]\n", nVarsMax ); fprintf( pErr, "\t-l num : the max number of logic levels of gates [default = %d]\n", nLevels ); fprintf( pErr, "\t-v : enable verbose output\n"); fprintf( pErr, "\t-h : print the help message\n"); return 1; /* error exit */ }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandGet( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * pNew = NULL, * p = Cba_AbcGetMan(pAbc); int c, fMapped = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "mvh" ) ) != EOF ) { switch ( c ) { case 'm': fMapped ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current design.\n" ); return 0; } if ( fMapped ) { if ( pAbc->pNtkCur == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current mapped design.\n" ); return 0; } pNew = Cba_ManInsertAbc( p, pAbc->pNtkCur ); } else { if ( pAbc->pGia == NULL ) { Abc_Print( 1, "Cba_CommandGet(): There is no current AIG.\n" ); return 0; } pNew = Cba_ManInsertGia( p, pAbc->pGia ); } Cba_AbcUpdateMan( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: @get [-mvh]\n" ); Abc_Print( -2, "\t extracts AIG or mapped network into the hierarchical design\n" ); Abc_Print( -2, "\t-m : toggle using mapped network from main-space [default = %s]\n", fMapped? "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 [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandWriteProfile( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr, * pFile; char * pFileName; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "h")) != EOF ) { switch (c) { case 'h': goto usage; break; default: goto usage; } } if ( Abc_FrameReadLibGen() == NULL ) { printf( "Library is not available.\n" ); return 1; } if ( argc != globalUtilOptind + 1 ) { printf( "The file name is not given.\n" ); return 1; } pFileName = argv[globalUtilOptind]; pFile = fopen( pFileName, "w" ); if ( pFile == NULL ) { printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName ); return 1; } Mio_LibraryWriteProfile( pFile, (Mio_Library_t *)Abc_FrameReadLibGen() ); fclose( pFile ); printf( "The current profile is written into file \"%s\".\n", pFileName ); return 0; usage: fprintf( pErr, "\nusage: write_profile [-h] <file>\n"); fprintf( pErr, "\t writes the current profile into a file\n" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t<file> : file name to write the profile\n"); return 1; }
/**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandPrintGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr; int fShort = 0; int fSelected = 0; int fVerbose = 0; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "savh")) != EOF ) { switch (c) { case 's': fShort ^= 1; break; case 'a': fSelected ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( Abc_FrameReadLibGen() == NULL ) { printf( "Library is not available.\n" ); return 1; } Mio_WriteLibrary( stdout, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, fShort, fSelected ); return 0; usage: fprintf( pErr, "\nusage: print_genlib [-savh]\n"); fprintf( pErr, "\t print the current genlib library\n" ); fprintf( pErr, "\t-s : toggles writing short form [default = %s]\n", fShort? "yes" : "no" ); fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandPut( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); Gia_Man_t * pGia = NULL; int c, fBarBufs = 1, fSeq = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "bsvh" ) ) != EOF ) { switch ( c ) { case 'b': fBarBufs ^= 1; break; case 's': fSeq ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandPut(): There is no current design.\n" ); return 0; } pGia = Cba_ManBlast( p, fBarBufs, fSeq, fVerbose ); if ( pGia == NULL ) { Abc_Print( 1, "Cba_CommandPut(): Conversion to AIG has failed.\n" ); return 0; } Abc_FrameUpdateGia( pAbc, pGia ); return 0; usage: Abc_Print( -2, "usage: @put [-bsvh]\n" ); Abc_Print( -2, "\t extracts AIG from the hierarchical design\n" ); Abc_Print( -2, "\t-b : toggle using barrier buffers [default = %s]\n", fBarBufs? "yes": "no" ); Abc_Print( -2, "\t-s : toggle blasting sequential elements [default = %s]\n", fSeq? "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 [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandPrintProfile( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr; int fShort = 0; int fSelected = 0; int fVerbose = 0; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "savh")) != EOF ) { switch (c) { case 's': fShort ^= 1; break; case 'a': fSelected ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( Abc_FrameReadLibGen() == NULL ) { printf( "Library is not available.\n" ); return 1; } Mio_LibraryWriteProfile( stdout, (Mio_Library_t *)Abc_FrameReadLibGen() ); return 0; usage: fprintf( pErr, "\nusage: print_profile [-h]\n"); fprintf( pErr, "\t print the current gate profile\n" ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; }
/**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandPrintLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr; Abc_Ntk_t * pNet; int fVerbose; int c; pNet = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fVerbose = 1; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) { switch (c) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind ) { goto usage; } // set the new network Mio_WriteLibrary( stdout, Abc_FrameReadLibGen(), 0 ); return 0; usage: fprintf( pErr, "\nusage: print_library [-vh]\n"); fprintf( pErr, "\t print the current genlib library\n" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; /* error exit */ }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandBlast( Abc_Frame_t * pAbc, int argc, char ** argv ) { Gia_Man_t * pNew = NULL; Cba_Man_t * p = Cba_AbcGetMan(pAbc); int c, fSeq = 0, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "svh" ) ) != EOF ) { switch ( c ) { case 's': fSeq ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandBlast(): There is no current design.\n" ); return 0; } pNew = Cba_ManBlast( p, 0, fSeq, fVerbose ); if ( pNew == NULL ) { Abc_Print( 1, "Cba_CommandBlast(): Bit-blasting has failed.\n" ); return 0; } Abc_FrameUpdateGia( pAbc, pNew ); return 0; usage: Abc_Print( -2, "usage: %%blast [-svh]\n" ); Abc_Print( -2, "\t performs bit-blasting of the word-level design\n" ); Abc_Print( -2, "\t-s : toggle blasting sequential elements [default = %s]\n", fSeq? "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 Map_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; Map_SuperLib_t * pLib; Abc_Ntk_t * pNet; char * FileName, * ExcludeFile; int fVerbose; int fAlgorithm; int c; pNet = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fVerbose = 1; fAlgorithm = 1; ExcludeFile = 0; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "eovh")) != EOF ) { switch (c) { case 'e': ExcludeFile = argv[globalUtilOptind]; if ( ExcludeFile == 0 ) goto usage; globalUtilOptind++; break; case 'o': fAlgorithm ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { goto usage; } // get the input file name FileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) // if ( (pFile = fopen( FileName, "r" )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); if (( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); // set the new network pLib = Map_SuperLibCreate( FileName, ExcludeFile, fAlgorithm, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading supergate library has failed.\n" ); goto usage; } // replace the current library // Map_SuperLibFree( s_pSuperLib ); // s_pSuperLib = pLib; Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() ); Abc_FrameSetLibSuper( pLib ); // replace the current genlib library // if ( s_pLib ) Mio_LibraryDelete( s_pLib ); // s_pLib = s_pSuperLib->pGenlib; Mio_LibraryDelete( (Mio_Library_t *)Abc_FrameReadLibGen() ); Abc_FrameSetLibGen( (Mio_Library_t *)pLib->pGenlib ); return 0; usage: fprintf( pErr, "\nusage: read_super [-ovh]\n"); fprintf( pErr, "\t read the supergate library from the file\n" ); fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" ); fprintf( pErr, "\t-o : toggles the use of old file format [default = %s]\n", (fAlgorithm? "new" : "old") ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the command usage\n"); return 1; /* error exit */ }
/**Function******************************************************************** Synopsis [] Description [] SideEffects [] SeeAlso [] ******************************************************************************/ int Cba_CommandPs( Abc_Frame_t * pAbc, int argc, char ** argv ) { Cba_Man_t * p = Cba_AbcGetMan(pAbc); int nModules = 0; int fShowMulti = 0; int fShowAdder = 0; int fDistrib = 0; int c, fVerbose = 0; Extra_UtilGetoptReset(); while ( ( c = Extra_UtilGetopt( argc, argv, "Mmadvh" ) ) != EOF ) { switch ( c ) { case 'M': if ( globalUtilOptind >= argc ) { Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" ); goto usage; } nModules = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nModules < 0 ) goto usage; break; case 'm': fShowMulti ^= 1; break; case 'a': fShowAdder ^= 1; break; case 'd': fDistrib ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; default: goto usage; } } if ( p == NULL ) { Abc_Print( 1, "Cba_CommandPs(): There is no current design.\n" ); return 0; } if ( nModules ) { Cba_ManPrintStats( p, nModules, fVerbose ); return 0; } Cba_NtkPrintStatsFull( Cba_ManRoot(p), fDistrib, fVerbose ); if ( fShowMulti ) Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_MUL ); if ( fShowAdder ) Cba_NtkPrintNodes( Cba_ManRoot(p), CBA_BOX_ADD ); return 0; usage: Abc_Print( -2, "usage: @ps [-M num] [-madvh]\n" ); Abc_Print( -2, "\t prints statistics\n" ); Abc_Print( -2, "\t-M num : the number of first modules to report [default = %d]\n", nModules ); Abc_Print( -2, "\t-m : toggle printing multipliers [default = %s]\n", fShowMulti? "yes": "no" ); Abc_Print( -2, "\t-a : toggle printing adders [default = %s]\n", fShowAdder? "yes": "no" ); Abc_Print( -2, "\t-d : toggle printing distrubition [default = %s]\n", fDistrib? "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_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; }
/**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Fpga_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; Fpga_LutLib_t * pLib; Abc_Ntk_t * pNet; char * FileName; int fVerbose; int c; pNet = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fVerbose = 1; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) { switch (c) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { goto usage; } // get the input file name FileName = argv[globalUtilOptind]; if ( (pFile = fopen( FileName, "r" )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); // set the new network pLib = Fpga_LutLibRead( FileName, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading LUT library has failed.\n" ); goto usage; } // replace the current library Fpga_LutLibFree( (Fpga_LutLib_t *)Abc_FrameReadLibLut() ); Abc_FrameSetLibLut( pLib ); return 0; usage: fprintf( pErr, "\nusage: read_lut [-vh]\n"); fprintf( pErr, "\t read the LUT library from the file\n" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t \n"); fprintf( pErr, "\t File format for a LUT library:\n"); fprintf( pErr, "\t (the default library is shown)\n"); fprintf( pErr, "\t \n"); fprintf( pErr, "\t # The area/delay of k-variable LUTs:\n"); fprintf( pErr, "\t # k area delay\n"); fprintf( pErr, "\t 1 1 1\n"); fprintf( pErr, "\t 2 2 2\n"); fprintf( pErr, "\t 3 4 3\n"); fprintf( pErr, "\t 4 8 4\n"); fprintf( pErr, "\t 5 16 5\n"); fprintf( pErr, "\t 6 32 6\n"); return 1; /* error exit */ }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandReadLiberty( Abc_Frame_t * pAbc, int argc, char **argv ) { int fUseFileInterface = 0; char Command[1000]; FILE * pFile; FILE * pOut, * pErr; char * pFileName; int fVerbose; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fVerbose = 0; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) { switch (c) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) goto usage; // get the input file name pFileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".scl", ".g", NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", pFileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); if ( fUseFileInterface ) { if ( !Amap_LibertyParse( pFileName, fVerbose ) ) return 0; assert( strlen(pFileName) < 900 ); sprintf( Command, "read_genlib %s", Extra_FileNameGenericAppend(pFileName, ".genlib") ); Cmd_CommandExecute( pAbc, Command ); } else { Vec_Str_t * vStr, * vStr2; int RetValue; vStr = Amap_LibertyParseStr( pFileName, fVerbose ); if ( vStr == NULL ) return 0; vStr2 = Vec_StrDup(vStr); RetValue = Mio_UpdateGenlib2( vStr, vStr2, pFileName, fVerbose ); Vec_StrFree( vStr ); Vec_StrFree( vStr2 ); if ( !RetValue ) printf( "Reading library has filed.\n" ); } return 0; usage: fprintf( pErr, "usage: read_liberty [-vh]\n"); fprintf( pErr, "\t read standard cell library in Liberty format\n" ); fprintf( pErr, "\t (if the library contains more than one gate\n" ); fprintf( pErr, "\t with the same Boolean function, only the gate\n" ); fprintf( pErr, "\t with the smallest area will be used)\n" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : enable verbose output\n"); return 1; }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Super_CommandSupergates( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; Mio_Library_t * pLib; char * FileName, * ExcludeFile; float DelayLimit; float AreaLimit; int fSkipInvs; int fWriteOldFormat; int nVarsMax, nLevels, TimeLimit; int fVerbose; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults nVarsMax = 5; nLevels = 3; DelayLimit = 3.5; AreaLimit = 9; TimeLimit = 10; fSkipInvs = 1; fVerbose = 0; fWriteOldFormat = 0; ExcludeFile = 0; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "eiltdasovh")) != EOF ) { switch (c) { case 'e': ExcludeFile = argv[globalUtilOptind]; if ( ExcludeFile == 0 ) goto usage; globalUtilOptind++; break; case 'i': nVarsMax = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nVarsMax < 0 ) goto usage; break; case 'l': nLevels = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( nLevels < 0 ) goto usage; break; case 't': TimeLimit = atoi(argv[globalUtilOptind]); globalUtilOptind++; if ( TimeLimit < 0 ) goto usage; break; case 'd': DelayLimit = (float)atof(argv[globalUtilOptind]); globalUtilOptind++; if ( DelayLimit <= 0.0 ) goto usage; break; case 'a': AreaLimit = (float)atof(argv[globalUtilOptind]); globalUtilOptind++; if ( AreaLimit <= 0.0 ) goto usage; break; case 's': fSkipInvs ^= 1; break; case 'o': fWriteOldFormat ^= 1; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { fprintf( pErr, "The GENLIB library file should be given on the command line.\n" ); goto usage; } if ( nVarsMax < 2 || nVarsMax > 6 ) { fprintf( pErr, "The max number of variables (%d) should be more than 1 and less than 7.\n", nVarsMax ); goto usage; } // get the input file name FileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) // if ( (pFile = fopen( FileName, "r" )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); if (( FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL ) )) fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); // set the new network pLib = Mio_LibraryRead( FileName, ExcludeFile, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading library has failed.\n" ); goto usage; } // compute the gates Super_Precompute( pLib, nVarsMax, nLevels, DelayLimit, AreaLimit, TimeLimit, fSkipInvs, fWriteOldFormat, fVerbose ); // delete the library Mio_LibraryDelete( pLib ); return 0; usage: fprintf( pErr, "usage: super [-i num] [-l num] [-d float] [-a float] [-t num] [-sovh] <genlib_file>\n"); fprintf( pErr, "\t precomputes the supergates for the given GENLIB library\n" ); fprintf( pErr, "\t-i num : the max number of supergate inputs [default = %d]\n", nVarsMax ); fprintf( pErr, "\t-l num : the max number of levels of gates [default = %d]\n", nLevels ); fprintf( pErr, "\t-d float : the max delay of the supergates [default = %.2f]\n", DelayLimit ); fprintf( pErr, "\t-a float : the max area of the supergates [default = %.2f]\n", AreaLimit ); fprintf( pErr, "\t-t num : the approximate runtime limit in seconds [default = %d]\n", TimeLimit ); fprintf( pErr, "\t-s : toggle the use of inverters at the inputs [default = %s]\n", (fSkipInvs? "no": "yes") ); fprintf( pErr, "\t-o : toggle dumping the supergate library in old format [default = %s]\n", (fWriteOldFormat? "yes": "no") ); fprintf( pErr, "\t-e file : file contains list of genlib gates to exclude\n" ); fprintf( pErr, "\t-v : enable verbose output [default = %s]\n", (fVerbose? "yes" : "no") ); fprintf( pErr, "\t-h : print the help message\n"); fprintf( pErr, "\n"); fprintf( pErr, "\tHere is a piece of advice on precomputing supergate libraries:\n"); fprintf( pErr, "\t\n"); fprintf( pErr, "\tStart with the number of inputs equal to 5 (-i 5), the number of \n"); fprintf( pErr, "\tlevels equal to 3 (-l 3), the delay equal to 2-3 delays of inverter, \n"); fprintf( pErr, "\tthe area equal to 3-4 areas of two input NAND, and runtime limit equal \n"); fprintf( pErr, "\tto 10 seconds (-t 10). Run precomputation and learn from the result.\n"); fprintf( pErr, "\tDetermine what parameter is most constraining and try to increase \n"); fprintf( pErr, "\tthe value of that parameter. The goal is to have a well-balanced\n"); fprintf( pErr, "\tset of constraints and the resulting supergate library containing\n"); fprintf( pErr, "\tapproximately 100K-200K supergates. Typically, it is better to increase\n"); fprintf( pErr, "\tdelay limit rather than area limit, because having large-area supergates\n"); fprintf( pErr, "\tmay result in a considerable increase in area.\n"); fprintf( pErr, "\t\n"); fprintf( pErr, "\tNote that a good supergate library for experiments typically can be \n"); fprintf( pErr, "\tprecomputed in 30 sec. Increasing the runtime limit makes sense when\n"); fprintf( pErr, "\tother parameters are well-balanced and it is needed to enumerate more\n"); fprintf( pErr, "\tchoices to have a good result. In the end, to compute the final library\n"); fprintf( pErr, "\tthe runtime can be set to 300 sec to ensure the ultimate quality.\n"); fprintf( pErr, "\tIn some cases, the runtime has to be reduced if the supergate library\n"); fprintf( pErr, "\tcontains too many supergates (> 500K).\n"); fprintf( pErr, "\t\n"); fprintf( pErr, "\tWhen precomputing libraries of 6 inputs (-i 6), start with even more \n"); fprintf( pErr, "\trestricted parameters and gradually increase them until the goal is met.\n"); fprintf( pErr, "\t\n"); return 1; /* error exit */ }
/**Function************************************************************* Synopsis [] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandReadGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; Mio_Library_t * pLib; Amap_Lib_t * pLib2; char * pFileName; char * pExcludeFile = NULL; int fVerbose; double WireDelay; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults WireDelay = 0.0; fVerbose = 1; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "WEvh")) != EOF ) { switch (c) { case 'W': if ( globalUtilOptind >= argc ) { Abc_Print( -1, "Command line switch \"-W\" should be followed by a floating point number.\n" ); goto usage; } WireDelay = (float)atof(argv[globalUtilOptind]); globalUtilOptind++; if ( WireDelay <= 0.0 ) goto usage; break; case 'E': if ( globalUtilOptind >= argc ) { Abc_Print( -1, "Command line switch \"-E\" should be followed by a file name.\n" ); goto usage; } pExcludeFile = argv[globalUtilOptind]; globalUtilOptind++; break; case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { goto usage; } // get the input file name pFileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( pFileName, "open_path", "r", 0 )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", pFileName ); if ( (pFileName = Extra_FileGetSimilarName( pFileName, ".genlib", ".lib", ".scl", ".g", NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", pFileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); // set the new network pLib = Mio_LibraryRead( pFileName, NULL, pExcludeFile, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading genlib library has failed.\n" ); return 1; } if ( fVerbose ) printf( "Entered genlib library with %d gates from file \"%s\".\n", Mio_LibraryReadGateNum(pLib), pFileName ); // add the fixed number (wire delay) to all delays in the library if ( WireDelay != 0.0 ) Mio_LibraryShiftDelay( pLib, WireDelay ); // prepare libraries Mio_UpdateGenlib( pLib ); // replace the current library pLib2 = Amap_LibReadAndPrepare( pFileName, NULL, 0, 0 ); if ( pLib2 == NULL ) { fprintf( pErr, "Reading second genlib library has failed.\n" ); return 1; } Abc_FrameSetLibGen2( pLib2 ); return 0; usage: fprintf( pErr, "usage: read_genlib [-W float] [-E filename] [-vh]\n"); fprintf( pErr, "\t read the library from a genlib file\n" ); fprintf( pErr, "\t (if the library contains more than one gate\n" ); fprintf( pErr, "\t with the same Boolean function, only the gate\n" ); fprintf( pErr, "\t with the smallest area will be used)\n" ); fprintf( pErr, "\t-W float : wire delay (added to pin-to-pin gate delays) [default = %g]\n", WireDelay ); fprintf( pErr, "\t-E file : the file name with gates to be excluded [default = none]\n" ); fprintf( pErr, "\t-v : toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" ); fprintf( pErr, "\t-h : enable verbose output\n"); return 1; }
/**Function************************************************************* Synopsis [Command procedure to read LUT libraries.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Mio_CommandWriteGenlib( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pOut, * pErr, * pFile; char * pFileName; int fSelected = 0; int fVerbose = 0; int c; pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "vah")) != EOF ) { switch (c) { case 'v': fVerbose ^= 1; break; case 'a': fSelected ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( Abc_FrameReadLibGen() == NULL ) { printf( "Library is not available.\n" ); return 1; } if ( argc != globalUtilOptind + 1 ) { printf( "The file name is not given.\n" ); return 1; } pFileName = argv[globalUtilOptind]; pFile = fopen( pFileName, "w" ); if ( pFile == NULL ) { printf( "Error! Cannot open file \"%s\" for writing the library.\n", pFileName ); return 1; } Mio_WriteLibrary( pFile, (Mio_Library_t *)Abc_FrameReadLibGen(), 0, 0, fSelected ); fclose( pFile ); printf( "The current genlib library is written into file \"%s\".\n", pFileName ); return 0; usage: fprintf( pErr, "\nusage: write_genlib [-vah] <file>\n"); fprintf( pErr, "\t writes the current genlib library into a file\n" ); fprintf( pErr, "\t-v : toggles enabling of verbose output [default = %s]\n", fVerbose? "yes" : "no" ); fprintf( pErr, "\t-a : toggles writing min-area gates [default = %s]\n", fSelected? "yes" : "no" ); fprintf( pErr, "\t-h : print the command usage\n"); fprintf( pErr, "\t<file> : optional file name to write the library\n"); return 1; }
/**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 Mio_CommandReadLibrary( Abc_Frame_t * pAbc, int argc, char **argv ) { FILE * pFile; FILE * pOut, * pErr; Mio_Library_t * pLib; Abc_Ntk_t * pNet; char * FileName; int fVerbose; int c; pNet = Abc_FrameReadNtk(pAbc); pOut = Abc_FrameReadOut(pAbc); pErr = Abc_FrameReadErr(pAbc); // set the defaults fVerbose = 1; Extra_UtilGetoptReset(); while ( (c = Extra_UtilGetopt(argc, argv, "vh")) != EOF ) { switch (c) { case 'v': fVerbose ^= 1; break; case 'h': goto usage; break; default: goto usage; } } if ( argc != globalUtilOptind + 1 ) { goto usage; } // get the input file name FileName = argv[globalUtilOptind]; if ( (pFile = Io_FileOpen( FileName, "open_path", "r", 0 )) == NULL ) { fprintf( pErr, "Cannot open input file \"%s\". ", FileName ); if ( (FileName = Extra_FileGetSimilarName( FileName, ".genlib", ".lib", ".gen", ".g", NULL )) ) fprintf( pErr, "Did you mean \"%s\"?", FileName ); fprintf( pErr, "\n" ); return 1; } fclose( pFile ); // set the new network pLib = Mio_LibraryRead( pAbc, FileName, 0, fVerbose ); if ( pLib == NULL ) { fprintf( pErr, "Reading GENLIB library has failed.\n" ); return 1; } // free the current superlib because it depends on the old Mio library if ( Abc_FrameReadLibSuper() ) { extern void Map_SuperLibFree( Map_SuperLib_t * p ); // Map_SuperLibFree( s_pSuperLib ); // s_pSuperLib = NULL; Map_SuperLibFree( Abc_FrameReadLibSuper() ); Abc_FrameSetLibSuper( NULL ); } // replace the current library // Mio_LibraryDelete( s_pLib ); // s_pLib = pLib; Mio_LibraryDelete( Abc_FrameReadLibGen() ); Abc_FrameSetLibGen( pLib ); return 0; usage: fprintf( pErr, "usage: read_library [-vh]\n"); fprintf( pErr, "\t read the library from a genlib file\n" ); fprintf( pErr, "\t-h : enable verbose output\n"); return 1; /* error exit */ }
/**Function************************************************************* Synopsis [The main() procedure.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int Abc_RealMain( int argc, char * argv[] ) { Abc_Frame_t * pAbc; char sCommandUsr[500] = {0}, sCommandTmp[100], sReadCmd[20], sWriteCmd[20]; const char * sOutFile, * sInFile; char * sCommand; int fStatus = 0; int c, fBatch, fInitSource, fInitRead, fFinalWrite; // added to detect memory leaks // watch for {,,msvcrtd.dll}*__p__crtBreakAlloc() // (http://support.microsoft.com/kb/151585) #if defined(_DEBUG) && defined(_MSC_VER) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // get global frame (singleton pattern) // will be initialized on first call pAbc = Abc_FrameGetGlobalFrame(); pAbc->sBinary = argv[0]; #ifdef ABC_PYTHON_EMBED { PyObject* pModule; void init_pyabc(void); Py_SetProgramName(argv[0]); Py_NoSiteFlag = 1; Py_Initialize(); init_pyabc(); pModule = PyImport_ImportModule("pyabc"); if (pModule) { Py_DECREF(pModule); } else { fprintf( pAbc->Err, "error: pyabc.py not found. PYTHONPATH may not be set properly.\n"); } } #endif /* ABC_PYTHON_EMBED */ // default options fBatch = 0; fInitSource = 1; fInitRead = 0; fFinalWrite = 0; sInFile = sOutFile = NULL; sprintf( sReadCmd, "read" ); sprintf( sWriteCmd, "write" ); Extra_UtilGetoptReset(); while ((c = Extra_UtilGetopt(argc, argv, "c:C:hf:F:o:st:T:xb")) != EOF) { switch(c) { case 'c': strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 1; break; case 'C': strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 2; break; case 'f': sprintf(sCommandUsr, "source %s", globalUtilOptarg); fBatch = 1; break; case 'F': sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); fBatch = 1; break; case 'h': goto usage; break; case 'o': sOutFile = globalUtilOptarg; fFinalWrite = 1; break; case 's': fInitSource = 0; break; case 't': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if ( !strcmp(globalUtilOptarg, "none") == 0 ) { fInitRead = 1; sprintf( sReadCmd, "read_%s", globalUtilOptarg ); } } else { goto usage; } fBatch = 1; break; case 'T': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if (!strcmp(globalUtilOptarg, "none") == 0) { fFinalWrite = 1; sprintf( sWriteCmd, "write_%s", globalUtilOptarg); } } else { goto usage; } fBatch = 1; break; case 'x': fFinalWrite = 0; fInitRead = 0; fBatch = 1; break; case 'b': Abc_FrameSetBridgeMode(); break; default: goto usage; } } if ( Abc_FrameIsBridgeMode() ) { extern Gia_Man_t * Gia_ManFromBridge( FILE * pFile, Vec_Int_t ** pvInit ); pAbc->pGia = Gia_ManFromBridge( stdin, NULL ); } else if ( fBatch && sCommandUsr[0] ) Abc_Print( 1, "ABC command line: \"%s\".\n\n", sCommandUsr ); if ( fBatch ) { pAbc->fBatchMode = 1; if (argc - globalUtilOptind == 0) { sInFile = NULL; } else if (argc - globalUtilOptind == 1) { fInitRead = 1; sInFile = argv[globalUtilOptind]; } else { Abc_UtilsPrintUsage( pAbc, argv[0] ); } // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } fStatus = 0; if ( fInitRead && sInFile ) { sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } if ( fStatus == 0 ) { /* cmd line contains `source <file>' */ fStatus = Cmd_CommandExecute( pAbc, sCommandUsr ); if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile ) { sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } } if (fBatch == 2){ fBatch = 0; pAbc->fBatchMode = 0; } } if ( !fBatch ) { // start interactive mode // print the hello line Abc_UtilsPrintHello( pAbc ); // print history of the recent commands Cmd_HistoryPrint( pAbc, 10 ); // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } // execute commands given by the user while ( !feof(stdin) ) { // print command line prompt and // get the command from the user sCommand = Abc_UtilsGetUsersInput( pAbc ); // execute the user's command fStatus = Cmd_CommandExecute( pAbc, sCommand ); // stop if the user quitted or an error occurred if ( fStatus == -1 || fStatus == -2 ) break; } } #ifdef ABC_PYTHON_EMBED { Py_Finalize(); } #endif /* ABC_PYTHON_EMBED */ // if the memory should be freed, quit packages // if ( fStatus < 0 ) { Abc_Stop(); } return 0; usage: Abc_UtilsPrintHello( pAbc ); Abc_UtilsPrintUsage( pAbc, argv[0] ); return 1; }
/**Function************************************************************* Synopsis [The main() procedure.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ int main( int argc, char * argv[] ) { Abc_Frame_t * pAbc; char sCommandUsr[500], sCommandTmp[100], sReadCmd[20], sWriteCmd[20], c; char * sCommand, * sOutFile, * sInFile; int fStatus = 0; bool fBatch, fInitSource, fInitRead, fFinalWrite; // added to detect memory leaks: #ifdef _DEBUG _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); #endif // Npn_Experiment(); // Npn_Generate(); // get global frame (singleton pattern) // will be initialized on first call pAbc = Abc_FrameGetGlobalFrame(); // default options fBatch = 0; fInitSource = 1; fInitRead = 0; fFinalWrite = 0; sInFile = sOutFile = NULL; sprintf( sReadCmd, "read" ); sprintf( sWriteCmd, "write" ); Extra_UtilGetoptReset(); while ((c = Extra_UtilGetopt(argc, argv, "c:hf:F:o:st:T:x")) != EOF) { switch(c) { case 'c': strcpy( sCommandUsr, globalUtilOptarg ); fBatch = 1; break; case 'f': sprintf(sCommandUsr, "source %s", globalUtilOptarg); fBatch = 1; break; case 'F': sprintf(sCommandUsr, "source -x %s", globalUtilOptarg); fBatch = 1; break; case 'h': goto usage; break; case 'o': sOutFile = globalUtilOptarg; fFinalWrite = 1; break; case 's': fInitSource = 0; break; case 't': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if ( !strcmp(globalUtilOptarg, "none") == 0 ) { fInitRead = 1; sprintf( sReadCmd, "read_%s", globalUtilOptarg ); } } else { goto usage; } fBatch = 1; break; case 'T': if ( TypeCheck( pAbc, globalUtilOptarg ) ) { if (!strcmp(globalUtilOptarg, "none") == 0) { fFinalWrite = 1; sprintf( sWriteCmd, "write_%s", globalUtilOptarg); } } else { goto usage; } fBatch = 1; break; case 'x': fFinalWrite = 0; fInitRead = 0; fBatch = 1; break; default: goto usage; } } if ( fBatch ) { pAbc->fBatchMode = 1; if (argc - globalUtilOptind == 0) { sInFile = NULL; } else if (argc - globalUtilOptind == 1) { fInitRead = 1; sInFile = argv[globalUtilOptind]; } else { Abc_UtilsPrintUsage( pAbc, argv[0] ); } // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } fStatus = 0; if ( fInitRead && sInFile ) { sprintf( sCommandTmp, "%s %s", sReadCmd, sInFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } if ( fStatus == 0 ) { /* cmd line contains `source <file>' */ fStatus = Cmd_CommandExecute( pAbc, sCommandUsr ); if ( (fStatus == 0 || fStatus == -1) && fFinalWrite && sOutFile ) { sprintf( sCommandTmp, "%s %s", sWriteCmd, sOutFile ); fStatus = Cmd_CommandExecute( pAbc, sCommandTmp ); } } } else { // start interactive mode // print the hello line Abc_UtilsPrintHello( pAbc ); // source the resource file if ( fInitSource ) { Abc_UtilsSource( pAbc ); } // execute commands given by the user while ( !feof(stdin) ) { // print command line prompt and // get the command from the user sCommand = Abc_UtilsGetUsersInput( pAbc ); // execute the user's command fStatus = Cmd_CommandExecute( pAbc, sCommand ); // stop if the user quitted or an error occurred if ( fStatus == -1 || fStatus == -2 ) break; } } // if the memory should be freed, quit packages if ( fStatus < 0 ) { Abc_Stop(); } return 0; usage: Abc_UtilsPrintHello( pAbc ); Abc_UtilsPrintUsage( pAbc, argv[0] ); return 1; }