diff options
| author | gatecat <gatecat@ds0.me> | 2021-12-14 18:47:35 +0000 | 
|---|---|---|
| committer | gatecat <gatecat@ds0.me> | 2021-12-14 18:47:35 +0000 | 
| commit | a120ae1fa7be5bac98e77755a6220df59e443b16 (patch) | |
| tree | 1acd5dc88596ff537e57c35bdeeade83deda497a | |
| parent | 256134d6158b59831462f26f0011627eda10beb2 (diff) | |
| download | nextpnr-a120ae1fa7be5bac98e77755a6220df59e443b16.tar.gz nextpnr-a120ae1fa7be5bac98e77755a6220df59e443b16.tar.bz2 nextpnr-a120ae1fa7be5bac98e77755a6220df59e443b16.zip | |
python: Bind getBelLocation/getPipLocation
Signed-off-by: gatecat <gatecat@ds0.me>
| -rw-r--r-- | common/arch_pybindings_shared.h | 4 | ||||
| -rw-r--r-- | common/pybindings.cc | 5 | 
2 files changed, 8 insertions, 1 deletions
| diff --git a/common/arch_pybindings_shared.h b/common/arch_pybindings_shared.h index f44aa70e..b3dc0506 100644 --- a/common/arch_pybindings_shared.h +++ b/common/arch_pybindings_shared.h @@ -48,6 +48,8 @@ fn_wrapper_2a_v<Context, decltype(&Context::copyBelPorts), &Context::copyBelPort  fn_wrapper_1a<Context, decltype(&Context::getBelType), &Context::getBelType, conv_to_str<IdString>,                conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelType"); +fn_wrapper_1a<Context, decltype(&Context::getBelLocation), &Context::getBelLocation, pass_through<Loc>, +              conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelLocation");  fn_wrapper_1a<Context, decltype(&Context::checkBelAvail), &Context::checkBelAvail, pass_through<bool>,                conv_from_str<BelId>>::def_wrap(ctx_cls, "checkBelAvail");  fn_wrapper_1a<Context, decltype(&Context::getBelChecksum), &Context::getBelChecksum, pass_through<uint32_t>, @@ -92,6 +94,8 @@ fn_wrapper_0a<Context, decltype(&Context::getPips), &Context::getPips, wrap_cont                                                                                                              "getPips");  fn_wrapper_1a<Context, decltype(&Context::getPipChecksum), &Context::getPipChecksum, pass_through<uint32_t>,                conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipChecksum"); +fn_wrapper_1a<Context, decltype(&Context::getPipLocation), &Context::getPipLocation, pass_through<Loc>, +              conv_from_str<PipId>>::def_wrap(ctx_cls, "getPipLocation");  fn_wrapper_3a_v<Context, decltype(&Context::bindPip), &Context::bindPip, conv_from_str<PipId>, addr_and_unwrap<NetInfo>,                  pass_through<PlaceStrength>>::def_wrap(ctx_cls, "bindPip");  fn_wrapper_1a_v<Context, decltype(&Context::unbindPip), &Context::unbindPip, conv_from_str<PipId>>::def_wrap( diff --git a/common/pybindings.cc b/common/pybindings.cc index f9ee9eb7..eef460ce 100644 --- a/common/pybindings.cc +++ b/common/pybindings.cc @@ -83,6 +83,8 @@ template <> struct string_converter<Property>  } // namespace PythonConversion +std::string loc_repr_py(Loc loc) { return stringf("Loc(%d, %d, %d)", loc.x, loc.y, loc.z); } +  PYBIND11_EMBEDDED_MODULE(MODULE_NAME, m)  {      py::register_exception_translator([](std::exception_ptr p) { @@ -175,7 +177,8 @@ PYBIND11_EMBEDDED_MODULE(MODULE_NAME, m)                             .def(py::init<int, int, int>())                             .def_readwrite("x", &Loc::x)                             .def_readwrite("y", &Loc::y) -                           .def_readwrite("z", &Loc::z); +                           .def_readwrite("z", &Loc::z) +                           .def("__repr__", loc_repr_py);      auto ci_cls = py::class_<ContextualWrapper<CellInfo &>>(m, "CellInfo");      readwrite_wrapper<CellInfo &, decltype(&CellInfo::name), &CellInfo::name, conv_to_str<IdString>, | 
