From f0d4e4fbc3847635e0f6151a9eda52b7fb952c19 Mon Sep 17 00:00:00 2001 From: gatecat Date: Mon, 2 May 2022 09:56:36 +0100 Subject: generic: Add some extra helpers for viaduct uarches Signed-off-by: gatecat --- generic/viaduct_helpers.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'generic/viaduct_helpers.cc') diff --git a/generic/viaduct_helpers.cc b/generic/viaduct_helpers.cc index a92d0de1..153d2a0e 100644 --- a/generic/viaduct_helpers.cc +++ b/generic/viaduct_helpers.cc @@ -25,9 +25,9 @@ NEXTPNR_NAMESPACE_BEGIN -void ViaductHelpers::resize_ids(int x, int y) +void ViaductHelpers::resize_ids(int x, int y, int z) { - NPNR_ASSERT(x >= 0 && y >= 0 && x <= 20000 && y <= 20000); + NPNR_ASSERT(x >= 0 && y >= 0 && x <= 20000 && y <= 20000 && z <= 1000); while (int(x_ids.size()) <= x) { IdString next = ctx->id(stringf("X%d", int(x_ids.size()))); x_ids.push_back(next); @@ -36,6 +36,10 @@ void ViaductHelpers::resize_ids(int x, int y) IdString next = ctx->id(stringf("Y%d", int(y_ids.size()))); y_ids.push_back(next); } + while (int(z_ids.size()) <= y) { + IdString next = ctx->id(stringf("Z%d", int(z_ids.size()))); + z_ids.push_back(next); + } } IdStringList ViaductHelpers::xy_id(int x, int y, IdString base) @@ -52,6 +56,20 @@ IdStringList ViaductHelpers::xy_id(int x, int y, IdStringList base) return IdStringList::concat(IdStringList(prefix), base); } +IdStringList ViaductHelpers::xyz_id(int x, int y, int z, IdString base) +{ + resize_ids(x, y, z); + std::array result{x_ids.at(x), y_ids.at(y), z_ids.at(z), base}; + return IdStringList(result); +} + +IdStringList ViaductHelpers::xyz_id(int x, int y, int z, IdStringList base) +{ + resize_ids(x, y, z); + std::array prefix{x_ids.at(x), y_ids.at(y), z_ids.at(z)}; + return IdStringList::concat(IdStringList(prefix), base); +} + void ViaductHelpers::remove_nextpnr_iobs(const pool &top_ports) { std::vector to_remove; -- cgit v1.2.3