From 44f98c545b353c823692f91953c1ca74b6be2d4f Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 12 Jan 2020 20:44:22 +0000 Subject: nexus: Add global networks Signed-off-by: David Shah --- common/nextpnr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/nextpnr.cc b/common/nextpnr.cc index 07b88471..9a856b99 100644 --- a/common/nextpnr.cc +++ b/common/nextpnr.cc @@ -506,7 +506,7 @@ void Context::check() const } } } - +#ifdef CHECK_WIRES for (auto w : getWires()) { auto ni = getBoundWireNet(w); if (ni != nullptr) { @@ -514,7 +514,7 @@ void Context::check() const CHECK_FAIL("wire '%s' missing in wires map of bound net '%s'\n", nameOfWire(w), nameOf(ni)); } } - +#endif for (auto &c : cells) { auto ci = c.second.get(); if (c.first != ci->name) -- cgit v1.2.3 From b5d46a0235464dbf27e49f804ef69e7fa434828c Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 13 Jan 2020 21:02:11 +0000 Subject: nexus: Add Python bindings Signed-off-by: David Shah --- common/arch_pybindings_shared.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'common') diff --git a/common/arch_pybindings_shared.h b/common/arch_pybindings_shared.h index 3f7efcc1..8bb93a80 100644 --- a/common/arch_pybindings_shared.h +++ b/common/arch_pybindings_shared.h @@ -103,11 +103,6 @@ fn_wrapper_1a, conv_from_str>::def_wrap(ctx_cls, "getPipDelay"); -fn_wrapper_1a, - pass_through>::def_wrap(ctx_cls, "getPackagePinBel"); -fn_wrapper_1a, - conv_from_str>::def_wrap(ctx_cls, "getBelPackagePin"); - fn_wrapper_0a>::def_wrap( ctx_cls, "getChipName"); fn_wrapper_0a>::def_wrap(ctx_cls, -- cgit v1.2.3 From 84d542624213ab8639bac31ade79ce27097f4e06 Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 20 Jan 2020 15:57:06 +0000 Subject: nexus: Working on validity checking Signed-off-by: David Shah --- common/design_utils.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'common') diff --git a/common/design_utils.h b/common/design_utils.h index 1ae1d648..301547c6 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -82,6 +82,13 @@ template CellInfo *net_driven_by(const Context *ctx, const NetInfo } } +// Check if a port is used +inline bool port_used(CellInfo *cell, IdString port_name) +{ + auto port_fnd = cell->ports.find(port_name); + return port_fnd != cell->ports.end() && port_fnd->second.net != nullptr; +} + // Connect a net to a port void connect_port(const Context *ctx, NetInfo *net, CellInfo *cell, IdString port_name); -- cgit v1.2.3 From 518ead2e2dd11ba3bcd19085c2c91178ba9e458c Mon Sep 17 00:00:00 2001 From: David Shah Date: Mon, 12 Oct 2020 11:41:26 +0100 Subject: nexus: IO pre-packing Signed-off-by: David Shah --- common/util.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/util.h b/common/util.h index 9512bd40..d82e984a 100644 --- a/common/util.h +++ b/common/util.h @@ -112,6 +112,15 @@ template std::map sorted(const std::unordered_m return retVal; }; +// Wrap an unordered_map, and allow it to be iterated over sorted by key +template std::map sorted_ref(std::unordered_map &orig) +{ + std::map retVal; + for (auto &item : orig) + retVal.emplace(std::make_pair(item.first, std::ref(item.second))); + return retVal; +}; + // Wrap an unordered_set, and allow it to be iterated over sorted by key template std::set sorted(const std::unordered_set &orig) { -- cgit v1.2.3 From 1bb509897c77b7a8931f10b84dc1de98668c04bd Mon Sep 17 00:00:00 2001 From: David Shah Date: Tue, 13 Oct 2020 10:07:28 +0100 Subject: nexus: More pin styles and FASM pinmux gen Signed-off-by: David Shah --- common/util.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'common') diff --git a/common/util.h b/common/util.h index d82e984a..07ebac75 100644 --- a/common/util.h +++ b/common/util.h @@ -121,6 +121,15 @@ template std::map sorted_ref(std::unordered_map return retVal; }; +// Wrap an unordered_map, and allow it to be iterated over sorted by key +template std::map sorted_cref(const std::unordered_map &orig) +{ + std::map retVal; + for (auto &item : orig) + retVal.emplace(std::make_pair(item.first, std::ref(item.second))); + return retVal; +}; + // Wrap an unordered_set, and allow it to be iterated over sorted by key template std::set sorted(const std::unordered_set &orig) { -- cgit v1.2.3 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') 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 5e90086d4f02910a973b743a42d8ae1853599ac1 Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 22 Oct 2020 16:43:10 +0100 Subject: router2: Fix case where src and dst are the same Signed-off-by: David Shah --- common/router2.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/router2.cc b/common/router2.cc index 4dfd868b..15c97e52 100644 --- a/common/router2.cc +++ b/common/router2.cc @@ -774,8 +774,11 @@ struct Router2 if (dst == WireId() || ctx->getBoundWireNet(dst) == net) return true; // Skip routes where there is no routing (special cases) - if (!ad.routed) + if (!ad.routed) { + if ((src == dst) && ctx->getBoundWireNet(dst) != net) + ctx->bindWire(src, net, STRENGTH_WEAK); return true; + } WireId cursor = dst; -- cgit v1.2.3 From a69c595802bb20517ced3a2a82a6dde4b8dc6a03 Mon Sep 17 00:00:00 2001 From: David Shah Date: Thu, 12 Nov 2020 11:08:13 +0000 Subject: router1: Fix same-source-dest case Signed-off-by: David Shah --- common/router1.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'common') diff --git a/common/router1.cc b/common/router1.cc index 946327d2..d2816c1e 100644 --- a/common/router1.cc +++ b/common/router1.cc @@ -469,6 +469,20 @@ struct Router1 } } + // special case + + if (src_wire == dst_wire) { + NetInfo *bound = ctx->getBoundWireNet(src_wire); + if (bound != nullptr) + NPNR_ASSERT(bound == net_info); + else { + ctx->bindWire(src_wire, net_info, STRENGTH_WEAK); + } + arc_to_wires[arc].insert(src_wire); + wire_to_arcs[src_wire].insert(arc); + return true; + } + // reset wire queue if (!queue.empty()) { -- 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 ++++++++++++++++++++++ common/design_utils.h | 6 ++++++ 2 files changed, 28 insertions(+) (limited to 'common') 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 diff --git a/common/design_utils.h b/common/design_utils.h index 301547c6..3a2245a7 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -104,6 +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 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 &bus, PortType dir); + void print_utilisation(const Context *ctx); 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 ++++++------------------ common/design_utils.h | 10 ++++------ 2 files changed, 10 insertions(+), 24 deletions(-) (limited to 'common') 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); } } 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 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 &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 -- 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 ++++---- common/design_utils.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'common') 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); } } diff --git a/common/design_utils.h b/common/design_utils.h index 2014e7ad..9d4b0550 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -107,8 +107,8 @@ void rename_net(Context *ctx, NetInfo *net, IdString new_name); 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); +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); NEXTPNR_NAMESPACE_END -- 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 +++++++++ common/design_utils.h | 3 +++ 2 files changed, 12 insertions(+) (limited to 'common') 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 -- 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 ++++++++++ common/design_utils.h | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'common') 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); -- cgit v1.2.3