From 9a9054188c52d76670dace9777981ffd28de5599 Mon Sep 17 00:00:00 2001 From: "William D. Jones" Date: Wed, 27 Jan 2021 01:46:32 -0500 Subject: machxo2: Implement getByName/getName for Wires and Pips. --- machxo2/arch.h | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'machxo2/arch.h') diff --git a/machxo2/arch.h b/machxo2/arch.h index d620be4e..d8442ec8 100644 --- a/machxo2/arch.h +++ b/machxo2/arch.h @@ -464,6 +464,8 @@ struct Arch : BaseCtx std::vector bel_to_cell; mutable std::unordered_map bel_by_name; + mutable std::unordered_map wire_by_name; + mutable std::unordered_map pip_by_name; // Placeholders to be removed. std::unordered_map bel_by_loc; @@ -512,6 +514,7 @@ struct Arch : BaseCtx // Bels BelId getBelByName(IdString name) const; + IdString getBelName(BelId bel) const { NPNR_ASSERT(bel != BelId()); @@ -611,7 +614,15 @@ struct Arch : BaseCtx // Wires WireId getWireByName(IdString name) const; - IdString getWireName(WireId wire) const; + + IdString getWireName(WireId wire) const + { + NPNR_ASSERT(wire != WireId()); + std::stringstream name; + name << "X" << wire.location.x << "/Y" << wire.location.y << "/" << tileInfo(wire)->bel_data[wire.index].name.get(); + return id(name.str()); + } + IdString getWireType(WireId wire) const; const std::map &getWireAttrs(WireId wire) const; uint32_t getWireChecksum(WireId wire) const; @@ -628,7 +639,8 @@ struct Arch : BaseCtx // Pips PipId getPipByName(IdString name) const; IdString getPipName(PipId pip) const; - IdString getPipType(PipId pip) const; + + IdString getPipType(PipId pip) const { return IdString(); } const std::map &getPipAttrs(PipId pip) const; uint32_t getPipChecksum(PipId pip) const; void bindPip(PipId pip, NetInfo *net, PlaceStrength strength); @@ -639,8 +651,25 @@ struct Arch : BaseCtx NetInfo *getConflictingPipNet(PipId pip) const; const std::vector &getPips() const; Loc getPipLocation(PipId pip) const; - WireId getPipSrcWire(PipId pip) const; - WireId getPipDstWire(PipId pip) const; + + WireId getPipSrcWire(PipId pip) const + { + WireId wire; + NPNR_ASSERT(pip != PipId()); + wire.index = tileInfo(pip)->pips_data[pip.index].src_idx; + wire.location = pip.location + tileInfo(pip)->pips_data[pip.index].src; + return wire; + } + + WireId getPipDstWire(PipId pip) const + { + WireId wire; + NPNR_ASSERT(pip != PipId()); + wire.index = tileInfo(pip)->pips_data[pip.index].dst_idx; + wire.location = pip.location + tileInfo(pip)->pips_data[pip.index].dst; + return wire; + } + DelayInfo getPipDelay(PipId pip) const; const std::vector &getPipsDownhill(WireId wire) const; const std::vector &getPipsUphill(WireId wire) const; -- cgit v1.2.3