cyclonev: Add some range types
Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
parent
c3cb9aa3f6
commit
af0bffbae9
@ -71,6 +71,61 @@ struct WireInfo
|
||||
uint64_t flags;
|
||||
};
|
||||
|
||||
// This transforms a WireIds, and adds the mising half of the pair to create a PipId
|
||||
using WireVecIterator = std::vector<WireId>::const_iterator;
|
||||
struct UpDownhillPipIterator
|
||||
{
|
||||
WireVecIterator base;
|
||||
WireId other_wire;
|
||||
bool is_uphill;
|
||||
|
||||
UpDownhillPipIterator(WireVecIterator base, WireId other_wire, bool is_uphill)
|
||||
: base(base), other_wire(other_wire), is_uphill(is_uphill){};
|
||||
|
||||
bool operator!=(const UpDownhillPipIterator &other) { return base != other.base; }
|
||||
UpDownhillPipIterator operator++()
|
||||
{
|
||||
++base;
|
||||
return *this;
|
||||
}
|
||||
UpDownhillPipIterator operator++(int)
|
||||
{
|
||||
UpDownhillPipIterator prior(*this);
|
||||
++(*this);
|
||||
return prior;
|
||||
}
|
||||
PipId operator*() { return is_uphill ? PipId(base->node, other_wire.node) : PipId(other_wire.node, base->node); }
|
||||
};
|
||||
|
||||
struct UpDownhillPipRange
|
||||
{
|
||||
UpDownhillPipIterator b, e;
|
||||
|
||||
UpDownhillPipRange(const std::vector<WireId> &v, WireId other_wire, bool is_uphill)
|
||||
: b(v.cbegin(), other_wire, is_uphill), e(v.cend(), other_wire, is_uphill){};
|
||||
|
||||
UpDownhillPipIterator begin() const { return b; }
|
||||
UpDownhillPipIterator end() const { return e; }
|
||||
};
|
||||
|
||||
// This transforms a map to a range of keys, used as the wire iterator
|
||||
template <typename T> struct key_range
|
||||
{
|
||||
key_range(const T &t) : b(t.cbegin()), e(t.cend()){};
|
||||
typename T::const_iterator b, e;
|
||||
|
||||
struct xformed_iterator : public T::const_iterator
|
||||
{
|
||||
explicit xformed_iterator(typename T::const_iterator base) : T::const_iterator(base){};
|
||||
typename T::key_type operator*() { return this->T::const_iterator::operator*().first; }
|
||||
};
|
||||
|
||||
xformed_iterator begin() const { return xformed_iterator(b); }
|
||||
xformed_iterator end() const { return xformed_iterator(e); }
|
||||
};
|
||||
|
||||
using AllWireRange = key_range<std::unordered_map<WireId, WireInfo>>;
|
||||
|
||||
struct ArchRanges : BaseArchRanges
|
||||
{
|
||||
using ArchArgsT = ArchArgs;
|
||||
@ -79,9 +134,9 @@ struct ArchRanges : BaseArchRanges
|
||||
using TileBelsRangeT = std::vector<BelId>;
|
||||
using BelPinsRangeT = std::vector<IdString>;
|
||||
// Wires
|
||||
using AllWiresRangeT = const std::unordered_set<WireId> &;
|
||||
using DownhillPipRangeT = const std::vector<PipId> &;
|
||||
using UphillPipRangeT = const std::vector<PipId> &;
|
||||
using AllWiresRangeT = AllWireRange;
|
||||
using DownhillPipRangeT = UpDownhillPipRange;
|
||||
using UphillPipRangeT = UpDownhillPipRange;
|
||||
using WireBelPinRangeT = const std::vector<BelPin> &;
|
||||
// Pips
|
||||
using AllPipsRangeT = const std::unordered_set<PipId> &;
|
||||
@ -127,7 +182,7 @@ struct Arch : BaseArch<ArchRanges>
|
||||
IdStringList getWireName(WireId wire) const override { return IdStringList(); }
|
||||
DelayQuad getWireDelay(WireId wire) const override { return DelayQuad(0); }
|
||||
const std::vector<BelPin> &getWireBelPins(WireId wire) const override { return empty_belpin_list; }
|
||||
const std::unordered_set<WireId> &getWires() const override { return all_wires; }
|
||||
AllWireRange getWires() const override { return AllWireRange(wires); }
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
@ -138,8 +193,14 @@ struct Arch : BaseArch<ArchRanges>
|
||||
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 { return DelayQuad(0); }
|
||||
const std::vector<PipId> &getPipsDownhill(WireId wire) const override { return empty_pip_list; }
|
||||
const std::vector<PipId> &getPipsUphill(WireId wire) const override { return empty_pip_list; }
|
||||
UpDownhillPipRange getPipsDownhill(WireId wire) const override
|
||||
{
|
||||
return UpDownhillPipRange(wires.at(wire).wires_downhill, wire, false);
|
||||
}
|
||||
UpDownhillPipRange getPipsUphill(WireId wire) const override
|
||||
{
|
||||
return UpDownhillPipRange(wires.at(wire).wires_uphill, wire, true);
|
||||
}
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
@ -166,8 +227,9 @@ struct Arch : BaseArch<ArchRanges>
|
||||
static const std::string defaultRouter;
|
||||
static const std::vector<std::string> availableRouters;
|
||||
|
||||
std::unordered_map<WireId, WireInfo> wires;
|
||||
|
||||
// WIP to link without failure
|
||||
std::unordered_set<WireId> all_wires;
|
||||
std::unordered_set<PipId> all_pips;
|
||||
std::vector<PipId> empty_pip_list;
|
||||
std::vector<BelPin> empty_belpin_list;
|
||||
|
Loading…
Reference in New Issue
Block a user