aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorDavid Shah <dave@ds0.me>2020-11-13 13:44:10 +0000
committerDavid Shah <dave@ds0.me>2020-11-30 08:45:28 +0000
commit094bf419d4b7aa62a606b8c7bdbcfc1fc63cacf7 (patch)
tree903101e26532a05915019c82ef56df1c3822aab1 /common
parent90608f2c898c179cb95fb469633867e7adc64fc4 (diff)
downloadnextpnr-094bf419d4b7aa62a606b8c7bdbcfc1fc63cacf7.tar.gz
nextpnr-094bf419d4b7aa62a606b8c7bdbcfc1fc63cacf7.tar.bz2
nextpnr-094bf419d4b7aa62a606b8c7bdbcfc1fc63cacf7.zip
nexus: Miscellaneous DSP infrastructure
Signed-off-by: David Shah <dave@ds0.me>
Diffstat (limited to 'common')
-rw-r--r--common/design_utils.cc24
-rw-r--r--common/design_utils.h10
2 files changed, 10 insertions, 24 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc
index 7f339bac..5227585f 100644
--- a/common/design_utils.cc
+++ b/common/design_utils.cc
@@ -164,25 +164,13 @@ void rename_net(Context *ctx, NetInfo *net, IdString new_name)
net->name = new_name;
}
-std::vector<NetInfo *> create_bus(Context *ctx, IdString base_name, const std::string &postfix, int width)
+void replace_bus(Context *ctx, CellInfo *old_cell, IdString old_name, int old_offset, CellInfo *new_cell,
+ IdString new_name, int new_offset, int width, bool square_brackets)
{
- std::vector<NetInfo *> nets;
- for (int i = 0; i < width; i++)
- nets.push_back(ctx->createNet(ctx->id(stringf("%s/%s[%d]", base_name.c_str(ctx), postfix.c_str(), i))));
- return nets;
-}
-
-void connect_bus(Context *ctx, CellInfo *cell, IdString port, std::vector<NetInfo *> &bus, PortType dir)
-{
- for (int i = 0; i < int(bus.size()); i++) {
- IdString p = ctx->id(stringf("%s%d", port.c_str(ctx), i));
- if (!cell->ports.count(p)) {
- cell->ports[p].name = p;
- cell->ports[p].type = dir;
- } else {
- NPNR_ASSERT(cell->ports.at(p).type == dir);
- }
- connect_port(ctx, bus.at(i), cell, p);
+ for (int i = 0; i < width; i++) {
+ IdString old_port = ctx->id(stringf(square_brackets ? "%s[%d]" : "%s%d", old_name.c_str(ctx), i + old_offset));
+ IdString new_port = ctx->id(stringf(square_brackets ? "%s[%d]" : "%s%d", new_name.c_str(ctx), i + new_offset));
+ replace_port(old_cell, old_port, new_cell, new_port);
}
}
diff --git a/common/design_utils.h b/common/design_utils.h
index 3a2245a7..2014e7ad 100644
--- a/common/design_utils.h
+++ b/common/design_utils.h
@@ -104,14 +104,12 @@ void rename_port(Context *ctx, CellInfo *cell, IdString old_name, IdString new_n
// Rename a net without invalidating pointers to it
void rename_net(Context *ctx, NetInfo *net, IdString new_name);
-// Create a bus of nets
-std::vector<NetInfo *> create_bus(Context *ctx, IdString base_name, const std::string &postfix, int width);
-
-// Connect a bus of nets to a bus of ports
-void connect_bus(Context *ctx, CellInfo *cell, IdString port, std::vector<NetInfo *> &bus, PortType dir);
-
void print_utilisation(const Context *ctx);
+// Disconnect a bus of nets (if connected) from old, and connect it to the new ports
+void replace_bus(Context *ctx, CellInfo *old_cell, IdString old_name, int old_offset, CellInfo *new_cell,
+ IdString new_name, int new_offset, int new_width, bool square_brackets = true);
+
NEXTPNR_NAMESPACE_END
#endif