From fb494d4dd74b1b372f01d0f80329b4b467fcd2d4 Mon Sep 17 00:00:00 2001 From: Johann Glaser Date: Sat, 16 Mar 2013 21:29:45 +0100 Subject: corrected typos Signed-off-by: Clifford Wolf --- passes/abc/abc.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'passes') diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index acd935465..c2c03e4a5 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -627,10 +627,10 @@ struct AbcPass : public Pass { log(" keeps using yosys's internal gate library.\n"); log("\n"); log(" -nocleanup\n"); - log(" when this option is used, the tempprary files created be this pass\n"); + log(" when this option is used, the temporary files created by this pass\n"); log(" are not removed. this is useful for debugging.\n"); log("\n"); - log("This pass does not operate on modules with uprocessed processes in it.\n"); + log("This pass does not operate on modules with unprocessed processes in it.\n"); log("(I.e. the 'proc' pass should be used first to convert processes to netlists.)\n"); log("\n"); log("[1] http://www.eecs.berkeley.edu/~alanmi/abc/\n"); -- cgit v1.2.3 From 0cb4a5936f92f0a526b4082a3cd52b3d98bae2fb Mon Sep 17 00:00:00 2001 From: Johann Glaser Date: Sat, 16 Mar 2013 22:04:55 +0100 Subject: added error checking at execution of ABC Signed-off-by: Clifford Wolf --- passes/abc/abc.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'passes') diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index c2c03e4a5..04d7ac67d 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -441,10 +441,28 @@ static void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std else snprintf(buffer, 1024, "%s -c 'read_verilog %s/input.v; read_library %s/stdcells.genlib; " "map; write_verilog %s/output.v' 2>&1", exe_file.c_str(), tempdir_name, tempdir_name, tempdir_name); + errno = ENOMEM; // popen does not set errno if memory allocation fails, therefore set it by hand f = popen(buffer, "r"); + if (!f) { + log("ABC: popen failed: %d, %s\n",errno,sys_errlist[errno]); + assert(0); + } while (fgets(buffer, 1024, f) != NULL) log("ABC: %s", buffer); - fclose(f); + errno = 0; + int ret = pclose(f); + if (ret < 0) { + log("ABC: pclose failed: %d, %s\n",errno,sys_errlist[errno]); + assert(0); + } + if (WEXITSTATUS(ret) != 0) { + switch (WEXITSTATUS(ret)) { + case 127: log("ABC: execution of command \"%s\" failed: Command not found\n",exe_file.c_str()); break; + case 126: log("ABC: execution of command \"%s\" failed: Command not executable\n",exe_file.c_str()); break; + default: log("ABC: execution of command \"%s\" failed: the shell returned %d\n",exe_file.c_str(),WEXITSTATUS(ret)); break; + } + assert(0); + } if (asprintf(&p, "%s/output.v", tempdir_name) < 0) abort(); f = fopen(p, "rt"); -- cgit v1.2.3 From 1390de4b749e922ff9d7d5b8694aee532a6d28d0 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Sun, 17 Mar 2013 09:17:18 +0100 Subject: Cleaned up ABC file/io error handling --- passes/abc/abc.cc | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'passes') diff --git a/passes/abc/abc.cc b/passes/abc/abc.cc index 04d7ac67d..e8f0a1449 100644 --- a/passes/abc/abc.cc +++ b/passes/abc/abc.cc @@ -332,7 +332,8 @@ static void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std tempdir_name[0] = tempdir_name[4] = '_'; char *p = mkdtemp(tempdir_name); log_header("Extracting gate logic of module `%s' to `%s/input.v'..\n", module->name.c_str(), tempdir_name); - assert(p != NULL); + if (p == NULL) + log_error("For some reason mkdtemp() failed!\n"); std::vector cells; cells.reserve(module->cells.size()); @@ -355,7 +356,8 @@ static void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std if (asprintf(&p, "%s/input.v", tempdir_name) < 0) abort(); FILE *f = fopen(p, "wt"); - assert(f != NULL); + if (f == NULL); + log_error("Opening %s for writing failed: %s\n", p, strerrno(errno)); free(p); fprintf(f, "module logic ("); @@ -418,7 +420,8 @@ static void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std if (asprintf(&p, "%s/stdcells.genlib", tempdir_name) < 0) abort(); f = fopen(p, "wt"); - assert(f != NULL); + if (f == NULL); + log_error("Opening %s for writing failed: %s\n", p, strerrno(errno)); fprintf(f, "GATE ZERO 1 Y=CONST0;\n"); fprintf(f, "GATE ONE 1 Y=CONST1;\n"); fprintf(f, "GATE BUF 1 Y=A; PIN * NONINV 1 999 1 0 1 0\n"); @@ -443,25 +446,20 @@ static void abc_module(RTLIL::Design *design, RTLIL::Module *current_module, std "map; write_verilog %s/output.v' 2>&1", exe_file.c_str(), tempdir_name, tempdir_name, tempdir_name); errno = ENOMEM; // popen does not set errno if memory allocation fails, therefore set it by hand f = popen(buffer, "r"); - if (!f) { - log("ABC: popen failed: %d, %s\n",errno,sys_errlist[errno]); - assert(0); - } + if (f == NULL) + log_error("Opening pipe to `%s' for reading failed: %s\n", buffer, strerrno(errno)); while (fgets(buffer, 1024, f) != NULL) log("ABC: %s", buffer); errno = 0; int ret = pclose(f); - if (ret < 0) { - log("ABC: pclose failed: %d, %s\n",errno,sys_errlist[errno]); - assert(0); - } + if (ret < 0) + log_error("Closing pipe to `%s' failed: %s\n", buffer, strerrno(errno)); if (WEXITSTATUS(ret) != 0) { switch (WEXITSTATUS(ret)) { - case 127: log("ABC: execution of command \"%s\" failed: Command not found\n",exe_file.c_str()); break; - case 126: log("ABC: execution of command \"%s\" failed: Command not executable\n",exe_file.c_str()); break; - default: log("ABC: execution of command \"%s\" failed: the shell returned %d\n",exe_file.c_str(),WEXITSTATUS(ret)); break; + case 127: log_error("ABC: execution of command \"%s\" failed: Command not found\n", exe_file.c_str()); break; + case 126: log_error("ABC: execution of command \"%s\" failed: Command not executable\n", exe_file.c_str()); break; + default: log_error("ABC: execution of command \"%s\" failed: the shell returned %d\n", exe_file.c_str(), WEXITSTATUS(ret)); break; } - assert(0); } if (asprintf(&p, "%s/output.v", tempdir_name) < 0) abort(); -- cgit v1.2.3