/**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 [Interface with the mapping package.] Description [] SideEffects [] SeeAlso [] ***********************************************************************/ Abc_Ntk_t * Abc_NtkMap( Abc_Ntk_t * pNtk, double DelayTarget, double AreaMulti, double DelayMulti, float LogFan, float Slew, float Gain, int nGatesMin, int fRecovery, int fSwitching, int fSkipFanout, int fVerbose ) { static int fUseMulti = 0; int fShowSwitching = 1; Abc_Ntk_t * pNtkNew; Map_Man_t * pMan; Vec_Int_t * vSwitching = NULL; float * pSwitching = NULL; abctime clk, clkTotal = Abc_Clock(); Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen(); assert( Abc_NtkIsStrash(pNtk) ); // derive library from SCL // if the library is created here, it will be deleted when pSuperLib is deleted in Map_SuperLibFree() if ( Abc_FrameReadLibScl() && Abc_SclHasDelayInfo( Abc_FrameReadLibScl() ) ) { pLib = Abc_SclDeriveGenlib( Abc_FrameReadLibScl(), Slew, Gain, nGatesMin, fVerbose ); if ( Abc_FrameReadLibGen() ) Mio_LibraryTransferDelays( (Mio_Library_t *)Abc_FrameReadLibGen(), pLib ); // remove supergate library Map_SuperLibFree( (Map_SuperLib_t *)Abc_FrameReadLibSuper() ); Abc_FrameSetLibSuper( NULL ); } // quit if there is no library if ( pLib == NULL ) { printf( "The current library is not available.\n" ); return 0; } if ( AreaMulti != 0.0 ) fUseMulti = 1, printf( "The cell areas are multiplied by the factor: <num_fanins> ^ (%.2f).\n", AreaMulti ); if ( DelayMulti != 0.0 ) fUseMulti = 1, printf( "The cell delays are multiplied by the factor: <num_fanins> ^ (%.2f).\n", DelayMulti ); // penalize large gates by increasing their area if ( AreaMulti != 0.0 ) Mio_LibraryMultiArea( pLib, AreaMulti ); if ( DelayMulti != 0.0 ) Mio_LibraryMultiDelay( pLib, DelayMulti ); // derive the supergate library if ( fUseMulti || Abc_FrameReadLibSuper() == NULL ) { if ( fVerbose ) printf( "Converting \"%s\" into supergate library \"%s\".\n", Mio_LibraryReadName(pLib), Extra_FileNameGenericAppend(Mio_LibraryReadName(pLib), ".super") ); // compute supergate library to be used for mapping Map_SuperLibDeriveFromGenlib( pLib, fVerbose ); } // return the library to normal if ( AreaMulti != 0.0 ) Mio_LibraryMultiArea( (Mio_Library_t *)Abc_FrameReadLibGen(), -AreaMulti ); if ( DelayMulti != 0.0 ) Mio_LibraryMultiDelay( (Mio_Library_t *)Abc_FrameReadLibGen(), -DelayMulti ); // print a warning about choice nodes if ( fVerbose && Abc_NtkGetChoiceNum( pNtk ) ) printf( "Performing mapping with choices.\n" ); // compute switching activity fShowSwitching |= fSwitching; if ( fShowSwitching ) { extern Vec_Int_t * Sim_NtkComputeSwitching( Abc_Ntk_t * pNtk, int nPatterns ); vSwitching = Sim_NtkComputeSwitching( pNtk, 4096 ); pSwitching = (float *)vSwitching->pArray; } // perform the mapping pMan = Abc_NtkToMap( pNtk, DelayTarget, fRecovery, pSwitching, fVerbose ); if ( pSwitching ) Vec_IntFree( vSwitching ); if ( pMan == NULL ) return NULL; clk = Abc_Clock(); Map_ManSetSwitching( pMan, fSwitching ); Map_ManSetSkipFanout( pMan, fSkipFanout ); if ( LogFan != 0 ) Map_ManCreateNodeDelays( pMan, LogFan ); if ( !Map_Mapping( pMan ) ) { Map_ManFree( pMan ); return NULL; } // Map_ManPrintStatsToFile( pNtk->pSpec, Map_ManReadAreaFinal(pMan), Map_ManReadRequiredGlo(pMan), Abc_Clock()-clk ); // reconstruct the network after mapping pNtkNew = Abc_NtkFromMap( pMan, pNtk ); Map_ManFree( pMan ); if ( pNtkNew == NULL ) return NULL; if ( pNtk->pExdc ) pNtkNew->pExdc = Abc_NtkDup( pNtk->pExdc ); if ( fVerbose ) { ABC_PRT( "Total runtime", Abc_Clock() - clkTotal ); } // make sure that everything is okay if ( !Abc_NtkCheck( pNtkNew ) ) { printf( "Abc_NtkMap: The network check has failed.\n" ); Abc_NtkDelete( pNtkNew ); return NULL; } return pNtkNew; }
/**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; }