@@ -43284,6 +43284,7 @@ static Gia_Man_t * Abc_ReadAigerOrVerilogFile( char * pFileName, char * pFileNam
4328443284 Gia_Man_t * pGia;
4328543285 char * pTemp;
4328643286 char * pOrigFileName = NULL;
43287+ char * pFileTemp = NULL;
4328743288 int fVerilog, fSystemVerilog;
4328843289
4328943290 *pAbc_ReadAigerOrVerilogFileStatus = 0;
@@ -43312,17 +43313,24 @@ static Gia_Man_t * Abc_ReadAigerOrVerilogFile( char * pFileName, char * pFileNam
4331243313 extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
4331343314 Aig_Man_t * pAig = NULL;
4331443315 char pCommand[2000];
43316+ char * pFileBase;
4331543317 int RetValue;
4331643318 int fSystemVerilog2 = pFileName2 && Extra_FileIsType( pFileName2, ".sv", NULL, NULL );
4331743319 // Save the original filename before changing it
4331843320 pOrigFileName = pFileName;
43321+ pFileBase = pTopModule ? Abc_UtilStrsav(pTopModule) :
43322+ Extra_FileNameGeneric( Extra_FileNameWithoutPath(pFileName) );
43323+ pFileTemp = ABC_ALLOC( char, strlen(pFileBase) + 5 );
43324+ sprintf( pFileTemp, "%s.aig", pFileBase );
43325+ ABC_FREE( pFileBase );
4331943326 snprintf( pCommand, sizeof(pCommand),
43320- "yosys -qp \"read_verilog %s%s %s%s%s%s; hierarchy %s%s; flatten; proc; opt; async2sync; opt; setundef -undriven -zero; techmap; memory -nomap; memory_map; dffunmap; opt_clean; opt_expr; %saigmap; write_aiger -symbols _temp_.aig \"",
43327+ "yosys -qp \"read_verilog %s%s %s%s%s%s; hierarchy %s%s; flatten; proc; opt; async2sync; opt; setundef -undriven -zero; techmap; memory -nomap; memory_map; dffunmap; opt_clean; opt_expr; %saigmap; write_aiger -symbols %s \"",
4332143328 pDefines ? "-D" : "", pDefines ? pDefines : "",
4332243329 (fSystemVerilog || fSystemVerilog2) ? "-sv " : "", pFileName,
4332343330 pFileName2 ? " " : "", pFileName2 ? pFileName2 : "",
4332443331 pTopModule ? "-top " : "-auto-top", pTopModule ? pTopModule : "",
43325- pFileName2 ? "delete t:\\$scopeinfo; " : "" );
43332+ pFileName2 ? "delete t:\\$scopeinfo; " : "",
43333+ pFileTemp );
4332643334#if defined(__wasm)
4332743335 RetValue = 1;
4332843336#else
@@ -43331,29 +43339,32 @@ static Gia_Man_t * Abc_ReadAigerOrVerilogFile( char * pFileName, char * pFileNam
4333143339 if ( RetValue != 0 )
4333243340 {
4333343341 Abc_Print( -1, "Yosys command failed: \"%s\".\n", pCommand );
43342+ ABC_FREE( pFileTemp );
4333443343 return NULL;
4333543344 }
4333643345 if ( pFileName2 )
4333743346 {
43338- Abc_Ntk_t * pNtk = Io_Read( "_temp_.aig" , IO_FILE_AIGER, 1, 0 );
43347+ Abc_Ntk_t * pNtk = Io_Read( pFileTemp , IO_FILE_AIGER, 1, 0 );
4333943348 if ( pNtk == NULL )
4334043349 {
43341- Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", "_temp_.aig" );
43350+ Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", pFileTemp );
43351+ ABC_FREE( pFileTemp );
4334243352 return NULL;
4334343353 }
4334443354 pAig = Abc_NtkToDar( pNtk, 0, 1 );
4334543355 Abc_NtkDelete( pNtk );
4334643356 if ( pAig == NULL )
4334743357 {
4334843358 Abc_Print( -1, "Converting the AIGER network into an internal AIG has failed.\n" );
43359+ ABC_FREE( pFileTemp );
4334943360 return NULL;
4335043361 }
4335143362 pGia = Gia_ManFromAig( pAig );
4335243363 Aig_ManStop( pAig );
4335343364 }
4335443365 else
4335543366 {
43356- pFileName = "_temp_.aig" ;
43367+ pFileName = pFileTemp ;
4335743368 pGia = Gia_AigerRead( pFileName, 0, 0, 0 );
4335843369 }
4335943370 }
@@ -43362,6 +43373,7 @@ static Gia_Man_t * Abc_ReadAigerOrVerilogFile( char * pFileName, char * pFileNam
4336243373 if ( pGia == NULL )
4336343374 {
4336443375 Abc_Print( -1, "Reading AIGER from file \"%s\" has failed.\n", pFileName );
43376+ ABC_FREE( pFileTemp );
4336543377 return NULL;
4336643378 }
4336743379
@@ -43372,6 +43384,7 @@ static Gia_Man_t * Abc_ReadAigerOrVerilogFile( char * pFileName, char * pFileNam
4337243384 pGia->pSpec = Abc_UtilStrsav( pOrigFileName );
4337343385 }
4337443386
43387+ ABC_FREE( pFileTemp );
4337543388 return pGia;
4337643389}
4337743390
0 commit comments