diff options
author | gatecat <gatecat@ds0.me> | 2021-05-01 13:12:33 +0100 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2021-05-15 14:54:33 +0100 |
commit | 9901a5fafc8ea05e21eae434e4a56c921eb951e7 (patch) | |
tree | 83cd46cdd5dfcfd8600ab109930daafa0e1bee35 | |
parent | 7e57196cf924237a5b6c77025768fcf225b9aa9d (diff) | |
download | nextpnr-9901a5fafc8ea05e21eae434e4a56c921eb951e7.tar.gz nextpnr-9901a5fafc8ea05e21eae434e4a56c921eb951e7.tar.bz2 nextpnr-9901a5fafc8ea05e21eae434e4a56c921eb951e7.zip |
cyclonev: Add wire and pip types
Signed-off-by: gatecat <gatecat@ds0.me>
-rw-r--r-- | cyclonev/arch.h | 20 | ||||
-rw-r--r-- | cyclonev/archdefs.h | 37 |
2 files changed, 45 insertions, 12 deletions
diff --git a/cyclonev/arch.h b/cyclonev/arch.h index 84ab72f2..e1294e3f 100644 --- a/cyclonev/arch.h +++ b/cyclonev/arch.h @@ -54,6 +54,22 @@ struct BelInfo bool gb; }; +struct WireInfo +{ + // name_override is only used for nextpnr-created wires + // otherwise; this is empty and a name is created according to mistral rules + IdString name_override; + + // these are transformed on-the-fly to PipId by the iterator, to save space (WireId is half the size of PipId) + std::vector<WireId> wires_downhill; + std::vector<WireId> wires_uphill; + + std::vector<BelPin> bel_pins; + + // flags for special wires (currently unused) + uint64_t flags; +}; + struct ArchRanges : BaseArchRanges { using ArchArgsT = ArchArgs; @@ -117,8 +133,8 @@ struct Arch : BaseArch<ArchRanges> const std::vector<PipId> &getPips() const override; Loc getPipLocation(PipId pip) const override; IdStringList getPipName(PipId pip) const override; - WireId getPipSrcWire(PipId pip) const override; - WireId getPipDstWire(PipId pip) const override; + WireId getPipSrcWire(PipId pip) const override { return WireId(pip.src); }; + WireId getPipDstWire(PipId pip) const override { return WireId(pip.dst); }; DelayQuad getPipDelay(PipId pip) const override; const std::vector<PipId> &getPipsDownhill(WireId wire) const override; const std::vector<PipId> &getPipsUphill(WireId wire) const override; diff --git a/cyclonev/archdefs.h b/cyclonev/archdefs.h index 71948ca1..249fd3d2 100644 --- a/cyclonev/archdefs.h +++ b/cyclonev/archdefs.h @@ -25,6 +25,7 @@ #include "cyclonev.h" #include "idstring.h" +#include "nextpnr_assertions.h" #include "nextpnr_namespaces.h" NEXTPNR_NAMESPACE_BEGIN @@ -84,22 +85,35 @@ struct BelId bool operator<(const BelId &other) const { return pos < other.pos || (pos == other.pos && z < other.z); } }; +static constexpr auto invalid_rnode = std::numeric_limits<CycloneV::rnode_t>::max(); + struct WireId { - int32_t index = -1; + WireId() = default; + explicit WireId(CycloneV::rnode_t node) : node(node){}; + CycloneV::rnode_t node = invalid_rnode; + + // Wires created by nextpnr have rnode type >= 128 + bool is_nextpnr_created() const + { + NPNR_ASSERT(node != invalid_rnode); + return CycloneV::rn2t(node) >= 128; + } - bool operator==(const WireId &other) const { return index == other.index; } - bool operator!=(const WireId &other) const { return index != other.index; } - bool operator<(const WireId &other) const { return index < other.index; } + bool operator==(const WireId &other) const { return node == other.node; } + bool operator!=(const WireId &other) const { return node != other.node; } + bool operator<(const WireId &other) const { return node < other.node; } }; struct PipId { - int32_t index = -1; + PipId() = default; + PipId(CycloneV::rnode_t src, CycloneV::rnode_t dst) : src(src), dst(dst){}; + CycloneV::rnode_t src = invalid_rnode, dst = invalid_rnode; - bool operator==(const PipId &other) const { return index == other.index; } - bool operator!=(const PipId &other) const { return index != other.index; } - bool operator<(const PipId &other) const { return index < other.index; } + bool operator==(const PipId &other) const { return src == other.src && dst == other.dst; } + bool operator!=(const PipId &other) const { return src != other.src || dst != other.dst; } + bool operator<(const PipId &other) const { return dst < other.dst || (dst == other.dst && src < other.src); } }; typedef IdString DecalId; @@ -129,13 +143,16 @@ template <> struct hash<NEXTPNR_NAMESPACE_PREFIX WireId> { std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX WireId &wire) const noexcept { - return hash<int>()(wire.index); + return hash<uint32_t>()(wire.node); } }; template <> struct hash<NEXTPNR_NAMESPACE_PREFIX PipId> { - std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept { return hash<int>()(pip.index); } + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX PipId &pip) const noexcept + { + return hash<uint64_t>()((uint64_t(pip.dst) << 32) | pip.src); + } }; } // namespace std |