diff options
author | gatecat <gatecat@ds0.me> | 2023-02-10 13:23:31 +0100 |
---|---|---|
committer | gatecat <gatecat@ds0.me> | 2023-02-10 13:23:31 +0100 |
commit | eb70e950796ccb6b1d44fff2240fe30da5eecf7b (patch) | |
tree | 74474bd8c46ec7f1e853fa4b06ab12d3f18a60e3 /generic/viaduct/fabulous | |
parent | 1226fad4f61e8e1696eccdf23c56ded61551f2ab (diff) | |
download | nextpnr-eb70e950796ccb6b1d44fff2240fe30da5eecf7b.tar.gz nextpnr-eb70e950796ccb6b1d44fff2240fe30da5eecf7b.tar.bz2 nextpnr-eb70e950796ccb6b1d44fff2240fe30da5eecf7b.zip |
fabulous: Improve names for BRAM bels
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to 'generic/viaduct/fabulous')
-rw-r--r-- | generic/viaduct/fabulous/fabric_parsing.h | 14 | ||||
-rw-r--r-- | generic/viaduct/fabulous/fabulous.cc | 17 |
2 files changed, 25 insertions, 6 deletions
diff --git a/generic/viaduct/fabulous/fabric_parsing.h b/generic/viaduct/fabulous/fabric_parsing.h index 3fa263ca..841b2465 100644 --- a/generic/viaduct/fabulous/fabric_parsing.h +++ b/generic/viaduct/fabulous/fabric_parsing.h @@ -68,6 +68,14 @@ struct parser_view return npos; } + size_t rfind(char tok) const + { + for (size_t i = m_length; i > 0; i--) + if (m_ptr[i - 1] == tok) + return i - 1; + return npos; + } + IdString to_id(const BaseCtx *ctx) { // This isn't really ideal, let's hope one day we can move to C++20 and have proper string_views instead :3 @@ -133,6 +141,12 @@ struct parser_view NPNR_ASSERT(pos != npos); return std::make_pair(parser_view(m_ptr, pos), parser_view(m_ptr + pos + 1, m_length - (pos + 1))); } + std::pair<parser_view, parser_view> rsplit(char delim) const + { + size_t pos = rfind(delim); + NPNR_ASSERT(pos != npos); + return std::make_pair(parser_view(m_ptr, pos), parser_view(m_ptr + pos + 1, m_length - (pos + 1))); + } }; struct CsvParser diff --git a/generic/viaduct/fabulous/fabulous.cc b/generic/viaduct/fabulous/fabulous.cc index e2fe1b74..7dad0c66 100644 --- a/generic/viaduct/fabulous/fabulous.cc +++ b/generic/viaduct/fabulous/fabulous.cc @@ -237,6 +237,16 @@ struct FabulousImpl : ViaductAPI NPNR_ASSERT(bel_idx.size() == 1); int bel_z = bel_idx[0] - 'A'; NPNR_ASSERT(bel_z >= 0 && bel_z < 26); + std::vector<parser_view> ports; + parser_view port; + while (!(port = csv.next_field()).empty()) { + ports.push_back(port); + } + IdString bel_name = bel_idx.to_id(ctx); + if (bel_type.in(id_InPass4_frame_config, id_OutPass4_frame_config)) { + // Assign BRAM IO a nicer name than just a letter + bel_name = ports.front().rsplit('_').first.to_id(ctx); + } /* In the future we will need to handle optionally splitting SLICEs into separate LUT/COMB and FF bels This is the preferred approach in nextpnr for arches where the LUT and FF can be used separately of @@ -245,12 +255,7 @@ struct FabulousImpl : ViaductAPI While this isn't yet the standard fabulous SLICE, it should be considered as a future option in fabulous. */ Loc loc(bel_x, bel_y, bel_z); - BelId bel = ctx->addBel(IdStringList::concat(tile, bel_idx.to_id(ctx)), bel_type, loc, false, false); - std::vector<parser_view> ports; - parser_view port; - while (!(port = csv.next_field()).empty()) { - ports.push_back(port); - } + BelId bel = ctx->addBel(IdStringList::concat(tile, bel_name), bel_type, loc, false, false); handle_bel_ports(bel, tile, bel_type, ports); } postprocess_bels(); |