clangformat run
This commit is contained in:
parent
ec47ce2320
commit
be47fc3e9a
@ -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))
|
||||
|
@ -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){};
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
Property& operator=(std::string other)
|
||||
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)
|
||||
{
|
||||
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);
|
||||
|
@ -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 */);
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef PLACE_H
|
||||
#define PLACE_H
|
||||
|
||||
#include "nextpnr.h"
|
||||
#include "log.h"
|
||||
#include "nextpnr.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
#ifndef PLACER_HEAP_H
|
||||
#define PLACER_HEAP_H
|
||||
#include "nextpnr.h"
|
||||
#include "log.h"
|
||||
#include "nextpnr.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
#ifndef ROUTER1_H
|
||||
#define ROUTER1_H
|
||||
|
||||
#include "nextpnr.h"
|
||||
#include "log.h"
|
||||
#include "nextpnr.h"
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
struct Router1Cfg
|
||||
|
@ -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)
|
||||
|
@ -17,8 +17,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "nextpnr.h"
|
||||
#include "log.h"
|
||||
#include "nextpnr.h"
|
||||
|
||||
NEXTPNR_NAMESPACE_BEGIN
|
||||
|
||||
|
36
ecp5/main.cc
36
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);
|
||||
|
@ -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();
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
|
@ -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());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user