From f3e098bbde8e94221047f971b1160f77cf02ea7e Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Mon, 8 Jul 2024 09:08:24 +0200 Subject: [PATCH] Move helper routines --- himbaechel/uarch/ng-ultra/location_map.cc | 85 +++++++++++++++++++++++ himbaechel/uarch/ng-ultra/location_map.h | 16 ++--- himbaechel/uarch/ng-ultra/ng_ultra.cc | 85 ----------------------- 3 files changed, 93 insertions(+), 93 deletions(-) diff --git a/himbaechel/uarch/ng-ultra/location_map.cc b/himbaechel/uarch/ng-ultra/location_map.cc index b88b7329..46987695 100644 --- a/himbaechel/uarch/ng-ultra/location_map.cc +++ b/himbaechel/uarch/ng-ultra/location_map.cc @@ -448,4 +448,89 @@ const Loc ng_ultra_place_xfifo[] = // {+1, 0, 28}, REQ2 }; +Loc getNextLocInDSPChain(const NgUltraImpl *impl, Loc loc) +{ + BelId bel = impl->ctx->getBelByLocation(loc); + BelId dsp = impl->dsp_cascade.at(bel); + return impl->ctx->getBelLocation(dsp); +} + +Loc getNextLocInCYChain(Loc loc) +{ + int section = (loc.x % 4 - 1 + 3 * (loc.y % 4)) * 4 + loc.z - BEL_CY_Z; + Loc result = ng_ultra_place_cy_map[section]; + result.x += loc.x; + result.y += loc.y; + result.z += loc.z; + return result; +} + +Loc getCYFE(Loc root, int pos) +{ + int p[] = { 2-1, 25-1, 10-1, 17-1 }; + int cy = root.z - BEL_CY_Z; + Loc result; + result.x = root.x; + result.y = root.y; + result.z = p[pos] + cy * 2; + return result; +} + +Loc getXLUTFE(Loc root, int pos) +{ + Loc result; + result.x = root.x; + result.y = root.y; + result.z = root.z - BEL_XLUT_Z + 8 * pos; + return result; +} + +Loc getXRFFE(Loc root, int pos) +{ + Loc result = ng_ultra_place_xrf[pos]; + if (root.z == BEL_XRF_Z) { + // XRF1 + result.x += root.x; + } else { + // RF1 or RF2 + result.x = root.x + ((root.z == BEL_RF_Z) ? -1 : +1); + } + result.y = root.y; + return result; +} + +Loc getCDCFE(Loc root, int pos) +{ + Loc result; + if (root.z == BEL_CDC_Z) { + result = ng_ultra_place_cdc1[pos]; + } else if (root.z == BEL_CDC_Z+1) { + result = ng_ultra_place_cdc2[pos]; + } else if (root.z == BEL_XCDC_Z) { + result = ng_ultra_place_xcdc[pos]; + } else { + log_error("Trying to place CDC on wrong location.\n"); + } + result.x += root.x; + result.y = root.y; + return result; +} + +Loc getFIFOFE(Loc root, int pos) +{ + Loc result; + if (root.z == BEL_FIFO_Z) { + result = ng_ultra_place_fifo1[pos]; + } else if (root.z == BEL_FIFO_Z+1) { + result = ng_ultra_place_fifo2[pos]; + } else if (root.z == BEL_XFIFO_Z) { + result = ng_ultra_place_xfifo[pos]; + } else { + log_error("Trying to place CDC on wrong location.\n"); + } + result.x += root.x; + result.y = root.y; + return result; +} + NEXTPNR_NAMESPACE_END diff --git a/himbaechel/uarch/ng-ultra/location_map.h b/himbaechel/uarch/ng-ultra/location_map.h index f290f55a..36c98c2e 100644 --- a/himbaechel/uarch/ng-ultra/location_map.h +++ b/himbaechel/uarch/ng-ultra/location_map.h @@ -18,20 +18,20 @@ */ #include "nextpnr.h" +#include "ng_ultra.h" #ifndef NG_ULTRA_LOCATION_MAP_H #define NG_ULTRA_LOCATION_MAP_H NEXTPNR_NAMESPACE_BEGIN -extern const Loc ng_ultra_place_cy_map[]; -extern const Loc ng_ultra_place_xrf[]; -extern const Loc ng_ultra_place_cdc1[]; -extern const Loc ng_ultra_place_cdc2[]; -extern const Loc ng_ultra_place_xcdc[]; -extern const Loc ng_ultra_place_fifo1[]; -extern const Loc ng_ultra_place_fifo2[]; -extern const Loc ng_ultra_place_xfifo[]; +Loc getNextLocInDSPChain(const NgUltraImpl *impl, Loc loc); +Loc getNextLocInCYChain(Loc loc); +Loc getCYFE(Loc root, int pos); +Loc getXLUTFE(Loc root, int pos); +Loc getXRFFE(Loc root, int pos); +Loc getCDCFE(Loc root, int pos); +Loc getFIFOFE(Loc root, int pos); NEXTPNR_NAMESPACE_END #endif diff --git a/himbaechel/uarch/ng-ultra/ng_ultra.cc b/himbaechel/uarch/ng-ultra/ng_ultra.cc index 9adf27de..370ac637 100644 --- a/himbaechel/uarch/ng-ultra/ng_ultra.cc +++ b/himbaechel/uarch/ng-ultra/ng_ultra.cc @@ -587,91 +587,6 @@ bool NgUltraImpl::isValidBelForCellType(IdString cell_type, BelId bel) const return (bel_type == cell_type); } -Loc getNextLocInDSPChain(const NgUltraImpl *impl, Loc loc) -{ - BelId bel = impl->ctx->getBelByLocation(loc); - BelId dsp = impl->dsp_cascade.at(bel); - return impl->ctx->getBelLocation(dsp); -} - -Loc getNextLocInCYChain(Loc loc) -{ - int section = (loc.x % 4 - 1 + 3 * (loc.y % 4)) * 4 + loc.z - BEL_CY_Z; - Loc result = ng_ultra_place_cy_map[section]; - result.x += loc.x; - result.y += loc.y; - result.z += loc.z; - return result; -} - -Loc getCYFE(Loc root, int pos) -{ - int p[] = { 2-1, 25-1, 10-1, 17-1 }; - int cy = root.z - BEL_CY_Z; - Loc result; - result.x = root.x; - result.y = root.y; - result.z = p[pos] + cy * 2; - return result; -} - -Loc getXLUTFE(Loc root, int pos) -{ - Loc result; - result.x = root.x; - result.y = root.y; - result.z = root.z - BEL_XLUT_Z + 8 * pos; - return result; -} - -Loc getXRFFE(Loc root, int pos) -{ - Loc result = ng_ultra_place_xrf[pos]; - if (root.z == BEL_XRF_Z) { - // XRF1 - result.x += root.x; - } else { - // RF1 or RF2 - result.x = root.x + ((root.z == BEL_RF_Z) ? -1 : +1); - } - result.y = root.y; - return result; -} - -Loc getCDCFE(Loc root, int pos) -{ - Loc result; - if (root.z == BEL_CDC_Z) { - result = ng_ultra_place_cdc1[pos]; - } else if (root.z == BEL_CDC_Z+1) { - result = ng_ultra_place_cdc2[pos]; - } else if (root.z == BEL_XCDC_Z) { - result = ng_ultra_place_xcdc[pos]; - } else { - log_error("Trying to place CDC on wrong location.\n"); - } - result.x += root.x; - result.y = root.y; - return result; -} - -Loc getFIFOFE(Loc root, int pos) -{ - Loc result; - if (root.z == BEL_FIFO_Z) { - result = ng_ultra_place_fifo1[pos]; - } else if (root.z == BEL_FIFO_Z+1) { - result = ng_ultra_place_fifo2[pos]; - } else if (root.z == BEL_XFIFO_Z) { - result = ng_ultra_place_xfifo[pos]; - } else { - log_error("Trying to place CDC on wrong location.\n"); - } - result.x += root.x; - result.y = root.y; - return result; -} - bool NgUltraImpl::getChildPlacement(const BaseClusterInfo *cluster, Loc root_loc, std::vector> &placement) const {