RF placement and legalization

This commit is contained in:
Miodrag Milanovic 2024-05-17 15:04:25 +02:00
parent 741f690848
commit 45bca49b2e
2 changed files with 88 additions and 43 deletions

View File

@ -274,6 +274,45 @@ bool NgUltraImpl::isBelLocationValid(BelId bel, bool explain_invalid) const
SectionFEWorker worker;
return worker.run(this, ctx, bel);
}
else if (ctx->getBelType(bel).in(id_RF, id_XRF)) {
CellInfo *cell = ctx->getBoundBelCell(bel);
if (cell == nullptr) {
return true;
}
Loc loc = ctx->getBelLocation(bel);
if (loc.z == BEL_XRF_Z) {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_RF_Z)))) return false;
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_RF_Z+1)))) return false;
} else {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_XRF_Z)))) return false;
}
}
else if (ctx->getBelType(bel).in(id_FIFO, id_XFIFO)) {
CellInfo *cell = ctx->getBoundBelCell(bel);
if (cell == nullptr) {
return true;
}
Loc loc = ctx->getBelLocation(bel);
if (loc.z == BEL_XFIFO_Z) {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_FIFO_Z)))) return false;
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_FIFO_Z+1)))) return false;
} else {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_XFIFO_Z)))) return false;
}
}
else if (ctx->getBelType(bel).in(id_CDC, id_XCDC)) {
CellInfo *cell = ctx->getBoundBelCell(bel);
if (cell == nullptr) {
return true;
}
Loc loc = ctx->getBelLocation(bel);
if (loc.z == BEL_XCDC_Z) {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_CDC_Z)))) return false;
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_CDC_Z+1)))) return false;
} else {
if (ctx->getBoundBelCell(ctx->getBelByLocation(Loc(loc.x,loc.y,BEL_XCDC_Z)))) return false;
}
}
return true;
}
@ -369,6 +408,7 @@ Loc getXRFFE(Loc root, int pos)
Loc(-1, 0, 25),// I/O16
Loc(-1, 0, 26),// I/O17
Loc(-1, 0, 29),// I/O18
Loc(+1, 0, 1),// I/O19
Loc(+1, 0, 2),// I/O20
Loc(+1, 0, 5),// I/O21
@ -388,12 +428,12 @@ Loc getXRFFE(Loc root, int pos)
Loc(+1, 0, 26),// I/O35
Loc(+1, 0, 29),// I/O36
Loc(-1, 0, 4),// RA1
Loc(-1, 0, 12),// RA2
Loc(-1, 0, 20),// RA3
Loc(-1, 0, 27),// RA4
Loc(-1, 0, 31),// RA5
Loc(+1, 0, 4),// RA6
Loc(+1, 0, 12),// RA7
Loc(+1, 0, 20),// RA8
@ -405,6 +445,7 @@ Loc getXRFFE(Loc root, int pos)
Loc(-1, 0, 19),// WA3
Loc(-1, 0, 23),// WA4
Loc(-1, 0, 28),// WA5
Loc(+1, 0, 3),// WA6
Loc(-1, 0, 0),// WE
@ -413,10 +454,15 @@ Loc getXRFFE(Loc root, int pos)
};
Loc result = map.at(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;
}
bool NgUltraImpl::getChildPlacement(const BaseClusterInfo *cluster, Loc root_loc,

View File

@ -861,22 +861,6 @@ void NgUltraPacker::pack_rfs(void)
continue;
int mode = int_or_default(ci.params, ctx->id("mode"), 0);
ci.type = id_RF;
if (mode > 1) {
// XRF
ci.type = id_XRF;
ci.ports[id_WCK1].name = id_WCK1;
ci.ports[id_WCK1].type = PORT_IN;
ci.ports[id_WCK2].name = id_WCK2;
ci.ports[id_WCK2].type = PORT_IN;
NetInfo *net = ci.getPort(id_WCK);
if (net) {
ci.disconnectPort(id_WCK);
ci.connectPort(id_WCK1, net);
ci.connectPort(id_WCK2, net);
}
}
ci.cluster = ci.name;
pack_xrf_input_and_output(&ci, ci.name, id_I1, id_O1, lut_only, lut_and_ff, dff_only);
@ -897,6 +881,21 @@ void NgUltraPacker::pack_rfs(void)
pack_xrf_input_and_output(&ci, ci.name, id_I16, id_O16, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I17, id_O17, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I18, id_O18, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA1, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA2, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA3, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA4, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA5, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA1, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA2, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA3, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA4, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA5, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WE, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WEA, IdString(), lut_only, lut_and_ff, dff_only);
if (mode > 1) {
// XRF
ci.type = id_XRF;
pack_xrf_input_and_output(&ci, ci.name, id_I19, id_O19, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I20, id_O20, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I21, id_O21, lut_only, lut_and_ff, dff_only);
@ -915,24 +914,24 @@ void NgUltraPacker::pack_rfs(void)
pack_xrf_input_and_output(&ci, ci.name, id_I34, id_O34, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I35, id_O35, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_I36, id_O36, lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA1, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA2, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA3, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA4, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA5, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA6, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA7, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA8, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA9, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_RA10, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA1, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA2, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA3, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA4, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA5, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WA6, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WE, IdString(), lut_only, lut_and_ff, dff_only);
pack_xrf_input_and_output(&ci, ci.name, id_WEA, IdString(), lut_only, lut_and_ff, dff_only);
ci.ports[id_WCK1].name = id_WCK1;
ci.ports[id_WCK1].type = PORT_IN;
ci.ports[id_WCK2].name = id_WCK2;
ci.ports[id_WCK2].type = PORT_IN;
NetInfo *net = ci.getPort(id_WCK);
if (net) {
ci.disconnectPort(id_WCK);
ci.connectPort(id_WCK1, net);
ci.connectPort(id_WCK2, net);
}
}
}
if (lut_only)
log_info(" %6d FEs used as LUT only\n", lut_only);