From cbf99d5e5390d8439722e0172067b687be5ac060 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 19 Oct 2020 13:31:21 +0100 Subject: nexus: LUTRAM support Signed-off-by: David Shah --- common/design_utils.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common/design_utils.cc') diff --git a/common/design_utils.cc b/common/design_utils.cc index dd866758..9478afb2 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -30,6 +30,13 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, IdS if (!old_cell->ports.count(old_name)) return; PortInfo &old = old_cell->ports.at(old_name); + + // Create port on the replacement cell if it doesn't already exist + if (!rep_cell->ports.count(rep_name)) { + rep_cell->ports[rep_name].name = rep_name; + rep_cell->ports[rep_name].type = old.type; + } + PortInfo &rep = rep_cell->ports.at(rep_name); NPNR_ASSERT(old.type == rep.type); -- cgit v1.2.3 From 90608f2c898c179cb95fb469633867e7adc64fc4 Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 13 Nov 2020 10:06:53 +0000 Subject: nexus: Add some infrastructure for DSP packing Signed-off-by: David Shah --- common/design_utils.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'common/design_utils.cc') diff --git a/common/design_utils.cc b/common/design_utils.cc index 9478afb2..7f339bac 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -164,4 +164,26 @@ void rename_net(Context *ctx, NetInfo *net, IdString new_name) net->name = new_name; } +std::vector create_bus(Context *ctx, IdString base_name, const std::string &postfix, int width) +{ + std::vector 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 &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); + } +} + NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From 094bf419d4b7aa62a606b8c7bdbcfc1fc63cacf7 Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 13 Nov 2020 13:44:10 +0000 Subject: nexus: Miscellaneous DSP infrastructure Signed-off-by: David Shah --- common/design_utils.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'common/design_utils.cc') 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 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 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 &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); } } -- cgit v1.2.3 From 92031816257dbf76e79bce4dc9c4963824932c4d Mon Sep 17 00:00:00 2001 From: David Shah Date: Fri, 13 Nov 2020 15:25:57 +0000 Subject: nexus: Support for unclocked 9x9 multiplies Signed-off-by: David Shah --- common/design_utils.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'common/design_utils.cc') diff --git a/common/design_utils.cc b/common/design_utils.cc index 5227585f..6cd8f0f7 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -164,12 +164,12 @@ void rename_net(Context *ctx, NetInfo *net, IdString new_name) net->name = new_name; } -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) +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) { 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)); + 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)); replace_port(old_cell, old_port, new_cell, new_port); } } -- cgit v1.2.3 From 30c65931b2bb86b5dfd6140b35672f7db46c8d32 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 16 Nov 2020 09:07:25 +0000 Subject: nexus: Add support for clocked MULT9X9s Signed-off-by: David Shah --- common/design_utils.cc | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common/design_utils.cc') 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 -- cgit v1.2.3 From d8e748bc5864f7937cf087cf08d7497bff0d4f6d Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 16 Nov 2020 13:04:43 +0000 Subject: nexus: Refactor DSP macro splitting to make it more generic Signed-off-by: David Shah --- common/design_utils.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'common/design_utils.cc') 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 -- cgit v1.2.3