aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-11-16 13:04:43 +0000
committerDavid Shah <dave@ds0.me>2020-11-30 08:45:28 +0000
commitd8e748bc5864f7937cf087cf08d7497bff0d4f6d (patch)
tree379777d98f3b349f6380585d29fee3c7b6ccced5 /common
parent30c65931b2bb86b5dfd6140b35672f7db46c8d32 (diff)
downloadnextpnr-d8e748bc5864f7937cf087cf08d7497bff0d4f6d.tar.gz
nextpnr-d8e748bc5864f7937cf087cf08d7497bff0d4f6d.tar.bz2
nextpnr-d8e748bc5864f7937cf087cf08d7497bff0d4f6d.zip
nexus: Refactor DSP macro splitting to make it more generic
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/design_utils.cc10
-rw-r--r--common/design_utils.h4
2 files changed, 14 insertions, 0 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 4d1c9e53..16cc2710 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -183,4 +183,14 @@ void copy_port(Context *ctx, CellInfo *old_cell, IdString old_name, CellInfo *ne
connect_port(ctx, old_cell->ports.at(old_name).net, new_cell, new_name);
}
+void copy_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)
+{
+ for (int i = 0; i < width; i++) {
+ IdString old_port = ctx->id(stringf(old_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset));
+ IdString new_port = ctx->id(stringf(new_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset));
+ copy_port(ctx, old_cell, old_port, new_cell, new_port);
+ }
+}
+
NEXTPNR_NAMESPACE_END
diff --git a/common/design_utils.h b/common/design_utils.h
index c93fe009..6f52eb0c 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -110,6 +110,10 @@ 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 bus of nets (if connected) from old, and connect it to the new ports
+void copy_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);