aboutsummaryrefslogtreecommitdiffstats
path: root/machxo2/arch.h
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-02-11 12:46:31 +0000
committergatecat <gatecat@ds0.me>2021-02-12 10:36:59 +0000
commitb539363cd05a2841661be3cc4fb0c2804dc35376 (patch)
tree9a103f575c1bd1ee6830366342b6cf4a22ea2774 /machxo2/arch.h
parent3f7618283d1eed2a35bbce161f905a4088020d8e (diff)
downloadnextpnr-b539363cd05a2841661be3cc4fb0c2804dc35376.tar.gz
nextpnr-b539363cd05a2841661be3cc4fb0c2804dc35376.tar.bz2
nextpnr-b539363cd05a2841661be3cc4fb0c2804dc35376.zip
machxo2: Use IdStringLists in earnest
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'machxo2/arch.h')
-rw-r--r--machxo2/arch.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/machxo2/arch.h b/machxo2/arch.h
index 466eca79..fae7523e 100644
--- a/machxo2/arch.h
+++ b/machxo2/arch.h
@@ -398,9 +398,12 @@ struct Arch : BaseArch<ArchRanges>
const ChipInfoPOD *chip_info;
const PackageInfoPOD *package_info;
- 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;
+ mutable std::unordered_map<IdStringList, PipId> pip_by_name;
+
+ // 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;
// Helpers
template <typename Id> const TileTypePOD *tileInfo(Id &id) const
@@ -439,15 +442,17 @@ struct Arch : BaseArch<ArchRanges>
// tiles can complicate this?
int getTilePipDimZ(int x, int y) const override { return 2; }
+ char getNameDelimiter() const override { return '/'; }
+
// Bels
BelId getBelByName(IdStringList name) const override;
IdStringList getBelName(BelId bel) const override
{
NPNR_ASSERT(bel != BelId());
- std::stringstream name;
- name << "X" << bel.location.x << "/Y" << bel.location.y << "/" << tileInfo(bel)->bel_data[bel.index].name.get();
- return IdStringList(id(name.str()));
+ std::array<IdString, 3> ids{x_ids.at(bel.location.x), y_ids.at(bel.location.y),
+ id(tileInfo(bel)->bel_data[bel.index].name.get())};
+ return IdStringList(ids);
}
Loc getBelLocation(BelId bel) const override
@@ -498,10 +503,9 @@ struct Arch : BaseArch<ArchRanges>
IdStringList getWireName(WireId wire) const override
{
NPNR_ASSERT(wire != WireId());
- std::stringstream name;
- name << "X" << wire.location.x << "/Y" << wire.location.y << "/"
- << tileInfo(wire)->wire_data[wire.index].name.get();
- return IdStringList(id(name.str()));
+ std::array<IdString, 3> ids{x_ids.at(wire.location.x), y_ids.at(wire.location.y),
+ id(tileInfo(wire)->wire_data[wire.index].name.get())};
+ return IdStringList(ids);
}
DelayInfo getWireDelay(WireId wire) const override { return DelayInfo(); }