diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/command.cc | 22 | ||||
-rw-r--r-- | common/command.h | 4 | ||||
-rw-r--r-- | common/nextpnr.cc | 47 | ||||
-rw-r--r-- | common/nextpnr.h | 37 | ||||
-rw-r--r-- | common/placer1.cc | 3 | ||||
-rw-r--r-- | common/placer1.h | 2 | ||||
-rw-r--r-- | common/placer_heap.h | 2 | ||||
-rw-r--r-- | common/router1.h | 2 | ||||
-rw-r--r-- | common/timing.cc | 10 | ||||
-rw-r--r-- | common/timing_opt.h | 2 |
10 files changed, 68 insertions, 63 deletions
diff --git a/common/command.cc b/common/command.cc index dc98d032..8acbafd2 100644 --- a/common/command.cc +++ b/common/command.cc @@ -27,8 +27,8 @@ #include "pybindings.h" #endif -#include <boost/algorithm/string/join.hpp> #include <boost/algorithm/string.hpp> +#include <boost/algorithm/string/join.hpp> #include <boost/filesystem/convenience.hpp> #include <boost/program_options.hpp> #include <fstream> @@ -156,7 +156,7 @@ void CommandHandler::setupContext(Context *ctx) { if (ctx->settings.find(ctx->id("seed")) != ctx->settings.end()) ctx->rngstate = ctx->setting<uint64_t>("seed"); - + if (vm.count("verbose")) { ctx->verbose = true; } @@ -239,7 +239,7 @@ void CommandHandler::setupContext(Context *ctx) ctx->settings[ctx->id("slack_redist_iter")] = "0"; if (ctx->settings.find(ctx->id("auto_freq")) == ctx->settings.end()) ctx->settings[ctx->id("auto_freq")] = std::to_string(false); - if (ctx->settings.find(ctx->id("placer")) == ctx->settings.end()) + if (ctx->settings.find(ctx->id("placer")) == ctx->settings.end()) ctx->settings[ctx->id("placer")] = Arch::defaultPlacer; ctx->settings[ctx->id("arch.name")] = std::string(ctx->archId().c_str(ctx)); @@ -298,16 +298,16 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) execute_python_file(filename.c_str()); } else #endif - if (vm.count("json")) { - bool do_pack = vm.count("pack-only")!=0 || vm.count("no-pack")==0; - bool do_place = vm.count("pack-only")==0 && vm.count("no-place")==0; - bool do_route = vm.count("pack-only")==0 && vm.count("no-route")==0; + if (vm.count("json")) { + bool do_pack = vm.count("pack-only") != 0 || vm.count("no-pack") == 0; + bool do_place = vm.count("pack-only") == 0 && vm.count("no-place") == 0; + bool do_route = vm.count("pack-only") == 0 && vm.count("no-route") == 0; if (do_pack) { run_script_hook("pre-pack"); if (!ctx->pack() && !ctx->force) log_error("Packing design failed.\n"); - } + } assign_budget(ctx.get()); ctx->check(); print_utilisation(ctx.get()); @@ -329,7 +329,7 @@ int CommandHandler::executeMain(std::unique_ptr<Context> ctx) customBitstream(ctx.get()); } - if (vm.count("write")) { + if (vm.count("write")) { std::string filename = vm["write"].as<std::string>(); std::ofstream f(filename); if (!write_json_file(f, filename, ctx.get())) @@ -370,7 +370,7 @@ int CommandHandler::exec() if (executeBeforeContext()) return 0; - std::unordered_map<std::string,Property> values; + std::unordered_map<std::string, Property> values; if (vm.count("json")) { std::string filename = vm["json"].as<std::string>(); std::ifstream f(filename); @@ -392,7 +392,7 @@ int CommandHandler::exec() std::unique_ptr<Context> CommandHandler::load_json(std::string filename) { vm.clear(); - std::unordered_map<std::string,Property> values; + std::unordered_map<std::string, Property> values; { std::ifstream f(filename); if (!load_json_settings(f, filename, values)) diff --git a/common/command.h b/common/command.h index b5908e3f..e52b5a48 100644 --- a/common/command.h +++ b/common/command.h @@ -23,8 +23,8 @@ #include <boost/program_options.hpp> #include <fstream> -#include "nextpnr.h" #include "log.h" +#include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN @@ -41,7 +41,7 @@ class CommandHandler protected: virtual void setupArchContext(Context *ctx) = 0; - virtual std::unique_ptr<Context> createContext(std::unordered_map<std::string,Property> &values) = 0; + virtual std::unique_ptr<Context> createContext(std::unordered_map<std::string, Property> &values) = 0; virtual po::options_description getArchOptions() = 0; virtual void validate(){}; virtual void customAfterLoad(Context *ctx){}; diff --git a/common/nextpnr.cc b/common/nextpnr.cc index a026b60d..d4cc4917 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -18,8 +18,8 @@ */ #include "nextpnr.h" -#include "log.h" #include <boost/algorithm/string.hpp> +#include "log.h" NEXTPNR_NAMESPACE_BEGIN @@ -465,23 +465,23 @@ void BaseCtx::archInfoToAttributes() ci->attrs[id("NEXTPNR_BEL")] = getCtx()->getBelName(ci->bel).c_str(this); ci->attrs[id("BEL_STRENGTH")] = std::to_string((int)ci->belStrength); } - if (ci->constr_x!= ci->UNCONSTR) + if (ci->constr_x != ci->UNCONSTR) ci->attrs[id("CONSTR_X")] = std::to_string(ci->constr_x); - if (ci->constr_y!= ci->UNCONSTR) + if (ci->constr_y != ci->UNCONSTR) ci->attrs[id("CONSTR_Y")] = std::to_string(ci->constr_y); - if (ci->constr_z!= ci->UNCONSTR) { + if (ci->constr_z != ci->UNCONSTR) { ci->attrs[id("CONSTR_Z")] = std::to_string(ci->constr_z); ci->attrs[id("CONSTR_ABS_Z")] = std::to_string(ci->constr_abs_z ? 1 : 0); } - if (ci->constr_parent!= nullptr) + if (ci->constr_parent != nullptr) ci->attrs[id("CONSTR_PARENT")] = ci->constr_parent->name.c_str(this); if (!ci->constr_children.empty()) { std::string constr = ""; - for(auto &item : ci->constr_children) - { - if (!constr.empty()) constr += std::string(";"); + for (auto &item : ci->constr_children) { + if (!constr.empty()) + constr += std::string(";"); constr += item->name.c_str(this); - } + } ci->attrs[id("CONSTR_CHILDREN")] = constr; } } @@ -490,7 +490,8 @@ void BaseCtx::archInfoToAttributes() std::string routing; bool first = true; for (auto &item : ni->wires) { - if (!first) routing += ";"; + if (!first) + routing += ";"; routing += getCtx()->getWireName(item.first).c_str(this); routing += ";"; if (item.second.pip != PipId()) @@ -501,7 +502,7 @@ void BaseCtx::archInfoToAttributes() ni->attrs[id("ROUTING")] = routing; } } - + void BaseCtx::attributesToArchInfo() { for (auto &cell : cells) { @@ -512,7 +513,7 @@ void BaseCtx::attributesToArchInfo() PlaceStrength strength = PlaceStrength::STRENGTH_USER; if (str != ci->attrs.end()) strength = (PlaceStrength)std::stoi(str->second.str); - + BelId b = getCtx()->getBelByName(id(val->second.str)); getCtx()->bindBel(b, ci, strength); } @@ -525,12 +526,12 @@ void BaseCtx::attributesToArchInfo() ci->constr_y = std::stoi(val->second.str); val = ci->attrs.find(id("CONSTR_Z")); - if (val != ci->attrs.end()) + if (val != ci->attrs.end()) ci->constr_z = std::stoi(val->second.str); val = ci->attrs.find(id("CONSTR_ABS_Z")); if (val != ci->attrs.end()) - ci->constr_abs_z = std::stoi(val->second.str)==1; + ci->constr_abs_z = std::stoi(val->second.str) == 1; val = ci->attrs.find(id("CONSTR_PARENT")); if (val != ci->attrs.end()) { @@ -541,11 +542,10 @@ void BaseCtx::attributesToArchInfo() val = ci->attrs.find(id("CONSTR_CHILDREN")); if (val != ci->attrs.end()) { std::vector<std::string> strs; - boost::split(strs,val->second.str,boost::is_any_of(";")); - for(auto val : strs) - { + boost::split(strs, val->second.str, boost::is_any_of(";")); + for (auto val : strs) { ci->constr_children.push_back(cells.find(id(val.c_str()))->second.get()); - } + } } } for (auto &net : getCtx()->nets) { @@ -553,12 +553,11 @@ void BaseCtx::attributesToArchInfo() auto val = ni->attrs.find(id("ROUTING")); if (val != ni->attrs.end()) { std::vector<std::string> strs; - boost::split(strs,val->second.str,boost::is_any_of(";")); - for(size_t i=0;i<strs.size()/3;i++) - { - std::string wire = strs[i*3]; - std::string pip = strs[i*3 + 1]; - PlaceStrength strength = (PlaceStrength)std::stoi(strs[i*3 + 2]); + boost::split(strs, val->second.str, boost::is_any_of(";")); + for (size_t i = 0; i < strs.size() / 3; i++) { + std::string wire = strs[i * 3]; + std::string pip = strs[i * 3 + 1]; + PlaceStrength strength = (PlaceStrength)std::stoi(strs[i * 3 + 2]); if (pip.empty()) getCtx()->bindWire(getCtx()->getWireByName(id(wire)), ni, strength); else diff --git a/common/nextpnr.h b/common/nextpnr.h index 6950ac76..3f434580 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -290,7 +290,7 @@ struct PipMap struct Property { bool is_string; - + std::string str; int num; @@ -299,22 +299,25 @@ struct Property bool isString() const { return is_string; } - void setNumber(int val) { is_string = false; num = val; str = std::to_string(val); } - void setString(std::string val) { is_string = true; str = val; } - - const char * c_str() const { return str.c_str(); } - operator std::string () const { return str; } - - bool operator==(const std::string other) const + void setNumber(int val) { - return str == other; - } - bool operator!=(const std::string other) const + is_string = false; + num = val; + str = std::to_string(val); + } + void setString(std::string val) { - return str != other; - } + is_string = true; + str = val; + } + + const char *c_str() const { return str.c_str(); } + operator std::string() const { return str; } + + bool operator==(const std::string other) const { return str == other; } + bool operator!=(const std::string other) const { return str != other; } - Property& operator=(std::string other) + Property &operator=(std::string other) { is_string = true; str = other; @@ -732,10 +735,10 @@ struct Context : Arch, DeterministicRNG return boost::lexical_cast<T>(settings.find(new_id)->second.str); else settings[id(name)] = std::to_string(defaultValue); - - return defaultValue; + + return defaultValue; } - + template <typename T> T setting(const char *name) const { IdString new_id = id(name); diff --git a/common/placer1.cc b/common/placer1.cc index a2272b83..7ab454c7 100644 --- a/common/placer1.cc +++ b/common/placer1.cc @@ -374,7 +374,8 @@ class SAPlacer assign_budget(ctx, true /* quiet */); } require_legal = false; - } else if (cfg.budgetBased && ctx->setting<int>("slack_redist_iter") > 0 && iter % ctx->setting<int>("slack_redist_iter") == 0) { + } else if (cfg.budgetBased && ctx->setting<int>("slack_redist_iter") > 0 && + iter % ctx->setting<int>("slack_redist_iter") == 0) { assign_budget(ctx, true /* quiet */); } diff --git a/common/placer1.h b/common/placer1.h index 0f2e2894..08edb2c4 100644 --- a/common/placer1.h +++ b/common/placer1.h @@ -19,8 +19,8 @@ #ifndef PLACE_H #define PLACE_H -#include "nextpnr.h" #include "log.h" +#include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN diff --git a/common/placer_heap.h b/common/placer_heap.h index 2def5e75..9b1c52cb 100644 --- a/common/placer_heap.h +++ b/common/placer_heap.h @@ -26,8 +26,8 @@ #ifndef PLACER_HEAP_H #define PLACER_HEAP_H -#include "nextpnr.h" #include "log.h" +#include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN diff --git a/common/router1.h b/common/router1.h index f3d325ad..a37784f4 100644 --- a/common/router1.h +++ b/common/router1.h @@ -20,8 +20,8 @@ #ifndef ROUTER1_H #define ROUTER1_H -#include "nextpnr.h" #include "log.h" +#include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN struct Router1Cfg diff --git a/common/timing.cc b/common/timing.cc index 60aef3fa..599d6dbd 100644 --- a/common/timing.cc +++ b/common/timing.cc @@ -658,10 +658,11 @@ void assign_budget(Context *ctx, bool quiet) { if (!quiet) { log_break(); - log_info("Annotating ports with timing budgets for target frequency %.2f MHz\n", ctx->setting<float>("target_freq") / 1e6); + log_info("Annotating ports with timing budgets for target frequency %.2f MHz\n", + ctx->setting<float>("target_freq") / 1e6); } - Timing timing(ctx, ctx->setting<int>("slack_redist_iter")> 0 /* net_delays */, true /* update */); + Timing timing(ctx, ctx->setting<int>("slack_redist_iter") > 0 /* net_delays */, true /* update */); timing.assign_budget(); if (!quiet || ctx->verbose) { @@ -686,11 +687,12 @@ void assign_budget(Context *ctx, bool quiet) // currently achieved maximum if (ctx->setting<bool>("auto_freq") && ctx->setting<int>("slack_redist_iter") > 0) { delay_t default_slack = delay_t((1.0e9 / ctx->getDelayNS(1)) / ctx->setting<float>("target_freq")); - ctx->settings[ctx->id("target_freq")] = std::to_string(1.0e9 / ctx->getDelayNS(default_slack - timing.min_slack)); + ctx->settings[ctx->id("target_freq")] = + std::to_string(1.0e9 / ctx->getDelayNS(default_slack - timing.min_slack)); if (ctx->verbose) log_info("minimum slack for this assign = %.2f ns, target Fmax for next " "update = %.2f MHz\n", - ctx->getDelayNS(timing.min_slack),ctx->setting<float>("target_freq") / 1e6); + ctx->getDelayNS(timing.min_slack), ctx->setting<float>("target_freq") / 1e6); } if (!quiet) diff --git a/common/timing_opt.h b/common/timing_opt.h index cdc02406..775d9596 100644 --- a/common/timing_opt.h +++ b/common/timing_opt.h @@ -17,8 +17,8 @@ * */ -#include "nextpnr.h" #include "log.h" +#include "nextpnr.h" NEXTPNR_NAMESPACE_BEGIN |