aboutsummaryrefslogtreecommitdiffstats
path: root/nexus
diff options
context:
space:
mode:
authorKeith Rothman <537074+litghost@users.noreply.github.com>2021-01-28 19:24:00 -0800
committerKeith Rothman <537074+litghost@users.noreply.github.com>2021-02-02 07:34:56 -0800
commit0338368afa369d097dfb35e0705fef10baa3d20e (patch)
tree961e59d870aa6df324ef723c72dd008390588f16 /nexus
parentd03d9d839b7e49a4bf3428e949bda85574adf403 (diff)
downloadnextpnr-0338368afa369d097dfb35e0705fef10baa3d20e.tar.gz
nextpnr-0338368afa369d097dfb35e0705fef10baa3d20e.tar.bz2
nextpnr-0338368afa369d097dfb35e0705fef10baa3d20e.zip
Add Partition APIs to ice40, nexus, gowin archs.
Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
Diffstat (limited to 'nexus')
-rw-r--r--nexus/arch.cc17
-rw-r--r--nexus/arch.h43
-rw-r--r--nexus/archdefs.h22
3 files changed, 80 insertions, 2 deletions
diff --git a/nexus/arch.cc b/nexus/arch.cc
index eadfaa4b..659703de 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);
+
+ PartitionId partition;
+ partition.name = bel_type;
+ partitions.push_back(partition);
+ }
}
// -----------------------------------------------------------------------
@@ -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 31bfa603..dfd00f90 100644
--- a/nexus/arch.h
+++ b/nexus/arch.h
@@ -1340,6 +1340,46 @@ struct Arch : BaseCtx
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;
+ }
+
// 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
@@ -1541,6 +1581,9 @@ struct Arch : BaseCtx
// -------------------------------------------------
void write_fasm(std::ostream &out) const;
+
+ std::vector<IdString> cell_types;
+ std::vector<PartitionId> partitions;
};
NEXTPNR_NAMESPACE_END
diff --git a/nexus/archdefs.h b/nexus/archdefs.h
index adc1342c..12bbd228 100644
--- a/nexus/archdefs.h
+++ b/nexus/archdefs.h
@@ -114,6 +114,17 @@ 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); }
+ bool operator<(const PartitionId &other) const
+ {
+ return name < other.name;
+ }
+};
+
struct GroupId
{
enum : int8_t
@@ -250,4 +261,15 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
return seed;
}
};
+
+template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PartitionId>
+{
+ std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PartitionId &partition) const noexcept
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, hash<NEXTPNR_NAMESPACE_PREFIX IdString>()(partition.name));
+ return seed;
+ }
+};
+
} // namespace std