aboutsummaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2021-02-02 16:55:13 +0000
committerGitHub <noreply@github.com>2021-02-02 16:55:13 +0000
commitd1ef3ae1bac8f108b642c42c4fbfbdd4899c7641 (patch)
tree3657232a91e97f839cd9114f40aa0c565afc23d4 /generic
parentefc98c517eb1d2eb4a8ecc2ae82e770aaa1a0edd (diff)
parentda74a425d23352d7cddf9d1c4b0b7c86dd567c40 (diff)
downloadnextpnr-d1ef3ae1bac8f108b642c42c4fbfbdd4899c7641.tar.gz
nextpnr-d1ef3ae1bac8f108b642c42c4fbfbdd4899c7641.tar.bz2
nextpnr-d1ef3ae1bac8f108b642c42c4fbfbdd4899c7641.zip
Merge pull request #557 from litghost/refactor_placer_arch_api
RFC: Initial refactoring of placer API.
Diffstat (limited to 'generic')
-rw-r--r--generic/arch.h33
-rw-r--r--generic/arch_pybindings.cc22
-rw-r--r--generic/archdefs.h1
3 files changed, 56 insertions, 0 deletions
diff --git a/generic/arch.h b/generic/arch.h
index 011d7d45..f3e26bb5 100644
--- a/generic/arch.h
+++ b/generic/arch.h
@@ -271,6 +271,38 @@ struct Arch : BaseCtx
bool place();
bool route();
+ std::vector<IdString> getCellTypes() const
+ {
+ std::vector<IdString> cell_types;
+ cell_types.reserve(bels.size());
+ for (auto bel : bels) {
+ cell_types.push_back(bel.first);
+ }
+
+ return cell_types;
+ }
+
+ std::vector<BelBucketId> getBelBuckets() const { return getCellTypes(); }
+
+ IdString getBelBucketName(BelBucketId bucket) const { return bucket; }
+
+ BelBucketId getBelBucketByName(IdString bucket) const { return bucket; }
+
+ BelBucketId getBelBucketForBel(BelId bel) const { return getBelType(bel); }
+
+ BelBucketId getBelBucketForCellType(IdString cell_type) const { return cell_type; }
+
+ std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
+ {
+ std::vector<BelId> bels;
+ for (BelId bel : getBels()) {
+ if (bucket == getBelBucketForBel(bel)) {
+ bels.push_back(bel);
+ }
+ }
+ return bels;
+ }
+
const std::vector<GraphicElement> &getDecalGraphics(DecalId decal) const;
DecalXY getBelDecal(BelId bel) const;
DecalXY getWireDecal(WireId wire) const;
@@ -283,6 +315,7 @@ struct Arch : BaseCtx
// Get the TimingClockingInfo of a port
TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const;
+ bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const;
diff --git a/generic/arch_pybindings.cc b/generic/arch_pybindings.cc
index 7f7229fd..23f2c05c 100644
--- a/generic/arch_pybindings.cc
+++ b/generic/arch_pybindings.cc
@@ -226,6 +226,28 @@ 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/generic/archdefs.h b/generic/archdefs.h
index 978c9c9b..7623bf40 100644
--- a/generic/archdefs.h
+++ b/generic/archdefs.h
@@ -51,6 +51,7 @@ typedef IdString WireId;
typedef IdString PipId;
typedef IdString GroupId;
typedef IdString DecalId;
+typedef IdString BelBucketId;
struct ArchNetInfo
{