aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/command.cc22
-rw-r--r--common/command.h4
-rw-r--r--common/nextpnr.cc47
-rw-r--r--common/nextpnr.h37
-rw-r--r--common/placer1.cc3
-rw-r--r--common/placer1.h2
-rw-r--r--common/placer_heap.h2
-rw-r--r--common/router1.h2
-rw-r--r--common/timing.cc10
-rw-r--r--common/timing_opt.h2
-rw-r--r--ecp5/main.cc36
-rw-r--r--generic/arch.cc3
-rw-r--r--generic/main.cc8
-rw-r--r--gui/basewindow.cc17
-rw-r--r--gui/basewindow.h2
-rw-r--r--gui/ecp5/mainwindow.cc9
-rw-r--r--gui/ice40/mainwindow.cc7
-rw-r--r--ice40/arch.cc5
-rw-r--r--ice40/main.cc16
-rw-r--r--ice40/pack.cc32
-rw-r--r--json/jsonparse.cc32
-rw-r--r--json/jsonparse.h3
-rw-r--r--json/jsonwrite.cc32
23 files changed, 171 insertions, 162 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
diff --git a/ecp5/main.cc b/ecp5/main.cc
index fa0783e1..75126cea 100644
--- a/ecp5/main.cc
+++ b/ecp5/main.cc
@@ -34,7 +34,7 @@ class ECP5CommandHandler : public CommandHandler
public:
ECP5CommandHandler(int argc, char **argv);
virtual ~ECP5CommandHandler(){};
- std::unique_ptr<Context> createContext(std::unordered_map<std::string,Property> &values) override;
+ std::unique_ptr<Context> createContext(std::unordered_map<std::string, Property> &values) override;
void setupArchContext(Context *ctx) override{};
void customAfterLoad(Context *ctx) override;
void validate() override;
@@ -100,16 +100,20 @@ void ECP5CommandHandler::customBitstream(Context *ctx)
static std::string speedString(ArchArgs::SpeedGrade speed)
{
- switch(speed){
- case ArchArgs::SPEED_6: return "6";
- case ArchArgs::SPEED_7: return "7";
- case ArchArgs::SPEED_8: return "8";
- case ArchArgs::SPEED_8_5G: return "8";
+ switch (speed) {
+ case ArchArgs::SPEED_6:
+ return "6";
+ case ArchArgs::SPEED_7:
+ return "7";
+ case ArchArgs::SPEED_8:
+ return "8";
+ case ArchArgs::SPEED_8_5G:
+ return "8";
}
return "";
}
-std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<std::string,Property> &values)
+std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<std::string, Property> &values)
{
ArchArgs chipArgs;
chipArgs.type = ArchArgs::NONE;
@@ -154,15 +158,15 @@ std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<st
if (chipArgs.type == ArchArgs::LFE5UM5G_25F || chipArgs.type == ArchArgs::LFE5UM5G_45F ||
chipArgs.type == ArchArgs::LFE5UM5G_85F) {
chipArgs.speed = ArchArgs::SPEED_8;
- } else
+ } else
chipArgs.speed = ArchArgs::SPEED_6;
}
- if (values.find("arch.name")!=values.end()) {
+ if (values.find("arch.name") != values.end()) {
std::string arch_name = values["arch.name"].str;
if (arch_name != "ecp5")
log_error("Unsuported architecture '%s'.\n", arch_name.c_str());
}
- if (values.find("arch.type")!=values.end()) {
+ if (values.find("arch.type") != values.end()) {
std::string arch_type = values["arch.type"].str;
if (chipArgs.type != ArchArgs::NONE)
log_error("Overriding architecture is unsuported.\n");
@@ -187,14 +191,14 @@ std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<st
chipArgs.type = ArchArgs::LFE5UM5G_85F;
if (chipArgs.type == ArchArgs::NONE)
- log_error("Unsuported FPGA type '%s'.\n",arch_type.c_str());
+ log_error("Unsuported FPGA type '%s'.\n", arch_type.c_str());
}
- if (values.find("arch.package")!=values.end()) {
+ if (values.find("arch.package") != values.end()) {
if (vm.count("package"))
log_error("Overriding architecture is unsuported.\n");
chipArgs.package = values["arch.package"].str;
}
- if (values.find("arch.speed")!=values.end()) {
+ if (values.find("arch.speed") != values.end()) {
std::string arch_speed = values["arch.speed"].str;
if (arch_speed == "6")
chipArgs.speed = ArchArgs::SPEED_6;
@@ -202,8 +206,8 @@ std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<st
chipArgs.speed = ArchArgs::SPEED_7;
else if (arch_speed == "8")
chipArgs.speed = ArchArgs::SPEED_8;
- else
- log_error("Unsuported speed '%s'.\n",arch_speed.c_str());
+ else
+ log_error("Unsuported speed '%s'.\n", arch_speed.c_str());
}
if (chipArgs.type == ArchArgs::NONE)
chipArgs.type = ArchArgs::LFE5U_45F;
@@ -220,7 +224,7 @@ std::unique_ptr<Context> ECP5CommandHandler::createContext(std::unordered_map<st
}
auto ctx = std::unique_ptr<Context>(new Context(chipArgs));
- for(auto &val : values)
+ for (auto &val : values)
ctx->settings[ctx->id(val.first)] = val.second;
ctx->settings[ctx->id("arch.package")] = ctx->archArgs().package;
ctx->settings[ctx->id("arch.speed")] = speedString(ctx->archArgs().speed);
diff --git a/generic/arch.cc b/generic/arch.cc
index 2db9e547..fa3c825d 100644
--- a/generic/arch.cc
+++ b/generic/arch.cc
@@ -505,7 +505,8 @@ bool Arch::place()
}
}
-bool Arch::route() {
+bool Arch::route()
+{
bool retVal = router1(getCtx(), Router1Cfg(getCtx()));
getCtx()->settings[getCtx()->id("route")] = "1";
archInfoToAttributes();
diff --git a/generic/main.cc b/generic/main.cc
index 1f0ee22d..ce1a51c7 100644
--- a/generic/main.cc
+++ b/generic/main.cc
@@ -32,7 +32,7 @@ class GenericCommandHandler : public CommandHandler
public:
GenericCommandHandler(int argc, char **argv);
virtual ~GenericCommandHandler(){};
- std::unique_ptr<Context> createContext(std::unordered_map<std::string,Property> &values) override;
+ std::unique_ptr<Context> createContext(std::unordered_map<std::string, Property> &values) override;
void setupArchContext(Context *ctx) override{};
void customBitstream(Context *ctx) override;
@@ -51,14 +51,14 @@ po::options_description GenericCommandHandler::getArchOptions()
void GenericCommandHandler::customBitstream(Context *ctx) {}
-std::unique_ptr<Context> GenericCommandHandler::createContext(std::unordered_map<std::string,Property> &values)
+std::unique_ptr<Context> GenericCommandHandler::createContext(std::unordered_map<std::string, Property> &values)
{
ArchArgs chipArgs;
- if (values.find("arch.name")!=values.end()) {
+ if (values.find("arch.name") != values.end()) {
std::string arch_name = values["arch.name"].str;
if (arch_name != "generic")
log_error("Unsuported architecture '%s'.\n", arch_name.c_str());
- }
+ }
return std::unique_ptr<Context>(new Context(chipArgs));
}
diff --git a/gui/basewindow.cc b/gui/basewindow.cc
index 5b03b667..550a4b93 100644
--- a/gui/basewindow.cc
+++ b/gui/basewindow.cc
@@ -310,11 +310,11 @@ void BaseMainWindow::save_json()
{
QString fileName = QFileDialog::getSaveFileName(this, QString("Save JSON"), QString(), QString("*.json"));
if (!fileName.isEmpty()) {
- std::string fn = fileName.toStdString();
+ std::string fn = fileName.toStdString();
std::ofstream f(fn);
if (write_json_file(f, fn, ctx.get()))
log("Saving JSON successful.\n");
- else
+ else
log("Saving JSON failed.\n");
}
}
@@ -335,7 +335,7 @@ void BaseMainWindow::budget_finish(bool status)
{
disableActions();
if (status) {
- log("Assigning timing budget successful.\n");
+ log("Assigning timing budget successful.\n");
updateActions();
} else {
log("Assigning timing budget failed.\n");
@@ -399,7 +399,7 @@ void BaseMainWindow::place() { Q_EMIT task->place(timing_driven); }
void BaseMainWindow::disableActions()
{
- actionLoadJSON->setEnabled(true);
+ actionLoadJSON->setEnabled(true);
actionPack->setEnabled(false);
actionAssignBudget->setEnabled(false);
actionPlace->setEnabled(false);
@@ -416,13 +416,12 @@ void BaseMainWindow::disableActions()
void BaseMainWindow::updateActions()
{
- if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
+ if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
actionPack->setEnabled(true);
- else if (ctx->settings.find(ctx->id("place"))==ctx->settings.end()) {
+ else if (ctx->settings.find(ctx->id("place")) == ctx->settings.end()) {
actionAssignBudget->setEnabled(true);
- actionPlace->setEnabled(true);
- }
- else if (ctx->settings.find(ctx->id("route"))==ctx->settings.end())
+ actionPlace->setEnabled(true);
+ } else if (ctx->settings.find(ctx->id("route")) == ctx->settings.end())
actionRoute->setEnabled(true);
onUpdateActions();
diff --git a/gui/basewindow.h b/gui/basewindow.h
index 4276c401..305cb6c9 100644
--- a/gui/basewindow.h
+++ b/gui/basewindow.h
@@ -20,9 +20,9 @@
#ifndef BASEMAINWINDOW_H
#define BASEMAINWINDOW_H
+#include "command.h"
#include "nextpnr.h"
#include "worker.h"
-#include "command.h"
#include <QMainWindow>
#include <QMenu>
diff --git a/gui/ecp5/mainwindow.cc b/gui/ecp5/mainwindow.cc
index b06e10e9..880af047 100644
--- a/gui/ecp5/mainwindow.cc
+++ b/gui/ecp5/mainwindow.cc
@@ -164,10 +164,11 @@ void MainWindow::onDisableActions()
actionSaveConfig->setEnabled(false);
}
-void MainWindow::onUpdateActions() {
- if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
- actionLoadLPF->setEnabled(true);
- if (ctx->settings.find(ctx->id("route"))!=ctx->settings.end())
+void MainWindow::onUpdateActions()
+{
+ if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
+ actionLoadLPF->setEnabled(true);
+ if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
actionSaveConfig->setEnabled(true);
}
diff --git a/gui/ice40/mainwindow.cc b/gui/ice40/mainwindow.cc
index c2ac264f..ccff2117 100644
--- a/gui/ice40/mainwindow.cc
+++ b/gui/ice40/mainwindow.cc
@@ -186,10 +186,11 @@ void MainWindow::onDisableActions()
actionSaveAsc->setEnabled(false);
}
-void MainWindow::onUpdateActions() {
- if (ctx->settings.find(ctx->id("pack"))==ctx->settings.end())
+void MainWindow::onUpdateActions()
+{
+ if (ctx->settings.find(ctx->id("pack")) == ctx->settings.end())
actionLoadPCF->setEnabled(true);
- if (ctx->settings.find(ctx->id("route"))!=ctx->settings.end())
+ if (ctx->settings.find(ctx->id("route")) != ctx->settings.end())
actionSaveAsc->setEnabled(true);
}
diff --git a/ice40/arch.cc b/ice40/arch.cc
index d58951dd..0b1d280c 100644
--- a/ice40/arch.cc
+++ b/ice40/arch.cc
@@ -694,8 +694,9 @@ bool Arch::place()
return retVal;
}
-bool Arch::route() {
- bool retVal = router1(getCtx(), Router1Cfg(getCtx()));
+bool Arch::route()
+{
+ bool retVal = router1(getCtx(), Router1Cfg(getCtx()));
getCtx()->settings[getCtx()->id("route")] = "1";
archInfoToAttributes();
return retVal;
diff --git a/ice40/main.cc b/ice40/main.cc
index de618cbf..83cb04b0 100644
--- a/ice40/main.cc
+++ b/ice40/main.cc
@@ -36,7 +36,7 @@ class Ice40CommandHandler : public CommandHandler
public:
Ice40CommandHandler(int argc, char **argv);
virtual ~Ice40CommandHandler(){};
- std::unique_ptr<Context> createContext(std::unordered_map<std::string,Property> &values) override;
+ std::unique_ptr<Context> createContext(std::unordered_map<std::string, Property> &values) override;
void setupArchContext(Context *ctx) override;
void validate() override;
void customAfterLoad(Context *ctx) override;
@@ -116,7 +116,7 @@ void Ice40CommandHandler::setupArchContext(Context *ctx)
}
}
-std::unique_ptr<Context> Ice40CommandHandler::createContext(std::unordered_map<std::string,Property> &values)
+std::unique_ptr<Context> Ice40CommandHandler::createContext(std::unordered_map<std::string, Property> &values)
{
ArchArgs chipArgs;
chipArgs.type = ArchArgs::NONE;
@@ -158,12 +158,12 @@ std::unique_ptr<Context> Ice40CommandHandler::createContext(std::unordered_map<s
if (vm.count("package"))
chipArgs.package = vm["package"].as<std::string>();
- if (values.find("arch.name")!=values.end()) {
+ if (values.find("arch.name") != values.end()) {
std::string arch_name = values["arch.name"].str;
if (arch_name != "ice40")
log_error("Unsuported architecture '%s'.\n", arch_name.c_str());
}
- if (values.find("arch.type")!=values.end()) {
+ if (values.find("arch.type") != values.end()) {
std::string arch_type = values["arch.type"].str;
if (chipArgs.type != ArchArgs::NONE)
log_error("Overriding architecture is unsuported.\n");
@@ -190,14 +190,14 @@ std::unique_ptr<Context> Ice40CommandHandler::createContext(std::unordered_map<s
chipArgs.type = ArchArgs::U4K;
}
if (chipArgs.type == ArchArgs::NONE)
- log_error("Unsuported FPGA type '%s'.\n",arch_type.c_str());
+ log_error("Unsuported FPGA type '%s'.\n", arch_type.c_str());
}
- if (values.find("arch.package")!=values.end()) {
+ if (values.find("arch.package") != values.end()) {
if (vm.count("package"))
log_error("Overriding architecture is unsuported.\n");
chipArgs.package = values["arch.package"].str;
}
-
+
if (chipArgs.type == ArchArgs::NONE) {
chipArgs.type = ArchArgs::HX1K;
chipArgs.package = "tq144";
@@ -209,7 +209,7 @@ std::unique_ptr<Context> Ice40CommandHandler::createContext(std::unordered_map<s
#endif
auto ctx = std::unique_ptr<Context>(new Context(chipArgs));
- for(auto &val : values)
+ for (auto &val : values)
ctx->settings[ctx->id(val.first)] = val.second;
ctx->settings[ctx->id("arch.package")] = ctx->archArgs().package;
diff --git a/ice40/pack.cc b/ice40/pack.cc
index 66c5c0e8..d1366c9c 100644
--- a/ice40/pack.cc
+++ b/ice40/pack.cc
@@ -340,10 +340,9 @@ static void pack_constants(Context *ctx)
gnd_net->driver.cell = gnd_cell.get();
gnd_net->driver.port = ctx->id("O");
gnd_cell->ports.at(ctx->id("O")).net = gnd_net.get();
-
- NetInfo* gnd_net_info = gnd_net.get();
- if (ctx->nets.find(ctx->id("$PACKER_GND_NET"))!=ctx->nets.end())
- {
+
+ NetInfo *gnd_net_info = gnd_net.get();
+ if (ctx->nets.find(ctx->id("$PACKER_GND_NET")) != ctx->nets.end()) {
gnd_net_info = ctx->nets.find(ctx->id("$PACKER_GND_NET"))->second.get();
}
@@ -354,10 +353,9 @@ static void pack_constants(Context *ctx)
vcc_net->driver.cell = vcc_cell.get();
vcc_net->driver.port = ctx->id("O");
vcc_cell->ports.at(ctx->id("O")).net = vcc_net.get();
-
- NetInfo* vcc_net_info = vcc_net.get();
- if (ctx->nets.find(ctx->id("$PACKER_VCC_NET"))!=ctx->nets.end())
- {
+
+ NetInfo *vcc_net_info = vcc_net.get();
+ if (ctx->nets.find(ctx->id("$PACKER_VCC_NET")) != ctx->nets.end()) {
vcc_net_info = ctx->nets.find(ctx->id("$PACKER_VCC_NET"))->second.get();
}
@@ -387,8 +385,7 @@ static void pack_constants(Context *ctx)
}
// Vcc cell always inserted for now, as it may be needed during carry legalisation (TODO: trim later if actually
// never used?)
- if (vcc_net_info == vcc_net.get())
- {
+ if (vcc_net_info == vcc_net.get()) {
ctx->cells[vcc_cell->name] = std::move(vcc_cell);
ctx->nets[vcc_net->name] = std::move(vcc_net);
}
@@ -1239,13 +1236,14 @@ static void pack_special(Context *ctx)
}
auto feedback_path = packed->params[ctx->id("FEEDBACK_PATH")];
- std::string fbp_value = feedback_path == "DELAY"
- ? "0"
- : feedback_path == "SIMPLE"
- ? "1"
- : feedback_path == "PHASE_AND_DELAY"
- ? "2"
- : feedback_path == "EXTERNAL" ? "6" : std::string(feedback_path);
+ std::string fbp_value =
+ feedback_path == "DELAY"
+ ? "0"
+ : feedback_path == "SIMPLE"
+ ? "1"
+ : feedback_path == "PHASE_AND_DELAY"
+ ? "2"
+ : feedback_path == "EXTERNAL" ? "6" : std::string(feedback_path);
if (!std::all_of(fbp_value.begin(), fbp_value.end(), isdigit))
log_error("PLL '%s' has unsupported FEEDBACK_PATH value '%s'\n", ci->name.c_str(ctx),
feedback_path.c_str());
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> &parameters, bool for_module=false)
+void write_parameters(std::ostream &f, Context *ctx, const std::unordered_map<IdString, Property> &parameters,
+ bool for_module = false)
{
bool first = true;
for (auto &param : 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);