diff options
| -rw-r--r-- | common/pybindings.cc | 6 | ||||
| -rw-r--r-- | dummy/pybindings.cc | 14 | ||||
| -rw-r--r-- | ice40/pybindings.cc | 27 |
3 files changed, 46 insertions, 1 deletions
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<t##Range>().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>("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 <utility> +#include <stdexcept> +#include <boost/python.hpp> +#include <boost/python/suite/indexing/vector_indexing_suite.hpp> +#include <boost/python/suite/indexing/map_indexing_suite.hpp> +#include <boost/python/suite/indexing/map_indexing_suite.hpp> + +using namespace boost::python; + +void arch_wrap_python() { + class_<ChipArgs>("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 <utility> +#include <stdexcept> +#include <boost/python.hpp> +#include <boost/python/enum.hpp> +#include <boost/python/suite/indexing/vector_indexing_suite.hpp> +#include <boost/python/suite/indexing/map_indexing_suite.hpp> +#include <boost/python/suite/indexing/map_indexing_suite.hpp> + +using namespace boost::python; + +void arch_wrap_python() { + class_<ChipArgs>("ChipArgs") + .def_readwrite("type", &ChipArgs::type); + + enum_<decltype(std::declval<ChipArgs>().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(); + +} |
