aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/design_utils.cc9
-rw-r--r--common/design_utils.h3
-rw-r--r--nexus/constids.inc9
-rw-r--r--nexus/pack.cc36
4 files changed, 57 insertions, 0 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 6cd8f0f7..4d1c9e53 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -174,4 +174,13 @@ void replace_bus(Context *ctx, CellInfo *old_cell, IdString old_name, int old_of
}
}
+void copy_port(Context *ctx, CellInfo *old_cell, IdString old_name, CellInfo *new_cell, IdString new_name)
+{
+ if (!old_cell->ports.count(old_name))
+ return;
+ new_cell->ports[new_name].name = new_name;
+ new_cell->ports[new_name].type = old_cell->ports.at(old_name).type;
+ connect_port(ctx, old_cell->ports.at(old_name).net, new_cell, new_name);
+}
+
NEXTPNR_NAMESPACE_END
diff --git a/common/design_utils.h b/common/design_utils.h
index 9d4b0550..c93fe009 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -110,6 +110,9 @@ void print_utilisation(const Context *ctx);
void replace_bus(Context *ctx, CellInfo *old_cell, IdString old_name, int old_offset, bool old_brackets,
CellInfo *new_cell, IdString new_name, int new_offset, bool new_brackets, int width);
+// Copy a port from one cell to another
+void copy_port(Context *ctx, CellInfo *old_cell, IdString old_name, CellInfo *new_cell, IdString new_name);
+
NEXTPNR_NAMESPACE_END
#endif
diff --git a/nexus/constids.inc b/nexus/constids.inc
index d5a878ea..90416594 100644
--- a/nexus/constids.inc
+++ b/nexus/constids.inc
@@ -292,6 +292,7 @@ X(PREADDCAS_EN)
X(SR_18BITSHIFT_EN)
X(OPC)
X(RESET)
+X(RESETMODE)
X(ASIGNED_OPERAND_EN)
X(BYPASS_MULT9)
@@ -303,3 +304,11 @@ X(SHIFTA)
X(REGBYPS)
X(PP)
+
+X(SIGNEDA)
+X(SIGNEDB)
+X(RSTOUT)
+X(CEOUT)
+X(REGINPUTA)
+X(REGINPUTB)
+X(REGOUTPUT)
diff --git a/nexus/pack.cc b/nexus/pack.cc
index 3a6b4796..0125378c 100644
--- a/nexus/pack.cc
+++ b/nexus/pack.cc
@@ -1443,6 +1443,23 @@ struct NexusPacker
return cell;
}
+ void copy_global_dsp_params(CellInfo *orig, CellInfo *root)
+ {
+ if (root->params.count(id_GSR) && orig->params.count(id_GSR))
+ root->params[id_GSR] = orig->params.at(id_GSR);
+ if (root->params.count(id_RESET) && orig->params.count(id_RESETMODE))
+ root->params[id_RESET] = orig->params.at(id_RESETMODE);
+ for (auto child : root->constr_children)
+ copy_global_dsp_params(orig, child);
+ }
+
+ void copy_param(CellInfo *orig, IdString orig_name, CellInfo *dst, IdString dst_name)
+ {
+ if (!orig->params.count(orig_name))
+ return;
+ dst->params[dst_name] = orig->params[orig_name];
+ }
+
void pack_dsps()
{
log_info("Packing DSPs...\n");
@@ -1458,6 +1475,25 @@ struct NexusPacker
replace_bus(ctx, ci, id_B, 0, true, preadd9_0, id_B, 0, false, 9);
replace_bus(ctx, ci, id_A, 0, true, mult9_0, id_A, 0, false, 9);
replace_bus(ctx, ci, id_Z, 0, true, reg18_0, id_PP, 0, false, 18);
+ replace_port(ci, id_SIGNEDA, mult9_0, id_ASIGNED);
+ replace_port(ci, id_SIGNEDB, preadd9_0, id_BSIGNED);
+
+ copy_port(ctx, ci, id_CLK, preadd9_0, id_CLK);
+ copy_port(ctx, ci, id_CLK, mult9_0, id_CLK);
+ copy_port(ctx, ci, id_CLK, reg18_0, id_CLK);
+
+ replace_port(ci, id_CEA, mult9_0, id_CEA);
+ replace_port(ci, id_RSTA, mult9_0, id_RSTA);
+ replace_port(ci, id_CEB, preadd9_0, id_CEB);
+ replace_port(ci, id_RSTB, preadd9_0, id_RSTB);
+ replace_port(ci, id_CEOUT, reg18_0, id_CEP);
+ replace_port(ci, id_RSTOUT, reg18_0, id_RSTP);
+
+ copy_param(ci, id_REGINPUTA, mult9_0, id_REGBYPSA1);
+ copy_param(ci, id_REGINPUTB, preadd9_0, id_REGBYPSBR0);
+ copy_param(ci, id_REGOUTPUT, reg18_0, id_REGBYPS);
+
+ copy_global_dsp_params(ci, preadd9_0);
auto_cascade_group(preadd9_0);
to_remove.push_back(ci);
}