diff --git a/common/nextpnr.h b/common/nextpnr.h index 8063a981..2d614058 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -291,10 +291,7 @@ struct Context : Arch return rngstate * 0x2545F4914F6CDD1D; } - int rng() - { - return rng64() & 0x3fffffff; - } + int rng() { return rng64() & 0x3fffffff; } int rng(int n) { @@ -310,22 +307,25 @@ struct Context : Arch m += 1; while (1) { - int x = rng64() & (m-1); - if (x < n) return x; + int x = rng64() & (m - 1); + if (x < n) + return x; } } void rngseed(uint64_t seed) { rngstate = seed ? seed : 0x3141592653589793; - for (int i = 0; i < 5; i++) rng64(); + for (int i = 0; i < 5; i++) + rng64(); } - template - void shuffle(std::vector &a) { + template void shuffle(std::vector &a) + { for (size_t i = 0; i != a.size(); i++) { size_t j = i + rng(a.size() - i); - if (j > i) std::swap(a[i], a[j]); + if (j > i) + std::swap(a[i], a[j]); } } }; diff --git a/common/route.cc b/common/route.cc index 04f0f4c2..d623b2cf 100644 --- a/common/route.cc +++ b/common/route.cc @@ -67,7 +67,8 @@ struct Router delay_t maxDelay = 0.0; WireId failedDest; - Router(Context *ctx, IdString net_name, bool ripup = false, delay_t ripup_penalty = 0) + Router(Context *ctx, IdString net_name, bool ripup = false, + delay_t ripup_penalty = 0) { auto net_info = ctx->nets.at(net_name); @@ -438,7 +439,8 @@ bool route_design(Context *ctx) netCnt = 0; int ripCnt = 0; - std::vector ripupArray(ripupQueue.begin(), ripupQueue.end()); + std::vector ripupArray(ripupQueue.begin(), + ripupQueue.end()); ctx->shuffle(ripupArray); for (auto net_name : ripupArray) { @@ -447,7 +449,8 @@ bool route_design(Context *ctx) net_name.c_str(ctx), int(ctx->nets.at(net_name)->users.size())); - Router router(ctx, net_name, true, ripup_penalty * (iterCnt - 1)); + Router router(ctx, net_name, true, + ripup_penalty * (iterCnt - 1)); netCnt++; visitCnt += router.visitCnt; diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc index b3d6f718..cfe2739c 100644 --- a/frontend/json/jsonparse.cc +++ b/frontend/json/jsonparse.cc @@ -748,12 +748,11 @@ void json_import(Context *ctx, string modname, JsonNode *node) int netid = bits->data_array.at(i)->data_number; if (netid >= netnames.size()) netnames.resize(netid + 1); - netnames.at(netid) = - ctx->id(basename + - (num_bits == 1 ? "" - : std::string("[") + - std::to_string(i) + - std::string("]"))); + netnames.at(netid) = ctx->id( + basename + + (num_bits == 1 ? "" : std::string("[") + + std::to_string(i) + + std::string("]"))); } } } diff --git a/ice40/arch.h b/ice40/arch.h index 0fdacfde..c1256a41 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -279,8 +279,13 @@ template <> struct hash } }; -template <> struct hash : hash {}; -template <> struct hash : hash {}; +template <> struct hash : hash +{ +}; + +template <> struct hash : hash +{ +}; } // namespace std NEXTPNR_NAMESPACE_BEGIN diff --git a/ice40/cells.cc b/ice40/cells.cc index 6a8e7b5e..b6f10f7b 100644 --- a/ice40/cells.cc +++ b/ice40/cells.cc @@ -37,7 +37,7 @@ CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name) CellInfo *new_cell = new CellInfo(); if (name.empty()) { new_cell->name = IdString(ctx, "$nextpnr_" + type.str() + "_" + - std::to_string(auto_idx++)); + std::to_string(auto_idx++)); } else { new_cell->name = ctx->id(name); } @@ -200,8 +200,8 @@ void nxio_to_sb(Context *ctx, CellInfo *nxio, CellInfo *sbio) } NetInfo *donet = sbio->ports.at(ctx->id("D_OUT_0")).net; CellInfo *tbuf = - net_driven_by(ctx, donet, [] - (const Context *ctx, const CellInfo *cell) { + net_driven_by(ctx, donet, + [](const Context *ctx, const CellInfo *cell) { return cell->type == ctx->id("$_TBUF_"); }, "Y"); @@ -251,7 +251,8 @@ bool is_enable_port(const Context *ctx, const PortRef &port) bool is_global_net(const Context *ctx, const NetInfo *net) { - return bool(net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT"))); + return bool( + net_driven_by(ctx, net, is_gbuf, ctx->id("GLOBAL_BUFFER_OUTPUT"))); } NEXTPNR_NAMESPACE_END diff --git a/ice40/cells.h b/ice40/cells.h index cc1fa1cb..19568ed0 100644 --- a/ice40/cells.h +++ b/ice40/cells.h @@ -27,8 +27,7 @@ NEXTPNR_NAMESPACE_BEGIN // Create a standard iCE40 cell and return it // Name will be automatically assigned if not specified -CellInfo *create_ice_cell(Context *ctx, IdString type, - std::string name = ""); +CellInfo *create_ice_cell(Context *ctx, IdString type, std::string name = ""); // Return true if a cell is a LUT inline bool is_lut(const Context *ctx, const CellInfo *cell) diff --git a/ice40/pack.cc b/ice40/pack.cc index 60c86a43..92f9a369 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -39,8 +39,8 @@ static void pack_lut_lutffs(Context *ctx) log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx), ci->type.c_str(ctx)); if (is_lut(ctx, ci)) { - CellInfo *packed = - create_ice_cell(ctx, "ICESTORM_LC", ci->name.str(ctx) + "_LC"); + CellInfo *packed = create_ice_cell(ctx, "ICESTORM_LC", + ci->name.str(ctx) + "_LC"); std::copy(ci->attrs.begin(), ci->attrs.end(), std::inserter(packed->attrs, packed->attrs.begin())); packed_cells.insert(ci->name); @@ -168,7 +168,8 @@ static void set_net_constant(const Context *ctx, NetInfo *orig, for (auto user : orig->users) { if (user.cell != nullptr) { CellInfo *uc = user.cell; - log_info("%s user %s\n", orig->name.c_str(ctx), uc->name.c_str(ctx)); + log_info("%s user %s\n", orig->name.c_str(ctx), + uc->name.c_str(ctx)); if (is_lut(ctx, uc) && (user.port.str(ctx).at(0) == 'I') && !constval) { uc->ports[user.port].net = nullptr; @@ -204,7 +205,8 @@ static void pack_constants(Context *ctx) for (auto net : ctx->nets) { NetInfo *ni = net.second; - if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) { + if (ni->driver.cell != nullptr && + ni->driver.cell->type == ctx->id("GND")) { set_net_constant(ctx, ni, gnd_net, false); ctx->cells[gnd_cell->name] = gnd_cell; ctx->nets[gnd_net->name] = gnd_net; @@ -224,7 +226,8 @@ static void pack_constants(Context *ctx) static bool is_nextpnr_iob(Context *ctx, CellInfo *cell) { - return cell->type == ctx->id("$nextpnr_ibuf") || cell->type == ctx->id("$nextpnr_obuf") || + return cell->type == ctx->id("$nextpnr_ibuf") || + cell->type == ctx->id("$nextpnr_obuf") || cell->type == ctx->id("$nextpnr_iobuf"); } @@ -240,7 +243,8 @@ static void pack_io(Context *ctx) CellInfo *ci = cell.second; if (is_nextpnr_iob(ctx, ci)) { CellInfo *sb = nullptr; - if (ci->type == ctx->id("$nextpnr_ibuf") || ci->type == ctx->id("$nextpnr_iobuf")) { + if (ci->type == ctx->id("$nextpnr_ibuf") || + ci->type == ctx->id("$nextpnr_iobuf")) { sb = net_only_drives(ctx, ci->ports.at("O").net, is_sb_io, "PACKAGE_PIN", true, ci); @@ -252,8 +256,8 @@ static void pack_io(Context *ctx) // Trivial case, SB_IO used. Just destroy the net and the // iobuf log_info("%s feeds SB_IO %s, removing %s %s.\n", - ci->name.c_str(ctx), sb->name.c_str(ctx), ci->type.c_str(ctx), - ci->name.c_str(ctx)); + ci->name.c_str(ctx), sb->name.c_str(ctx), + ci->type.c_str(ctx), ci->name.c_str(ctx)); NetInfo *net = sb->ports.at("PACKAGE_PIN").net; if (net != nullptr) { ctx->nets.erase(net->name);