Added appending FFs to other existing LUT cluster types (carry, widefn)
Signed-off-by: Maciej Kurc <mkurc@antmicro.com>
This commit is contained in:
parent
086bcf0615
commit
5bc97c94ae
@ -2310,6 +2310,7 @@ struct NexusPacker
|
|||||||
size_t num_comb = 0;
|
size_t num_comb = 0;
|
||||||
size_t num_ff = 0;
|
size_t num_ff = 0;
|
||||||
size_t num_pair = 0;
|
size_t num_pair = 0;
|
||||||
|
size_t num_glue = 0;
|
||||||
|
|
||||||
for (auto &cell : ctx->cells) {
|
for (auto &cell : ctx->cells) {
|
||||||
CellInfo *ff = cell.second.get();
|
CellInfo *ff = cell.second.get();
|
||||||
@ -2320,34 +2321,48 @@ struct NexusPacker
|
|||||||
num_ff++;
|
num_ff++;
|
||||||
|
|
||||||
// Get input net
|
// Get input net
|
||||||
NetInfo *di = get_net_or_empty(ff, id_M); // At the packing stage all inputs go to M
|
// At the packing stage all inputs go to M
|
||||||
|
NetInfo *di = get_net_or_empty(ff, id_M);
|
||||||
if (di == nullptr || di->driver.cell == nullptr) {
|
if (di == nullptr || di->driver.cell == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if there are multiple sinks
|
// Skip if there are multiple sinks on that net
|
||||||
if (di->users.size() != 1) {
|
if (di->users.size() != 1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the driver is a LUT and the direct connection is from F
|
// Check if the driver is a LUT and the direct connection is from F
|
||||||
CellInfo* lut = di->driver.cell;
|
CellInfo* lut = di->driver.cell;
|
||||||
if (lut->type != id_OXIDE_COMB || di->driver.port != id_F) {
|
if (lut->type != id_OXIDE_COMB) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (di->driver.port != id_F &&
|
||||||
|
di->driver.port != id_F1 &&
|
||||||
|
di->driver.port != id_OFX)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The LUT must be in LOGIC mode
|
// The FF must not use M and DI at the same time
|
||||||
if (str_or_default(lut->params, id_MODE, "LOGIC") != "LOGIC") {
|
if (get_net_or_empty(ff, id_DI)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip clusters
|
// The LUT must be in LOGIC/CARRY mode
|
||||||
// FIXME: In case of carry chain make the LUTFF part of the chain
|
if (str_or_default(lut->params, id_MODE, "LOGIC") != "LOGIC" &&
|
||||||
if (lut->cluster != ClusterId() || ff->cluster != ClusterId()) {
|
str_or_default(lut->params, id_MODE, "LOGIC") != "CCU2") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make a cluster
|
// The FF cannot be in another cluster
|
||||||
|
if (ff->cluster != ClusterId()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A free LUT, create a new cluster
|
||||||
|
if (lut->cluster == ClusterId()) {
|
||||||
|
|
||||||
lut->cluster = lut->name;
|
lut->cluster = lut->name;
|
||||||
lut->constr_children.push_back(ff);
|
lut->constr_children.push_back(ff);
|
||||||
|
|
||||||
@ -2359,6 +2374,39 @@ struct NexusPacker
|
|||||||
|
|
||||||
num_pair++;
|
num_pair++;
|
||||||
}
|
}
|
||||||
|
// Attach the FF to the existing cluster of the LUT
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Find the cluster root
|
||||||
|
CellInfo* root = nullptr;
|
||||||
|
if (!lut->constr_children.empty()) {
|
||||||
|
root = lut;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
for (auto &it : ctx->cells) {
|
||||||
|
if (it.second->cluster == lut->cluster && !it.second->constr_children.empty()) {
|
||||||
|
root = it.second.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NPNR_ASSERT(root != nullptr);
|
||||||
|
|
||||||
|
// Constrain the FF relative to the LUT
|
||||||
|
ff->cluster = root->cluster;
|
||||||
|
ff->constr_x = lut->constr_x;
|
||||||
|
ff->constr_y = lut->constr_y;
|
||||||
|
ff->constr_z = lut->constr_z + 2;
|
||||||
|
ff->constr_abs_z = false;
|
||||||
|
root->constr_children.push_back(ff);
|
||||||
|
|
||||||
|
num_glue++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reconnect M to DI
|
||||||
|
rename_port(ctx, ff, id_M, id_DI);
|
||||||
|
ff->params[id_SEL] = std::string("DL");
|
||||||
|
}
|
||||||
|
|
||||||
// Count OXIDE_COMB, OXIDE_FF are already counted
|
// Count OXIDE_COMB, OXIDE_FF are already counted
|
||||||
for (auto &cell : ctx->cells) {
|
for (auto &cell : ctx->cells) {
|
||||||
@ -2369,8 +2417,9 @@ struct NexusPacker
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Print statistics
|
// Print statistics
|
||||||
log_info(" Created %zu LUT+FF pairs from %zu FFs and %zu LUTs\n",
|
log_info(" Created %zu LUT+FF pairs and extended %zu clusters using total %zu FFs and %zu LUTs\n",
|
||||||
num_pair,
|
num_pair,
|
||||||
|
num_glue,
|
||||||
num_ff,
|
num_ff,
|
||||||
num_comb
|
num_comb
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user