diff options
author | David Shah <davey1576@gmail.com> | 2018-06-12 11:49:54 +0200 |
---|---|---|
committer | David Shah <davey1576@gmail.com> | 2018-06-12 11:49:54 +0200 |
commit | 5f813410aabdae3de84e11861248dcd0699b41c2 (patch) | |
tree | 9754b5e5c4bc5aa56417e4ab107c0d4df0b37e10 /common | |
parent | 3ce32b6b1dfe8855ecb9cc18f460805111f1e6a3 (diff) | |
download | nextpnr-5f813410aabdae3de84e11861248dcd0699b41c2.tar.gz nextpnr-5f813410aabdae3de84e11861248dcd0699b41c2.tar.bz2 nextpnr-5f813410aabdae3de84e11861248dcd0699b41c2.zip |
ice40: Adding cell utilities for packing
Signed-off-by: David Shah <davey1576@gmail.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/design_utils.cc | 34 | ||||
-rw-r--r-- | common/design_utils.h | 8 |
2 files changed, 27 insertions, 15 deletions
diff --git a/common/design_utils.cc b/common/design_utils.cc index a7298aec..8b52697b 100644 --- a/common/design_utils.cc +++ b/common/design_utils.cc @@ -19,22 +19,30 @@ #include "design_utils.h" -void replace_port(CellInfo *old_cell, PortInfo *old, CellInfo *rep_cell, - PortInfo *rep) +void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, + IdString rep_name) { - assert(old->type == rep->type); + PortInfo &old = old_cell->ports.at(old_name); + PortInfo &rep = rep_cell->ports.at(rep_name); + assert(old.type == rep.type); - rep->net = old->net; - old->net = nullptr; - if (rep->type == PORT_OUT) { - rep->net->driver.cell = rep_cell; - rep->net->driver.port = rep->name; - } else if (rep->type == PORT_IN) { - for (PortRef &load : rep->net->users) { - if (load.cell == old_cell && load.port == old->name) { - load.cell = rep_cell; - load.port = rep->name; + rep.net = old.net; + old.net = nullptr; + if (rep.type == PORT_OUT) { + if (rep.net != nullptr) { + rep.net->driver.cell = rep_cell; + rep.net->driver.port = rep_name; + } + } else if (rep.type == PORT_IN) { + if (rep.net != nullptr) { + for (PortRef &load : rep.net->users) { + if (load.cell == old_cell && load.port == old_name) { + load.cell = rep_cell; + load.port = rep_name; + } } } + } else { + assert(false); } } diff --git a/common/design_utils.h b/common/design_utils.h index 2faceddc..43ff180b 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -19,13 +19,15 @@ #include "nextpnr.h" +#ifndef DESIGN_UTILS_H +#define DESIGN_UTILS_H /* Utilities for design manipulation, intended for use inside packing algorithms */ // Disconnect a net (if connected) from old, and connect it to rep -void replace_port(CellInfo *old_cell, PortInfo *old, CellInfo *rep_cell, - PortInfo *rep); +void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, + IdString rep_name); // If a net drives a given port of a cell matching a predicate (in many // cases more than one cell type, e.g. SB_DFFxx so a predicate is used), return @@ -58,3 +60,5 @@ CellInfo *net_driven_by(NetInfo *net, F1 cell_pred, IdString port) return nullptr; } } + +#endif |