diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/design_utils.cc | 10 | ||||
-rw-r--r-- | common/design_utils.h | 4 |
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); |