From ccbe2dd18d12d9d201afd5499e9e70ed8d2539de Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 1 Jun 2019 11:41:50 +0200 Subject: Add reading attributes to nets from json --- json/jsonparse.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index eec7041c..a78affbe 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -332,6 +332,30 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json pId.c_str(ctx), cell->params[pId].c_str(), cell->name.c_str(ctx), modname.c_str()); } +void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNode *param_node, + std::unordered_map *dest, int param_id) +{ + // + JsonNode *param; + IdString pId; + // + param = param_node->data_dict.at(param_node->data_dict_keys[param_id]); + + pId = ctx->id(param_node->data_dict_keys[param_id]); + if (param->type == 'N') { + (*dest)[pId] = std::to_string(param->data_number); + } else if (param->type == 'S') + (*dest)[pId] = param->data_string; + else + log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), + net->name.c_str(ctx)); + + if (json_debug) + log_info(" Added parameter \'%s\'=%s to net \'%s\' " + "of module \'%s\'\n", + pId.c_str(ctx), net->attrs[pId].c_str(), net->name.c_str(ctx), modname.c_str()); +} + static int const_net_idx = 0; template @@ -790,6 +814,41 @@ void json_import(Context *ctx, string modname, JsonNode *node) json_import_toplevel_port(ctx, modname, netids, ports_parent->data_dict_keys[portid], here); } } + if (node->data_dict.count("netnames")) { + JsonNode *net_parent = node->data_dict.at("netnames"); + for (int nnid = 0; nnid < GetSize(net_parent->data_dict_keys); nnid++) { + JsonNode *here; + + here = net_parent->data_dict.at(net_parent->data_dict_keys[nnid]); + std::string basename = net_parent->data_dict_keys[nnid]; + if (here->data_dict.count("bits")) { + JsonNode *bits = here->data_dict.at("bits"); + assert(bits->type == 'A'); + size_t num_bits = bits->data_array.size(); + for (size_t i = 0; i < num_bits; i++) { + std::string name = + basename + (num_bits == 1 ? "" : std::string("[") + std::to_string(i) + std::string("]")); + IdString net_id = ctx->id(name); + if (here->data_dict.count("attributes") && ctx->nets.find(net_id)!=ctx->nets.end()) { + NetInfo *this_net = ctx->nets[net_id].get(); + + JsonNode *attr_node = here->data_dict.at("attributes"); + if (attr_node->type != 'D') + log_error("JSON attribute list of \'%s\' is not a data dictionary\n", this_net->name.c_str(ctx)); + + // + // Loop through all attributes, adding them into the + // design to annotate the cell + // + for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { + json_import_net_attrib(ctx, modname, this_net, attr_node, &this_net->attrs, attrid); + } + + } + } + } + } + } check_all_nets_driven(ctx); } }; // End Namespace JsonParser -- cgit v1.2.3 From d5d8213871d8cb68b2e4ef9b3557879c80ff5b51 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 1 Jun 2019 15:52:32 +0200 Subject: Added support for attributes/properties types --- json/jsonparse.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index a78affbe..df21eb0f 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -309,7 +309,7 @@ bool is_blackbox(JsonNode *node) } void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, JsonNode *param_node, - std::unordered_map *dest, int param_id) + std::unordered_map *dest, int param_id) { // JsonNode *param; @@ -319,9 +319,9 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json pId = ctx->id(param_node->data_dict_keys[param_id]); if (param->type == 'N') { - (*dest)[pId] = std::to_string(param->data_number); + (*dest)[pId].setNumber(param->data_number); } else if (param->type == 'S') - (*dest)[pId] = param->data_string; + (*dest)[pId].setString(param->data_string); else log_error("JSON parameter type of \"%s\' of cell \'%s\' not supported\n", pId.c_str(ctx), cell->name.c_str(ctx)); @@ -333,7 +333,7 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json } void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNode *param_node, - std::unordered_map *dest, int param_id) + std::unordered_map *dest, int param_id) { // JsonNode *param; @@ -343,9 +343,9 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod pId = ctx->id(param_node->data_dict_keys[param_id]); if (param->type == 'N') { - (*dest)[pId] = std::to_string(param->data_number); + (*dest)[pId].setNumber(param->data_number); } else if (param->type == 'S') - (*dest)[pId] = param->data_string; + (*dest)[pId].setString(param->data_string); else log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), net->name.c_str(ctx)); -- cgit v1.2.3 From d5f804832f1accf318e8f62a9989149f5bc0b34a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 3 Jun 2019 21:13:47 +0200 Subject: hacky way to support ECP5 for now --- json/jsonparse.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index df21eb0f..7d11cd03 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -349,7 +349,11 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod else log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), net->name.c_str(ctx)); - +#ifdef ARCH_ECP5 + if (param_node->data_dict_keys[param_id]== "NEXTPNR_IS_GLOBAL") { + net->is_global = (*dest)[pId].num; + } +#endif if (json_debug) log_info(" Added parameter \'%s\'=%s to net \'%s\' " "of module \'%s\'\n", -- cgit v1.2.3 From 1093d7e1228272ca73114bbc4415c48d6cba76ed Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 11:48:15 +0200 Subject: WIP saving/loading attributes --- json/jsonparse.cc | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 7d11cd03..41d54188 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -349,11 +349,6 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod else log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), net->name.c_str(ctx)); -#ifdef ARCH_ECP5 - if (param_node->data_dict_keys[param_id]== "NEXTPNR_IS_GLOBAL") { - net->is_global = (*dest)[pId].num; - } -#endif if (json_debug) log_info(" Added parameter \'%s\'=%s to net \'%s\' " "of module \'%s\'\n", @@ -885,6 +880,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); ctx->settings.emplace(ctx->id("input/json"), filename); + ctx->attributesToCommonInfo(); return true; } catch (log_execution_error_exception) { return false; -- cgit v1.2.3 From a8871ea8aa6e17b2fbc8f70ce0f96cca18bac928 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 13:18:43 +0200 Subject: Cleanup and fixes, flow works now --- json/jsonparse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 41d54188..1ff4f5af 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -880,7 +880,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); ctx->settings.emplace(ctx->id("input/json"), filename); - ctx->attributesToCommonInfo(); + ctx->attributesToArchInfo(); return true; } catch (log_execution_error_exception) { return false; -- cgit v1.2.3 From d9b0bac248a12466cd2b62d02ec11b2e60d25019 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 7 Jun 2019 16:11:11 +0200 Subject: Save top level attrs and store current step --- json/jsonparse.cc | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 1ff4f5af..a36f891d 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -355,6 +355,27 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod pId.c_str(ctx), net->attrs[pId].c_str(), net->name.c_str(ctx), modname.c_str()); } +void json_import_top_attrib(Context *ctx, string &modname, JsonNode *param_node, + std::unordered_map *dest, int param_id) +{ + // + JsonNode *param; + IdString pId; + // + param = param_node->data_dict.at(param_node->data_dict_keys[param_id]); + + pId = ctx->id(param_node->data_dict_keys[param_id]); + if (param->type == 'N') { + (*dest)[pId].setNumber(param->data_number); + } else if (param->type == 'S') + (*dest)[pId].setString(param->data_string); + else + log_error("JSON parameter type of \"%s\' of module not supported\n", pId.c_str(ctx)); + if (json_debug) + log_info(" Added parameter \'%s\'=%s module \'%s\'\n", + pId.c_str(ctx), (*dest)[pId].c_str(), modname.c_str()); +} + static int const_net_idx = 0; template @@ -714,7 +735,14 @@ void json_import(Context *ctx, string modname, JsonNode *node) return; log_info("Importing module %s\n", modname.c_str()); - + ctx->attrs[ctx->id("module")] = modname; + JsonNode *attr_node = node->data_dict.at("attributes"); + for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { + json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid); + } + if (ctx->attrs.find(ctx->id("step")) == ctx->attrs.end()) + ctx->attrs[ctx->id("step")] = "synth"; + JsonNode *ports_parent = nullptr; if (node->data_dict.count("ports") > 0) ports_parent = node->data_dict.at("ports"); -- cgit v1.2.3 From 856760599e51bd4c6da34112c993dc8bfb995f36 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 12 Jun 2019 18:34:34 +0200 Subject: Use properties for settings and save in json --- json/jsonparse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index a36f891d..f0d0069a 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -907,7 +907,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); - ctx->settings.emplace(ctx->id("input/json"), filename); + ctx->settings[ctx->id("input/json")] = filename; ctx->attributesToArchInfo(); return true; } catch (log_execution_error_exception) { -- cgit v1.2.3 From 4de147d9e42d7c932773544011a36e4550530a9e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 18:39:16 +0200 Subject: Save settings that we saved in project --- json/jsonparse.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index f0d0069a..df8f45db 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -907,7 +907,6 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) log_info("Checksum: 0x%08x\n", ctx->checksum()); log_break(); - ctx->settings[ctx->id("input/json")] = filename; ctx->attributesToArchInfo(); return true; } catch (log_execution_error_exception) { -- cgit v1.2.3 From 03dff10cbde4c55e4ac9b53a01ba84f4bdac169b Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 13 Jun 2019 20:42:11 +0200 Subject: Load properties from json and propagate to context create --- json/jsonparse.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index df8f45db..a6b45282 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -914,4 +914,53 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) } } +bool load_json_settings(std::istream &f, std::string &filename, std::unordered_map &values) +{ + try { + using namespace JsonParser; + + if (!f) + log_error("failed to open JSON file.\n"); + + int lineno = 1; + + JsonNode root(f, lineno); + + 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 (modules->type != 'D') + log_error("JSON modules node is not a dictionary.\n"); + + for (auto &it : modules->data_dict) { + JsonNode *node = it.second; + if (is_blackbox(node)) + continue; + + if (node->data_dict.count("settings")) { + JsonNode *attr_node = node->data_dict.at("settings"); + for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { + JsonNode *param = attr_node->data_dict.at(attr_node->data_dict_keys[attrid]); + std::string pId = attr_node->data_dict_keys[attrid]; + if (param->type == 'N') { + values[pId].setNumber(param->data_number); + } else if (param->type == 'S') + values[pId].setString(param->data_string); + else + log_error("JSON parameter type of \"%s\' of module not supported\n", pId.c_str()); + + } + } + } + } + + return true; + } catch (log_execution_error_exception) { + return false; + } +} + NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 36ccc22fc93eddd9b6ed867782668b0057ec67e2 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 14 Jun 2019 09:59:04 +0200 Subject: Use flags for each step --- json/jsonparse.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index a6b45282..b2597828 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -740,8 +740,6 @@ void json_import(Context *ctx, string modname, JsonNode *node) for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid); } - if (ctx->attrs.find(ctx->id("step")) == ctx->attrs.end()) - ctx->attrs[ctx->id("step")] = "synth"; JsonNode *ports_parent = nullptr; if (node->data_dict.count("ports") > 0) -- cgit v1.2.3 From 0d8c80ad5daafc02030385da90c5a57182a5d4e5 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 14 Jun 2019 11:14:18 +0200 Subject: gui for json write and proper statuses --- json/jsonparse.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index b2597828..92bbf92f 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -740,7 +740,8 @@ void json_import(Context *ctx, string modname, JsonNode *node) for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid); } - + ctx->settings[ctx->id("synth")] = "1"; + JsonNode *ports_parent = nullptr; if (node->data_dict.count("ports") > 0) ports_parent = node->data_dict.at("ports"); -- cgit v1.2.3 From 92da4a91de0b602b0414754bd3ae05fdd70acbe7 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Jun 2019 09:43:47 +0200 Subject: Preserve ports --- json/jsonparse.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 92bbf92f..76854bf9 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -717,6 +717,12 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, const string assert(false); } ctx->cells[iobuf->name] = std::move(iobuf); + + PortInfo pinfo; + pinfo.name = net->name; + pinfo.net = net; + pinfo.type = type; + ctx->ports[net->name] = pinfo; } void json_import_toplevel_port(Context *ctx, const string &modname, const std::vector &netnames, @@ -726,7 +732,7 @@ void json_import_toplevel_port(Context *ctx, const string &modname, const std::v JsonNode *nets_node = node->data_dict.at("bits"); json_import_ports( ctx, modname, netnames, "Top Level IO", portname, dir_node, nets_node, - [ctx](PortType type, const std::string &name, NetInfo *net) { insert_iobuf(ctx, net, type, name); }); + [ctx](PortType type, const std::string &name, NetInfo *net) { insert_iobuf(ctx, net, type, name); }); } void json_import(Context *ctx, string modname, JsonNode *node) -- cgit v1.2.3 From 87ecd492957af9871db60155d3dddf121ef15714 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Jun 2019 11:31:59 +0200 Subject: Fix loading json --- json/jsonparse.cc | 110 +++++++++++++++++++++++++++--------------------------- 1 file changed, 56 insertions(+), 54 deletions(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 76854bf9..5c5c1bcd 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -661,62 +661,64 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, const string // During packing, this generic IO buffer will be converted to an // architecure primitive. // - std::unique_ptr iobuf = std::unique_ptr(new CellInfo()); - iobuf->name = ctx->id(name); - std::copy(net->attrs.begin(), net->attrs.end(), std::inserter(iobuf->attrs, iobuf->attrs.begin())); - if (type == PORT_IN) { - 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 - if (net->driver.cell != nullptr) { - if (net->driver.cell->type != ctx->id("$nextpnr_iobuf")) - log_error("Top-level input '%s' also driven by %s.%s.\n", name.c_str(), - net->driver.cell->name.c_str(ctx), net->driver.port.c_str(ctx)); - net = net->driver.cell->ports.at(ctx->id("I")).net; - } - assert(net->driver.cell == nullptr); - net->driver.port = ctx->id("O"); - net->driver.cell = iobuf.get(); - } else if (type == PORT_OUT) { - 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; - ref.cell = iobuf.get(); - ref.port = ctx->id("I"); - net->users.push_back(ref); - } else if (type == PORT_INOUT) { - 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}; - - // Split the input and output nets for bidir ports - std::unique_ptr net2 = std::unique_ptr(new NetInfo()); - net2->name = ctx->id("$" + net->name.str(ctx) + "$iobuf_i"); - net2->driver = net->driver; - if (net->driver.cell != nullptr) { - net2->driver.cell->ports[net2->driver.port].net = net2.get(); - net->driver.cell = nullptr; + if (ctx->settings.find(ctx->id("synth"))==ctx->settings.end()) { + std::unique_ptr iobuf = std::unique_ptr(new CellInfo()); + iobuf->name = ctx->id(name); + std::copy(net->attrs.begin(), net->attrs.end(), std::inserter(iobuf->attrs, iobuf->attrs.begin())); + if (type == PORT_IN) { + 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 + if (net->driver.cell != nullptr) { + if (net->driver.cell->type != ctx->id("$nextpnr_iobuf")) + log_error("Top-level input '%s' also driven by %s.%s.\n", name.c_str(), + net->driver.cell->name.c_str(ctx), net->driver.port.c_str(ctx)); + net = net->driver.cell->ports.at(ctx->id("I")).net; + } + assert(net->driver.cell == nullptr); + net->driver.port = ctx->id("O"); + net->driver.cell = iobuf.get(); + } else if (type == PORT_OUT) { + 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; + ref.cell = iobuf.get(); + ref.port = ctx->id("I"); + net->users.push_back(ref); + } else if (type == PORT_INOUT) { + 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}; + + // Split the input and output nets for bidir ports + std::unique_ptr net2 = std::unique_ptr(new NetInfo()); + net2->name = ctx->id("$" + net->name.str(ctx) + "$iobuf_i"); + net2->driver = net->driver; + if (net->driver.cell != nullptr) { + net2->driver.cell->ports[net2->driver.port].net = net2.get(); + net->driver.cell = nullptr; + } + iobuf->ports[ctx->id("I")].net = net2.get(); + PortRef ref; + ref.cell = iobuf.get(); + ref.port = ctx->id("I"); + net2->users.push_back(ref); + ctx->nets[net2->name] = std::move(net2); + + iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT}; + assert(net->driver.cell == nullptr); + net->driver.port = ctx->id("O"); + net->driver.cell = iobuf.get(); + } else { + assert(false); } - iobuf->ports[ctx->id("I")].net = net2.get(); - PortRef ref; - ref.cell = iobuf.get(); - ref.port = ctx->id("I"); - net2->users.push_back(ref); - ctx->nets[net2->name] = std::move(net2); - - iobuf->ports[ctx->id("O")] = PortInfo{ctx->id("O"), net, PORT_OUT}; - assert(net->driver.cell == nullptr); - net->driver.port = ctx->id("O"); - net->driver.cell = iobuf.get(); - } else { - assert(false); + ctx->cells[iobuf->name] = std::move(iobuf); } - ctx->cells[iobuf->name] = std::move(iobuf); PortInfo pinfo; pinfo.name = net->name; -- cgit v1.2.3 From 0c3093fe49d9ba14577b38bd5032081699e05680 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 21 Jun 2019 17:45:53 +0200 Subject: fix regression --- json/jsonparse.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 5c5c1bcd..81b0c3be 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -748,7 +748,6 @@ void json_import(Context *ctx, string modname, JsonNode *node) for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { json_import_top_attrib(ctx, modname, attr_node, &ctx->attrs, attrid); } - ctx->settings[ctx->id("synth")] = "1"; JsonNode *ports_parent = nullptr; if (node->data_dict.count("ports") > 0) @@ -884,6 +883,7 @@ void json_import(Context *ctx, string modname, JsonNode *node) } } check_all_nets_driven(ctx); + ctx->settings[ctx->id("synth")] = "1"; } }; // End Namespace JsonParser -- cgit v1.2.3 From be47fc3e9a81a4890b05223ae18803cb07674dc9 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Tue, 25 Jun 2019 18:19:25 +0200 Subject: clangformat run --- json/jsonparse.cc | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'json/jsonparse.cc') diff --git a/json/jsonparse.cc b/json/jsonparse.cc index 29dcac0a..caedbb5b 100644 --- a/json/jsonparse.cc +++ b/json/jsonparse.cc @@ -338,7 +338,7 @@ void json_import_cell_params(Context *ctx, string &modname, CellInfo *cell, Json } void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNode *param_node, - std::unordered_map *dest, int param_id) + std::unordered_map *dest, int param_id) { // JsonNode *param; @@ -352,8 +352,7 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod } else if (param->type == 'S') (*dest)[pId].setString(param->data_string); else - log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), - net->name.c_str(ctx)); + log_error("JSON parameter type of \"%s\' of net \'%s\' not supported\n", pId.c_str(ctx), net->name.c_str(ctx)); if (json_debug) log_info(" Added parameter \'%s\'=%s to net \'%s\' " "of module \'%s\'\n", @@ -361,7 +360,7 @@ void json_import_net_attrib(Context *ctx, string &modname, NetInfo *net, JsonNod } void json_import_top_attrib(Context *ctx, string &modname, JsonNode *param_node, - std::unordered_map *dest, int param_id) + std::unordered_map *dest, int param_id) { // JsonNode *param; @@ -377,8 +376,8 @@ void json_import_top_attrib(Context *ctx, string &modname, JsonNode *param_node, else log_error("JSON parameter type of \"%s\' of module not supported\n", pId.c_str(ctx)); if (json_debug) - log_info(" Added parameter \'%s\'=%s module \'%s\'\n", - pId.c_str(ctx), (*dest)[pId].c_str(), modname.c_str()); + log_info(" Added parameter \'%s\'=%s module \'%s\'\n", pId.c_str(ctx), (*dest)[pId].c_str(), + modname.c_str()); } static int const_net_idx = 0; @@ -669,7 +668,7 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, const string // During packing, this generic IO buffer will be converted to an // architecure primitive. // - if (ctx->settings.find(ctx->id("synth"))==ctx->settings.end()) { + if (ctx->settings.find(ctx->id("synth")) == ctx->settings.end()) { std::unique_ptr iobuf = std::unique_ptr(new CellInfo()); iobuf->name = ctx->id(name); std::copy(net->attrs.begin(), net->attrs.end(), std::inserter(iobuf->attrs, iobuf->attrs.begin())); @@ -682,7 +681,7 @@ static void insert_iobuf(Context *ctx, NetInfo *net, PortType type, const string if (net->driver.cell != nullptr) { if (net->driver.cell->type != ctx->id("$nextpnr_iobuf")) log_error("Top-level input '%s' also driven by %s.%s.\n", name.c_str(), - net->driver.cell->name.c_str(ctx), net->driver.port.c_str(ctx)); + net->driver.cell->name.c_str(ctx), net->driver.port.c_str(ctx)); net = net->driver.cell->ports.at(ctx->id("I")).net; } assert(net->driver.cell == nullptr); @@ -897,12 +896,13 @@ void json_import(Context *ctx, string modname, JsonNode *node) std::string name = basename + (num_bits == 1 ? "" : std::string("[") + std::to_string(i) + std::string("]")); IdString net_id = ctx->id(name); - if (here->data_dict.count("attributes") && ctx->nets.find(net_id)!=ctx->nets.end()) { - NetInfo *this_net = ctx->nets[net_id].get(); - + if (here->data_dict.count("attributes") && ctx->nets.find(net_id) != ctx->nets.end()) { + NetInfo *this_net = ctx->nets[net_id].get(); + JsonNode *attr_node = here->data_dict.at("attributes"); if (attr_node->type != 'D') - log_error("JSON attribute list of \'%s\' is not a data dictionary\n", this_net->name.c_str(ctx)); + log_error("JSON attribute list of \'%s\' is not a data dictionary\n", + this_net->name.c_str(ctx)); // // Loop through all attributes, adding them into the @@ -911,12 +911,11 @@ void json_import(Context *ctx, string modname, JsonNode *node) for (int attrid = 0; attrid < GetSize(attr_node->data_dict_keys); attrid++) { json_import_net_attrib(ctx, modname, this_net, attr_node, &this_net->attrs, attrid); } - } } - } + } } - } + } check_all_nets_driven(ctx); ctx->settings[ctx->id("synth")] = "1"; } @@ -956,7 +955,7 @@ bool parse_json_file(std::istream &f, std::string &filename, Context *ctx) } } -bool load_json_settings(std::istream &f, std::string &filename, std::unordered_map &values) +bool load_json_settings(std::istream &f, std::string &filename, std::unordered_map &values) { try { using namespace JsonParser; @@ -993,7 +992,6 @@ bool load_json_settings(std::istream &f, std::string &filename, std::unordered_m values[pId].setString(param->data_string); else log_error("JSON parameter type of \"%s\' of module not supported\n", pId.c_str()); - } } } -- cgit v1.2.3