diff options
author | David Shah <davey1576@gmail.com> | 2018-09-30 15:12:06 +0100 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-09-30 15:13:31 +0100 |
commit | 6afc2c75fdf73493d63c511322ce06dbaa4ab0d7 (patch) | |
tree | b99252798562269ac9851dddb6a9425731a2dd41 /common/design_utils.cc | |
parent | ea03aafc26f8d7c6cde75b9054a508470f91965b (diff) | |
download | nextpnr-6afc2c75fdf73493d63c511322ce06dbaa4ab0d7.tar.gz nextpnr-6afc2c75fdf73493d63c511322ce06dbaa4ab0d7.tar.bz2 nextpnr-6afc2c75fdf73493d63c511322ce06dbaa4ab0d7.zip |
ecp5: Adding carry helper functions
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common/design_utils.cc')
-rw-r--r-- | common/design_utils.cc | 19 |
1 files changed, 19 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 |