aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-15 13:09:49 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-15 13:09:49 +0200
commit95280060b869f266beaff023dd63d74905c39ef4 (patch)
tree98d49d09ef31161ea712341767ff7019616cb342 /common
parent66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 (diff)
downloadnextpnr-95280060b869f266beaff023dd63d74905c39ef4.tar.gz
nextpnr-95280060b869f266beaff023dd63d74905c39ef4.tar.bz2
nextpnr-95280060b869f266beaff023dd63d74905c39ef4.zip
No need for settings class
Diffstat (limited to 'common')
-rw-r--r--common/command.cc22
-rw-r--r--common/command.h3
-rw-r--r--common/nextpnr.h13
-rw-r--r--common/placer1.cc10
-rw-r--r--common/placer1.h4
-rw-r--r--common/placer_heap.cc10
-rw-r--r--common/placer_heap.h4
-rw-r--r--common/router1.cc10
-rw-r--r--common/router1.h5
-rw-r--r--common/settings.h66
-rw-r--r--common/timing_opt.h6
11 files changed, 48 insertions, 105 deletions
diff --git a/common/command.cc b/common/command.cc
index 1a8f810e..ca054532 100644
--- a/common/command.cc
+++ b/common/command.cc
@@ -192,11 +192,11 @@ void CommandHandler::setupContext(Context *ctx)
}
if (vm.count("ignore-loops")) {
- settings->set("timing/ignoreLoops", true);
+ ctx->settings[ctx->id("timing/ignoreLoops")] = std::to_string(true);
}
if (vm.count("timing-allow-fail")) {
- settings->set("timing/allowFail", true);
+ ctx->settings[ctx->id("timing/allowFail")] = std::to_string(true);
}
if (vm.count("placer")) {
@@ -205,20 +205,20 @@ void CommandHandler::setupContext(Context *ctx)
Arch::availablePlacers.end())
log_error("Placer algorithm '%s' is not supported (available options: %s)\n", placer.c_str(),
boost::algorithm::join(Arch::availablePlacers, ", ").c_str());
- settings->set("placer", placer);
+ ctx->settings[ctx->id("placer")] = placer;
} else {
- settings->set("placer", Arch::defaultPlacer);
+ ctx->settings[ctx->id("placer")] = Arch::defaultPlacer;
}
if (vm.count("cstrweight")) {
- settings->set("placer1/constraintWeight", vm["cstrweight"].as<float>());
+ ctx->settings[ctx->id("placer1/constraintWeight")] = std::to_string(vm["cstrweight"].as<float>());
}
if (vm.count("starttemp")) {
- settings->set("placer1/startTemp", vm["starttemp"].as<float>());
+ ctx->settings[ctx->id("placer1/startTemp")] = std::to_string(vm["starttemp"].as<float>());
}
if (vm.count("placer-budgets")) {
- settings->set("placer1/budgetBased", true);
+ ctx->settings[ctx->id("placer1/budgetBased")] = std::to_string(true);
}
if (vm.count("freq")) {
auto freq = vm["freq"].as<double>();
@@ -230,9 +230,9 @@ void CommandHandler::setupContext(Context *ctx)
if (vm.count("no-tmdriv"))
ctx->timing_driven = false;
- settings->set("arch.name", std::string(ctx->archId().c_str(ctx)));
- settings->set("arch.type", std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx)));
- settings->set("seed", ctx->rngstate);
+ ctx->settings[ctx->id("arch.name")] = std::string(ctx->archId().c_str(ctx));
+ ctx->settings[ctx->id("arch.type")] = std::string(ctx->archArgsToId(ctx->archArgs()).c_str(ctx));
+ ctx->settings[ctx->id("seed")] = std::to_string(ctx->rngstate);
}
int CommandHandler::executeMain(std::unique_ptr<Context> ctx)
@@ -366,7 +366,6 @@ int CommandHandler::exec()
log_error("Loading design failed.\n");
}
std::unique_ptr<Context> ctx = createContext(values);
- settings = std::unique_ptr<Settings>(new Settings(ctx.get()));
setupContext(ctx.get());
setupArchContext(ctx.get());
int rc = executeMain(std::move(ctx));
@@ -388,7 +387,6 @@ std::unique_ptr<Context> CommandHandler::load_json(std::string filename)
log_error("Loading design failed.\n");
}
std::unique_ptr<Context> ctx = createContext(values);
- settings = std::unique_ptr<Settings>(new Settings(ctx.get()));
setupContext(ctx.get());
setupArchContext(ctx.get());
{
diff --git a/common/command.h b/common/command.h
index c7b58517..b5908e3f 100644
--- a/common/command.h
+++ b/common/command.h
@@ -24,7 +24,7 @@
#include <boost/program_options.hpp>
#include <fstream>
#include "nextpnr.h"
-#include "settings.h"
+#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -59,7 +59,6 @@ class CommandHandler
protected:
po::variables_map vm;
- std::unique_ptr<Settings> settings;
private:
po::options_description options;
diff --git a/common/nextpnr.h b/common/nextpnr.h
index 66134456..b796b8aa 100644
--- a/common/nextpnr.h
+++ b/common/nextpnr.h
@@ -32,6 +32,7 @@
#include <vector>
#include <boost/functional/hash.hpp>
+#include <boost/lexical_cast.hpp>
#ifndef NEXTPNR_H
#define NEXTPNR_H
@@ -724,6 +725,18 @@ struct Context : Arch, DeterministicRNG
void check() const;
void archcheck() const;
+
+ template <typename T> T setting(const char *name, T defaultValue)
+ {
+ IdString new_id = id(name);
+ if (settings.find(new_id) != settings.end())
+ return boost::lexical_cast<T>(settings.find(new_id)->second.str);
+ else
+ settings[id(name)] = std::to_string(defaultValue);
+
+ return defaultValue;
+ }
+
};
NEXTPNR_NAMESPACE_END
diff --git a/common/placer1.cc b/common/placer1.cc
index a8ddd8a6..89e4f919 100644
--- a/common/placer1.cc
+++ b/common/placer1.cc
@@ -1131,12 +1131,12 @@ class SAPlacer
Placer1Cfg cfg;
};
-Placer1Cfg::Placer1Cfg(Context *ctx) : Settings(ctx)
+Placer1Cfg::Placer1Cfg(Context *ctx)
{
- constraintWeight = get<float>("placer1/constraintWeight", 10);
- minBelsForGridPick = get<int>("placer1/minBelsForGridPick", 64);
- budgetBased = get<bool>("placer1/budgetBased", false);
- startTemp = get<float>("placer1/startTemp", 1);
+ constraintWeight = ctx->setting<float>("placer1/constraintWeight", 10);
+ minBelsForGridPick = ctx->setting<int>("placer1/minBelsForGridPick", 64);
+ budgetBased = ctx->setting<bool>("placer1/budgetBased", false);
+ startTemp = ctx->setting<float>("placer1/startTemp", 1);
timingFanoutThresh = std::numeric_limits<int>::max();
}
diff --git a/common/placer1.h b/common/placer1.h
index 4c7c7339..0f2e2894 100644
--- a/common/placer1.h
+++ b/common/placer1.h
@@ -20,11 +20,11 @@
#define PLACE_H
#include "nextpnr.h"
-#include "settings.h"
+#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
-struct Placer1Cfg : public Settings
+struct Placer1Cfg
{
Placer1Cfg(Context *ctx);
float constraintWeight;
diff --git a/common/placer_heap.cc b/common/placer_heap.cc
index f9b639f8..4d1f4863 100644
--- a/common/placer_heap.cc
+++ b/common/placer_heap.cc
@@ -1516,11 +1516,11 @@ int HeAPPlacer::CutSpreader::seq = 0;
bool placer_heap(Context *ctx, PlacerHeapCfg cfg) { return HeAPPlacer(ctx, cfg).place(); }
-PlacerHeapCfg::PlacerHeapCfg(Context *ctx) : Settings(ctx)
+PlacerHeapCfg::PlacerHeapCfg(Context *ctx)
{
- alpha = get<float>("placerHeap/alpha", 0.1);
- criticalityExponent = get<int>("placerHeap/criticalityExponent", 2);
- timingWeight = get<int>("placerHeap/timingWeight", 10);
+ alpha = ctx->setting<float>("placerHeap/alpha", 0.1);
+ criticalityExponent = ctx->setting<int>("placerHeap/criticalityExponent", 2);
+ timingWeight = ctx->setting<int>("placerHeap/timingWeight", 10);
}
NEXTPNR_NAMESPACE_END
@@ -1538,7 +1538,7 @@ bool placer_heap(Context *ctx, PlacerHeapCfg cfg)
return false;
}
-PlacerHeapCfg::PlacerHeapCfg(Context *ctx) : Settings(ctx) {}
+PlacerHeapCfg::PlacerHeapCfg(Context *ctx) {}
NEXTPNR_NAMESPACE_END
diff --git a/common/placer_heap.h b/common/placer_heap.h
index 841aa0d9..2def5e75 100644
--- a/common/placer_heap.h
+++ b/common/placer_heap.h
@@ -27,11 +27,11 @@
#ifndef PLACER_HEAP_H
#define PLACER_HEAP_H
#include "nextpnr.h"
-#include "settings.h"
+#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
-struct PlacerHeapCfg : public Settings
+struct PlacerHeapCfg
{
PlacerHeapCfg(Context *ctx);
diff --git a/common/router1.cc b/common/router1.cc
index 28a422c8..02c817c7 100644
--- a/common/router1.cc
+++ b/common/router1.cc
@@ -733,12 +733,12 @@ struct Router1
NEXTPNR_NAMESPACE_BEGIN
-Router1Cfg::Router1Cfg(Context *ctx) : Settings(ctx)
+Router1Cfg::Router1Cfg(Context *ctx)
{
- maxIterCnt = get<int>("router1/maxIterCnt", 200);
- cleanupReroute = get<bool>("router1/cleanupReroute", true);
- fullCleanupReroute = get<bool>("router1/fullCleanupReroute", true);
- useEstimate = get<bool>("router1/useEstimate", true);
+ maxIterCnt = ctx->setting<int>("router1/maxIterCnt", 200);
+ cleanupReroute = ctx->setting<bool>("router1/cleanupReroute", true);
+ fullCleanupReroute = ctx->setting<bool>("router1/fullCleanupReroute", true);
+ useEstimate = ctx->setting<bool>("router1/useEstimate", true);
wireRipupPenalty = ctx->getRipupDelayPenalty();
netRipupPenalty = 10 * ctx->getRipupDelayPenalty();
diff --git a/common/router1.h b/common/router1.h
index 80d7aa96..f3d325ad 100644
--- a/common/router1.h
+++ b/common/router1.h
@@ -21,11 +21,10 @@
#define ROUTER1_H
#include "nextpnr.h"
-#include "settings.h"
-
+#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
-struct Router1Cfg : Settings
+struct Router1Cfg
{
Router1Cfg(Context *ctx);
diff --git a/common/settings.h b/common/settings.h
deleted file mode 100644
index 9d43c774..00000000
--- a/common/settings.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * nextpnr -- Next Generation Place and Route
- *
- * Copyright (C) 2018 Miodrag Milanovic <miodrag@symbioticeda.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- */
-#ifndef SETTINGS_H
-#define SETTINGS_H
-
-#include <boost/lexical_cast.hpp>
-#include "log.h"
-#include "nextpnr.h"
-
-NEXTPNR_NAMESPACE_BEGIN
-
-class Settings
-{
- public:
- explicit Settings(Context *ctx) : ctx(ctx) {}
-
- template <typename T> T get(const char *name, T defaultValue)
- {
- try {
- IdString id = ctx->id(name);
- if (ctx->settings.find(id) != ctx->settings.end())
- return boost::lexical_cast<T>(ctx->settings.find(id)->second.str);
- else
- ctx->settings[ctx->id(name)] = std::to_string(defaultValue);
-
- } catch (boost::bad_lexical_cast &) {
- log_error("Problem reading setting %s, using default value\n", name);
- }
- return defaultValue;
- }
-
- template <typename T> void set(const char *name, T value);
-
- private:
- Context *ctx;
-};
-
-template <typename T> inline void Settings::set(const char *name, T value)
-{
- ctx->settings[ctx->id(name)] = std::to_string(value);
-}
-
-template <> inline void Settings::set<std::string>(const char *name, std::string value)
-{
- ctx->settings[ctx->id(name)] = value;
-}
-
-NEXTPNR_NAMESPACE_END
-
-#endif // SETTINGS_H
diff --git a/common/timing_opt.h b/common/timing_opt.h
index ceb35c71..cdc02406 100644
--- a/common/timing_opt.h
+++ b/common/timing_opt.h
@@ -18,13 +18,13 @@
*/
#include "nextpnr.h"
-#include "settings.h"
+#include "log.h"
NEXTPNR_NAMESPACE_BEGIN
-struct TimingOptCfg : public Settings
+struct TimingOptCfg
{
- TimingOptCfg(Context *ctx) : Settings(ctx) {}
+ TimingOptCfg(Context *ctx) {}
// The timing optimiser will *only* optimise cells of these types
// Normally these would only be logic cells (or tiles if applicable), the algorithm makes little sense