diff options
author | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-01-28 19:24:00 -0800 |
---|---|---|
committer | Keith Rothman <537074+litghost@users.noreply.github.com> | 2021-02-02 07:34:56 -0800 |
commit | 0338368afa369d097dfb35e0705fef10baa3d20e (patch) | |
tree | 961e59d870aa6df324ef723c72dd008390588f16 /ice40 | |
parent | d03d9d839b7e49a4bf3428e949bda85574adf403 (diff) | |
download | nextpnr-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 'ice40')
-rw-r--r-- | ice40/arch.cc | 13 | ||||
-rw-r--r-- | ice40/arch.h | 43 | ||||
-rw-r--r-- | ice40/archdefs.h | 22 |
3 files changed, 78 insertions, 0 deletions
diff --git a/ice40/arch.cc b/ice40/arch.cc index e450e682..fcf6506d 100644 --- a/ice40/arch.cc +++ b/ice40/arch.cc @@ -115,6 +115,19 @@ Arch::Arch(ArchArgs args) : args(args) wire_to_net.resize(chip_info->wire_data.size()); pip_to_net.resize(chip_info->pip_data.size()); switches_locked.resize(chip_info->num_switches); + + 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); + } } // ----------------------------------------------------------------------- diff --git a/ice40/arch.h b/ice40/arch.h index 60171a4c..18fc3aeb 100644 --- a/ice40/arch.h +++ b/ice40/arch.h @@ -826,6 +826,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 @@ -867,6 +907,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; }; void ice40DelayFuzzerMain(Context *ctx); diff --git a/ice40/archdefs.h b/ice40/archdefs.h index e95953f1..1b7821b0 100644 --- a/ice40/archdefs.h +++ b/ice40/archdefs.h @@ -170,6 +170,17 @@ struct ArchCellInfo }; }; +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; + } +}; + NEXTPNR_NAMESPACE_END namespace std { @@ -213,4 +224,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 |