aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-09 12:55:56 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-11 10:42:09 +0200
commitb397dd80712005e4c71b492e27d6af35e6bdc1e9 (patch)
treea0261de3869cdae576066de1698a9195eb4538b8 /common
parentbad926bcc3e4d77bcb76d54eff689a91233c71fb (diff)
downloadnextpnr-b397dd80712005e4c71b492e27d6af35e6bdc1e9.tar.gz
nextpnr-b397dd80712005e4c71b492e27d6af35e6bdc1e9.tar.bz2
nextpnr-b397dd80712005e4c71b492e27d6af35e6bdc1e9.zip
ecp5: Adding bitstream gen for slice config
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 60eb35af..b492b98c 100644
--- a/common/util.h
+++ b/common/util.h
@@ -39,6 +39,18 @@ ValueType get_or_default(const Container &ct, const KeyType &key, ValueType def
return found->second;
};
+// Get a value from a map-style container, returning default if value is not
+// found (forces string)
+template <typename Container, typename KeyType>
+std::string str_or_default(const Container &ct, const KeyType &key, std::string def = "")
+{
+ auto found = ct.find(key);
+ if (found == ct.end())
+ return def;
+ else
+ return found->second;
+};
+
// Get a value from a map-style container, converting to int, and returning
// default if value is not found
template <typename Container, typename KeyType> int int_or_default(const Container &ct, const KeyType &key, int def = 0)