Move helper routines

This commit is contained in:
Miodrag Milanovic 2024-07-08 09:08:24 +02:00
parent 69ad2b87f0
commit f3e098bbde
3 changed files with 93 additions and 93 deletions

View File

@ -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

View File

@ -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

View File

@ -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<std::pair<CellInfo *, BelId>> &placement) const
{