aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-06-22 12:57:22 +0200
committerDavid Shah <davey1576@gmail.com>2018-06-22 12:57:22 +0200
commit63baa10032ecf301523e4cb1fca198d8a8b79e23 (patch)
tree248c430920d910bd20eaf136db6c370b3f5252ac /common
parent71176ac5384c696dde1d5601ea1beb5c46f281c6 (diff)
downloadnextpnr-63baa10032ecf301523e4cb1fca198d8a8b79e23.tar.gz
nextpnr-63baa10032ecf301523e4cb1fca198d8a8b79e23.tar.bz2
nextpnr-63baa10032ecf301523e4cb1fca198d8a8b79e23.zip
ice40: Make the packer deterministic
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/util.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 34b2ed02..8151564f 100644
--- a/common/util.h
+++ b/common/util.h
@@ -21,6 +21,7 @@
#define UTIL_H
#include <string>
+#include <map>
#include "nextpnr.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -56,6 +57,13 @@ bool bool_or_default(const Container &ct, const KeyType &key, bool def = false)
{
return bool(int_or_default(ct, key, int(def)));
};
+
+// Wrap an unordered_map, and allow it to be iterated over sorted by key
+template <typename K, typename V> std::map<K, V> sorted(const std::unordered_map<K, V> &orig) {
+ return std::map<K, V>(orig.begin(), orig.end());
+};
+
+
NEXTPNR_NAMESPACE_END
#endif