diff options
author | William D. Jones <thor0505@comcast.net> | 2021-01-27 01:46:32 -0500 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2021-02-12 10:36:59 +0000 |
commit | 9a9054188c52d76670dace9777981ffd28de5599 (patch) | |
tree | 362224e53a91c124c5aa2a83c8b16d23c4b8c0e2 /machxo2 | |
parent | e4a6fd35716b8d587eff971b23d20af4b1a1a2cb (diff) | |
download | nextpnr-9a9054188c52d76670dace9777981ffd28de5599.tar.gz nextpnr-9a9054188c52d76670dace9777981ffd28de5599.tar.bz2 nextpnr-9a9054188c52d76670dace9777981ffd28de5599.zip |
machxo2: Implement getByName/getName for Wires and Pips.
Diffstat (limited to 'machxo2')
-rw-r--r-- | machxo2/arch.cc | 70 | ||||
-rw-r--r-- | machxo2/arch.h | 37 |
2 files changed, 94 insertions, 13 deletions
diff --git a/machxo2/arch.cc b/machxo2/arch.cc index abc281cb..3fc4dcd8 100644 --- a/machxo2/arch.cc +++ b/machxo2/arch.cc @@ -277,9 +277,30 @@ BelId Arch::getPackagePinBel(const std::string &pin) const // --------------------------------------------------------------- -WireId Arch::getWireByName(IdString name) const { return WireId(); } +WireId Arch::getWireByName(IdString name) const +{ + WireId ret; + + auto it = wire_by_name.find(name); + if (it != wire_by_name.end()) + return it->second; -IdString Arch::getWireName(WireId wire) const { return IdString(); } + Location loc; + std::string basename; + std::tie(loc.x, loc.y, basename) = split_identifier_name(name.str(this)); + ret.location = loc; + + const TileTypePOD *tilei = tileInfo(ret); + for (int i = 0; i < tilei->num_wires; i++) { + if (std::strcmp(tilei->wire_data[i].name.get(), basename.c_str()) == 0) { + ret.index = i; + break; + } + } + if (ret.index >= 0) + wire_by_name[name] = ret; + return ret; +} IdString Arch::getWireType(WireId wire) const { return IdString(); } @@ -307,11 +328,46 @@ const std::vector<WireId> &Arch::getWires() const { return wire_id_dummy; } // --------------------------------------------------------------- -PipId Arch::getPipByName(IdString name) const { return PipId(); } +PipId Arch::getPipByName(IdString name) const +{ + PipId ret; -IdString Arch::getPipName(PipId pip) const { return IdString(); } + auto it = pip_by_name.find(name); + if (it != pip_by_name.end()) + return it->second; -IdString Arch::getPipType(PipId pip) const { return IdString(); } + Location loc; + std::string basename; + std::tie(loc.x, loc.y, basename) = split_identifier_name(name.str(this)); + ret.location = loc; + + const TileTypePOD *tilei = tileInfo(ret); + for (int i = 0; i < tilei->num_pips; i++) { + PipId curr; + curr.location = loc; + curr.index = i; + pip_by_name[getPipName(curr)] = curr; + } + if (pip_by_name.find(name) == pip_by_name.end()) + NPNR_ASSERT_FALSE_STR("no pip named " + name.str(this)); + return pip_by_name[name]; +} + +IdString Arch::getPipName(PipId pip) const +{ + NPNR_ASSERT(pip != PipId()); + + int x = pip.location.x; + int y = pip.location.y; + + std::string src_name = getWireName(getPipSrcWire(pip)).str(this); + std::replace(src_name.begin(), src_name.end(), '/', '.'); + + std::string dst_name = getWireName(getPipDstWire(pip)).str(this); + std::replace(dst_name.begin(), dst_name.end(), '/', '.'); + + return id("X" + std::to_string(x) + "/Y" + std::to_string(y) + "/" + src_name + ".->." + dst_name); +} const std::map<IdString, std::string> &Arch::getPipAttrs(PipId pip) const { return attrs_dummy; } @@ -337,10 +393,6 @@ const std::vector<PipId> &Arch::getPips() const { return pip_id_dummy; } Loc Arch::getPipLocation(PipId pip) const { return Loc(); } -WireId Arch::getPipSrcWire(PipId pip) const { return WireId(); } - -WireId Arch::getPipDstWire(PipId pip) const { return WireId(); } - DelayInfo Arch::getPipDelay(PipId pip) const { return DelayInfo(); } const std::vector<PipId> &Arch::getPipsDownhill(WireId wire) const { return pip_id_dummy; } 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<CellInfo *> bel_to_cell; 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; // Placeholders to be removed. std::unordered_map<Loc, BelId> 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<IdString, std::string> &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<IdString, std::string> &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<PipId> &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<PipId> &getPipsDownhill(WireId wire) const; const std::vector<PipId> &getPipsUphill(WireId wire) const; |