From ff92d19fed274c6469720cc726e80dc777fa767f Mon Sep 17 00:00:00 2001 From: "D. Shah" Date: Fri, 29 Jan 2021 11:11:08 +0000 Subject: arch: Add getNameDelimiter API for string lists Signed-off-by: D. Shah --- ecp5/arch.h | 1 + 1 file changed, 1 insertion(+) (limited to 'ecp5/arch.h') diff --git a/ecp5/arch.h b/ecp5/arch.h index 18a70fe8..6b32f284 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -471,6 +471,7 @@ struct Arch : BaseCtx int getGridDimY() const { return chip_info->height; }; int getTileBelDimZ(int, int) const { return max_loc_bels; }; int getTilePipDimZ(int, int) const { return 1; }; + char getNameDelimiter() const { return '/'; } // ------------------------------------------------- -- cgit v1.2.3 From 6d23461bcd83d27c6b365948a5e85db80389832e Mon Sep 17 00:00:00 2001 From: "D. Shah" Date: Fri, 29 Jan 2021 12:12:12 +0000 Subject: ecp5: Proof-of-concept using IdStringList for bel names This uses the new IdStringList API to store bel names for the ECP5. Note that other arches and the GUI do not yet build with this proof-of-concept patch. getBelByName still uses the old implementation and could be more efficiently implemented with further development. Signed-off-by: D. Shah --- ecp5/arch.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ecp5/arch.h') diff --git a/ecp5/arch.h b/ecp5/arch.h index 6b32f284..303d9afe 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -450,6 +450,9 @@ struct Arch : BaseCtx std::unordered_map pip_to_net; std::unordered_map wire_fanout; + // fast access to X and Y IdStrings for building object names + std::vector x_ids, y_ids; + ArchArgs args; Arch(ArchArgs args); @@ -475,19 +478,19 @@ struct Arch : BaseCtx // ------------------------------------------------- - BelId getBelByName(IdString name) const; + BelId getBelByName(IdStringList name) const; template const LocationTypePOD *locInfo(Id &id) const { return &(chip_info->locations[chip_info->location_type[id.location.y * chip_info->width + id.location.x]]); } - IdString getBelName(BelId bel) const + IdStringList getBelName(BelId bel) const { NPNR_ASSERT(bel != BelId()); - std::stringstream name; - name << "X" << bel.location.x << "/Y" << bel.location.y << "/" << locInfo(bel)->bel_data[bel.index].name.get(); - return id(name.str()); + std::array ids{x_ids.at(bel.location.x), y_ids.at(bel.location.y), + id(locInfo(bel)->bel_data[bel.index].name.get())}; + return IdStringList(ids); } uint32_t getBelChecksum(BelId bel) const { return bel.index; } -- cgit v1.2.3 From d792bce0fb03529ee57b6f6ed5b0c234f503e452 Mon Sep 17 00:00:00 2001 From: "D. Shah" Date: Fri, 29 Jan 2021 13:30:56 +0000 Subject: ecp5: Implement IdStringList for all arch object names This is a complete implementation of IdStringList for ECP5; excluding the GUI (which you will have to disable for it to build). Signed-off-by: D. Shah --- ecp5/arch.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'ecp5/arch.h') diff --git a/ecp5/arch.h b/ecp5/arch.h index 303d9afe..9997cd5c 100644 --- a/ecp5/arch.h +++ b/ecp5/arch.h @@ -441,9 +441,7 @@ struct Arch : BaseCtx const PackageInfoPOD *package_info; const SpeedGradePOD *speed_grade; - mutable std::unordered_map bel_by_name; - mutable std::unordered_map wire_by_name; - mutable std::unordered_map pip_by_name; + mutable std::unordered_map pip_by_name; std::vector bel_to_cell; std::unordered_map wire_to_net; @@ -452,6 +450,8 @@ struct Arch : BaseCtx // fast access to X and Y IdStrings for building object names std::vector x_ids, y_ids; + // inverse of the above for name->object mapping + std::unordered_map id_to_x, id_to_y; ArchArgs args; Arch(ArchArgs args); @@ -598,16 +598,14 @@ struct Arch : BaseCtx // ------------------------------------------------- - WireId getWireByName(IdString name) const; + WireId getWireByName(IdStringList name) const; - IdString getWireName(WireId wire) const + IdStringList getWireName(WireId wire) const { NPNR_ASSERT(wire != WireId()); - - std::stringstream name; - name << "X" << wire.location.x << "/Y" << wire.location.y << "/" - << locInfo(wire)->wire_data[wire.index].name.get(); - return id(name.str()); + std::array ids{x_ids.at(wire.location.x), y_ids.at(wire.location.y), + id(locInfo(wire)->wire_data[wire.index].name.get())}; + return IdStringList(ids); } IdString getWireType(WireId wire) const @@ -716,8 +714,8 @@ struct Arch : BaseCtx // ------------------------------------------------- - PipId getPipByName(IdString name) const; - IdString getPipName(PipId pip) const; + PipId getPipByName(IdStringList name) const; + IdStringList getPipName(PipId pip) const; IdString getPipType(PipId pip) const { return IdString(); } @@ -895,8 +893,8 @@ struct Arch : BaseCtx // ------------------------------------------------- - GroupId getGroupByName(IdString name) const; - IdString getGroupName(GroupId group) const; + GroupId getGroupByName(IdStringList name) const; + IdStringList getGroupName(GroupId group) const; std::vector getGroups() const; std::vector getGroupBels(GroupId group) const; std::vector getGroupWires(GroupId group) const; -- cgit v1.2.3