From 6afc2c75fdf73493d63c511322ce06dbaa4ab0d7 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 30 Sep 2018 15:12:06 +0100 Subject: ecp5: Adding carry helper functions Signed-off-by: David Shah --- common/design_utils.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common/design_utils.cc') diff --git a/common/design_utils.cc b/common/design_utils.cc index 21c9dcc4..0976d6dd 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -73,4 +73,23 @@ void print_utilisation(const Context *ctx) log_break(); } +// Connect a net to a port +void connect_port(const Context *ctx, NetInfo *net, CellInfo *cell, IdString port_name) { + PortInfo &port = cell->ports.at(port_name); + NPNR_ASSERT(port.net == nullptr); + port.net = net; + if (port.type == PORT_OUT) { + NPNR_ASSERT(net->driver.cell == nullptr); + net->driver.cell = cell; + net->driver.port = port_name; + } else if (port.type == PORT_IN) { + PortRef user; + user.cell = cell; + user.port = port_name; + net->users.push_back(user); + } else { + NPNR_ASSERT_FALSE("invalid port type for connect_port"); + } +} + NEXTPNR_NAMESPACE_END -- cgit v1.2.3 From a27c7b45dee834dbf7342df0acff257aab946f25 Mon Sep 17 00:00:00 2001 From: David Shah Date: Sun, 30 Sep 2018 16:29:26 +0100 Subject: Refactor chain finder to its own file Signed-off-by: David Shah --- common/design_utils.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common/design_utils.cc') diff --git a/common/design_utils.cc b/common/design_utils.cc index 0976d6dd..7ad7f749 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -74,7 +74,8 @@ void print_utilisation(const Context *ctx) } // Connect a net to a port -void connect_port(const Context *ctx, NetInfo *net, CellInfo *cell, IdString port_name) { +void connect_port(const Context *ctx, NetInfo *net, CellInfo *cell, IdString port_name) +{ PortInfo &port = cell->ports.at(port_name); NPNR_ASSERT(port.net == nullptr); port.net = net; -- cgit v1.2.3