aboutsummaryrefslogtreecommitdiffstats
path: root/nexus/arch.h
diff options
context:
space:
mode:
authorD. Shah <dave@ds0.me>2021-02-01 11:46:10 +0000
committerD. Shah <dave@ds0.me>2021-02-02 17:00:33 +0000
commit6566a011b43289b9b550f3b7f8801156275cb321 (patch)
tree7c8f89b52c7a18f6df3d2026b5403bf5c1e416f2 /nexus/arch.h
parentb31b21fd5151ab783fbe665e23a0848b2c172339 (diff)
downloadnextpnr-6566a011b43289b9b550f3b7f8801156275cb321.tar.gz
nextpnr-6566a011b43289b9b550f3b7f8801156275cb321.tar.bz2
nextpnr-6566a011b43289b9b550f3b7f8801156275cb321.zip
nexus: Implement IdStringList for all arch object names
Signed-off-by: D. Shah <dave@ds0.me>
Diffstat (limited to 'nexus/arch.h')
-rw-r--r--nexus/arch.h43
1 files changed, 21 insertions, 22 deletions
diff --git a/nexus/arch.h b/nexus/arch.h
index 3063ce67..d37c5026 100644
--- a/nexus/arch.h
+++ b/nexus/arch.h
@@ -897,6 +897,11 @@ struct Arch : BaseCtx
std::unordered_map<WireId, NetInfo *> wire_to_net;
std::unordered_map<PipId, NetInfo *> pip_to_net;
+ // fast access to X and Y IdStrings for building object names
+ std::vector<IdString> x_ids, y_ids;
+ // inverse of the above for name->object mapping
+ std::unordered_map<IdString, int> id_to_x, id_to_y;
+
// -------------------------------------------------
std::string getChipName() const;
@@ -913,17 +918,14 @@ struct Arch : BaseCtx
// -------------------------------------------------
- BelId getBelByName(IdString name) const;
+ BelId getBelByName(IdStringList name) const;
- IdString getBelName(BelId bel) const
+ IdStringList getBelName(BelId bel) const
{
- std::string name = "X";
- name += std::to_string(bel.tile % chip_info->width);
- name += "/Y";
- name += std::to_string(bel.tile / chip_info->width);
- name += "/";
- name += nameOf(IdString(bel_data(bel).name));
- return id(name);
+ NPNR_ASSERT(bel != BelId());
+ std::array<IdString, 3> ids{x_ids.at(bel.tile % chip_info->width), y_ids.at(bel.tile / chip_info->width),
+ IdString(bel_data(bel).name)};
+ return IdStringList(ids);
}
uint32_t getBelChecksum(BelId bel) const { return (bel.tile << 16) ^ bel.index; }
@@ -1024,16 +1026,13 @@ struct Arch : BaseCtx
// -------------------------------------------------
- WireId getWireByName(IdString name) const;
- IdString getWireName(WireId wire) const
+ WireId getWireByName(IdStringList name) const;
+ IdStringList getWireName(WireId wire) const
{
- std::string name = "X";
- name += std::to_string(wire.tile % chip_info->width);
- name += "/Y";
- name += std::to_string(wire.tile / chip_info->width);
- name += "/";
- name += nameOf(IdString(wire_data(wire).name));
- return id(name);
+ NPNR_ASSERT(wire != WireId());
+ std::array<IdString, 3> ids{x_ids.at(wire.tile % chip_info->width), y_ids.at(wire.tile / chip_info->width),
+ IdString(wire_data(wire).name)};
+ return IdStringList(ids);
}
IdString getWireType(WireId wire) const;
@@ -1137,8 +1136,8 @@ struct Arch : BaseCtx
// -------------------------------------------------
- PipId getPipByName(IdString name) const;
- IdString getPipName(PipId pip) const;
+ PipId getPipByName(IdStringList name) const;
+ IdStringList getPipName(PipId pip) const;
void bindPip(PipId pip, NetInfo *net, PlaceStrength strength)
{
@@ -1290,8 +1289,8 @@ struct Arch : BaseCtx
// -------------------------------------------------
- GroupId getGroupByName(IdString name) const { return GroupId(); }
- IdString getGroupName(GroupId group) const { return IdString(); }
+ GroupId getGroupByName(IdStringList name) const { return GroupId(); }
+ IdStringList getGroupName(GroupId group) const { return IdStringList(); }
std::vector<GroupId> getGroups() const { return {}; }
std::vector<BelId> getGroupBels(GroupId group) const { return {}; }
std::vector<WireId> getGroupWires(GroupId group) const { return {}; }