aboutsummaryrefslogtreecommitdiffstats
path: root/ecp5/arch.h
diff options
context:
space:
mode:
authorSergiusz Bazanski <q3k@q3k.org>2018-07-14 11:25:38 +0100
committerSergiusz Bazanski <q3k@q3k.org>2018-07-14 11:25:38 +0100
commitf333a68753655a4ccf7da9a4da96e7fdd19f9d08 (patch)
treed2464ef182805d07139089d86522f190fcb8b153 /ecp5/arch.h
parent8ca7a6da2525463be5be4ee9f62cfae0acc06b01 (diff)
downloadnextpnr-f333a68753655a4ccf7da9a4da96e7fdd19f9d08.tar.gz
nextpnr-f333a68753655a4ccf7da9a4da96e7fdd19f9d08.tar.bz2
nextpnr-f333a68753655a4ccf7da9a4da96e7fdd19f9d08.zip
Add read/mutate context stubs for ECP5
Diffstat (limited to 'ecp5/arch.h')
-rw-r--r--ecp5/arch.h105
1 files changed, 103 insertions, 2 deletions
diff --git a/ecp5/arch.h b/ecp5/arch.h
index 930c488e..421a7738 100644
--- a/ecp5/arch.h
+++ b/ecp5/arch.h
@@ -339,8 +339,10 @@ struct ArchArgs
struct Arch : BaseCtx
{
- const ChipInfoPOD *chip_info;
-
+ // We let proxy methods access our state.
+ friend class ArchMutateMethods;
+ friend class ArchReadMethods;
+private:
mutable std::unordered_map<IdString, BelId> bel_by_name;
mutable std::unordered_map<IdString, WireId> wire_by_name;
mutable std::unordered_map<IdString, PipId> pip_by_name;
@@ -350,6 +352,9 @@ struct Arch : BaseCtx
std::unordered_map<PipId, IdString> pip_to_net;
std::unordered_map<PipId, IdString> switches_locked;
+public:
+ const ChipInfoPOD *chip_info;
+
ArchArgs args;
Arch(ArchArgs args);
@@ -762,4 +767,100 @@ struct Arch : BaseCtx
bool isBelLocationValid(BelId bel) const;
};
+class ArchReadMethods : public BaseReadCtx
+{
+ private:
+ const Arch *parent_;
+ const ChipInfoPOD *chip_info;
+
+ const std::unordered_map<BelId, IdString> &bel_to_cell;
+ const std::unordered_map<WireId, IdString> &wire_to_net;
+ const std::unordered_map<PipId, IdString> &pip_to_net;
+ const std::unordered_map<PipId, IdString> &switches_locked;
+ std::unordered_map<IdString, BelId> &bel_by_name;
+ std::unordered_map<IdString, WireId> &wire_by_name;
+ std::unordered_map<IdString, PipId> &pip_by_name;
+
+ public:
+ ~ArchReadMethods() noexcept {}
+ ArchReadMethods(const Arch *parent)
+ : BaseReadCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
+ wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
+ switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
+ wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
+ {
+ }
+ ArchReadMethods(ArchReadMethods &&other) noexcept : ArchReadMethods(other.parent_) {}
+ ArchReadMethods(const ArchReadMethods &other) : ArchReadMethods(other.parent_) {}
+
+ /// Perform placement validity checks, returning false on failure (all implemented in arch_place.cc)
+ // 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
+ // such as conflicting set/reset signals, etc
+ bool isValidBelForCell(CellInfo *cell, BelId bel) const;
+ // Return true whether all Bels at a given location are valid
+ bool isBelLocationValid(BelId bel) const;
+ // Helper function for above
+ bool logicCellsCompatible(const std::vector<const CellInfo *> &cells) const;
+
+ bool checkWireAvail(WireId wire) const;
+ bool checkPipAvail(PipId pip) const;
+ bool checkBelAvail(BelId bel) const;
+
+ WireId getWireByName(IdString name) const;
+ WireId getWireBelPin(BelId bel, PortPin pin) const;
+ PipId getPipByName(IdString name) const;
+
+ IdString getConflictingWireNet(WireId wire) const;
+ IdString getConflictingPipNet(PipId pip) const;
+ IdString getConflictingBelCell(BelId bel) const;
+
+ IdString getBoundWireNet(WireId wire) const;
+ IdString getBoundPipNet(PipId pip) const;
+ IdString getBoundBelCell(BelId bel) const;
+
+ BelId getBelByName(IdString name) const;
+
+ std::vector<GraphicElement> getDecalGraphics(DecalId decal) const;
+};
+
+class ArchMutateMethods : public BaseMutateCtx
+{
+ friend class MutateContext;
+
+ private:
+ Arch *parent_;
+ const ChipInfoPOD *chip_info;
+
+ std::unordered_map<BelId, IdString> &bel_to_cell;
+ std::unordered_map<WireId, IdString> &wire_to_net;
+ std::unordered_map<PipId, IdString> &pip_to_net;
+ std::unordered_map<PipId, IdString> &switches_locked;
+ std::unordered_map<IdString, BelId> &bel_by_name;
+ std::unordered_map<IdString, WireId> &wire_by_name;
+ std::unordered_map<IdString, PipId> &pip_by_name;
+
+ public:
+ ~ArchMutateMethods() noexcept {}
+ ArchMutateMethods(Arch *parent)
+ : BaseMutateCtx(parent), parent_(parent), chip_info(parent->chip_info), bel_to_cell(parent->bel_to_cell),
+ wire_to_net(parent->wire_to_net), pip_to_net(parent->pip_to_net),
+ switches_locked(parent->switches_locked), bel_by_name(parent->bel_by_name),
+ wire_by_name(parent->wire_by_name), pip_by_name(parent->pip_by_name)
+ {
+ }
+ ArchMutateMethods(ArchMutateMethods &&other) noexcept : ArchMutateMethods(other.parent_) {}
+ ArchMutateMethods(const ArchMutateMethods &other) : ArchMutateMethods(other.parent_) {}
+
+ void unbindWire(WireId wire);
+ void unbindPip(PipId pip);
+ void unbindBel(BelId bel);
+ void bindWire(WireId wire, IdString net, PlaceStrength strength);
+ void bindPip(PipId pip, IdString net, PlaceStrength strength);
+ void bindBel(BelId bel, IdString cell, PlaceStrength strength);
+ // Returned pointer is valid as long as Proxy object exists.
+ CellInfo *getCell(IdString cell);
+};
+
+
NEXTPNR_NAMESPACE_END