aboutsummaryrefslogtreecommitdiffstats
path: root/common/util.h
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-11 09:09:18 +0000
committerDavid Shah <davey1576@gmail.com>2018-07-11 09:09:18 +0000
commita70f5ce109309119d5ab45ee53f7cd3549144871 (patch)
treee8fb02674ffff3e45b4c3b7bf7e010148b32ad51 /common/util.h
parentd5be9ff5845e17f17a22fb11cdb5099a84a6bb4d (diff)
parentbcc63091fb30ac15c9f98bfc3b3a41d921af0bd4 (diff)
downloadnextpnr-a70f5ce109309119d5ab45ee53f7cd3549144871.tar.gz
nextpnr-a70f5ce109309119d5ab45ee53f7cd3549144871.tar.bz2
nextpnr-a70f5ce109309119d5ab45ee53f7cd3549144871.zip
Merge branch 'ecp5' into 'master'
Adding ECP5 support See merge request SymbioticEDA/nextpnr!5
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 60eb35af..8f361dc8 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)
@@ -84,6 +96,7 @@ inline const NetInfo *get_net_or_empty(const CellInfo *cell, const IdString port
else
return nullptr;
};
+
NEXTPNR_NAMESPACE_END
#endif