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 +++++++++++++++++++ common/design_utils.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'common') 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 diff --git a/common/design_utils.h b/common/design_utils.h index 95975179..ccf2463b 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -82,6 +82,9 @@ template CellInfo *net_driven_by(const Context *ctx, const NetInfo } } +// Connect a net to a port +void connect_port(const Context *ctx, NetInfo *net, CellInfo *cell, IdString port_name); + void print_utilisation(const Context *ctx); NEXTPNR_NAMESPACE_END -- cgit v1.2.3