diff options
author | David Shah <dave@ds0.me> | 2019-11-15 18:04:02 +0000 |
---|---|---|
committer | David Shah <dave@ds0.me> | 2019-12-27 10:44:30 +0000 |
commit | 3e21f894f4cbf843fbf3c9d1603886e63f2a8d5b (patch) | |
tree | 99aaa7e25726bfb72ec21af2c140648a4fa3b9ed | |
parent | 9e6770af9086326b3d7c0cb29e8b144fb3578369 (diff) | |
download | nextpnr-3e21f894f4cbf843fbf3c9d1603886e63f2a8d5b.tar.gz nextpnr-3e21f894f4cbf843fbf3c9d1603886e63f2a8d5b.tar.bz2 nextpnr-3e21f894f4cbf843fbf3c9d1603886e63f2a8d5b.zip |
frontend: Improved error handling and fixes
Signed-off-by: David Shah <dave@ds0.me>
-rw-r--r-- | frontend/frontend_base.h | 9 | ||||
-rw-r--r-- | frontend/json_frontend.cc | 4 |
2 files changed, 12 insertions, 1 deletions
diff --git a/frontend/frontend_base.h b/frontend/frontend_base.h index 3484b5b4..40d03863 100644 --- a/frontend/frontend_base.h +++ b/frontend/frontend_base.h @@ -104,6 +104,7 @@ #include "design_utils.h" #include "log.h" #include "nextpnr.h" +#include "util.h" NEXTPNR_NAMESPACE_BEGIN namespace { @@ -193,8 +194,14 @@ template <typename FrontendType> struct GenericFrontend for (auto &mod : mods) for (auto &c : mod.second.instantiated_celltypes) candidate_top.erase(c); - if (candidate_top.size() != 1) + if (candidate_top.size() != 1) { + if (candidate_top.size() == 0) + log_info("No candidate top level modules.\n"); + else + for (auto ctp : sorted(candidate_top)) + log_info("Candidate top module: '%s'\n", ctx->nameOf(ctp)); log_error("Failed to autodetect top module, please specify using --top.\n"); + } top = *(candidate_top.begin()); } diff --git a/frontend/json_frontend.cc b/frontend/json_frontend.cc index 37c1dabd..2eb0a39b 100644 --- a/frontend/json_frontend.cc +++ b/frontend/json_frontend.cc @@ -181,6 +181,10 @@ bool parse_json(std::istream &in, const std::string &filename, Context *ctx) root = Json::parse(json_str, error, JsonParse::COMMENTS); if (root.is_null()) log_error("Failed to parse JSON file '%s': %s.\n", filename.c_str(), error.c_str()); + root = root["modules"]; + if (root.is_null()) + log_error("JSON file '%s' doesn't look like a netlist (doesn't contain \"modules\" key)\n", + filename.c_str()); } GenericFrontend<JsonFrontendImpl>(ctx, JsonFrontendImpl(root))(); return true; |