No need for settings class
This commit is contained in:
parent
66ea9f39f7
commit
95280060b8
@ -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());
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user