aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ecp5/arch.cc13
-rw-r--r--ecp5/arch.h44
-rw-r--r--ecp5/archdefs.h7
3 files changed, 64 insertions, 0 deletions
diff --git a/ecp5/arch.cc b/ecp5/arch.cc
index 74a1b17f..4368f0d0 100644
--- a/ecp5/arch.cc
+++ b/ecp5/arch.cc
@@ -115,6 +115,19 @@ Arch::Arch(ArchArgs args) : args(args)
log_error("Unsupported package '%s' for '%s'.\n", args.package.c_str(), getChipName().c_str());
bel_to_cell.resize(chip_info->height * chip_info->width * max_loc_bels, nullptr);
+
+ 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);
+
+ PartitionId partition;
+ partition.name = bel_type;
+ partitions.push_back(partitions);
+ }
}
// -----------------------------------------------------------------------
diff --git a/ecp5/arch.h b/ecp5/arch.h
index 5c543cb3..921cbc29 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -953,6 +953,47 @@ struct Arch : BaseCtx
bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel);
}
+
+ const std::vector<IdString> &getCellTypes() const {
+ return cell_types;
+ }
+
+ std::vector<PartitionId> getPartitions() const {
+ return partitions;
+ }
+
+ IdString getPartitionName(PartitionId partition) const {
+ return partition.name;
+ }
+
+ PartitionId getPartitionByName(IdString name) const {
+ PartitionId partition;
+ partition.name = name;
+ return partition;
+ }
+
+ PartitionId getPartitionForBel(BelId bel) const {
+ PartitionId partition;
+ partition.name = getBelType(bel);
+ return partition;
+ }
+
+ PartitionId getPartitionForCellType(IdString cell_type) const {
+ PartitionId partition;
+ partition.name = cell_type;
+ return partition;
+ }
+
+ std::vector<BelId> getBelsForPartition(PartitionId partition) const {
+ std::vector<BelId> bels;
+ for(BelId bel : getBels()) {
+ if(getBelType(bel) == partition.name) {
+ bels.push_back(bel);
+ }
+ }
+ return bels;
+ }
+
bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const;
@@ -1025,6 +1066,9 @@ struct Arch : BaseCtx
static const std::vector<std::string> availablePlacers;
static const std::string defaultRouter;
static const std::vector<std::string> availableRouters;
+
+ std::vector<IdString> cell_types;
+ std::vector<PartitionId> partitions;
};
NEXTPNR_NAMESPACE_END
diff --git a/ecp5/archdefs.h b/ecp5/archdefs.h
index 586c385f..b0e01e4d 100644
--- a/ecp5/archdefs.h
+++ b/ecp5/archdefs.h
@@ -126,6 +126,13 @@ struct PipId
}
};
+struct PartitionId {
+ IdString name;
+
+ bool operator==(const PartitionId &other) const { return (name == other.name); }
+ bool operator!=(const PartitionId &other) const { return (name != other.name); }
+};
+
struct GroupId
{
enum : int8_t