From 7ad9914e519d465cfb36e0114a644e2d03c6f4fa Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 9 Mar 2023 11:04:38 +0100 Subject: Extend chipdb with metadata --- machxo2/arch.h | 69 ++++++++++++++++++++++++---------------------------------- 1 file changed, 28 insertions(+), 41 deletions(-) (limited to 'machxo2/arch.h') diff --git a/machxo2/arch.h b/machxo2/arch.h index 26e8a9ef..4e0ed2fd 100644 --- a/machxo2/arch.h +++ b/machxo2/arch.h @@ -25,31 +25,13 @@ #include #include "base_arch.h" -#include "nextpnr_namespaces.h" #include "nextpnr_types.h" +#include "relptr.h" NEXTPNR_NAMESPACE_BEGIN /**** Everything in this section must be kept in sync with chipdb.py ****/ -template struct RelPtr -{ - int32_t offset; - - // void set(const T *ptr) { - // offset = reinterpret_cast(ptr) - - // reinterpret_cast(this); - // } - - const T *get() const { return reinterpret_cast(reinterpret_cast(this) + offset); } - - const T &operator[](std::size_t index) const { return get()[index]; } - - const T &operator*() const { return *(get()); } - - const T *operator->() const { return get(); } -}; - // FIXME: All "rel locs" are actually absolute, naming typo in facade_import. // Does not affect runtime functionality. @@ -141,7 +123,29 @@ NPNR_PACKED_STRUCT(struct TileInfoPOD { RelPtr tile_names; }); +NPNR_PACKED_STRUCT(struct PackageSupportedPOD { + RelPtr name; + RelPtr short_name; +}); + +NPNR_PACKED_STRUCT(struct SuffixeSupportedPOD { + RelPtr suffix; +}); + +NPNR_PACKED_STRUCT(struct SpeedSupportedPOD { + int32_t speed; +}); + +NPNR_PACKED_STRUCT(struct VariantInfoPOD { + RelPtr name; + RelSlice packages; + RelSlice speed_grades; + RelSlice suffixes; +}); + NPNR_PACKED_STRUCT(struct ChipInfoPOD { + RelPtr family; + RelPtr device_name; int32_t width, height; int32_t num_tiles; int32_t num_packages, num_pios; @@ -151,6 +155,7 @@ NPNR_PACKED_STRUCT(struct ChipInfoPOD { RelPtr package_info; RelPtr pio_info; RelPtr tile_info; + RelSlice variants; }); /************************ End of chipdb section. ************************/ @@ -361,26 +366,7 @@ struct PipRange struct ArchArgs { - enum ArchArgsTypes - { - NONE, - LCMXO2_256HC, - LCMXO2_640HC, - LCMXO2_1200HC, - LCMXO2_2000HC, - LCMXO2_4000HC, - LCMXO2_7000HC, - } type = NONE; - std::string package; - enum SpeedGrade - { - SPEED_1 = 0, - SPEED_2, - SPEED_3, - SPEED_4, - SPEED_5, - SPEED_6, - } speed = SPEED_4; + std::string device; }; struct ArchRanges : BaseArchRanges @@ -403,6 +389,8 @@ struct Arch : BaseArch { const ChipInfoPOD *chip_info; const PackageInfoPOD *package_info; + const char *package_name; + const char *device_name; mutable dict pip_by_name; @@ -429,8 +417,7 @@ struct Arch : BaseArch ArchArgs args; Arch(ArchArgs args); - static bool is_available(ArchArgs::ArchArgsTypes chip); - static std::vector get_supported_packages(ArchArgs::ArchArgsTypes chip); + static void list_devices(); std::string getChipName() const override; // Extra helper -- cgit v1.2.3