diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-25 18:19:25 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-25 18:19:25 +0200 |
commit | be47fc3e9a81a4890b05223ae18803cb07674dc9 (patch) | |
tree | b0690ae9c7fd1c06db96ab036c3e177d50f6961d /json | |
parent | ec47ce2320fdc9d698e71c07af0844f7ecc2445c (diff) | |
download | nextpnr-be47fc3e9a81a4890b05223ae18803cb07674dc9.tar.gz nextpnr-be47fc3e9a81a4890b05223ae18803cb07674dc9.tar.bz2 nextpnr-be47fc3e9a81a4890b05223ae18803cb07674dc9.zip |
clangformat run
Diffstat (limited to 'json')
-rw-r--r-- | json/jsonparse.cc | 32 | ||||
-rw-r--r-- | json/jsonparse.h | 3 | ||||
-rw-r--r-- | json/jsonwrite.cc | 32 |
3 files changed, 33 insertions, 34 deletions
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<IdString, Property> *dest, int param_id) + std::unordered_map<IdString, Property> *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<IdString, Property> *dest, int param_id) + std::unordered_map<IdString, Property> *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<CellInfo> iobuf = std::unique_ptr<CellInfo>(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<std::string,Property> &values) +bool load_json_settings(std::istream &f, std::string &filename, std::unordered_map<std::string, Property> &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()); - } } } diff --git a/json/jsonparse.h b/json/jsonparse.h index ca971e5f..65e3f02e 100644 --- a/json/jsonparse.h +++ b/json/jsonparse.h @@ -27,7 +27,8 @@ NEXTPNR_NAMESPACE_BEGIN extern bool parse_json_file(std::istream &, std::string &, Context *); -extern bool load_json_settings(std::istream &f, std::string &filename, std::unordered_map<std::string,Property> &values); +extern bool load_json_settings(std::istream &f, std::string &filename, + std::unordered_map<std::string, Property> &values); NEXTPNR_NAMESPACE_END #endif diff --git a/json/jsonwrite.cc b/json/jsonwrite.cc index 552cd398..0b7a5b25 100644 --- a/json/jsonwrite.cc +++ b/json/jsonwrite.cc @@ -43,17 +43,15 @@ std::string get_string(std::string str) return newstr + "\""; } -std::string get_name(IdString name, Context *ctx) -{ - return get_string(name.c_str(ctx)); -} +std::string get_name(IdString name, Context *ctx) { return get_string(name.c_str(ctx)); } -void write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<IdString, Property> ¶meters, bool for_module=false) +void write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<IdString, Property> ¶meters, + bool for_module = false) { bool first = true; for (auto ¶m : parameters) { f << stringf("%s\n", first ? "" : ","); - f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first,ctx).c_str()); + f << stringf(" %s%s: ", for_module ? "" : " ", get_name(param.first, ctx).c_str()); if (param.second.isString()) f << get_string(param.second); else @@ -65,7 +63,7 @@ void write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<Id void write_module(std::ostream &f, Context *ctx) { auto val = ctx->attrs.find(ctx->id("module")); - if (val != ctx->attrs.end()) + if (val != ctx->attrs.end()) f << stringf(" %s: {\n", get_string(val->second.str).c_str()); else f << stringf(" %s: {\n", get_string("top").c_str()); @@ -81,16 +79,17 @@ void write_module(std::ostream &f, Context *ctx) auto &c = pair.second; f << stringf("%s\n", first ? "" : ","); f << stringf(" %s: {\n", get_name(c.name, ctx).c_str()); - f << stringf(" \"direction\": \"%s\",\n", c.type == PORT_IN ? "input" : c.type == PORT_INOUT ? "inout" : "output"); + f << stringf(" \"direction\": \"%s\",\n", + c.type == PORT_IN ? "input" : c.type == PORT_INOUT ? "inout" : "output"); f << stringf(" \"bits\": [ %d ]\n", pair.first.index); f << stringf(" }"); first = false; - } + } f << stringf("\n },\n"); f << stringf(" \"cells\": {"); first = true; - for (auto &pair : ctx->cells) { + for (auto &pair : ctx->cells) { auto &c = pair.second; f << stringf("%s\n", first ? "" : ","); f << stringf(" %s: {\n", get_name(c->name, ctx).c_str()); @@ -118,9 +117,9 @@ void write_module(std::ostream &f, Context *ctx) auto &p = conn.second; f << stringf("%s\n", first2 ? "" : ","); if (p.net) - f << stringf(" %s: [ %d ]", get_name(conn.first,ctx).c_str(), p.net->name.index); - else - f << stringf(" %s: [ ]", get_name(conn.first,ctx).c_str()); + f << stringf(" %s: [ %d ]", get_name(conn.first, ctx).c_str(), p.net->name.index); + else + f << stringf(" %s: [ ]", get_name(conn.first, ctx).c_str()); first2 = false; } @@ -146,7 +145,7 @@ void write_module(std::ostream &f, Context *ctx) f << stringf(" }"); first = false; } - + f << stringf("\n }\n"); f << stringf(" }"); } @@ -154,7 +153,8 @@ void write_module(std::ostream &f, Context *ctx) void write_context(std::ostream &f, Context *ctx) { f << stringf("{\n"); - f << stringf(" \"creator\": %s,\n", get_string( "Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")").c_str()); + f << stringf(" \"creator\": %s,\n", + get_string("Next Generation Place and Route (git sha1 " GIT_COMMIT_HASH_STR ")").c_str()); f << stringf(" \"modules\": {\n"); write_module(f, ctx); f << stringf("\n }"); @@ -166,7 +166,7 @@ void write_context(std::ostream &f, Context *ctx) bool write_json_file(std::ostream &f, std::string &filename, Context *ctx) { try { - using namespace JsonWriter; + using namespace JsonWriter; if (!f) log_error("failed to open JSON file.\n"); write_context(f, ctx); |