aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/arch_pybindings.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2020-07-23 18:35:18 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2020-07-23 18:35:18 +0200
commit8f2b707d026597018333ac60e707e5ab78c25a91 (patch)
treeebf5c6490a56269d674a5d1d5357c7b5e2210872 /ice40/arch_pybindings.cc
parent444e535f000fd7b53dadf6726d5cd29ac34cc75f (diff)
downloadnextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.gz
nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.tar.bz2
nextpnr-8f2b707d026597018333ac60e707e5ab78c25a91.zip
Initial conversion to pybind11
Diffstat (limited to 'ice40/arch_pybindings.cc')
-rw-r--r--ice40/arch_pybindings.cc36
1 files changed, 17 insertions, 19 deletions
diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc
index 9dd17f01..9011d1dc 100644
--- a/ice40/arch_pybindings.cc
+++ b/ice40/arch_pybindings.cc
@@ -26,12 +26,12 @@
NEXTPNR_NAMESPACE_BEGIN
-void arch_wrap_python()
+void arch_wrap_python(py::module &m)
{
using namespace PythonConversion;
- class_<ArchArgs>("ArchArgs").def_readwrite("type", &ArchArgs::type);
+ py::class_<ArchArgs>(m, "ArchArgs").def_readwrite("type", &ArchArgs::type);
- enum_<decltype(std::declval<ArchArgs>().type)>("iCE40Type")
+ py::enum_<decltype(std::declval<ArchArgs>().type)>(m, "iCE40Type")
.value("NONE", ArchArgs::NONE)
.value("LP384", ArchArgs::LP384)
.value("LP1K", ArchArgs::LP1K)
@@ -47,16 +47,14 @@ void arch_wrap_python()
.value("U4K", ArchArgs::U4K)
.export_values();
- class_<BelId>("BelId").def_readwrite("index", &BelId::index);
+ py::class_<BelId>(m, "BelId").def_readwrite("index", &BelId::index);
- class_<WireId>("WireId").def_readwrite("index", &WireId::index);
+ py::class_<WireId>(m, "WireId").def_readwrite("index", &WireId::index);
- class_<PipId>("PipId").def_readwrite("index", &PipId::index);
+ py::class_<PipId>(m, "PipId").def_readwrite("index", &PipId::index);
- class_<BelPin>("BelPin").def_readwrite("bel", &BelPin::bel).def_readwrite("pin", &BelPin::pin);
-
- auto arch_cls = class_<Arch, Arch *, bases<BaseCtx>, boost::noncopyable>("Arch", init<ArchArgs>());
- auto ctx_cls = class_<Context, Context *, bases<Arch>, boost::noncopyable>("Context", no_init)
+ auto arch_cls = py::class_<Arch, BaseCtx>(m, "Arch").def(py::init<ArchArgs>());
+ auto ctx_cls = py::class_<Context, Arch>(m, "Context")
.def("checksum", &Context::checksum)
.def("pack", &Context::pack)
.def("place", &Context::place)
@@ -70,21 +68,21 @@ void arch_wrap_python()
typedef std::unordered_map<IdString, IdString> AliasMap;
typedef std::unordered_map<IdString, HierarchicalCell> HierarchyMap;
- auto belpin_cls = class_<ContextualWrapper<BelPin>>("BelPin", no_init);
+ auto belpin_cls = py::class_<ContextualWrapper<BelPin>>(m, "BelPin");
readonly_wrapper<BelPin, decltype(&BelPin::bel), &BelPin::bel, conv_to_str<BelId>>::def_wrap(belpin_cls, "bel");
readonly_wrapper<BelPin, decltype(&BelPin::pin), &BelPin::pin, conv_to_str<IdString>>::def_wrap(belpin_cls, "pin");
#include "arch_pybindings_shared.h"
- WRAP_RANGE(Bel, conv_to_str<BelId>);
- WRAP_RANGE(Wire, conv_to_str<WireId>);
- WRAP_RANGE(AllPip, conv_to_str<PipId>);
- WRAP_RANGE(Pip, conv_to_str<PipId>);
- WRAP_RANGE(BelPin, wrap_context<BelPin>);
+ WRAP_RANGE(m, Bel, conv_to_str<BelId>);
+ WRAP_RANGE(m, Wire, conv_to_str<WireId>);
+ WRAP_RANGE(m, AllPip, conv_to_str<PipId>);
+ WRAP_RANGE(m, Pip, conv_to_str<PipId>);
+ WRAP_RANGE(m, BelPin, wrap_context<BelPin>);
- WRAP_MAP_UPTR(CellMap, "IdCellMap");
- WRAP_MAP_UPTR(NetMap, "IdNetMap");
- WRAP_MAP(HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap");
+ WRAP_MAP_UPTR(m, CellMap, "IdCellMap");
+ WRAP_MAP_UPTR(m, NetMap, "IdNetMap");
+ WRAP_MAP(m, HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap");
}
NEXTPNR_NAMESPACE_END