From e88bd34c02272ecdad6295123941d9040fa4f043 Mon Sep 17 00:00:00 2001 From: gatecat Date: Thu, 30 Dec 2021 13:18:34 +0000 Subject: Viaduct API for a hybrid between generic and full-custom arch Signed-off-by: gatecat --- generic/arch.h | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'generic/arch.h') diff --git a/generic/arch.h b/generic/arch.h index 885089ca..e96853f1 100644 --- a/generic/arch.h +++ b/generic/arch.h @@ -23,10 +23,12 @@ #include #include "arch_api.h" +#include "base_arch.h" #include "idstring.h" #include "idstringlist.h" #include "nextpnr_namespaces.h" #include "nextpnr_types.h" +#include "viaduct_api.h" NEXTPNR_NAMESPACE_BEGIN @@ -126,7 +128,7 @@ template struct linear_range iterator end() const { return iterator(size); } }; -struct ArchRanges +struct ArchRanges : BaseArchRanges { using ArchArgsT = ArchArgs; // Bels @@ -158,9 +160,10 @@ struct ArchRanges using BucketBelRangeT = std::vector; }; -struct Arch : ArchAPI +struct Arch : BaseArch { std::string chipName; + std::unique_ptr uarch{}; std::vector wires; std::vector pips; @@ -325,6 +328,8 @@ struct Arch : ArchAPI std::vector getCellTypes() const override { + if (uarch) + return uarch->getCellTypes(); pool cell_types; for (auto bel : bels) { cell_types.insert(bel.type); @@ -339,9 +344,15 @@ struct Arch : ArchAPI BelBucketId getBelBucketByName(IdString bucket) const override { return bucket; } - BelBucketId getBelBucketForBel(BelId bel) const override { return getBelType(bel); } + BelBucketId getBelBucketForBel(BelId bel) const override + { + return uarch ? uarch->getBelBucketForBel(bel) : getBelType(bel); + } - BelBucketId getBelBucketForCellType(IdString cell_type) const override { return cell_type; } + BelBucketId getBelBucketForCellType(IdString cell_type) const override + { + return uarch ? uarch->getBelBucketForCellType(cell_type) : cell_type; + } std::vector getBelsInBucket(BelBucketId bucket) const override { @@ -366,19 +377,11 @@ struct Arch : ArchAPI // Get the TimingClockingInfo of a port TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override; - bool isValidBelForCellType(IdString cell_type, BelId bel) const override { return cell_type == getBelType(bel); } - bool isBelLocationValid(BelId bel) const override; - - // TODO - CellInfo *getClusterRootCell(ClusterId cluster) const override { NPNR_ASSERT_FALSE("unimplemented"); } - ArcBounds getClusterBounds(ClusterId cluster) const override { NPNR_ASSERT_FALSE("unimplemented"); } - Loc getClusterOffset(const CellInfo *cell) const override { NPNR_ASSERT_FALSE("unimplemented"); } - bool isClusterStrict(const CellInfo *cell) const override { NPNR_ASSERT_FALSE("unimplemented"); } - bool getClusterPlacement(ClusterId cluster, BelId root_bel, - std::vector> &placement) const override + bool isValidBelForCellType(IdString cell_type, BelId bel) const override { - NPNR_ASSERT_FALSE("unimplemented"); + return uarch ? uarch->isValidBelForCellType(cell_type, bel) : cell_type == getBelType(bel); } + bool isBelLocationValid(BelId bel) const override; static const std::string defaultPlacer; static const std::vector availablePlacers; -- cgit v1.2.3