From 993f6ef7d31ceee5fc71a99fcec19b521694e4f3 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 21 Jun 2018 14:09:50 +0200 Subject: Improve log messages, move many messages to verbose mode Signed-off-by: Clifford Wolf --- frontend/json/jsonparse.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'frontend/json/jsonparse.cc') diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index a936bdaa..32ae0953 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -659,7 +659,8 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, std::copy(net->attrs.begin(), net->attrs.end(), std::inserter(iobuf->attrs, iobuf->attrs.begin())); if (type == PORT_IN) { - log_info("processing input port %s\n", name.c_str()); + if (ctx->verbose) + log_info("processing input port %s\n", name.c_str()); iobuf->type = ctx->id("$nextpnr_ibuf"); iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT}; // Special case: input, etc, directly drives inout @@ -671,7 +672,8 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, net->driver.port = ctx->id("O"); net->driver.cell = iobuf; } else if (type == PORT_OUT) { - log_info("processing output port %s\n", name.c_str()); + if (ctx->verbose) + log_info("processing output port %s\n", name.c_str()); iobuf->type = ctx->id("$nextpnr_obuf"); iobuf->ports[ctx->id("I")] = PortInfo{ctx->id("I"), net, PORT_IN}; PortRef ref; @@ -679,7 +681,8 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, ref.port = ctx->id("I"); net->users.push_back(ref); } else if (type == PORT_INOUT) { - log_info("processing inout port %s\n", name.c_str()); + if (ctx->verbose) + log_info("processing inout port %s\n", name.c_str()); iobuf->type = ctx->id("$nextpnr_iobuf"); iobuf->ports[ctx->id("I")] = PortInfo{ctx->id("I"), nullptr, PORT_IN}; -- cgit v1.2.3 From a29bfc788eba9f11f1e0cd3d62a32c3894cddf49 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 21 Jun 2018 15:47:41 +0200 Subject: Add ctx->checksum(), slightly improve log messages Signed-off-by: Clifford Wolf --- frontend/json/jsonparse.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'frontend/json/jsonparse.cc') diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 32ae0953..277e602a 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -828,6 +828,9 @@ void parse_json_file(std::istream *&f, std::string &filename, Context *ctx) { auto *parser = new JsonParser::JsonFrontend(); parser->execute(f, filename, ctx); + + log_info("Checksum: 0x%08x\n", ctx->checksum()); + log_break(); } NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 4fefdbd57c52d6373456bd379e3e54df770e1945 Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Thu, 21 Jun 2018 16:16:58 +0200 Subject: Cleanup parse_json_file API, some other cleanups Signed-off-by: Clifford Wolf --- frontend/json/jsonparse.cc | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'frontend/json/jsonparse.cc') diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 277e602a..7d9e9dcf 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -795,39 +795,26 @@ void json_import(Context *ctx, string modname, JsonNode *node) } check_all_nets_driven(ctx); } +}; // End Namespace JsonParser -struct JsonFrontend +void parse_json_file(std::istream &f, std::string &filename, Context *ctx) { - // JsonFrontend() : Frontend("json", "read JSON file") { } - JsonFrontend(void) {} - virtual void help() {} - virtual void execute(std::istream *&f, std::string &filename, Context *ctx) - { - // log_header(ctx, "Executing JSON frontend.\n"); + using namespace JsonParser; - JsonNode root(*f); + JsonNode root(f); - if (root.type != 'D') - log_error("JSON root node is not a dictionary.\n"); + if (root.type != 'D') + log_error("JSON root node is not a dictionary.\n"); - if (root.data_dict.count("modules") != 0) { - JsonNode *modules = root.data_dict.at("modules"); + if (root.data_dict.count("modules") != 0) { + JsonNode *modules = root.data_dict.at("modules"); - if (modules->type != 'D') - log_error("JSON modules node is not a dictionary.\n"); + if (modules->type != 'D') + log_error("JSON modules node is not a dictionary.\n"); - for (auto &it : modules->data_dict) - json_import(ctx, it.first, it.second); - } + for (auto &it : modules->data_dict) + json_import(ctx, it.first, it.second); } -}; // JsonFrontend; - -}; // End Namespace JsonParser - -void parse_json_file(std::istream *&f, std::string &filename, Context *ctx) -{ - auto *parser = new JsonParser::JsonFrontend(); - parser->execute(f, filename, ctx); log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); -- cgit v1.2.3 From c33a039ac388bfcb5e068a04a7cb1b05ebec7d7f Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 21 Jun 2018 18:08:28 +0200 Subject: Added return code to json parsing and pcf reading --- frontend/json/jsonparse.cc | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'frontend/json/jsonparse.cc') diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index 7d9e9dcf..a832e9e5 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -797,27 +797,32 @@ void json_import(Context *ctx, string modname, JsonNode *node) } }; // End Namespace JsonParser -void parse_json_file(std::istream &f, std::string &filename, Context *ctx) +bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) { - using namespace JsonParser; + try { + using namespace JsonParser; - JsonNode root(f); + JsonNode root(f); - if (root.type != 'D') - log_error("JSON root node is not a dictionary.\n"); + if (root.type != 'D') + log_error("JSON root node is not a dictionary.\n"); - if (root.data_dict.count("modules") != 0) { - JsonNode *modules = root.data_dict.at("modules"); + if (root.data_dict.count("modules") != 0) { + JsonNode *modules = root.data_dict.at("modules"); - if (modules->type != 'D') - log_error("JSON modules node is not a dictionary.\n"); + if (modules->type != 'D') + log_error("JSON modules node is not a dictionary.\n"); - for (auto &it : modules->data_dict) - json_import(ctx, it.first, it.second); - } + for (auto &it : modules->data_dict) + json_import(ctx, it.first, it.second); + } - log_info("Checksum: 0x%08x\n", ctx->checksum()); - log_break(); + log_info("Checksum: 0x%08x\n", ctx->checksum()); + log_break(); + return true; + } catch (log_execution_error_exception) { + return false; + } } NEXTPNR_NAMESPACE_END -- cgit v1.2.3