aboutsummaryrefslogtreecommitdiffstats
path: root/common/nextpnr.h
diff options
context:
space:
mode:
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r--common/nextpnr.h13
1 files changed, 13 insertions, 0 deletions
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