frontend: Improved error handling and fixes
Signed-off-by: David Shah <dave@ds0.me>
This commit is contained in:
parent
9e6770af90
commit
3e21f894f4
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user