Add architecture specific Python defs

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-01 15:18:18 +02:00
parent a7415bfbc3
commit f353453a7f
3 changed files with 46 additions and 1 deletions

View File

@ -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();
}

14
dummy/pybindings.cc Normal file
View File

@ -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");
}

27
ice40/pybindings.cc Normal file
View File

@ -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();
}