diff options
author | D. Shah <dave@ds0.me> | 2021-02-04 10:56:19 +0000 |
---|---|---|
committer | D. Shah <dave@ds0.me> | 2021-02-05 19:19:17 +0000 |
commit | 6d794abf495be78c6d1a2a69af432021c1eabfad (patch) | |
tree | 10839432752fc20afc21fe1d7d013371dadc4095 | |
parent | d4363b7ee593ee84957dbe60969cf694903d70ad (diff) | |
download | nextpnr-6d794abf495be78c6d1a2a69af432021c1eabfad.tar.gz nextpnr-6d794abf495be78c6d1a2a69af432021c1eabfad.tar.bz2 nextpnr-6d794abf495be78c6d1a2a69af432021c1eabfad.zip |
Add a few more functions to ArchBase
Signed-off-by: D. Shah <dave@ds0.me>
-rw-r--r-- | common/nextpnr.h | 22 | ||||
-rw-r--r-- | ecp5/arch.h | 7 |
2 files changed, 18 insertions, 11 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index 4063999d..e2e87cbc 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -99,6 +99,8 @@ inline void assert_fail_impl_str(std::string message, const char *expr_str, cons #define NPNR_ASSERT_FALSE(msg) (assert_fail_impl(msg, "false", __FILE__, __LINE__)) #define NPNR_ASSERT_FALSE_STR(msg) (assert_fail_impl_str(msg, "false", __FILE__, __LINE__)) +#define STRINGIFY(x) #x + struct BaseCtx; struct Context; @@ -1016,6 +1018,8 @@ template <typename R> struct ArchBase : BaseCtx // Arch API base // Basic config + virtual std::string getChipName() const = 0; + virtual IdString archId() const { id(STRINGIFY(ARCHNAME)); } virtual int getGridDimX() const = 0; virtual int getGridDimY() const = 0; virtual int getTileBelDimZ(int x, int y) const = 0; @@ -1163,15 +1167,16 @@ template <typename R> struct ArchBase : BaseCtx virtual Loc getPipLocation(PipId pip) const = 0; // Group methods - virtual GroupId getGroupByName(IdStringList name) const = 0; - virtual IdStringList getGroupName(GroupId group) const = 0; + virtual GroupId getGroupByName(IdStringList name) const { return GroupId(); }; + virtual IdStringList getGroupName(GroupId group) const { return IdStringList(); }; virtual delay_t estimateDelay(WireId src, WireId dst) const = 0; virtual ArcBounds getRouteBoundingBox(WireId src, WireId dst) const = 0; virtual typename R::AllGroupsRange getGroups() const = 0; - virtual typename R::GroupBelsRange getGroupBels(GroupId group) const = 0; - virtual typename R::GroupWiresRange getGroupWires(GroupId group) const = 0; - virtual typename R::GroupPipsRange getGroupPips(GroupId group) const = 0; - virtual typename R::GroupGroupsRange getGroupGroups(GroupId group) const = 0; + // Default implementation of these assumes no groups so never called + virtual typename R::GroupBelsRange getGroupBels(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); }; + virtual typename R::GroupWiresRange getGroupWires(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); }; + virtual typename R::GroupPipsRange getGroupPips(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); }; + virtual typename R::GroupGroupsRange getGroupGroups(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); }; // Delay methods virtual delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const = 0; @@ -1186,6 +1191,7 @@ template <typename R> struct ArchBase : BaseCtx } // Decal methods + virtual typename R::DecalGfxRange getDecalGraphics(DecalId decal) const { NPNR_ASSERT_FALSE("unreachable"); }; virtual DecalXY getBelDecal(BelId bel) const { return DecalXY(); } virtual DecalXY getWireDecal(WireId wire) const { return DecalXY(); } virtual DecalXY getPipDecal(PipId pip) const { return DecalXY(); } @@ -1209,8 +1215,8 @@ template <typename R> struct ArchBase : BaseCtx virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); } virtual IdString getBelBucketName(BelBucketId bucket) const = 0; virtual BelBucketId getBelBucketByName(IdString name) const = 0; - virtual BelBucketId getBelBucketForBel(BelId bel) const = 0; - virtual BelBucketId getBelBucketForCellType(IdString cell_type) const = 0; + virtual BelBucketId getBelBucketForBel(BelId bel) const { return getBelBucketForCellType(getBelType(bel)); }; + virtual BelBucketId getBelBucketForCellType(IdString cell_type) const { return getBelBucketByName(cell_type); }; virtual bool isValidBelForCell(CellInfo *cell, BelId bel) const { return true; } virtual bool isBelLocationValid(BelId bel) const { return true; } virtual typename R::CellTypeRange getCellTypes() const = 0; diff --git a/ecp5/arch.h b/ecp5/arch.h index 80374e0d..705a9ebb 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -457,6 +457,8 @@ struct ArchRanges using GroupWiresRange = std::vector<WireId>; using GroupPipsRange = std::vector<PipId>; using GroupGroupsRange = std::vector<GroupId>; + // Decals + using DecalGfxRange = std::vector<GraphicElement>; // Placement validity using CellTypeRange = const std::vector<IdString> &; using BelBucketRange = std::vector<BelBucketId>; @@ -485,10 +487,9 @@ struct Arch : ArchBase<ArchRanges> static bool is_available(ArchArgs::ArchArgsTypes chip); static std::vector<std::string> get_supported_packages(ArchArgs::ArchArgsTypes chip); - std::string getChipName() const; + std::string getChipName() const override; std::string get_full_chip_name() const; - IdString archId() const { return id("ecp5"); } ArchArgs archArgs() const { return args; } IdString archArgsToId(ArchArgs args) const; @@ -864,7 +865,7 @@ struct Arch : ArchBase<ArchRanges> // ------------------------------------------------- - std::vector<GraphicElement> getDecalGraphics(DecalId decal) const; + std::vector<GraphicElement> getDecalGraphics(DecalId decal) const override; DecalXY getBelDecal(BelId bel) const override; DecalXY getWireDecal(WireId wire) const override; |