Add pure-virtual ArchAPI interface
This splits out the pure-virtual definition of the architecture API into ArchAPI; leaving BaseArch to only provide default implementations (which can now be completely opted out of by deriving from ArchAPI instead of BaseArch). Signed-off-by: D. Shah <dave@ds0.me>
This commit is contained in:
parent
b4227f586c
commit
a8a27299ae
302
common/nextpnr.h
302
common/nextpnr.h
@ -1064,26 +1064,128 @@ typename std::enable_if<!std::is_same<Tret, Tc>::value, Tret>::type return_if_ma
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
template <typename R> struct BaseArch : BaseCtx
|
// The specification of the Arch API (pure virtual)
|
||||||
|
template <typename R> struct ArchAPI : BaseCtx
|
||||||
{
|
{
|
||||||
// --------------------------------------------------------------
|
|
||||||
// Arch API base
|
|
||||||
|
|
||||||
// Basic config
|
// Basic config
|
||||||
|
virtual IdString archId() const = 0;
|
||||||
virtual std::string getChipName() const = 0;
|
virtual std::string getChipName() const = 0;
|
||||||
virtual IdString archId() const { return id(STRINGIFY(ARCHNAME)); }
|
|
||||||
virtual int getGridDimX() const = 0;
|
virtual int getGridDimX() const = 0;
|
||||||
virtual int getGridDimY() const = 0;
|
virtual int getGridDimY() const = 0;
|
||||||
virtual int getTileBelDimZ(int x, int y) const = 0;
|
virtual int getTileBelDimZ(int x, int y) const = 0;
|
||||||
virtual int getTilePipDimZ(int x, int y) const { return 1; }
|
virtual int getTilePipDimZ(int x, int y) const = 0;
|
||||||
virtual char getNameDelimiter() const { return ' '; }
|
virtual char getNameDelimiter() const = 0;
|
||||||
|
|
||||||
// Bel methods
|
// Bel methods
|
||||||
virtual typename R::AllBelsRange getBels() const = 0;
|
virtual typename R::AllBelsRange getBels() const = 0;
|
||||||
virtual BelId getBelByName(IdStringList name) const = 0;
|
|
||||||
virtual IdStringList getBelName(BelId bel) const = 0;
|
virtual IdStringList getBelName(BelId bel) const = 0;
|
||||||
virtual uint32_t getBelChecksum(BelId bel) const { return uint32_t(std::hash<BelId>()(bel)); }
|
virtual BelId getBelByName(IdStringList name) const = 0;
|
||||||
virtual void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength)
|
virtual uint32_t getBelChecksum(BelId bel) const = 0;
|
||||||
|
virtual void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) = 0;
|
||||||
|
virtual void unbindBel(BelId bel) = 0;
|
||||||
|
virtual Loc getBelLocation(BelId bel) const = 0;
|
||||||
|
virtual BelId getBelByLocation(Loc loc) const = 0;
|
||||||
|
virtual typename R::TileBelsRange getBelsByTile(int x, int y) const = 0;
|
||||||
|
virtual bool getBelGlobalBuf(BelId bel) const = 0;
|
||||||
|
virtual bool checkBelAvail(BelId bel) const = 0;
|
||||||
|
virtual CellInfo *getBoundBelCell(BelId bel) const = 0;
|
||||||
|
virtual CellInfo *getConflictingBelCell(BelId bel) const = 0;
|
||||||
|
virtual IdString getBelType(BelId bel) const = 0;
|
||||||
|
virtual typename R::BelAttrsRange getBelAttrs(BelId bel) const = 0;
|
||||||
|
virtual WireId getBelPinWire(BelId bel, IdString pin) const = 0;
|
||||||
|
virtual PortType getBelPinType(BelId bel, IdString pin) const = 0;
|
||||||
|
// Wire methods
|
||||||
|
virtual typename R::AllWiresRange getWires() const = 0;
|
||||||
|
virtual WireId getWireByName(IdStringList name) const = 0;
|
||||||
|
virtual IdStringList getWireName(WireId wire) const = 0;
|
||||||
|
virtual IdString getWireType(WireId wire) const = 0;
|
||||||
|
virtual typename R::WireAttrsRange getWireAttrs(WireId) const = 0;
|
||||||
|
virtual typename R::DownhillPipRange getPipsDownhill(WireId wire) const = 0;
|
||||||
|
virtual typename R::UphillPipRange getPipsUphill(WireId wire) const = 0;
|
||||||
|
virtual typename R::WireBelPinRange getWireBelPins(WireId wire) const = 0;
|
||||||
|
virtual uint32_t getWireChecksum(WireId wire) const = 0;
|
||||||
|
virtual void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) = 0;
|
||||||
|
virtual void unbindWire(WireId wire) = 0;
|
||||||
|
virtual bool checkWireAvail(WireId wire) const = 0;
|
||||||
|
virtual NetInfo *getBoundWireNet(WireId wire) const = 0;
|
||||||
|
virtual WireId getConflictingWireWire(WireId wire) const = 0;
|
||||||
|
virtual NetInfo *getConflictingWireNet(WireId wire) const = 0;
|
||||||
|
virtual DelayInfo getWireDelay(WireId wire) const = 0;
|
||||||
|
// Pip methods
|
||||||
|
virtual typename R::AllPipsRange getPips() const = 0;
|
||||||
|
virtual PipId getPipByName(IdStringList name) const = 0;
|
||||||
|
virtual IdStringList getPipName(PipId pip) const = 0;
|
||||||
|
virtual IdString getPipType(PipId pip) const = 0;
|
||||||
|
virtual typename R::PipAttrsRange getPipAttrs(PipId) const = 0;
|
||||||
|
virtual uint32_t getPipChecksum(PipId pip) const = 0;
|
||||||
|
virtual void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) = 0;
|
||||||
|
virtual void unbindPip(PipId pip) = 0;
|
||||||
|
virtual bool checkPipAvail(PipId pip) const = 0;
|
||||||
|
virtual NetInfo *getBoundPipNet(PipId pip) const = 0;
|
||||||
|
virtual WireId getConflictingPipWire(PipId pip) const = 0;
|
||||||
|
virtual NetInfo *getConflictingPipNet(PipId pip) const = 0;
|
||||||
|
virtual WireId getPipSrcWire(PipId pip) const = 0;
|
||||||
|
virtual WireId getPipDstWire(PipId pip) const = 0;
|
||||||
|
virtual DelayInfo getPipDelay(PipId pip) const = 0;
|
||||||
|
virtual Loc getPipLocation(PipId pip) const = 0;
|
||||||
|
// Group methods
|
||||||
|
virtual GroupId getGroupByName(IdStringList name) const = 0;
|
||||||
|
virtual IdStringList getGroupName(GroupId group) 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;
|
||||||
|
// Delay Methods
|
||||||
|
virtual delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const = 0;
|
||||||
|
virtual delay_t getDelayEpsilon() const = 0;
|
||||||
|
virtual delay_t getRipupDelayPenalty() const = 0;
|
||||||
|
virtual float getDelayNS(delay_t v) const = 0;
|
||||||
|
virtual DelayInfo getDelayFromNS(float ns) const = 0;
|
||||||
|
virtual uint32_t getDelayChecksum(delay_t v) const = 0;
|
||||||
|
virtual bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const = 0;
|
||||||
|
virtual delay_t estimateDelay(WireId src, WireId dst) const = 0;
|
||||||
|
virtual ArcBounds getRouteBoundingBox(WireId src, WireId dst) const = 0;
|
||||||
|
// Decal methods
|
||||||
|
virtual typename R::DecalGfxRange getDecalGraphics(DecalId decal) const = 0;
|
||||||
|
virtual DecalXY getBelDecal(BelId bel) const = 0;
|
||||||
|
virtual DecalXY getWireDecal(WireId wire) const = 0;
|
||||||
|
virtual DecalXY getPipDecal(PipId pip) const = 0;
|
||||||
|
virtual DecalXY getGroupDecal(GroupId group) const = 0;
|
||||||
|
// Cell timing methods
|
||||||
|
virtual bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const = 0;
|
||||||
|
virtual TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const = 0;
|
||||||
|
virtual TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const = 0;
|
||||||
|
// Placement validity checks
|
||||||
|
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const = 0;
|
||||||
|
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 bool isValidBelForCell(CellInfo *cell, BelId bel) const = 0;
|
||||||
|
virtual bool isBelLocationValid(BelId bel) const = 0;
|
||||||
|
virtual typename R::CellTypeRange getCellTypes() const = 0;
|
||||||
|
virtual typename R::BelBucketRange getBelBuckets() const = 0;
|
||||||
|
virtual typename R::BucketBelRange getBelsInBucket(BelBucketId bucket) const = 0;
|
||||||
|
// Flow methods
|
||||||
|
virtual bool pack() = 0;
|
||||||
|
virtual bool place() = 0;
|
||||||
|
virtual bool route() = 0;
|
||||||
|
virtual void assignArchInfo() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename R> struct BaseArch : ArchAPI<R>
|
||||||
|
{
|
||||||
|
// --------------------------------------------------------------
|
||||||
|
// Default, trivial, implementations of Arch API functions for arches that don't need complex behaviours
|
||||||
|
|
||||||
|
// Basic config
|
||||||
|
virtual IdString archId() const override { return this->id(STRINGIFY(ARCHNAME)); }
|
||||||
|
virtual int getTilePipDimZ(int x, int y) const override { return 1; }
|
||||||
|
virtual char getNameDelimiter() const override { return ' '; }
|
||||||
|
|
||||||
|
// Bel methods
|
||||||
|
virtual uint32_t getBelChecksum(BelId bel) const override { return uint32_t(std::hash<BelId>()(bel)); }
|
||||||
|
virtual void bindBel(BelId bel, CellInfo *cell, PlaceStrength strength) override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
auto &entry = base_bel2cell[bel];
|
auto &entry = base_bel2cell[bel];
|
||||||
@ -1091,9 +1193,9 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
cell->bel = bel;
|
cell->bel = bel;
|
||||||
cell->belStrength = strength;
|
cell->belStrength = strength;
|
||||||
entry = cell;
|
entry = cell;
|
||||||
refreshUiBel(bel);
|
this->refreshUiBel(bel);
|
||||||
}
|
}
|
||||||
virtual void unbindBel(BelId bel)
|
virtual void unbindBel(BelId bel) override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel != BelId());
|
NPNR_ASSERT(bel != BelId());
|
||||||
auto &entry = base_bel2cell[bel];
|
auto &entry = base_bel2cell[bel];
|
||||||
@ -1101,41 +1203,31 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
entry->bel = BelId();
|
entry->bel = BelId();
|
||||||
entry->belStrength = STRENGTH_NONE;
|
entry->belStrength = STRENGTH_NONE;
|
||||||
entry = nullptr;
|
entry = nullptr;
|
||||||
refreshUiBel(bel);
|
this->refreshUiBel(bel);
|
||||||
}
|
}
|
||||||
virtual Loc getBelLocation(BelId bel) const = 0;
|
|
||||||
virtual BelId getBelByLocation(Loc loc) const = 0;
|
virtual bool getBelGlobalBuf(BelId bel) const override { return false; }
|
||||||
virtual typename R::TileBelsRange getBelsByTile(int x, int y) const = 0;
|
virtual bool checkBelAvail(BelId bel) const override { return getBoundBelCell(bel) == nullptr; };
|
||||||
virtual bool getBelGlobalBuf(BelId bel) const { return false; }
|
virtual CellInfo *getBoundBelCell(BelId bel) const override
|
||||||
virtual bool checkBelAvail(BelId bel) const { return getBoundBelCell(bel) == nullptr; };
|
|
||||||
virtual CellInfo *getBoundBelCell(BelId bel) const
|
|
||||||
{
|
{
|
||||||
auto fnd = base_bel2cell.find(bel);
|
auto fnd = base_bel2cell.find(bel);
|
||||||
return fnd == base_bel2cell.end() ? nullptr : fnd->second;
|
return fnd == base_bel2cell.end() ? nullptr : fnd->second;
|
||||||
}
|
}
|
||||||
virtual CellInfo *getConflictingBelCell(BelId bel) const { return getBoundBelCell(bel); }
|
virtual CellInfo *getConflictingBelCell(BelId bel) const override { return getBoundBelCell(bel); }
|
||||||
virtual IdString getBelType(BelId bel) const = 0;
|
virtual typename R::BelAttrsRange getBelAttrs(BelId bel) const override
|
||||||
virtual typename R::BelAttrsRange getBelAttrs(BelId bel) const
|
|
||||||
{
|
{
|
||||||
return empty_if_possible<typename R::BelAttrsRange>();
|
return empty_if_possible<typename R::BelAttrsRange>();
|
||||||
}
|
}
|
||||||
virtual WireId getBelPinWire(BelId bel, IdString pin) const = 0;
|
|
||||||
virtual PortType getBelPinType(BelId bel, IdString pin) const = 0;
|
|
||||||
|
|
||||||
// Wire methods
|
// Wire methods
|
||||||
virtual typename R::AllWiresRange getWires() const = 0;
|
virtual IdString getWireType(WireId wire) const override { return IdString(); }
|
||||||
virtual WireId getWireByName(IdStringList name) const = 0;
|
virtual typename R::WireAttrsRange getWireAttrs(WireId) const override
|
||||||
virtual IdStringList getWireName(WireId wire) const = 0;
|
|
||||||
virtual IdString getWireType(WireId wire) const { return IdString(); }
|
|
||||||
virtual typename R::WireAttrsRange getWireAttrs(WireId) const
|
|
||||||
{
|
{
|
||||||
return empty_if_possible<typename R::WireAttrsRange>();
|
return empty_if_possible<typename R::WireAttrsRange>();
|
||||||
}
|
}
|
||||||
virtual uint32_t getWireChecksum(WireId wire) const { return uint32_t(std::hash<WireId>()(wire)); }
|
virtual uint32_t getWireChecksum(WireId wire) const override { return uint32_t(std::hash<WireId>()(wire)); }
|
||||||
virtual typename R::DownhillPipRange getPipsDownhill(WireId wire) const = 0;
|
|
||||||
virtual typename R::UphillPipRange getPipsUphill(WireId wire) const = 0;
|
virtual void bindWire(WireId wire, NetInfo *net, PlaceStrength strength) override
|
||||||
virtual typename R::WireBelPinRange getWireBelPins(WireId wire) const = 0;
|
|
||||||
virtual void bindWire(WireId wire, NetInfo *net, PlaceStrength strength)
|
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(wire != WireId());
|
NPNR_ASSERT(wire != WireId());
|
||||||
auto &w2n_entry = base_wire2net[wire];
|
auto &w2n_entry = base_wire2net[wire];
|
||||||
@ -1143,9 +1235,9 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
net->wires[wire].pip = PipId();
|
net->wires[wire].pip = PipId();
|
||||||
net->wires[wire].strength = strength;
|
net->wires[wire].strength = strength;
|
||||||
w2n_entry = net;
|
w2n_entry = net;
|
||||||
refreshUiWire(wire);
|
this->refreshUiWire(wire);
|
||||||
}
|
}
|
||||||
virtual void unbindWire(WireId wire)
|
virtual void unbindWire(WireId wire) override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(wire != WireId());
|
NPNR_ASSERT(wire != WireId());
|
||||||
auto &w2n_entry = base_wire2net[wire];
|
auto &w2n_entry = base_wire2net[wire];
|
||||||
@ -1164,48 +1256,44 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
base_wire2net[wire] = nullptr;
|
base_wire2net[wire] = nullptr;
|
||||||
|
|
||||||
w2n_entry = nullptr;
|
w2n_entry = nullptr;
|
||||||
refreshUiWire(wire);
|
this->refreshUiWire(wire);
|
||||||
}
|
}
|
||||||
virtual bool checkWireAvail(WireId wire) const { return getBoundWireNet(wire) == nullptr; }
|
virtual bool checkWireAvail(WireId wire) const override { return getBoundWireNet(wire) == nullptr; }
|
||||||
virtual NetInfo *getBoundWireNet(WireId wire) const
|
virtual NetInfo *getBoundWireNet(WireId wire) const override
|
||||||
{
|
{
|
||||||
auto fnd = base_wire2net.find(wire);
|
auto fnd = base_wire2net.find(wire);
|
||||||
return fnd == base_wire2net.end() ? nullptr : fnd->second;
|
return fnd == base_wire2net.end() ? nullptr : fnd->second;
|
||||||
}
|
}
|
||||||
virtual WireId getConflictingWireWire(WireId wire) const { return wire; };
|
virtual WireId getConflictingWireWire(WireId wire) const override { return wire; };
|
||||||
virtual NetInfo *getConflictingWireNet(WireId wire) const { return getBoundWireNet(wire); }
|
virtual NetInfo *getConflictingWireNet(WireId wire) const override { return getBoundWireNet(wire); }
|
||||||
virtual DelayInfo getWireDelay(WireId wire) const = 0;
|
|
||||||
|
|
||||||
// Pip methods
|
// Pip methods
|
||||||
virtual typename R::AllPipsRange getPips() const = 0;
|
|
||||||
virtual PipId getPipByName(IdStringList name) const = 0;
|
|
||||||
virtual IdStringList getPipName(PipId pip) const = 0;
|
|
||||||
virtual IdString getPipType(PipId pip) const { return IdString(); }
|
virtual IdString getPipType(PipId pip) const { return IdString(); }
|
||||||
virtual typename R::PipAttrsRange getPipAttrs(PipId) const
|
virtual typename R::PipAttrsRange getPipAttrs(PipId) const override
|
||||||
{
|
{
|
||||||
return empty_if_possible<typename R::PipAttrsRange>();
|
return empty_if_possible<typename R::PipAttrsRange>();
|
||||||
}
|
}
|
||||||
virtual uint32_t getPipChecksum(PipId pip) const { return uint32_t(std::hash<PipId>()(pip)); }
|
virtual uint32_t getPipChecksum(PipId pip) const override { return uint32_t(std::hash<PipId>()(pip)); }
|
||||||
virtual void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
|
virtual void bindPip(PipId pip, NetInfo *net, PlaceStrength strength) override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(pip != PipId());
|
NPNR_ASSERT(pip != PipId());
|
||||||
auto &p2n_entry = base_pip2net[pip];
|
auto &p2n_entry = base_pip2net[pip];
|
||||||
NPNR_ASSERT(p2n_entry == nullptr);
|
NPNR_ASSERT(p2n_entry == nullptr);
|
||||||
p2n_entry = net;
|
p2n_entry = net;
|
||||||
|
|
||||||
WireId dst = getPipDstWire(pip);
|
WireId dst = this->getPipDstWire(pip);
|
||||||
auto &w2n_entry = base_wire2net[dst];
|
auto &w2n_entry = base_wire2net[dst];
|
||||||
NPNR_ASSERT(w2n_entry == nullptr);
|
NPNR_ASSERT(w2n_entry == nullptr);
|
||||||
w2n_entry = net;
|
w2n_entry = net;
|
||||||
net->wires[dst].pip = pip;
|
net->wires[dst].pip = pip;
|
||||||
net->wires[dst].strength = strength;
|
net->wires[dst].strength = strength;
|
||||||
}
|
}
|
||||||
virtual void unbindPip(PipId pip)
|
virtual void unbindPip(PipId pip) override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(pip != PipId());
|
NPNR_ASSERT(pip != PipId());
|
||||||
auto &p2n_entry = base_pip2net[pip];
|
auto &p2n_entry = base_pip2net[pip];
|
||||||
NPNR_ASSERT(p2n_entry != nullptr);
|
NPNR_ASSERT(p2n_entry != nullptr);
|
||||||
WireId dst = getPipDstWire(pip);
|
WireId dst = this->getPipDstWire(pip);
|
||||||
|
|
||||||
auto &w2n_entry = base_wire2net[dst];
|
auto &w2n_entry = base_wire2net[dst];
|
||||||
NPNR_ASSERT(w2n_entry != nullptr);
|
NPNR_ASSERT(w2n_entry != nullptr);
|
||||||
@ -1214,93 +1302,99 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
p2n_entry->wires.erase(dst);
|
p2n_entry->wires.erase(dst);
|
||||||
p2n_entry = nullptr;
|
p2n_entry = nullptr;
|
||||||
}
|
}
|
||||||
virtual bool checkPipAvail(PipId pip) const { return getBoundPipNet(pip) == nullptr; }
|
virtual bool checkPipAvail(PipId pip) const override { return getBoundPipNet(pip) == nullptr; }
|
||||||
virtual NetInfo *getBoundPipNet(PipId pip) const
|
virtual NetInfo *getBoundPipNet(PipId pip) const override
|
||||||
{
|
{
|
||||||
auto fnd = base_pip2net.find(pip);
|
auto fnd = base_pip2net.find(pip);
|
||||||
return fnd == base_pip2net.end() ? nullptr : fnd->second;
|
return fnd == base_pip2net.end() ? nullptr : fnd->second;
|
||||||
}
|
}
|
||||||
virtual WireId getConflictingPipWire(PipId pip) const { return WireId(); }
|
virtual WireId getConflictingPipWire(PipId pip) const override { return WireId(); }
|
||||||
virtual NetInfo *getConflictingPipNet(PipId pip) const { return getBoundPipNet(pip); }
|
virtual NetInfo *getConflictingPipNet(PipId pip) const override { return getBoundPipNet(pip); }
|
||||||
virtual WireId getPipSrcWire(PipId pip) const = 0;
|
|
||||||
virtual WireId getPipDstWire(PipId pip) const = 0;
|
|
||||||
virtual DelayInfo getPipDelay(PipId pip) const = 0;
|
|
||||||
virtual Loc getPipLocation(PipId pip) const = 0;
|
|
||||||
|
|
||||||
// Group methods
|
// Group methods
|
||||||
virtual GroupId getGroupByName(IdStringList name) const { return GroupId(); };
|
virtual GroupId getGroupByName(IdStringList name) const override { return GroupId(); };
|
||||||
virtual IdStringList getGroupName(GroupId group) const { return IdStringList(); };
|
virtual IdStringList getGroupName(GroupId group) const override { return IdStringList(); };
|
||||||
virtual delay_t estimateDelay(WireId src, WireId dst) const = 0;
|
virtual typename R::AllGroupsRange getGroups() const override
|
||||||
virtual ArcBounds getRouteBoundingBox(WireId src, WireId dst) const = 0;
|
{
|
||||||
virtual typename R::AllGroupsRange getGroups() const { return empty_if_possible<typename R::AllGroupsRange>(); }
|
return empty_if_possible<typename R::AllGroupsRange>();
|
||||||
|
}
|
||||||
// Default implementation of these assumes no groups so never called
|
// 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::GroupBelsRange getGroupBels(GroupId group) const override { NPNR_ASSERT_FALSE("unreachable"); };
|
||||||
virtual typename R::GroupWiresRange getGroupWires(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); };
|
virtual typename R::GroupWiresRange getGroupWires(GroupId group) const override
|
||||||
virtual typename R::GroupPipsRange getGroupPips(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); };
|
{
|
||||||
virtual typename R::GroupGroupsRange getGroupGroups(GroupId group) const { NPNR_ASSERT_FALSE("unreachable"); };
|
NPNR_ASSERT_FALSE("unreachable");
|
||||||
|
};
|
||||||
|
virtual typename R::GroupPipsRange getGroupPips(GroupId group) const override { NPNR_ASSERT_FALSE("unreachable"); };
|
||||||
|
virtual typename R::GroupGroupsRange getGroupGroups(GroupId group) const override
|
||||||
|
{
|
||||||
|
NPNR_ASSERT_FALSE("unreachable");
|
||||||
|
};
|
||||||
|
|
||||||
// Delay methods
|
// Delay methods
|
||||||
virtual delay_t predictDelay(const NetInfo *net_info, const PortRef &sink) const = 0;
|
virtual bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const override
|
||||||
virtual delay_t getDelayEpsilon() const = 0;
|
|
||||||
virtual delay_t getRipupDelayPenalty() const = 0;
|
|
||||||
virtual float getDelayNS(delay_t v) const = 0;
|
|
||||||
virtual DelayInfo getDelayFromNS(float ns) const = 0;
|
|
||||||
virtual uint32_t getDelayChecksum(delay_t v) const = 0;
|
|
||||||
virtual bool getBudgetOverride(const NetInfo *net_info, const PortRef &sink, delay_t &budget) const
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decal methods
|
// Decal methods
|
||||||
virtual typename R::DecalGfxRange getDecalGraphics(DecalId decal) const { NPNR_ASSERT_FALSE("unreachable"); };
|
virtual typename R::DecalGfxRange getDecalGraphics(DecalId decal) const override
|
||||||
virtual DecalXY getBelDecal(BelId bel) const { return DecalXY(); }
|
{
|
||||||
virtual DecalXY getWireDecal(WireId wire) const { return DecalXY(); }
|
NPNR_ASSERT_FALSE("unreachable");
|
||||||
virtual DecalXY getPipDecal(PipId pip) const { return DecalXY(); }
|
};
|
||||||
virtual DecalXY getGroupDecal(GroupId group) const { return DecalXY(); }
|
virtual DecalXY getBelDecal(BelId bel) const override { return DecalXY(); }
|
||||||
|
virtual DecalXY getWireDecal(WireId wire) const override { return DecalXY(); }
|
||||||
|
virtual DecalXY getPipDecal(PipId pip) const override { return DecalXY(); }
|
||||||
|
virtual DecalXY getGroupDecal(GroupId group) const override { return DecalXY(); }
|
||||||
|
|
||||||
// Cell timing methods
|
// Cell timing methods
|
||||||
virtual bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const
|
virtual bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayInfo &delay) const override
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
virtual TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const
|
virtual TimingPortClass getPortTimingClass(const CellInfo *cell, IdString port, int &clockInfoCount) const override
|
||||||
{
|
{
|
||||||
return TMG_IGNORE;
|
return TMG_IGNORE;
|
||||||
}
|
}
|
||||||
virtual TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const
|
virtual TimingClockingInfo getPortClockingInfo(const CellInfo *cell, IdString port, int index) const override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT_FALSE("unreachable");
|
NPNR_ASSERT_FALSE("unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Placement validity checks
|
// Placement validity checks
|
||||||
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const { return cell_type == getBelType(bel); }
|
virtual bool isValidBelForCellType(IdString cell_type, BelId bel) const override
|
||||||
virtual IdString getBelBucketName(BelBucketId bucket) const { return bbid_to_name<BelBucketId>(bucket); }
|
{
|
||||||
virtual BelBucketId getBelBucketByName(IdString name) const { return bbid_from_name<BelBucketId>(name); }
|
return cell_type == this->getBelType(bel);
|
||||||
virtual BelBucketId getBelBucketForBel(BelId bel) const { return getBelBucketForCellType(getBelType(bel)); };
|
}
|
||||||
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const { return getBelBucketByName(cell_type); };
|
virtual IdString getBelBucketName(BelBucketId bucket) const override { return bbid_to_name<BelBucketId>(bucket); }
|
||||||
virtual bool isValidBelForCell(CellInfo *cell, BelId bel) const { return true; }
|
virtual BelBucketId getBelBucketByName(IdString name) const override { return bbid_from_name<BelBucketId>(name); }
|
||||||
virtual bool isBelLocationValid(BelId bel) const { return true; }
|
virtual BelBucketId getBelBucketForBel(BelId bel) const override
|
||||||
virtual typename R::CellTypeRange getCellTypes() const
|
{
|
||||||
|
return getBelBucketForCellType(this->getBelType(bel));
|
||||||
|
};
|
||||||
|
virtual BelBucketId getBelBucketForCellType(IdString cell_type) const override
|
||||||
|
{
|
||||||
|
return getBelBucketByName(cell_type);
|
||||||
|
};
|
||||||
|
virtual bool isValidBelForCell(CellInfo *cell, BelId bel) const override { return true; }
|
||||||
|
virtual bool isBelLocationValid(BelId bel) const override { return true; }
|
||||||
|
virtual typename R::CellTypeRange getCellTypes() const override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(cell_types_initialised);
|
NPNR_ASSERT(cell_types_initialised);
|
||||||
return return_if_match<const std::vector<IdString> &, typename R::CellTypeRange>(cell_types);
|
return return_if_match<const std::vector<IdString> &, typename R::CellTypeRange>(cell_types);
|
||||||
}
|
}
|
||||||
virtual typename R::BelBucketRange getBelBuckets() const
|
virtual typename R::BelBucketRange getBelBuckets() const override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel_buckets_initialised);
|
NPNR_ASSERT(bel_buckets_initialised);
|
||||||
return return_if_match<const std::vector<BelBucketId> &, typename R::BelBucketRange>(bel_buckets);
|
return return_if_match<const std::vector<BelBucketId> &, typename R::BelBucketRange>(bel_buckets);
|
||||||
}
|
}
|
||||||
virtual typename R::BucketBelRange getBelsInBucket(BelBucketId bucket) const
|
virtual typename R::BucketBelRange getBelsInBucket(BelBucketId bucket) const override
|
||||||
{
|
{
|
||||||
NPNR_ASSERT(bel_buckets_initialised);
|
NPNR_ASSERT(bel_buckets_initialised);
|
||||||
return return_if_match<const std::vector<BelId> &, typename R::BucketBelRange>(bucket_bels.at(bucket));
|
return return_if_match<const std::vector<BelId> &, typename R::BucketBelRange>(bucket_bels.at(bucket));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flow methods
|
// Flow methods
|
||||||
virtual bool pack() = 0;
|
virtual void assignArchInfo() override{};
|
||||||
virtual bool place() = 0;
|
|
||||||
virtual bool route() = 0;
|
|
||||||
virtual void assignArchInfo(){};
|
|
||||||
|
|
||||||
// --------------------------------------------------------------
|
// --------------------------------------------------------------
|
||||||
// These structures are used to provide default implementations of bel/wire/pip binding. Arches might want to
|
// These structures are used to provide default implementations of bel/wire/pip binding. Arches might want to
|
||||||
@ -1321,20 +1415,20 @@ template <typename R> struct BaseArch : BaseCtx
|
|||||||
void init_cell_types()
|
void init_cell_types()
|
||||||
{
|
{
|
||||||
std::unordered_set<IdString> bel_types;
|
std::unordered_set<IdString> bel_types;
|
||||||
for (auto bel : getBels())
|
for (auto bel : this->getBels())
|
||||||
bel_types.insert(getBelType(bel));
|
bel_types.insert(this->getBelType(bel));
|
||||||
std::copy(bel_types.begin(), bel_types.end(), std::back_inserter(cell_types));
|
std::copy(bel_types.begin(), bel_types.end(), std::back_inserter(cell_types));
|
||||||
std::sort(cell_types.begin(), cell_types.end());
|
std::sort(cell_types.begin(), cell_types.end());
|
||||||
cell_types_initialised = true;
|
cell_types_initialised = true;
|
||||||
}
|
}
|
||||||
void init_bel_buckets()
|
void init_bel_buckets()
|
||||||
{
|
{
|
||||||
for (auto cell_type : getCellTypes()) {
|
for (auto cell_type : this->getCellTypes()) {
|
||||||
auto bucket = getBelBucketForCellType(cell_type);
|
auto bucket = this->getBelBucketForCellType(cell_type);
|
||||||
bucket_bels[bucket]; // create empty bucket
|
bucket_bels[bucket]; // create empty bucket
|
||||||
}
|
}
|
||||||
for (auto bel : getBels()) {
|
for (auto bel : this->getBels()) {
|
||||||
auto bucket = getBelBucketForBel(bel);
|
auto bucket = this->getBelBucketForBel(bel);
|
||||||
bucket_bels[bucket].push_back(bel);
|
bucket_bels[bucket].push_back(bel);
|
||||||
}
|
}
|
||||||
for (auto &b : bucket_bels)
|
for (auto &b : bucket_bels)
|
||||||
|
Loading…
Reference in New Issue
Block a user