aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/arch_pybindings.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 /ecp5/arch_pybindings.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 'ecp5/arch_pybindings.h')
-rw-r--r--ecp5/arch_pybindings.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/ecp5/arch_pybindings.h b/ecp5/arch_pybindings.h
new file mode 100644
index 00000000..a5044f29
--- /dev/null
+++ b/ecp5/arch_pybindings.h
@@ -0,0 +1,75 @@
+/*
+ * nextpnr -- Next Generation Place and Route
+ *
+ * Copyright (C) 2018 Clifford Wolf <clifford@symbioticeda.com>
+ * Copyright (C) 2018 David Shah <david@symbioticeda.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+#ifndef ARCH_PYBINDINGS_H
+#define ARCH_PYBINDINGS_H
+#ifndef NO_PYTHON
+
+#include "nextpnr.h"
+#include "pybindings.h"
+
+NEXTPNR_NAMESPACE_BEGIN
+
+namespace PythonConversion {
+
+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)
+ {
+ if (id == BelId())
+ throw bad_wrap();
+ return ctx->getBelName(id).str(ctx);
+ }
+};
+
+template <> struct string_converter<BelType>
+{
+ BelType from_str(Context *ctx, std::string name) { return ctx->belTypeFromId(ctx->id(name)); }
+
+ std::string to_str(Context *ctx, BelType typ) { return ctx->belTypeToId(typ).str(ctx); }
+};
+
+template <> struct string_converter<WireId>
+{
+ WireId from_str(Context *ctx, std::string name) { return ctx->getWireByName(ctx->id(name)); }
+
+ std::string to_str(Context *ctx, WireId id) { return ctx->getWireName(id).str(ctx); }
+};
+
+template <> struct string_converter<PipId>
+{
+ PipId from_str(Context *ctx, std::string name) { return ctx->getPipByName(ctx->id(name)); }
+
+ std::string to_str(Context *ctx, PipId id) { return ctx->getPipName(id).str(ctx); }
+};
+
+template <> struct string_converter<PortPin>
+{
+ PortPin from_str(Context *ctx, std::string name) { return ctx->portPinFromId(ctx->id(name)); }
+
+ std::string to_str(Context *ctx, PortPin id) { return ctx->portPinToId(id).str(ctx); }
+};
+
+} // namespace PythonConversion
+
+NEXTPNR_NAMESPACE_END
+#endif
+#endif