From f353453a7faa8c7fa87acfac161cdcbebfae04d1 Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 1 Jun 2018 15:18:18 +0200 Subject: Add architecture specific Python defs Signed-off-by: David Shah --- common/pybindings.cc | 6 +++++- dummy/pybindings.cc | 14 ++++++++++++++ ice40/pybindings.cc | 27 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 dummy/pybindings.cc create mode 100644 ice40/pybindings.cc diff --git a/common/pybindings.cc b/common/pybindings.cc index 0990c00c..22c06c2e 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -84,12 +84,16 @@ struct range_wrapper { #define WRAP_RANGE(t) range_wrapper().wrap(#t "Range", #t "Iterator") +// Architecture-specific bindings should be created in the below function, which must be implemented in all +// architectures +void arch_wrap_python(); + BOOST_PYTHON_MODULE (MODULE_NAME) { // From Chip.h - class_("ChipArgs"); WRAP_RANGE(Bels); WRAP_RANGE(AllWires); WRAP_RANGE(WireDelay); WRAP_RANGE(BelPin); + arch_wrap_python(); } diff --git a/dummy/pybindings.cc b/dummy/pybindings.cc new file mode 100644 index 00000000..5e49eaa5 --- /dev/null +++ b/dummy/pybindings.cc @@ -0,0 +1,14 @@ +#include "design.h" +#include "chip.h" +#include +#include +#include +#include +#include +#include + +using namespace boost::python; + +void arch_wrap_python() { + class_("ChipArgs"); +} diff --git a/ice40/pybindings.cc b/ice40/pybindings.cc new file mode 100644 index 00000000..4f409194 --- /dev/null +++ b/ice40/pybindings.cc @@ -0,0 +1,27 @@ +#include "design.h" +#include "chip.h" +#include +#include +#include +#include +#include +#include +#include + +using namespace boost::python; + +void arch_wrap_python() { + class_("ChipArgs") + .def_readwrite("type", &ChipArgs::type); + + enum_().type)>("iCE40Type") + .value("NONE", ChipArgs::NONE) + .value("LP384", ChipArgs::LP384) + .value("LP1K", ChipArgs::LP1K) + .value("LP8K", ChipArgs::LP8K) + .value("HX1K", ChipArgs::HX1K) + .value("HX8K", ChipArgs::HX8K) + .value("UP5K", ChipArgs::UP5K) + .export_values(); + +} -- cgit v1.2.3