aboutsummaryrefslogtreecommitdiffstats
path: root/nexus
diff options
context:
space:
mode:
Diffstat (limited to 'nexus')
-rw-r--r--nexus/arch.cc17
-rw-r--r--nexus/arch.h44
-rw-r--r--nexus/arch_pybindings.cc3
-rw-r--r--nexus/arch_pybindings.h12
-rw-r--r--nexus/archdefs.h20
5 files changed, 94 insertions, 2 deletions
diff --git a/nexus/arch.cc b/nexus/arch.cc
index eadfaa4b..95b409bf 100644
--- a/nexus/arch.cc
+++ b/nexus/arch.cc
@@ -171,6 +171,19 @@ Arch::Arch(ArchArgs args) : args(args)
}
if (!speed_grade)
log_error("Unknown speed grade '%s'.\n", speed.c_str());
+
+ std::unordered_set<IdString> bel_types;
+ for (BelId bel : getBels()) {
+ bel_types.insert(getBelType(bel));
+ }
+
+ for (IdString bel_type : bel_types) {
+ cell_types.push_back(bel_type);
+
+ BelBucketId bucket;
+ bucket.name = bel_type;
+ buckets.push_back(bucket);
+ }
}
// -----------------------------------------------------------------------
@@ -635,8 +648,8 @@ bool Arch::place()
cfg.ioBufTypes.insert(id_SEIO18_CORE);
cfg.ioBufTypes.insert(id_OSC_CORE);
cfg.cellGroups.emplace_back();
- cfg.cellGroups.back().insert(id_OXIDE_COMB);
- cfg.cellGroups.back().insert(id_OXIDE_FF);
+ cfg.cellGroups.back().insert({id_OXIDE_COMB});
+ cfg.cellGroups.back().insert({id_OXIDE_FF});
cfg.beta = 0.5;
cfg.criticalityExponent = 7;
diff --git a/nexus/arch.h b/nexus/arch.h
index 56b48bf3..ee66599a 100644
--- a/nexus/arch.h
+++ b/nexus/arch.h
@@ -1335,6 +1335,47 @@ struct Arch : BaseCtx
// Perform placement validity checks, returning false on failure (all
// implemented in arch_place.cc)
+ // Whether this cell type can be placed at this BEL.
+ bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
+
+ const std::vector<IdString> &getCellTypes() const { return cell_types; }
+
+ std::vector<BelBucketId> getBelBuckets() const { return buckets; }
+
+ IdString getBelBucketName(BelBucketId bucket) const { return bucket.name; }
+
+ BelBucketId getBelBucketByName(IdString name) const
+ {
+ BelBucketId bucket;
+ bucket.name = name;
+ return bucket;
+ }
+
+ BelBucketId getBelBucketForBel(BelId bel) const
+ {
+ BelBucketId bucket;
+ bucket.name = getBelType(bel);
+ return bucket;
+ }
+
+ BelBucketId getBelBucketForCellType(IdString cell_type) const
+ {
+ BelBucketId bucket;
+ bucket.name = cell_type;
+ return bucket;
+ }
+
+ std::vector<BelId> getBelsInBucket(BelBucketId bucket) const
+ {
+ std::vector<BelId> bels;
+ for (BelId bel : getBels()) {
+ if (getBelType(bel) == bucket.name) {
+ bels.push_back(bel);
+ }
+ }
+ return bels;
+ }
+
// Whether or not a given cell can be placed at a given Bel
// This is not intended for Bel type checks, but finer-grained constraints
// such as conflicting set/reset signals, etc
@@ -1536,6 +1577,9 @@ struct Arch : BaseCtx
// -------------------------------------------------
void write_fasm(std::ostream &out) const;
+
+ std::vector<IdString> cell_types;
+ std::vector<BelBucketId> buckets;
};
NEXTPNR_NAMESPACE_END
diff --git a/nexus/arch_pybindings.cc b/nexus/arch_pybindings.cc
index 1a3890ff..b07031f7 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)
diff --git a/nexus/archdefs.h b/nexus/archdefs.h
index adc1342c..7e427e06 100644
--- a/nexus/archdefs.h
+++ b/nexus/archdefs.h
@@ -114,6 +114,15 @@ struct PipId
}
};
+struct BelBucketId
+{
+ IdString name;
+
+ bool operator==(const BelBucketId &other) const { return (name == other.name); }
+ bool operator!=(const BelBucketId &other) const { return (name != other.name); }
+ bool operator<(const BelBucketId &other) const { return name < other.name; }
+};
+
struct GroupId
{
enum : int8_t
@@ -250,4 +259,15 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
return seed;
}
};
+
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX BelBucketId>
+{
+ std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX BelBucketId &bucket) const noexcept
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(bucket.name));
+ return seed;
+ }
+};
+
} // namespace std