aboutsummaryrefslogtreecommitdiffstats
path: root/ice40
diff options
context:
space:
mode:
authorDavid Shah <davey1576@gmail.com>2018-07-04 15:26:09 +0200
committerDavid Shah <davey1576@gmail.com>2018-07-04 15:26:09 +0200
commit726f2020f140a1f5e89e966e7cbde1d1f79473ba (patch)
treecd4dd51251c46bf5c17064e7e029e81740406587 /ice40
parent11fb625195168c0b6c4d49cfb2a9ed9a70108ccf (diff)
downloadnextpnr-726f2020f140a1f5e89e966e7cbde1d1f79473ba.tar.gz
nextpnr-726f2020f140a1f5e89e966e7cbde1d1f79473ba.tar.bz2
nextpnr-726f2020f140a1f5e89e966e7cbde1d1f79473ba.zip
python: Convert empty BelId to None
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'ice40')
-rw-r--r--ice40/arch_pybindings.cc2
-rw-r--r--ice40/arch_pybindings.h10
2 files changed, 9 insertions, 3 deletions
diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc
index bcf6039d..4cbfc8af 100644
--- a/ice40/arch_pybindings.cc
+++ b/ice40/arch_pybindings.cc
@@ -20,9 +20,9 @@
#ifndef NO_PYTHON
-#include "pybindings.h"
#include "arch_pybindings.h"
#include "nextpnr.h"
+#include "pybindings.h"
NEXTPNR_NAMESPACE_BEGIN
diff --git a/ice40/arch_pybindings.h b/ice40/arch_pybindings.h
index 42fe8a6d..e502905f 100644
--- a/ice40/arch_pybindings.h
+++ b/ice40/arch_pybindings.h
@@ -21,8 +21,9 @@
#define ARCH_PYBINDINGS_H
#ifndef NO_PYTHON
-#include "pybindings.h"
#include "nextpnr.h"
+#include "pybindings.h"
+#include "pywrappers.h"
NEXTPNR_NAMESPACE_BEGIN
@@ -32,7 +33,12 @@ template <> struct string_converter<BelId>
{
BelId from_str(Context *ctx, std::string name) { return ctx->getBelByName(ctx->id(name)); }
- std::string to_str(Context *ctx, BelId id) { return ctx->getBelName(id).str(ctx); }
+ std::string to_str(Context *ctx, BelId id)
+ {
+ if (id == BelId())
+ throw bad_wrap();
+ return ctx->getBelName(id).str(ctx);
+ }
};
template <> struct string_converter<BelType>