diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/design_utils.cc | 19 | ||||
-rw-r--r-- | common/design_utils.h | 3 |
2 files changed, 22 insertions, 0 deletions
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 <typename F1> 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 |