Add Partition APIs to ice40, nexus, gowin archs.

Signed-off-by: Keith Rothman <537074+litghost@users.noreply.github.com>
This commit is contained in:
Keith Rothman 2021-01-28 19:24:00 -08:00
parent d03d9d839b
commit 0338368afa
10 changed files with 207 additions and 4 deletions

View File

@ -30,7 +30,7 @@ NEXTPNR_NAMESPACE_BEGIN
struct FastBels { struct FastBels {
struct TypeData { struct TypeData {
size_t type_index; size_t type_index;
size_t number_of_possible_bels; int number_of_possible_bels;
}; };
FastBels(Context *ctx, int minBelsForGridPick) : ctx(ctx), minBelsForGridPick(minBelsForGridPick) {} FastBels(Context *ctx, int minBelsForGridPick) : ctx(ctx), minBelsForGridPick(minBelsForGridPick) {}
@ -133,7 +133,7 @@ struct FastBels {
typedef std::vector<std::vector<std::vector<BelId>>> FastBelsData; typedef std::vector<std::vector<std::vector<BelId>>> FastBelsData;
size_t getBelsForCellType(IdString cell_type, FastBelsData **data) { int getBelsForCellType(IdString cell_type, FastBelsData **data) {
auto iter = cell_types.find(cell_type); auto iter = cell_types.find(cell_type);
if(iter == cell_types.end()) { if(iter == cell_types.end()) {
addCellType(cell_type); addCellType(cell_type);

View File

@ -739,6 +739,15 @@ Arch::Arch(ArchArgs args) : args(args)
} }
// Dummy for empty decals // Dummy for empty decals
decal_graphics[IdString()]; decal_graphics[IdString()];
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);
}
} }
void IdString::initialize_arch(const BaseCtx *ctx) void IdString::initialize_arch(const BaseCtx *ctx)

View File

@ -425,6 +425,41 @@ struct Arch : BaseCtx
bool isValidBelForCellType(IdString cell_type, BelId bel) const { bool isValidBelForCellType(IdString cell_type, BelId bel) const {
return cell_type == getBelType(bel); return cell_type == getBelType(bel);
} }
const std::vector<IdString> &getCellTypes() const {
return cell_types;
}
std::vector<PartitionId> getPartitions() const {
return cell_types;
}
IdString getPartitionName(PartitionId partition) const {
return partition;
}
PartitionId getPartitionByName(IdString name) const {
return name;
}
PartitionId getPartitionForBel(BelId bel) const {
return getBelType(bel);
}
PartitionId getPartitionForCellType(IdString cell_type) const {
return cell_type;
}
std::vector<BelId> getBelsForPartition(PartitionId partition) const {
std::vector<BelId> bels;
for(BelId bel : getBels()) {
if(getBelType(bel) == partition) {
bels.push_back(bel);
}
}
return bels;
}
bool isValidBelForCell(CellInfo *cell, BelId bel) const; bool isValidBelForCell(CellInfo *cell, BelId bel) const;
bool isBelLocationValid(BelId bel) const; bool isBelLocationValid(BelId bel) const;
@ -437,6 +472,8 @@ struct Arch : BaseCtx
// Internal usage // Internal usage
void assignArchInfo(); void assignArchInfo();
bool cellsCompatible(const CellInfo **cells, int count) const; bool cellsCompatible(const CellInfo **cells, int count) const;
std::vector<IdString> cell_types;
}; };
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -72,6 +72,7 @@ typedef IdString WireId;
typedef IdString PipId; typedef IdString PipId;
typedef IdString GroupId; typedef IdString GroupId;
typedef IdString DecalId; typedef IdString DecalId;
typedef IdString PartitionId;
struct ArchNetInfo struct ArchNetInfo
{ {

View File

@ -115,6 +115,19 @@ Arch::Arch(ArchArgs args) : args(args)
wire_to_net.resize(chip_info->wire_data.size()); wire_to_net.resize(chip_info->wire_data.size());
pip_to_net.resize(chip_info->pip_data.size()); pip_to_net.resize(chip_info->pip_data.size());
switches_locked.resize(chip_info->num_switches); 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);
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------

View File

@ -826,6 +826,46 @@ struct Arch : BaseCtx
return cell_type == getBelType(bel); 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 // 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 // This is not intended for Bel type checks, but finer-grained constraints
// such as conflicting set/reset signals, etc // such as conflicting set/reset signals, etc
@ -867,6 +907,9 @@ struct Arch : BaseCtx
static const std::vector<std::string> availablePlacers; static const std::vector<std::string> availablePlacers;
static const std::string defaultRouter; static const std::string defaultRouter;
static const std::vector<std::string> availableRouters; static const std::vector<std::string> availableRouters;
std::vector<IdString> cell_types;
std::vector<PartitionId> partitions;
}; };
void ice40DelayFuzzerMain(Context *ctx); void ice40DelayFuzzerMain(Context *ctx);

View File

@ -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 NEXTPNR_NAMESPACE_END
namespace std { namespace std {
@ -213,4 +224,15 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
return seed; 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 } // namespace std

View File

@ -171,6 +171,19 @@ Arch::Arch(ArchArgs args) : args(args)
} }
if (!speed_grade) if (!speed_grade)
log_error("Unknown speed grade '%s'.\n", speed.c_str()); 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_SEIO18_CORE);
cfg.ioBufTypes.insert(id_OSC_CORE); cfg.ioBufTypes.insert(id_OSC_CORE);
cfg.cellGroups.emplace_back(); cfg.cellGroups.emplace_back();
cfg.cellGroups.back().insert(id_OXIDE_COMB); cfg.cellGroups.back().insert({id_OXIDE_COMB});
cfg.cellGroups.back().insert(id_OXIDE_FF); cfg.cellGroups.back().insert({id_OXIDE_FF});
cfg.beta = 0.5; cfg.beta = 0.5;
cfg.criticalityExponent = 7; cfg.criticalityExponent = 7;

View File

@ -1340,6 +1340,46 @@ struct Arch : BaseCtx
return cell_type == getBelType(bel); 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 // 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 // This is not intended for Bel type checks, but finer-grained constraints
// such as conflicting set/reset signals, etc // such as conflicting set/reset signals, etc
@ -1541,6 +1581,9 @@ struct Arch : BaseCtx
// ------------------------------------------------- // -------------------------------------------------
void write_fasm(std::ostream &out) const; void write_fasm(std::ostream &out) const;
std::vector<IdString> cell_types;
std::vector<PartitionId> partitions;
}; };
NEXTPNR_NAMESPACE_END NEXTPNR_NAMESPACE_END

View File

@ -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 struct GroupId
{ {
enum : int8_t enum : int8_t
@ -250,4 +261,15 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX DecalId>
return seed; 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 } // namespace std