diff options
author | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-01-29 15:35:00 -0800 |
---|---|---|
committer | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-02-02 07:43:36 -0800 |
commit | 9089ee2d1631fe2346143823c2896a2a85a27e8b (patch) | |
tree | 7fb694eec79c542fa4658392b058b56a45f7013f | |
parent | 9fe546f279cd643a308322ffa6af622630892315 (diff) | |
download | nextpnr-9089ee2d1631fe2346143823c2896a2a85a27e8b.tar.gz nextpnr-9089ee2d1631fe2346143823c2896a2a85a27e8b.tar.bz2 nextpnr-9089ee2d1631fe2346143823c2896a2a85a27e8b.zip |
Add pybindings for new APIs.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
-rw-r--r-- | common/arch_pybindings_shared.h | 16 | ||||
-rw-r--r-- | ecp5/arch_pybindings.cc | 2 | ||||
-rw-r--r-- | ecp5/arch_pybindings.h | 12 | ||||
-rw-r--r-- | generic/arch_pybindings.cc | 26 | ||||
-rw-r--r-- | ice40/arch_pybindings.cc | 2 | ||||
-rw-r--r-- | ice40/arch_pybindings.h | 12 | ||||
-rw-r--r-- | nexus/arch_pybindings.cc | 3 | ||||
-rw-r--r-- | nexus/arch_pybindings.h | 12 |
8 files changed, 85 insertions, 0 deletions
diff --git a/common/arch_pybindings_shared.h b/common/arch_pybindings_shared.h index 88f95020..b8ea7b17 100644 --- a/common/arch_pybindings_shared.h +++ b/common/arch_pybindings_shared.h @@ -110,3 +110,19 @@ fn_wrapper_0a<Context, decltype(&Context::archId), &Context::archId, conv_to_str fn_wrapper_2a_v<Context, decltype(&Context::writeSVG), &Context::writeSVG, pass_through<std::string>, pass_through<std::string>>::def_wrap(ctx_cls, "writeSVG"); + +// const\_range\<BelBucketId\> getBelBuckets() const +fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), &Context::getBelBuckets, wrap_context<BelBucketRange>>::def_wrap(ctx_cls, + "getBelBuckets"); +// BelBucketId getBelBucketForBel(BelId bel) const +fn_wrapper_1a<Context, decltype(&Context::getBelBucketForBel), &Context::getBelBucketForBel, conv_to_str<BelBucketId>, + conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelBucketForBel"); +// BelBucketId getBelBucketForCellType(IdString cell\_type) const +fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType), &Context::getBelBucketForCellType, conv_to_str<BelBucketId>, + conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType"); +// const\_range\<BelId\> getBelsInBucket(BelBucketId bucket) const +fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket), &Context::getBelsInBucket, wrap_context<BelRangeForBelBucket>, + conv_from_str<BelBucketId>>::def_wrap(ctx_cls, "getBelsInBucket"); +// bool isValidBelForCellType(IdString cell\_type, BelId bel) const +fn_wrapper_2a<Context, decltype(&Context::isValidBelForCellType), &Context::isValidBelForCellType, pass_through<bool>, + conv_from_str<IdString>, conv_from_str<BelId>>::def_wrap(ctx_cls, "isValidBelForCellType"); diff --git a/ecp5/arch_pybindings.cc b/ecp5/arch_pybindings.cc index 8618bec1..b000ea78 100644 --- a/ecp5/arch_pybindings.cc +++ b/ecp5/arch_pybindings.cc @@ -59,6 +59,8 @@ void arch_wrap_python(py::module &m) typedef const PipRange UphillPipRange; typedef const PipRange DownhillPipRange; + typedef const std::vector<BelBucketId> & BelBucketRange; + typedef const std::vector<BelId> & BelRangeForBelBucket; #include "arch_pybindings_shared.h" WRAP_RANGE(m, Bel, conv_to_str<BelId>); diff --git a/ecp5/arch_pybindings.h b/ecp5/arch_pybindings.h index cf343976..dd3161ae 100644 --- a/ecp5/arch_pybindings.h +++ b/ecp5/arch_pybindings.h @@ -76,6 +76,18 @@ template <> struct string_converter<PipId> } }; +template <> struct string_converter<BelBucketId> +{ + BelBucketId from_str(Context *ctx, std::string name) { return ctx->getBelBucketByName(ctx->id(name)); } + + std::string to_str(Context *ctx, BelBucketId id) + { + if (id == BelBucketId()) + throw bad_wrap(); + return ctx->getBelBucketName(id).str(ctx); + } +}; + template <> struct string_converter<BelPin> { BelPin from_str(Context *ctx, std::string name) diff --git a/generic/arch_pybindings.cc b/generic/arch_pybindings.cc index 7f7229fd..9e98bfe5 100644 --- a/generic/arch_pybindings.cc +++ b/generic/arch_pybindings.cc @@ -226,6 +226,32 @@ void arch_wrap_python(py::module &m) pass_through<DelayInfo>>::def_wrap(ctx_cls, "addCellTimingClockToOut", "cell"_a, "port"_a, "clock"_a, "clktoq"_a); + // const\_range\<BelBucketId\> getBelBuckets() const + fn_wrapper_0a<Context, decltype(&Context::getBelBuckets), + &Context::getBelBuckets, + wrap_context<const std::vector<BelBucketId> &>>::def_wrap(ctx_cls, "getBelBuckets"); + + // BelBucketId getBelBucketForBel(BelId bel) const + fn_wrapper_1a<Context, decltype(&Context::getBelBucketForBel), + &Context::getBelBucketForBel, conv_to_str<BelBucketId>, + conv_from_str<BelId>>::def_wrap(ctx_cls, "getBelBucketForBel"); + + // BelBucketId getBelBucketForCellType(IdString cell\_type) const + fn_wrapper_1a<Context, decltype(&Context::getBelBucketForCellType), + &Context::getBelBucketForCellType, conv_to_str<BelBucketId>, + conv_from_str<IdString>>::def_wrap(ctx_cls, "getBelBucketForCellType"); + + // const\_range\<BelId\> getBelsInBucket(BelBucketId bucket) const + fn_wrapper_1a<Context, decltype(&Context::getBelsInBucket), + &Context::getBelsInBucket, wrap_context<const std::vector<BelId> &>, + conv_from_str<BelBucketId>>::def_wrap(ctx_cls, "getBelsInBucket"); + + // bool isValidBelForCellType(IdString cell\_type, BelId bel) const + fn_wrapper_2a<Context, decltype(&Context::isValidBelForCellType), + &Context::isValidBelForCellType, pass_through<bool>, + conv_from_str<IdString>, conv_from_str<BelId>>::def_wrap( + ctx_cls, "isValidBelForCellType"); + WRAP_MAP_UPTR(m, CellMap, "IdCellMap"); WRAP_MAP_UPTR(m, NetMap, "IdNetMap"); WRAP_MAP(m, HierarchyMap, wrap_context<HierarchicalCell &>, "HierarchyMap"); diff --git a/ice40/arch_pybindings.cc b/ice40/arch_pybindings.cc index 921956e8..060cf0b1 100644 --- a/ice40/arch_pybindings.cc +++ b/ice40/arch_pybindings.cc @@ -75,6 +75,8 @@ void arch_wrap_python(py::module &m) typedef const PipRange UphillPipRange; typedef const PipRange DownhillPipRange; + typedef const std::vector<BelBucketId> & BelBucketRange; + typedef const std::vector<BelId> & BelRangeForBelBucket; #include "arch_pybindings_shared.h" WRAP_RANGE(m, Bel, conv_to_str<BelId>); diff --git a/ice40/arch_pybindings.h b/ice40/arch_pybindings.h index cf343976..dd3161ae 100644 --- a/ice40/arch_pybindings.h +++ b/ice40/arch_pybindings.h @@ -76,6 +76,18 @@ template <> struct string_converter<PipId> } }; +template <> struct string_converter<BelBucketId> +{ + BelBucketId from_str(Context *ctx, std::string name) { return ctx->getBelBucketByName(ctx->id(name)); } + + std::string to_str(Context *ctx, BelBucketId id) + { + if (id == BelBucketId()) + throw bad_wrap(); + return ctx->getBelBucketName(id).str(ctx); + } +}; + template <> struct string_converter<BelPin> { BelPin from_str(Context *ctx, std::string name) diff --git a/nexus/arch_pybindings.cc b/nexus/arch_pybindings.cc index 1a3890ff..cf0badae 100644 --- a/nexus/arch_pybindings.cc +++ b/nexus/arch_pybindings.cc @@ -55,6 +55,9 @@ void arch_wrap_python(py::module &m) typedef UpDownhillPipRange DownhillPipRange; typedef WireBelPinRange BelPinRange; + typedef const std::vector<BelBucketId> & BelBucketRange; + typedef const std::vector<BelId> & BelRangeForBelBucket; + #include "arch_pybindings_shared.h" WRAP_RANGE(m, Bel, conv_to_str<BelId>); diff --git a/nexus/arch_pybindings.h b/nexus/arch_pybindings.h index 326af306..7694090b 100644 --- a/nexus/arch_pybindings.h +++ b/nexus/arch_pybindings.h @@ -76,6 +76,18 @@ template <> struct string_converter<PipId> } }; +template <> struct string_converter<BelBucketId> +{ + BelBucketId from_str(Context *ctx, std::string name) { return ctx->getBelBucketByName(ctx->id(name)); } + + std::string to_str(Context *ctx, BelBucketId id) + { + if (id == BelBucketId()) + throw bad_wrap(); + return ctx->getBelBucketName(id).str(ctx); + } +}; + template <> struct string_converter<BelPin> { BelPin from_str(Context *ctx, std::string name) |